Clean up and typing
This commit is contained in:
@@ -14,7 +14,6 @@
|
|||||||
"@iconify/react": "^5.2.0",
|
"@iconify/react": "^5.2.0",
|
||||||
"@mantine/core": "^7.17.2",
|
"@mantine/core": "^7.17.2",
|
||||||
"@mantine/hooks": "^7.17.2",
|
"@mantine/hooks": "^7.17.2",
|
||||||
"@mantine/modals": "^7.17.2",
|
|
||||||
"@tabler/icons-react": "^3.31.0",
|
"@tabler/icons-react": "^3.31.0",
|
||||||
"@tanstack/react-query": "^5.69.0",
|
"@tanstack/react-query": "^5.69.0",
|
||||||
"@tanstack/react-query-devtools": "^5.69.0",
|
"@tanstack/react-query-devtools": "^5.69.0",
|
||||||
|
|||||||
21
src/App.tsx
21
src/App.tsx
@@ -4,7 +4,6 @@ import {
|
|||||||
createTheme,
|
createTheme,
|
||||||
mergeMantineTheme,
|
mergeMantineTheme,
|
||||||
} from '@mantine/core';
|
} from '@mantine/core';
|
||||||
import { ModalsProvider } from '@mantine/modals';
|
|
||||||
import { useCommonHooks, useQueryAPI } from 'hooks';
|
import { useCommonHooks, useQueryAPI } from 'hooks';
|
||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
import {
|
import {
|
||||||
@@ -20,6 +19,7 @@ import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
|
|||||||
import './index.css';
|
import './index.css';
|
||||||
import { Homepage, Settings } from 'pages';
|
import { Homepage, Settings } from 'pages';
|
||||||
import { ToastContainer } from 'react-toastify';
|
import { ToastContainer } from 'react-toastify';
|
||||||
|
import type { Theme, ThemePlaylist } from 'types';
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
const { data: allThemes, isFetched: isAllThemesFetched } = useQueryAPI({
|
const { data: allThemes, isFetched: isAllThemesFetched } = useQueryAPI({
|
||||||
@@ -62,25 +62,28 @@ function App() {
|
|||||||
if (allThemes && themeName) {
|
if (allThemes && themeName) {
|
||||||
if (currentThemePlaylist === 'All') {
|
if (currentThemePlaylist === 'All') {
|
||||||
if (themeName !== 'random') {
|
if (themeName !== 'random') {
|
||||||
const temp = allThemes.find((t: any) => t.name === themeName);
|
const temp = allThemes.find((t: Theme) => t.name === themeName);
|
||||||
setTheme(temp);
|
setTheme(temp);
|
||||||
} else {
|
} else {
|
||||||
handleThemeChange(allThemes, false);
|
handleThemeChange(allThemes, false);
|
||||||
}
|
}
|
||||||
} else if (currentThemePlaylist === 'Time of Day') {
|
} else if (currentThemePlaylist === 'Time of Day') {
|
||||||
const themeList = JSON.parse(
|
const themeList = JSON.parse(
|
||||||
themePlaylists.find((t: any) => t.name === currentThemePlaylist).themeList,
|
themePlaylists.find((t: ThemePlaylist) => t.name === currentThemePlaylist)
|
||||||
|
.themeList,
|
||||||
);
|
);
|
||||||
setTheme(
|
setTheme(
|
||||||
allThemes.find(
|
allThemes.find(
|
||||||
(t: any) => t.id === Number(themeList[Math.floor(new Date().getHours() / 6)]),
|
(t: Theme) =>
|
||||||
|
t.id === Number(themeList[Math.floor(new Date().getHours() / 6)]),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
const themeList = JSON.parse(
|
const themeList = JSON.parse(
|
||||||
themePlaylists.find((t: any) => t.name === currentThemePlaylist).themeList,
|
themePlaylists.find((t: ThemePlaylist) => t.name === currentThemePlaylist)
|
||||||
|
.themeList,
|
||||||
);
|
);
|
||||||
const filteredThemes = allThemes.filter((t: any) => themeList.includes(t.id));
|
const filteredThemes = allThemes.filter((t: Theme) => themeList.includes(t.id));
|
||||||
setTheme('random');
|
setTheme('random');
|
||||||
handleThemeChange(filteredThemes, false);
|
handleThemeChange(filteredThemes, false);
|
||||||
}
|
}
|
||||||
@@ -93,10 +96,8 @@ function App() {
|
|||||||
<MantineProvider theme={mantineTheme}>
|
<MantineProvider theme={mantineTheme}>
|
||||||
<ThemeProvider theme={theme}>
|
<ThemeProvider theme={theme}>
|
||||||
<ToastContainer />
|
<ToastContainer />
|
||||||
<ModalsProvider>
|
<RouterProvider router={router} />
|
||||||
<RouterProvider router={router} />
|
<ReactQueryDevtools initialIsOpen={false} />
|
||||||
<ReactQueryDevtools initialIsOpen={false} />
|
|
||||||
</ModalsProvider>
|
|
||||||
</ThemeProvider>
|
</ThemeProvider>
|
||||||
</MantineProvider>
|
</MantineProvider>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { Divider, Modal, Stack } from '@mantine/core';
|
import { Divider, Modal, Stack } from '@mantine/core';
|
||||||
import { useCommonHooks } from 'hooks';
|
import { useCommonHooks } from 'hooks';
|
||||||
import { modalClasses } from 'styles';
|
import { modalClasses } from 'styles';
|
||||||
|
import type { Provider } from 'types';
|
||||||
import HelpSection from './HelpSection';
|
import HelpSection from './HelpSection';
|
||||||
|
|
||||||
export function HelpModal({
|
export function HelpModal({
|
||||||
@@ -47,7 +48,7 @@ export function HelpModal({
|
|||||||
<Stack gap={0} w={'100%'} align='center'>
|
<Stack gap={0} w={'100%'} align='center'>
|
||||||
<HelpSection
|
<HelpSection
|
||||||
name={'Search Providers'}
|
name={'Search Providers'}
|
||||||
items={providerData.map((provider: any) => {
|
items={providerData.map((provider: Provider) => {
|
||||||
return {
|
return {
|
||||||
name: provider.name,
|
name: provider.name,
|
||||||
command: provider.prefix,
|
command: provider.prefix,
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
import { atom } from 'jotai';
|
|
||||||
|
|
||||||
export const HomepageFilters = atom([{ value: 'All', label: 'All' }]);
|
|
||||||
@@ -1,2 +1 @@
|
|||||||
export { HomepageFilters } from './HomepageFilters';
|
|
||||||
export { appTheme } from './theme';
|
export { appTheme } from './theme';
|
||||||
|
|||||||
@@ -2,8 +2,10 @@ import { useLocalStorage } from '@mantine/hooks';
|
|||||||
import { appTheme } from 'contexts';
|
import { appTheme } from 'contexts';
|
||||||
import { useAtom } from 'jotai';
|
import { useAtom } from 'jotai';
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
|
import { useMutationAPI } from './useAPI';
|
||||||
|
|
||||||
export function useCommonHooks() {
|
export function useCommonHooks() {
|
||||||
|
const { mutateAsync } = useMutationAPI();
|
||||||
const isMobile = window.matchMedia('(max-width: 600px)').matches;
|
const isMobile = window.matchMedia('(max-width: 600px)').matches;
|
||||||
const [theme, setTheme] = useAtom(appTheme);
|
const [theme, setTheme] = useAtom(appTheme);
|
||||||
const [themeName, setThemeName] = useLocalStorage<any>({
|
const [themeName, setThemeName] = useLocalStorage<any>({
|
||||||
@@ -51,6 +53,25 @@ export function useCommonHooks() {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const modalStyle = {
|
||||||
|
'--color-text-pri': theme.primaryColor,
|
||||||
|
'--color-text-acc': theme.accentColor,
|
||||||
|
'--color-background': theme.backgroundColor,
|
||||||
|
'--color-border': theme.borderColor,
|
||||||
|
'--color-search-background': theme.searchColor,
|
||||||
|
'--image-background': `url(${theme.backgroundImage})`,
|
||||||
|
};
|
||||||
|
|
||||||
|
const urlPattern = new RegExp(
|
||||||
|
'^(https?:\\/\\/)?' + // protocol
|
||||||
|
'((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|' + // domain name
|
||||||
|
'((\\d{1,3}\\.){3}\\d{1,3}))' + // OR ip (v4) address
|
||||||
|
'(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*' + // port and path
|
||||||
|
'(\\?[;&a-z\\d%_.~+=-]*)?' + // query string
|
||||||
|
'(\\#[-a-z\\d_]*)?$',
|
||||||
|
'i',
|
||||||
|
); // fragment locator
|
||||||
|
|
||||||
const handleThemeChange = (themes: any, save: any) => {
|
const handleThemeChange = (themes: any, save: any) => {
|
||||||
const enabled = themes
|
const enabled = themes
|
||||||
.filter((t: any) => t.randomEnabled)
|
.filter((t: any) => t.randomEnabled)
|
||||||
@@ -69,11 +90,26 @@ export function useCommonHooks() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleDelete = (item: any, endpoint: any) => {
|
||||||
|
mutateAsync({ method: 'DELETE', endpoint: endpoint, body: item });
|
||||||
|
};
|
||||||
|
|
||||||
|
function fixDigits(k: any) {
|
||||||
|
if (k < 10) {
|
||||||
|
return `0${k}`;
|
||||||
|
}
|
||||||
|
return k;
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
isMobile,
|
isMobile,
|
||||||
theme,
|
theme,
|
||||||
setTheme,
|
setTheme,
|
||||||
|
modalStyle,
|
||||||
|
urlPattern,
|
||||||
|
fixDigits,
|
||||||
handleThemeChange,
|
handleThemeChange,
|
||||||
|
handleDelete,
|
||||||
themeName,
|
themeName,
|
||||||
setThemeName,
|
setThemeName,
|
||||||
appFilter,
|
appFilter,
|
||||||
|
|||||||
@@ -4,8 +4,13 @@ import CurrentWeather from 'components/WeatherModal/CurrentWeather';
|
|||||||
import { useCommonHooks, useOSMAPI, useQueryAPI, useWeatherAPI } from 'hooks';
|
import { useCommonHooks, useOSMAPI, useQueryAPI, useWeatherAPI } from 'hooks';
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { stackClasses } from 'styles';
|
import { stackClasses } from 'styles';
|
||||||
import type { CurrentWeather as CW, OutlookWeather } from 'types';
|
import type {
|
||||||
import type { ExtendedForecast as EF } from 'types/weather';
|
CurrentWeather as CW,
|
||||||
|
ExtendedForecast as EF,
|
||||||
|
Message,
|
||||||
|
OutlookWeather,
|
||||||
|
PersonalData,
|
||||||
|
} from 'types';
|
||||||
import Applications from './components/Applications/Applications';
|
import Applications from './components/Applications/Applications';
|
||||||
import Bookmarks from './components/Bookmarks/Bookmarks';
|
import Bookmarks from './components/Bookmarks/Bookmarks';
|
||||||
import Header from './components/Header/Header';
|
import Header from './components/Header/Header';
|
||||||
@@ -24,11 +29,6 @@ export function Homepage() {
|
|||||||
} = useQueryAPI({
|
} = useQueryAPI({
|
||||||
endpoint: 'api/messages',
|
endpoint: 'api/messages',
|
||||||
});
|
});
|
||||||
const [personalData, setPersonalData] = useState<any>(null);
|
|
||||||
const [messages, setMessages] = useState<any>(null);
|
|
||||||
const [displayedGreeting, setDisplayedGreeting] = useState('');
|
|
||||||
const [weatherModalOpened, { open: openWeatherModal, close: closeWeatherModal }] =
|
|
||||||
useDisclosure(false);
|
|
||||||
const {
|
const {
|
||||||
appFilter,
|
appFilter,
|
||||||
bookmarkFilter,
|
bookmarkFilter,
|
||||||
@@ -37,6 +37,11 @@ export function Homepage() {
|
|||||||
currentLocation,
|
currentLocation,
|
||||||
setCurrentLocation,
|
setCurrentLocation,
|
||||||
} = useCommonHooks();
|
} = useCommonHooks();
|
||||||
|
const [personalData, setPersonalData] = useState<PersonalData>();
|
||||||
|
const [messages, setMessages] = useState<Message[]>([]);
|
||||||
|
const [displayedGreeting, setDisplayedGreeting] = useState('');
|
||||||
|
const [weatherModalOpened, { open: openWeatherModal, close: closeWeatherModal }] =
|
||||||
|
useDisclosure(false);
|
||||||
const dateOptions: Intl.DateTimeFormatOptions = !isMobile
|
const dateOptions: Intl.DateTimeFormatOptions = !isMobile
|
||||||
? {
|
? {
|
||||||
weekday: 'long',
|
weekday: 'long',
|
||||||
@@ -54,23 +59,22 @@ export function Homepage() {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (personal && personalIsFetched) {
|
if (personal && personalIsFetched) {
|
||||||
setCurrentUser(personal[0]);
|
setCurrentUser(personal[0]);
|
||||||
setPersonalData(personal);
|
setPersonalData(personal[0]);
|
||||||
}
|
}
|
||||||
}, [personal, personalIsFetched]);
|
}, [personal, personalIsFetched]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (messages && personalData) {
|
if (messages && personalData) {
|
||||||
setDisplayedGreeting(() => {
|
setDisplayedGreeting(() => {
|
||||||
if (Math.floor(Math.random() * 100) > 10 || messages.length === 0) {
|
if (Math.floor(Math.random() * 100) > 10 || messages.length === 0) {
|
||||||
switch (Math.floor(new Date().getHours() / 6)) {
|
switch (Math.floor(new Date().getHours() / 6)) {
|
||||||
case 0:
|
case 0:
|
||||||
return `Good night, ${personalData?.[0]?.firstName}!`;
|
return `Good night, ${personalData?.firstName}!`;
|
||||||
case 1:
|
case 1:
|
||||||
return `Good morning, ${personalData?.[0]?.firstName}!`;
|
return `Good morning, ${personalData?.firstName}!`;
|
||||||
case 2:
|
case 2:
|
||||||
return `Good afternoon, ${personalData?.[0]?.firstName}!`;
|
return `Good afternoon, ${personalData?.firstName}!`;
|
||||||
case 3:
|
case 3:
|
||||||
return `Good evening, ${personalData?.[0]?.firstName}!`;
|
return `Good evening, ${personalData?.firstName}!`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return messages[Math.floor(Math.random() * messages.length)].message;
|
return messages[Math.floor(Math.random() * messages.length)].message;
|
||||||
|
|||||||
@@ -5,9 +5,9 @@ import { useState } from 'react';
|
|||||||
import { stackClasses, textClasses } from 'styles';
|
import { stackClasses, textClasses } from 'styles';
|
||||||
|
|
||||||
function AppItem({ url, icon, name }: any) {
|
function AppItem({ url, icon, name }: any) {
|
||||||
|
const { isMobile } = useCommonHooks();
|
||||||
const [textDecoration, setTextDecoration] = useState<string>('none');
|
const [textDecoration, setTextDecoration] = useState<string>('none');
|
||||||
const [hover, setHover] = useState<boolean>(false);
|
const [hover, setHover] = useState<boolean>(false);
|
||||||
const { isMobile } = useCommonHooks();
|
|
||||||
const validUrl =
|
const validUrl =
|
||||||
url.startsWith('http://') || url.startsWith('https://') ? url : `http://${url}`;
|
url.startsWith('http://') || url.startsWith('https://') ? url : `http://${url}`;
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -2,14 +2,15 @@ import { Stack, Text } from '@mantine/core';
|
|||||||
import { useCommonHooks, useQueryAPI } from 'hooks';
|
import { useCommonHooks, useQueryAPI } from 'hooks';
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { textClasses } from 'styles';
|
import { textClasses } from 'styles';
|
||||||
|
import type { Application } from 'types';
|
||||||
import AppItem from './AppItem';
|
import AppItem from './AppItem';
|
||||||
|
|
||||||
function Applications({ contentType }: any) {
|
function Applications({ contentType }: any) {
|
||||||
const { data: apps, isFetching: isAppsFetching } = useQueryAPI({
|
const { data: apps, isFetching: isAppsFetching } = useQueryAPI({
|
||||||
endpoint: 'api/apps',
|
endpoint: 'api/apps',
|
||||||
});
|
});
|
||||||
const [applicationData, setApplicationData] = useState<any>([]);
|
|
||||||
const { isMobile } = useCommonHooks();
|
const { isMobile } = useCommonHooks();
|
||||||
|
const [applicationData, setApplicationData] = useState<Application[]>([]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (apps && !isAppsFetching) {
|
if (apps && !isAppsFetching) {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { Stack, Text } from '@mantine/core';
|
|||||||
import { useCommonHooks, useQueryAPI } from 'hooks';
|
import { useCommonHooks, useQueryAPI } from 'hooks';
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { textClasses } from 'styles';
|
import { textClasses } from 'styles';
|
||||||
|
import type { Bookmark, BookmarkGroup } from 'types';
|
||||||
import LinkGroups from './LinkGroups';
|
import LinkGroups from './LinkGroups';
|
||||||
|
|
||||||
function Links({ contentType }: any) {
|
function Links({ contentType }: any) {
|
||||||
@@ -11,9 +12,9 @@ function Links({ contentType }: any) {
|
|||||||
const { data: groupData, isFetched: groupsIsFetched } = useQueryAPI({
|
const { data: groupData, isFetched: groupsIsFetched } = useQueryAPI({
|
||||||
endpoint: 'api/categories',
|
endpoint: 'api/categories',
|
||||||
});
|
});
|
||||||
const [bookmarkData, setBookmarkData] = useState<any>([]);
|
|
||||||
const [groups, setGroups] = useState([]);
|
|
||||||
const { isMobile } = useCommonHooks();
|
const { isMobile } = useCommonHooks();
|
||||||
|
const [bookmarkData, setBookmarkData] = useState<Bookmark[]>([]);
|
||||||
|
const [groups, setGroups] = useState<BookmarkGroup[]>([]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (linkData && linksIsFetched) {
|
if (linkData && linksIsFetched) {
|
||||||
@@ -23,10 +24,14 @@ function Links({ contentType }: any) {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (groupData && groupsIsFetched) {
|
if (groupData && groupsIsFetched) {
|
||||||
const groupList = groupData?.map((category: any) => {
|
const groupList = groupData?.map((category: BookmarkGroup) => {
|
||||||
return category;
|
return category;
|
||||||
});
|
});
|
||||||
setGroups(groupList);
|
setGroups(
|
||||||
|
groupList.sort((a: BookmarkGroup, b: BookmarkGroup) =>
|
||||||
|
a.categoryIndex > b.categoryIndex ? 1 : -1,
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}, [groupData, groupsIsFetched]);
|
}, [groupData, groupsIsFetched]);
|
||||||
|
|
||||||
@@ -50,24 +55,23 @@ function Links({ contentType }: any) {
|
|||||||
gridTemplateRows: 'auto',
|
gridTemplateRows: 'auto',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{groups
|
{groups.map((category: BookmarkGroup) => {
|
||||||
.sort((a: any, b: any) => (a.categoryIndex > b.categoryIndex ? 1 : -1))
|
if (
|
||||||
.map((category: any) => {
|
contentType.includes(category.filterName) ||
|
||||||
if (
|
contentType.includes('All')
|
||||||
contentType.includes(category.filterName) ||
|
) {
|
||||||
contentType.includes('All')
|
return (
|
||||||
) {
|
<LinkGroups
|
||||||
return (
|
key={category.categoryName}
|
||||||
<LinkGroups
|
category={category.categoryName}
|
||||||
key={category.categoryName}
|
links={bookmarkData.filter(
|
||||||
category={category.categoryName}
|
(bookmark: Bookmark) =>
|
||||||
links={bookmarkData.filter(
|
bookmark.category === category.categoryName,
|
||||||
(bookmark: any) => bookmark.category === category.categoryName,
|
)}
|
||||||
)}
|
/>
|
||||||
/>
|
);
|
||||||
);
|
}
|
||||||
}
|
})}
|
||||||
})}
|
|
||||||
</Stack>
|
</Stack>
|
||||||
</Stack>
|
</Stack>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -8,8 +8,6 @@ function LinkItem({ link }: any) {
|
|||||||
classNames={textClasses}
|
classNames={textClasses}
|
||||||
component='a'
|
component='a'
|
||||||
href={link.url}
|
href={link.url}
|
||||||
style={{ overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}
|
|
||||||
w={'min-content'}
|
|
||||||
>
|
>
|
||||||
{link.name}
|
{link.name}
|
||||||
</Text>
|
</Text>
|
||||||
|
|||||||
@@ -18,14 +18,7 @@ function Header({
|
|||||||
openWeatherModal,
|
openWeatherModal,
|
||||||
}: any) {
|
}: any) {
|
||||||
const [time, setTime] = useState(new Date());
|
const [time, setTime] = useState(new Date());
|
||||||
const { isMobile, currentUser } = useCommonHooks();
|
const { isMobile, currentUser, fixDigits } = useCommonHooks();
|
||||||
|
|
||||||
function fixDigits(k: any) {
|
|
||||||
if (k < 10) {
|
|
||||||
return `0${k}`;
|
|
||||||
}
|
|
||||||
return k;
|
|
||||||
}
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
|
|||||||
@@ -5,14 +5,7 @@ import { textClasses } from 'styles';
|
|||||||
|
|
||||||
function LargeHeader({ greet, date, setCurrent, weather, basicWeather }: any) {
|
function LargeHeader({ greet, date, setCurrent, weather, basicWeather }: any) {
|
||||||
const [time, setTime] = useState(new Date());
|
const [time, setTime] = useState(new Date());
|
||||||
const { isMobile, currentUser } = useCommonHooks();
|
const { isMobile, currentUser, fixDigits } = useCommonHooks();
|
||||||
|
|
||||||
function fixDigits(k: any) {
|
|
||||||
if (k < 10) {
|
|
||||||
return `0${k}`;
|
|
||||||
}
|
|
||||||
return k;
|
|
||||||
}
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import { useCommonHooks, useMutationAPI, useQueryAPI } from 'hooks';
|
|||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { FiEdit, FiTrash } from 'react-icons/fi';
|
import { FiEdit, FiTrash } from 'react-icons/fi';
|
||||||
import { actionIconClasses, selectClasses } from 'styles';
|
import { actionIconClasses, selectClasses } from 'styles';
|
||||||
|
import type { Application, Provider } from 'types';
|
||||||
|
|
||||||
export default function Search({
|
export default function Search({
|
||||||
current,
|
current,
|
||||||
@@ -24,7 +25,7 @@ export default function Search({
|
|||||||
const { data: providers, isFetched: providersIsFetched } = useQueryAPI({
|
const { data: providers, isFetched: providersIsFetched } = useQueryAPI({
|
||||||
endpoint: 'api/providers',
|
endpoint: 'api/providers',
|
||||||
});
|
});
|
||||||
const [providerData, setProviderData] = useState<any>([]);
|
const [providerData, setProviderData] = useState<Provider[]>([]);
|
||||||
const { data: apps, isFetching: isAppsFetching } = useQueryAPI({
|
const { data: apps, isFetching: isAppsFetching } = useQueryAPI({
|
||||||
endpoint: 'api/apps',
|
endpoint: 'api/apps',
|
||||||
});
|
});
|
||||||
@@ -42,6 +43,7 @@ export default function Search({
|
|||||||
const [listIndex, setListIndex] = useState(0);
|
const [listIndex, setListIndex] = useState(0);
|
||||||
const {
|
const {
|
||||||
theme,
|
theme,
|
||||||
|
urlPattern,
|
||||||
providerLabel,
|
providerLabel,
|
||||||
setProviderLabel,
|
setProviderLabel,
|
||||||
providerURL,
|
providerURL,
|
||||||
@@ -53,15 +55,6 @@ export default function Search({
|
|||||||
} = useCommonHooks();
|
} = useCommonHooks();
|
||||||
const [placeholderValue, setPlaceholderValue] = useState('');
|
const [placeholderValue, setPlaceholderValue] = useState('');
|
||||||
const [value, setValue] = useState(0);
|
const [value, setValue] = useState(0);
|
||||||
const urlPattern = new RegExp(
|
|
||||||
'^(https?:\\/\\/)?' + // protocol
|
|
||||||
'((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|' + // domain name
|
|
||||||
'((\\d{1,3}\\.){3}\\d{1,3}))' + // OR ip (v4) address
|
|
||||||
'(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*' + // port and path
|
|
||||||
'(\\?[;&a-z\\d%_.~+=-]*)?' + // query string
|
|
||||||
'(\\#[-a-z\\d_]*)?$',
|
|
||||||
'i',
|
|
||||||
); // fragment locator
|
|
||||||
|
|
||||||
const handleSearchHistoryItem = (item: any) => {
|
const handleSearchHistoryItem = (item: any) => {
|
||||||
const url =
|
const url =
|
||||||
@@ -104,7 +97,7 @@ export default function Search({
|
|||||||
openWeatherModal();
|
openWeatherModal();
|
||||||
} else if (providerLabel.startsWith('Launch')) {
|
} else if (providerLabel.startsWith('Launch')) {
|
||||||
open(
|
open(
|
||||||
`https://${applicationData?.find((app: any) => app.baseUrl.substr(1).toLowerCase() === item.target.value.substr(1)).url}`,
|
`https://${applicationData ?? applicationData.find((app: Application) => app.baseUrl.substring(1).toLowerCase() === item.target.value.substr(1)).url}`,
|
||||||
'_self',
|
'_self',
|
||||||
);
|
);
|
||||||
} else if (urlPattern.test(item.target.value)) {
|
} else if (urlPattern.test(item.target.value)) {
|
||||||
@@ -213,11 +206,11 @@ export default function Search({
|
|||||||
setProviderPrefix('/g');
|
setProviderPrefix('/g');
|
||||||
} else if (item.target.value.startsWith('/')) {
|
} else if (item.target.value.startsWith('/')) {
|
||||||
const provider = providerData?.find(
|
const provider = providerData?.find(
|
||||||
(p: any) => p.prefix === item.target.value.split(' ')[0],
|
(p: Provider) => p.prefix === item.target.value.split(' ')[0],
|
||||||
);
|
);
|
||||||
setProviderLabel(provider?.name || 'Invalid Search');
|
setProviderLabel(provider?.name ?? 'Invalid Search');
|
||||||
setProviderURL(provider?.url);
|
setProviderURL(provider?.url ?? '');
|
||||||
setProviderPrefix(provider?.prefix);
|
setProviderPrefix(provider?.prefix ?? '');
|
||||||
} else if (item.target.value.startsWith('!')) {
|
} else if (item.target.value.startsWith('!')) {
|
||||||
if (item.target.value === '!w' || item.target.value === '!weather') {
|
if (item.target.value === '!w' || item.target.value === '!weather') {
|
||||||
setProviderLabel('Show weather');
|
setProviderLabel('Show weather');
|
||||||
@@ -255,9 +248,12 @@ export default function Search({
|
|||||||
}
|
}
|
||||||
return options
|
return options
|
||||||
.filter((option: any) => {
|
.filter((option: any) => {
|
||||||
const words = option.value.toLowerCase().trim().split(' ');
|
|
||||||
return splittedSearch.every((searchWord) =>
|
return splittedSearch.every((searchWord) =>
|
||||||
words.some((word: any) => word.includes(searchWord)),
|
option.value
|
||||||
|
.toLowerCase()
|
||||||
|
.trim()
|
||||||
|
.split(' ')
|
||||||
|
.some((word: any) => word.includes(searchWord)),
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
.slice(0, 10);
|
.slice(0, 10);
|
||||||
|
|||||||
@@ -24,13 +24,14 @@ import {
|
|||||||
selectClasses,
|
selectClasses,
|
||||||
stackClasses,
|
stackClasses,
|
||||||
} from 'styles';
|
} from 'styles';
|
||||||
|
import type { AppCategory, Theme, ThemePlaylist, WolClient } from 'types';
|
||||||
|
|
||||||
function SettingsButton() {
|
function SettingsButton() {
|
||||||
const { data, isFetched } = useQueryAPI({ endpoint: 'api/appCategories' });
|
const { data, isFetched } = useQueryAPI({ endpoint: 'api/appCategories' });
|
||||||
const { data: wolClients, isFetched: wolClientsIsFetched } = useQueryAPI({
|
const { data: wolClients, isFetched: wolClientsIsFetched } = useQueryAPI({
|
||||||
endpoint: 'api/wolClients',
|
endpoint: 'api/wolClients',
|
||||||
});
|
});
|
||||||
const [wolClientsData, setWolClientsData] = useState<any>([]);
|
const [wolClientsData, setWolClientsData] = useState<WolClient[]>([]);
|
||||||
const { data: allThemes, isFetched: isAllThemesFetched } = useQueryAPI({
|
const { data: allThemes, isFetched: isAllThemesFetched } = useQueryAPI({
|
||||||
endpoint: 'api/themes',
|
endpoint: 'api/themes',
|
||||||
});
|
});
|
||||||
@@ -38,9 +39,9 @@ function SettingsButton() {
|
|||||||
endpoint: 'api/themePlaylists',
|
endpoint: 'api/themePlaylists',
|
||||||
});
|
});
|
||||||
const { mutateAsync: wakeRequest } = useMutationAPI();
|
const { mutateAsync: wakeRequest } = useMutationAPI();
|
||||||
const [allThemeData, setAllThemeData] = useState<any>([]);
|
const [allThemeData, setAllThemeData] = useState<Theme[]>([]);
|
||||||
const [categories, setCategories] = useState([{ value: 'All', label: 'All' }]);
|
const [categories, setCategories] = useState([{ value: 'All', label: 'All' }]);
|
||||||
const [selectedClient, setSelectedClient] = useState<any>(wolClients?.[0]);
|
const [selectedClient, setSelectedClient] = useState<WolClient>(wolClients?.[0]);
|
||||||
const [overlayOpened, setOverlayOpened] = useState(false);
|
const [overlayOpened, setOverlayOpened] = useState(false);
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const notify = (notification: any) => toast(notification, { position: 'bottom-right' });
|
const notify = (notification: any) => toast(notification, { position: 'bottom-right' });
|
||||||
@@ -50,7 +51,6 @@ function SettingsButton() {
|
|||||||
setThemeName,
|
setThemeName,
|
||||||
handleThemeChange,
|
handleThemeChange,
|
||||||
theme,
|
theme,
|
||||||
setTheme,
|
|
||||||
appFilter,
|
appFilter,
|
||||||
setAppFilter,
|
setAppFilter,
|
||||||
bookmarkFilter,
|
bookmarkFilter,
|
||||||
@@ -69,7 +69,7 @@ function SettingsButton() {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (data) {
|
if (data) {
|
||||||
const list: [any] = data.map((category: any) => {
|
const list: [any] = data.map((category: AppCategory) => {
|
||||||
return { value: category.filterName, label: category.filterName };
|
return { value: category.filterName, label: category.filterName };
|
||||||
});
|
});
|
||||||
list.unshift({ value: 'All', label: 'All' });
|
list.unshift({ value: 'All', label: 'All' });
|
||||||
@@ -232,7 +232,7 @@ function SettingsButton() {
|
|||||||
value={currentThemePlaylist}
|
value={currentThemePlaylist}
|
||||||
data={
|
data={
|
||||||
themePlaylists
|
themePlaylists
|
||||||
?.map((playlist: any) => {
|
?.map((playlist: ThemePlaylist) => {
|
||||||
return {
|
return {
|
||||||
value: playlist.name,
|
value: playlist.name,
|
||||||
label: playlist.name,
|
label: playlist.name,
|
||||||
@@ -254,12 +254,13 @@ function SettingsButton() {
|
|||||||
setThemeName('random');
|
setThemeName('random');
|
||||||
} else {
|
} else {
|
||||||
const themeList = JSON.parse(
|
const themeList = JSON.parse(
|
||||||
themePlaylists.find((t: any) => t.name === 'Time of Day')
|
themePlaylists.find(
|
||||||
.themeList,
|
(t: ThemePlaylist) => t.name === 'Time of Day',
|
||||||
|
).themeList,
|
||||||
);
|
);
|
||||||
setThemeName(
|
setThemeName(
|
||||||
allThemes.find(
|
allThemes.find(
|
||||||
(t: any) =>
|
(t: Theme) =>
|
||||||
t.id ===
|
t.id ===
|
||||||
Number(themeList[Math.floor(new Date().getHours() / 6)]),
|
Number(themeList[Math.floor(new Date().getHours() / 6)]),
|
||||||
).name,
|
).name,
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import {
|
|||||||
textClasses,
|
textClasses,
|
||||||
textInputClasses,
|
textInputClasses,
|
||||||
} from 'styles';
|
} from 'styles';
|
||||||
|
import type { Application } from 'types';
|
||||||
import AppSettingsItem from './AppSettingsItem';
|
import AppSettingsItem from './AppSettingsItem';
|
||||||
import DebouncedApplication from './DebouncedApplication';
|
import DebouncedApplication from './DebouncedApplication';
|
||||||
|
|
||||||
@@ -32,27 +33,26 @@ const ApplicationSettings = () => {
|
|||||||
const { data: apps, isFetching: isAppsFetching } = useQueryAPI({
|
const { data: apps, isFetching: isAppsFetching } = useQueryAPI({
|
||||||
endpoint: endpoint,
|
endpoint: endpoint,
|
||||||
});
|
});
|
||||||
const [applicationData, setApplicationData] = useState<any>([]);
|
const [applicationData, setApplicationData] = useState<Application[]>([]);
|
||||||
const { theme, isMobile } = useCommonHooks();
|
const { theme, isMobile, modalStyle } = useCommonHooks();
|
||||||
const [newApplication, setNewApplication] = useState<any>({
|
const [newApplication, setNewApplication] = useState<Application>({
|
||||||
|
id: undefined,
|
||||||
name: '',
|
name: '',
|
||||||
url: '',
|
url: '',
|
||||||
icon: '',
|
icon: '',
|
||||||
baseUrl: '',
|
baseUrl: '',
|
||||||
filterName: '',
|
filterName: '',
|
||||||
|
index: 0,
|
||||||
});
|
});
|
||||||
const { mutateAsync } = useMutationAPI();
|
const { mutateAsync } = useMutationAPI();
|
||||||
const [searchValue, setSearchValue] = useState('');
|
const [searchValue, setSearchValue] = useState('');
|
||||||
const [debouncedSearch] = useDebouncedValue(searchValue, 500);
|
const [debouncedSearch] = useDebouncedValue(searchValue, 500);
|
||||||
const [modalOpened, { open: openModal, close: closeModal }] = useDisclosure(false);
|
const [modalOpened, { open: openModal, close: closeModal }] = useDisclosure(false);
|
||||||
const handleDelete = (application: any) => {
|
|
||||||
mutateAsync({ method: 'DELETE', endpoint: endpoint, body: application });
|
|
||||||
};
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (apps && !isAppsFetching) {
|
if (apps && !isAppsFetching) {
|
||||||
setApplicationData(
|
setApplicationData(
|
||||||
apps.filter((a: any) =>
|
apps.filter((a: Application) =>
|
||||||
a.name.toLowerCase().includes(debouncedSearch.toLowerCase()),
|
a.name.toLowerCase().includes(debouncedSearch.toLowerCase()),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -70,14 +70,7 @@ const ApplicationSettings = () => {
|
|||||||
onClose={() => {
|
onClose={() => {
|
||||||
closeModal();
|
closeModal();
|
||||||
}}
|
}}
|
||||||
style={{
|
style={modalStyle}
|
||||||
'--color-text-pri': theme.primaryColor,
|
|
||||||
'--color-text-acc': theme.accentColor,
|
|
||||||
'--color-background': theme.backgroundColor,
|
|
||||||
'--color-border': theme.borderColor,
|
|
||||||
'--color-search-background': theme.searchColor,
|
|
||||||
'--image-background': `url(${theme.backgroundImage})`,
|
|
||||||
}}
|
|
||||||
closeOnEscape
|
closeOnEscape
|
||||||
closeOnClickOutside
|
closeOnClickOutside
|
||||||
>
|
>
|
||||||
@@ -269,7 +262,7 @@ const ApplicationSettings = () => {
|
|||||||
</Group>
|
</Group>
|
||||||
<Stack w={'100%'} align='center'>
|
<Stack w={'100%'} align='center'>
|
||||||
<Grid columns={18} w={'75%'}>
|
<Grid columns={18} w={'75%'}>
|
||||||
{applicationData?.map((application: any) => (
|
{applicationData?.map((application: Application) => (
|
||||||
<GridCol span={6} key={application.id}>
|
<GridCol span={6} key={application.id}>
|
||||||
<Popover withArrow withOverlay withinPortal={false}>
|
<Popover withArrow withOverlay withinPortal={false}>
|
||||||
<Popover.Target>
|
<Popover.Target>
|
||||||
@@ -286,10 +279,7 @@ const ApplicationSettings = () => {
|
|||||||
</Box>
|
</Box>
|
||||||
</Popover.Target>
|
</Popover.Target>
|
||||||
<Popover.Dropdown>
|
<Popover.Dropdown>
|
||||||
<DebouncedApplication
|
<DebouncedApplication application={application} />
|
||||||
application={application}
|
|
||||||
handleDelete={handleDelete}
|
|
||||||
/>
|
|
||||||
</Popover.Dropdown>
|
</Popover.Dropdown>
|
||||||
</Popover>
|
</Popover>
|
||||||
</GridCol>
|
</GridCol>
|
||||||
|
|||||||
@@ -14,14 +14,15 @@ import { IconTrash } from '@tabler/icons-react';
|
|||||||
import { useCommonHooks, useMutationAPI } from 'hooks';
|
import { useCommonHooks, useMutationAPI } from 'hooks';
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { cardClasses, modalClasses, textInputClasses } from 'styles';
|
import { cardClasses, modalClasses, textInputClasses } from 'styles';
|
||||||
|
import type { Application } from 'types';
|
||||||
|
|
||||||
function DebouncedApplication({ application, handleDelete }: any) {
|
function DebouncedApplication({ application }: { application: Application }) {
|
||||||
const { theme, isMobile } = useCommonHooks();
|
const { theme, isMobile, modalStyle, handleDelete } = useCommonHooks();
|
||||||
const [modalOpened, { open: openModal, close: closeModal }] = useDisclosure(false);
|
const [modalOpened, { open: openModal, close: closeModal }] = useDisclosure(false);
|
||||||
const { mutateAsync } = useMutationAPI();
|
const { mutateAsync } = useMutationAPI();
|
||||||
|
|
||||||
const [app, setApp] = useState<any>(application);
|
const [app, setApp] = useState<Application>(application);
|
||||||
const [update, setUpdate] = useState({});
|
const [update, setUpdate] = useState<any>();
|
||||||
const [debounced] = useDebouncedValue(update, 1000);
|
const [debounced] = useDebouncedValue(update, 1000);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -47,14 +48,7 @@ function DebouncedApplication({ application, handleDelete }: any) {
|
|||||||
onClose={() => {
|
onClose={() => {
|
||||||
closeModal();
|
closeModal();
|
||||||
}}
|
}}
|
||||||
style={{
|
style={modalStyle}
|
||||||
'--color-text-pri': theme.primaryColor,
|
|
||||||
'--color-text-acc': theme.accentColor,
|
|
||||||
'--color-background': theme.backgroundColor,
|
|
||||||
'--color-border': theme.borderColor,
|
|
||||||
'--color-search-background': theme.searchColor,
|
|
||||||
'--image-background': `url(${theme.backgroundImage})`,
|
|
||||||
}}
|
|
||||||
closeOnEscape
|
closeOnEscape
|
||||||
closeOnClickOutside
|
closeOnClickOutside
|
||||||
>
|
>
|
||||||
@@ -84,7 +78,7 @@ function DebouncedApplication({ application, handleDelete }: any) {
|
|||||||
color={'red'}
|
color={'red'}
|
||||||
styles={{ label: { color: 'black' } }}
|
styles={{ label: { color: 'black' } }}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
handleDelete(app);
|
handleDelete(app, 'api/apps');
|
||||||
closeModal();
|
closeModal();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -25,20 +25,26 @@ import {
|
|||||||
textClasses,
|
textClasses,
|
||||||
textInputClasses,
|
textInputClasses,
|
||||||
} from 'styles';
|
} from 'styles';
|
||||||
|
import type { Bookmark, BookmarkGroup } from 'types';
|
||||||
import DebouncedGroupSettingsItem from './DebouncedGroupSettingsItem';
|
import DebouncedGroupSettingsItem from './DebouncedGroupSettingsItem';
|
||||||
const BookmarkSettings = () => {
|
const BookmarkSettings = () => {
|
||||||
const { data: linkData, isFetched: linksIsFetched } = useQueryAPI({
|
const { data: linkData, isFetched: linksIsFetched } = useQueryAPI({
|
||||||
endpoint: 'api/links',
|
endpoint: 'api/links',
|
||||||
});
|
});
|
||||||
const [bookmarks, setBookmarks] = useState<any>([]);
|
const [bookmarks, setBookmarks] = useState<Bookmark[]>([]);
|
||||||
const { data: groupData, isFetched: groupsIsFetched } = useQueryAPI({
|
const { data: groupData, isFetched: groupsIsFetched } = useQueryAPI({
|
||||||
endpoint: 'api/categories',
|
endpoint: 'api/categories',
|
||||||
});
|
});
|
||||||
const [dragging, setDragging] = useState(false);
|
const [dragging, setDragging] = useState(false);
|
||||||
const [groups, setGroups] = useState<any>([]);
|
const [groups, setGroups] = useState<BookmarkGroup[]>([]);
|
||||||
const [newGroup, setNewGroup] = useState<any>({});
|
const [newGroup, setNewGroup] = useState<BookmarkGroup>({
|
||||||
const [groupList, setGroupList] = useState<any>([]);
|
id: undefined,
|
||||||
const { theme, isMobile } = useCommonHooks();
|
categoryName: '',
|
||||||
|
categoryIndex: 0,
|
||||||
|
filterName: '',
|
||||||
|
});
|
||||||
|
const [groupList, setGroupList] = useState<BookmarkGroup[]>([]);
|
||||||
|
const { theme, isMobile, modalStyle } = useCommonHooks();
|
||||||
const { mutateAsync } = useMutationAPI();
|
const { mutateAsync } = useMutationAPI();
|
||||||
const [searchValue, setSearchValue] = useState('');
|
const [searchValue, setSearchValue] = useState('');
|
||||||
const [debouncedGroupSearch] = useDebouncedValue(searchValue, 500);
|
const [debouncedGroupSearch] = useDebouncedValue(searchValue, 500);
|
||||||
@@ -80,9 +86,13 @@ const BookmarkSettings = () => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (groupData && groupsIsFetched) {
|
if (groupData && groupsIsFetched) {
|
||||||
setGroups(
|
setGroups(
|
||||||
groupData.filter((a: any) =>
|
groupData
|
||||||
a.categoryName.toLowerCase().includes(debouncedGroupSearch.toLowerCase()),
|
.filter((a: BookmarkGroup) =>
|
||||||
),
|
a.categoryName.toLowerCase().includes(debouncedGroupSearch.toLowerCase()),
|
||||||
|
)
|
||||||
|
.sort((a: BookmarkGroup, b: BookmarkGroup) =>
|
||||||
|
a.categoryIndex > b.categoryIndex ? 1 : -1,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}, [groupData, groupsIsFetched, debouncedGroupSearch]);
|
}, [groupData, groupsIsFetched, debouncedGroupSearch]);
|
||||||
@@ -104,14 +114,7 @@ const BookmarkSettings = () => {
|
|||||||
onClose={() => {
|
onClose={() => {
|
||||||
closeModal();
|
closeModal();
|
||||||
}}
|
}}
|
||||||
style={{
|
style={modalStyle}
|
||||||
'--color-text-pri': theme.primaryColor,
|
|
||||||
'--color-text-acc': theme.accentColor,
|
|
||||||
'--color-background': theme.backgroundColor,
|
|
||||||
'--color-border': theme.borderColor,
|
|
||||||
'--color-search-background': theme.searchColor,
|
|
||||||
'--image-background': `url(${theme.backgroundImage})`,
|
|
||||||
}}
|
|
||||||
closeOnEscape
|
closeOnEscape
|
||||||
closeOnClickOutside
|
closeOnClickOutside
|
||||||
>
|
>
|
||||||
@@ -282,69 +285,65 @@ const BookmarkSettings = () => {
|
|||||||
ref={provided.innerRef}
|
ref={provided.innerRef}
|
||||||
{...provided.droppableProps}
|
{...provided.droppableProps}
|
||||||
>
|
>
|
||||||
{groups
|
{groups?.map((group: BookmarkGroup) => (
|
||||||
?.sort((a: any, b: any) =>
|
<Draggable
|
||||||
a.categoryIndex > b.categoryIndex ? 1 : -1,
|
key={group.id}
|
||||||
)
|
draggableId={`${group.id}`}
|
||||||
.map((group: any) => (
|
index={Number(group.categoryIndex)}
|
||||||
<Draggable
|
>
|
||||||
key={group.id}
|
{(provided) => (
|
||||||
draggableId={`${group.id}`}
|
<Box
|
||||||
index={Number(group.categoryIndex)}
|
ref={provided.innerRef}
|
||||||
>
|
{...provided.draggableProps}
|
||||||
{(provided) => (
|
{...provided.dragHandleProps}
|
||||||
<Box
|
>
|
||||||
ref={provided.innerRef}
|
<Card
|
||||||
{...provided.draggableProps}
|
w={'400px'}
|
||||||
{...provided.dragHandleProps}
|
style={{
|
||||||
|
backgroundColor: theme.searchColor,
|
||||||
|
border: '1px solid var(--color-border)',
|
||||||
|
borderRadius: '8px',
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<Card
|
<Group gap={0} align='center' justify='space-between'>
|
||||||
w={'400px'}
|
<Stack gap={0}>
|
||||||
style={{
|
<Text c={theme.accentColor} fz={14}>
|
||||||
backgroundColor: theme.searchColor,
|
Name
|
||||||
border: '1px solid var(--color-border)',
|
</Text>
|
||||||
borderRadius: '8px',
|
<Text
|
||||||
}}
|
p={4}
|
||||||
>
|
style={{
|
||||||
<Group gap={0} align='center' justify='space-between'>
|
borderRadius: '4px',
|
||||||
<Stack gap={0}>
|
paddingLeft: '8px',
|
||||||
<Text c={theme.accentColor} fz={14}>
|
color: theme.primaryColor,
|
||||||
Name
|
backgroundColor: theme.searchColor,
|
||||||
</Text>
|
}}
|
||||||
<Text
|
>
|
||||||
p={4}
|
{group.categoryName}
|
||||||
style={{
|
</Text>
|
||||||
borderRadius: '4px',
|
</Stack>
|
||||||
paddingLeft: '8px',
|
<Stack gap={0}>
|
||||||
color: theme.primaryColor,
|
<Text c={theme.accentColor} fz={14}>
|
||||||
backgroundColor: theme.searchColor,
|
Filter Name
|
||||||
}}
|
</Text>
|
||||||
>
|
<Text
|
||||||
{group.categoryName}
|
p={4}
|
||||||
</Text>
|
style={{
|
||||||
</Stack>
|
borderRadius: '4px',
|
||||||
<Stack gap={0}>
|
paddingLeft: '8px',
|
||||||
<Text c={theme.accentColor} fz={14}>
|
color: theme.primaryColor,
|
||||||
Filter Name
|
backgroundColor: theme.searchColor,
|
||||||
</Text>
|
}}
|
||||||
<Text
|
>
|
||||||
p={4}
|
{group.filterName}
|
||||||
style={{
|
</Text>
|
||||||
borderRadius: '4px',
|
</Stack>
|
||||||
paddingLeft: '8px',
|
</Group>
|
||||||
color: theme.primaryColor,
|
</Card>
|
||||||
backgroundColor: theme.searchColor,
|
</Box>
|
||||||
}}
|
)}
|
||||||
>
|
</Draggable>
|
||||||
{group.filterName}
|
))}
|
||||||
</Text>
|
|
||||||
</Stack>
|
|
||||||
</Group>
|
|
||||||
</Card>
|
|
||||||
</Box>
|
|
||||||
)}
|
|
||||||
</Draggable>
|
|
||||||
))}
|
|
||||||
{provided.placeholder}
|
{provided.placeholder}
|
||||||
</Stack>
|
</Stack>
|
||||||
)}
|
)}
|
||||||
@@ -354,17 +353,15 @@ const BookmarkSettings = () => {
|
|||||||
) : (
|
) : (
|
||||||
<Stack w={'100%'} align='center'>
|
<Stack w={'100%'} align='center'>
|
||||||
<Group w={'75%'} align='start'>
|
<Group w={'75%'} align='start'>
|
||||||
{groups
|
{groups?.map((group: BookmarkGroup) => (
|
||||||
?.sort((a: any, b: any) => (a.categoryIndex > b.categoryIndex ? 1 : -1))
|
<DebouncedGroupSettingsItem
|
||||||
.map((group: any) => (
|
key={group.id}
|
||||||
<DebouncedGroupSettingsItem
|
bookmarkGroup={group}
|
||||||
key={group.id}
|
bookmarks={bookmarks
|
||||||
bookmarkGroup={group}
|
.filter((a: Bookmark) => a.category === group.categoryName)
|
||||||
bookmarks={bookmarks
|
.sort((a: Bookmark, b: Bookmark) => (a.index > b.index ? 1 : -1))}
|
||||||
.filter((a: any) => a.category === group.categoryName)
|
/>
|
||||||
.sort((a: any, b: any) => (a.index > b.index ? 1 : -1))}
|
))}
|
||||||
/>
|
|
||||||
))}
|
|
||||||
</Group>
|
</Group>
|
||||||
</Stack>
|
</Stack>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -14,14 +14,15 @@ import { IconTrash } from '@tabler/icons-react';
|
|||||||
import { useCommonHooks, useMutationAPI } from 'hooks';
|
import { useCommonHooks, useMutationAPI } from 'hooks';
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { cardClasses, modalClasses, textInputClasses } from 'styles';
|
import { cardClasses, modalClasses, textInputClasses } from 'styles';
|
||||||
|
import type { Bookmark } from 'types';
|
||||||
|
|
||||||
function DebouncedBookmarkItem({ bookmarkItem, handleDelete }: any) {
|
function DebouncedBookmarkItem({ bookmarkItem }: { bookmarkItem: Bookmark }) {
|
||||||
const { theme, isMobile } = useCommonHooks();
|
const { theme, isMobile, modalStyle, handleDelete } = useCommonHooks();
|
||||||
const [modalOpened, { open: openModal, close: closeModal }] = useDisclosure(false);
|
const [modalOpened, { open: openModal, close: closeModal }] = useDisclosure(false);
|
||||||
const { mutateAsync } = useMutationAPI();
|
const { mutateAsync } = useMutationAPI();
|
||||||
|
|
||||||
const [bookmark, setBookmark] = useState<any>(bookmarkItem);
|
const [bookmark, setBookmark] = useState<Bookmark>(bookmarkItem);
|
||||||
const [update, setUpdate] = useState({});
|
const [update, setUpdate] = useState<any>({});
|
||||||
const [debounced] = useDebouncedValue(update, 1000);
|
const [debounced] = useDebouncedValue(update, 1000);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -47,14 +48,7 @@ function DebouncedBookmarkItem({ bookmarkItem, handleDelete }: any) {
|
|||||||
onClose={() => {
|
onClose={() => {
|
||||||
closeModal();
|
closeModal();
|
||||||
}}
|
}}
|
||||||
style={{
|
style={modalStyle}
|
||||||
'--color-text-pri': theme.primaryColor,
|
|
||||||
'--color-text-acc': theme.accentColor,
|
|
||||||
'--color-background': theme.backgroundColor,
|
|
||||||
'--color-border': theme.borderColor,
|
|
||||||
'--color-search-background': theme.searchColor,
|
|
||||||
'--image-background': `url(${theme.backgroundImage})`,
|
|
||||||
}}
|
|
||||||
closeOnEscape
|
closeOnEscape
|
||||||
closeOnClickOutside
|
closeOnClickOutside
|
||||||
>
|
>
|
||||||
@@ -84,7 +78,7 @@ function DebouncedBookmarkItem({ bookmarkItem, handleDelete }: any) {
|
|||||||
color={'red'}
|
color={'red'}
|
||||||
styles={{ label: { color: 'black' } }}
|
styles={{ label: { color: 'black' } }}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
handleDelete(bookmark);
|
handleDelete(bookmark, 'api/links');
|
||||||
closeModal();
|
closeModal();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -18,25 +18,29 @@ import { useCommonHooks, useMutationAPI } from 'hooks';
|
|||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { FiPlus } from 'react-icons/fi';
|
import { FiPlus } from 'react-icons/fi';
|
||||||
import { buttonClasses, cardClasses, modalClasses, textInputClasses } from 'styles';
|
import { buttonClasses, cardClasses, modalClasses, textInputClasses } from 'styles';
|
||||||
|
import type { Bookmark, BookmarkGroup } from 'types';
|
||||||
import BookmarkSettingsItem from './BookmarkSettingsItem';
|
import BookmarkSettingsItem from './BookmarkSettingsItem';
|
||||||
import DebouncedBookmarkItem from './DebouncedBookmarkItem';
|
import DebouncedBookmarkItem from './DebouncedBookmarkItem';
|
||||||
|
|
||||||
function DebouncedGroupSettingsItem({ bookmarkGroup, bookmarks }: any) {
|
function DebouncedGroupSettingsItem({
|
||||||
const { theme, isMobile } = useCommonHooks();
|
bookmarkGroup,
|
||||||
|
bookmarks,
|
||||||
|
}: { bookmarkGroup: BookmarkGroup; bookmarks: Bookmark[] }) {
|
||||||
|
const { theme, isMobile, modalStyle, handleDelete } = useCommonHooks();
|
||||||
const [modalOpened, { open: openModal, close: closeModal }] = useDisclosure(false);
|
const [modalOpened, { open: openModal, close: closeModal }] = useDisclosure(false);
|
||||||
const [popoverOpened, setPopoverOpened] = useState(false);
|
const [popoverOpened, setPopoverOpened] = useState(false);
|
||||||
const { mutateAsync } = useMutationAPI();
|
const { mutateAsync } = useMutationAPI();
|
||||||
const [group, setGroup] = useState<any>(bookmarkGroup);
|
const [group, setGroup] = useState<BookmarkGroup>(bookmarkGroup);
|
||||||
const [update, setUpdate] = useState({});
|
const [update, setUpdate] = useState<any>({});
|
||||||
const [debounced] = useDebouncedValue(update, 1000);
|
const [debounced] = useDebouncedValue(update, 1000);
|
||||||
const [newBookmark, setNewBookmark] = useState<any>({});
|
const [newBookmark, setNewBookmark] = useState<Bookmark>({
|
||||||
const [bookmarkList, setBookmarkList] = useState<any>(bookmarks);
|
id: undefined,
|
||||||
const handleDeleteBookmark = (application: any) => {
|
name: '',
|
||||||
mutateAsync({ method: 'DELETE', endpoint: 'api/links', body: application });
|
url: '',
|
||||||
};
|
category: group.categoryName,
|
||||||
const handleDeleteGroup = (application: any) => {
|
index: 0,
|
||||||
mutateAsync({ method: 'DELETE', endpoint: 'api/categories', body: application });
|
});
|
||||||
};
|
const [bookmarkList, setBookmarkList] = useState<Bookmark[]>(bookmarks);
|
||||||
|
|
||||||
const reorder = (list: any, startIndex: any, endIndex: any) => {
|
const reorder = (list: any, startIndex: any, endIndex: any) => {
|
||||||
const result = Array.from(list);
|
const result = Array.from(list);
|
||||||
@@ -95,14 +99,7 @@ function DebouncedGroupSettingsItem({ bookmarkGroup, bookmarks }: any) {
|
|||||||
onClose={() => {
|
onClose={() => {
|
||||||
closeModal();
|
closeModal();
|
||||||
}}
|
}}
|
||||||
style={{
|
style={modalStyle}
|
||||||
'--color-text-pri': theme.primaryColor,
|
|
||||||
'--color-text-acc': theme.accentColor,
|
|
||||||
'--color-background': theme.backgroundColor,
|
|
||||||
'--color-border': theme.borderColor,
|
|
||||||
'--color-search-background': theme.searchColor,
|
|
||||||
'--image-background': `url(${theme.backgroundImage})`,
|
|
||||||
}}
|
|
||||||
closeOnEscape
|
closeOnEscape
|
||||||
closeOnClickOutside
|
closeOnClickOutside
|
||||||
>
|
>
|
||||||
@@ -132,7 +129,7 @@ function DebouncedGroupSettingsItem({ bookmarkGroup, bookmarks }: any) {
|
|||||||
color={'red'}
|
color={'red'}
|
||||||
styles={{ label: { color: 'black' } }}
|
styles={{ label: { color: 'black' } }}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
handleDeleteGroup(group);
|
handleDelete(group, 'api/categories');
|
||||||
closeModal();
|
closeModal();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
@@ -234,47 +231,42 @@ function DebouncedGroupSettingsItem({ bookmarkGroup, bookmarks }: any) {
|
|||||||
<Droppable droppableId={`${bookmarkGroup.id}`}>
|
<Droppable droppableId={`${bookmarkGroup.id}`}>
|
||||||
{(provided) => (
|
{(provided) => (
|
||||||
<Stack ref={provided.innerRef} {...provided.droppableProps}>
|
<Stack ref={provided.innerRef} {...provided.droppableProps}>
|
||||||
{bookmarks
|
{bookmarks.map((bookmark: Bookmark) => (
|
||||||
.sort((a: any, b: any) => (a.index > b.index ? 1 : -1))
|
<Draggable
|
||||||
.map((bookmark: any) => (
|
key={bookmark.id}
|
||||||
<Draggable
|
draggableId={`${bookmark.id}`}
|
||||||
key={bookmark.id}
|
index={bookmark.index}
|
||||||
draggableId={`${bookmark.id}`}
|
>
|
||||||
index={bookmark.index}
|
{(provided: any) => (
|
||||||
>
|
<Box
|
||||||
{(provided: any) => (
|
ref={provided.innerRef}
|
||||||
<Box
|
{...provided.draggableProps}
|
||||||
ref={provided.innerRef}
|
{...provided.dragHandleProps}
|
||||||
{...provided.draggableProps}
|
>
|
||||||
{...provided.dragHandleProps}
|
<Popover withArrow withOverlay>
|
||||||
>
|
<Popover.Target>
|
||||||
<Popover withArrow withOverlay>
|
<Box>
|
||||||
<Popover.Target>
|
<BookmarkSettingsItem bookmark={bookmark} />
|
||||||
<Box>
|
</Box>
|
||||||
<BookmarkSettingsItem bookmark={bookmark} />
|
</Popover.Target>
|
||||||
</Box>
|
<Popover.Dropdown
|
||||||
</Popover.Target>
|
style={{
|
||||||
<Popover.Dropdown
|
'--color-text-pri': theme.primaryColor,
|
||||||
style={{
|
'--color-text-acc': theme.accentColor,
|
||||||
'--color-text-pri': theme.primaryColor,
|
'--color-background': theme.backgroundColor,
|
||||||
'--color-text-acc': theme.accentColor,
|
'--color-border': theme.borderColor,
|
||||||
'--color-background': theme.backgroundColor,
|
'--color-search-background': theme.searchColor,
|
||||||
'--color-border': theme.borderColor,
|
'--image-background': `url(${theme.backgroundImage})`,
|
||||||
'--color-search-background': theme.searchColor,
|
}}
|
||||||
'--image-background': `url(${theme.backgroundImage})`,
|
>
|
||||||
}}
|
<DebouncedBookmarkItem bookmarkItem={bookmark} />
|
||||||
>
|
</Popover.Dropdown>
|
||||||
<DebouncedBookmarkItem
|
</Popover>
|
||||||
bookmarkItem={bookmark}
|
{provided.placeholder}
|
||||||
handleDelete={handleDeleteBookmark}
|
</Box>
|
||||||
/>
|
)}
|
||||||
</Popover.Dropdown>
|
</Draggable>
|
||||||
</Popover>
|
))}
|
||||||
{provided.placeholder}
|
|
||||||
</Box>
|
|
||||||
)}
|
|
||||||
</Draggable>
|
|
||||||
))}
|
|
||||||
|
|
||||||
{provided.placeholder}
|
{provided.placeholder}
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ import { IconTrash } from '@tabler/icons-react';
|
|||||||
import { useCommonHooks } from 'hooks';
|
import { useCommonHooks } from 'hooks';
|
||||||
import { cardClasses, modalClasses, textInputClasses } from 'styles';
|
import { cardClasses, modalClasses, textInputClasses } from 'styles';
|
||||||
|
|
||||||
function DebouncedMessage({ label, message, setMessage, handleDelete }: any) {
|
function DebouncedMessage({ label, message, setMessage }: any) {
|
||||||
const { theme, isMobile } = useCommonHooks();
|
const { theme, isMobile, modalStyle, handleDelete } = useCommonHooks();
|
||||||
const [modalOpened, { open: openModal, close: closeModal }] = useDisclosure(false);
|
const [modalOpened, { open: openModal, close: closeModal }] = useDisclosure(false);
|
||||||
return (
|
return (
|
||||||
<Card className={cardClasses.settingsItem} classNames={cardClasses}>
|
<Card className={cardClasses.settingsItem} classNames={cardClasses}>
|
||||||
@@ -28,14 +28,7 @@ function DebouncedMessage({ label, message, setMessage, handleDelete }: any) {
|
|||||||
onClose={() => {
|
onClose={() => {
|
||||||
closeModal();
|
closeModal();
|
||||||
}}
|
}}
|
||||||
style={{
|
style={modalStyle}
|
||||||
'--color-text-pri': theme.primaryColor,
|
|
||||||
'--color-text-acc': theme.accentColor,
|
|
||||||
'--color-background': theme.backgroundColor,
|
|
||||||
'--color-border': theme.borderColor,
|
|
||||||
'--color-search-background': theme.searchColor,
|
|
||||||
'--image-background': `url(${theme.backgroundImage})`,
|
|
||||||
}}
|
|
||||||
closeOnEscape
|
closeOnEscape
|
||||||
closeOnClickOutside
|
closeOnClickOutside
|
||||||
>
|
>
|
||||||
@@ -65,7 +58,7 @@ function DebouncedMessage({ label, message, setMessage, handleDelete }: any) {
|
|||||||
color={'red'}
|
color={'red'}
|
||||||
styles={{ label: { color: 'black' } }}
|
styles={{ label: { color: 'black' } }}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
handleDelete(message);
|
handleDelete(message, 'api/messages');
|
||||||
closeModal();
|
closeModal();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -24,14 +24,15 @@ import {
|
|||||||
textClasses,
|
textClasses,
|
||||||
textInputClasses,
|
textInputClasses,
|
||||||
} from 'styles';
|
} from 'styles';
|
||||||
|
import type { Message } from 'types';
|
||||||
const MessageSettings = () => {
|
const MessageSettings = () => {
|
||||||
const endpoint = 'api/messages';
|
const endpoint = 'api/messages';
|
||||||
const { data: messageData, isFetched: isMessagesFetched } = useQueryAPI({
|
const { data: messageData, isFetched: isMessagesFetched } = useQueryAPI({
|
||||||
endpoint: 'api/messages',
|
endpoint: endpoint,
|
||||||
});
|
});
|
||||||
const { theme, isMobile } = useCommonHooks();
|
const { theme, isMobile, modalStyle } = useCommonHooks();
|
||||||
const { mutateAsync } = useMutationAPI();
|
const { mutateAsync } = useMutationAPI();
|
||||||
const [messages, setMessages] = useState<any>([]);
|
const [messages, setMessages] = useState<Message[]>([]);
|
||||||
const [newMessage, setNewMessage] = useState('');
|
const [newMessage, setNewMessage] = useState('');
|
||||||
const [newMessageError, setNewMessageError] = useState<string>('');
|
const [newMessageError, setNewMessageError] = useState<string>('');
|
||||||
const [message, setMessage] = useState({});
|
const [message, setMessage] = useState({});
|
||||||
@@ -40,14 +41,10 @@ const MessageSettings = () => {
|
|||||||
const [debouncedSearch] = useDebouncedValue(searchValue, 500);
|
const [debouncedSearch] = useDebouncedValue(searchValue, 500);
|
||||||
const [modalOpened, { open: openModal, close: closeModal }] = useDisclosure(false);
|
const [modalOpened, { open: openModal, close: closeModal }] = useDisclosure(false);
|
||||||
|
|
||||||
const handleDelete = (message: any) => {
|
|
||||||
mutateAsync({ method: 'DELETE', endpoint: endpoint, body: message });
|
|
||||||
};
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (messageData && isMessagesFetched) {
|
if (messageData && isMessagesFetched) {
|
||||||
setMessages(
|
setMessages(
|
||||||
messageData.filter((m: any) =>
|
messageData.filter((m: Message) =>
|
||||||
m.message.toLowerCase().includes(debouncedSearch.toLowerCase()),
|
m.message.toLowerCase().includes(debouncedSearch.toLowerCase()),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -71,14 +68,7 @@ const MessageSettings = () => {
|
|||||||
onClose={() => {
|
onClose={() => {
|
||||||
closeModal();
|
closeModal();
|
||||||
}}
|
}}
|
||||||
style={{
|
style={modalStyle}
|
||||||
'--color-text-pri': theme.primaryColor,
|
|
||||||
'--color-text-acc': theme.accentColor,
|
|
||||||
'--color-background': theme.backgroundColor,
|
|
||||||
'--color-border': theme.borderColor,
|
|
||||||
'--color-search-background': theme.searchColor,
|
|
||||||
'--image-background': `url(${theme.backgroundImage})`,
|
|
||||||
}}
|
|
||||||
closeOnEscape
|
closeOnEscape
|
||||||
closeOnClickOutside
|
closeOnClickOutside
|
||||||
>
|
>
|
||||||
@@ -203,13 +193,12 @@ const MessageSettings = () => {
|
|||||||
</Group>
|
</Group>
|
||||||
<Stack w={'100%'} align='center'>
|
<Stack w={'100%'} align='center'>
|
||||||
<Grid w={'75%'}>
|
<Grid w={'75%'}>
|
||||||
{messages?.map((message: any) => (
|
{messages?.map((message: Message) => (
|
||||||
<GridCol span={isMobile ? 12 : 6} key={message.id}>
|
<GridCol span={isMobile ? 12 : 6} key={message.id}>
|
||||||
<DebouncedMessage
|
<DebouncedMessage
|
||||||
label={`ID# ${message.id}`}
|
label={`ID# ${message.id}`}
|
||||||
message={message}
|
message={message}
|
||||||
setMessage={setMessage}
|
setMessage={setMessage}
|
||||||
handleDelete={handleDelete}
|
|
||||||
/>
|
/>
|
||||||
</GridCol>
|
</GridCol>
|
||||||
))}
|
))}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { useDebouncedValue } from '@mantine/hooks';
|
|||||||
import { useCommonHooks, useMutationAPI, useQueryAPI } from 'hooks';
|
import { useCommonHooks, useMutationAPI, useQueryAPI } from 'hooks';
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { cardClasses, textClasses, textInputClasses } from 'styles';
|
import { cardClasses, textClasses, textInputClasses } from 'styles';
|
||||||
|
import type { PersonalData } from 'types';
|
||||||
const PersonalizationSettings = () => {
|
const PersonalizationSettings = () => {
|
||||||
const endpoint = 'api/personalData';
|
const endpoint = 'api/personalData';
|
||||||
const {
|
const {
|
||||||
@@ -12,8 +13,8 @@ const PersonalizationSettings = () => {
|
|||||||
} = useQueryAPI({
|
} = useQueryAPI({
|
||||||
endpoint: endpoint,
|
endpoint: endpoint,
|
||||||
});
|
});
|
||||||
const [personal, setPersonal] = useState<any>({});
|
const [personal, setPersonal] = useState<PersonalData>();
|
||||||
const [update, setUpdate] = useState({});
|
const [update, setUpdate] = useState<any>({});
|
||||||
const [debounced] = useDebouncedValue(update, 1000);
|
const [debounced] = useDebouncedValue(update, 1000);
|
||||||
const { mutateAsync: editRow } = useMutationAPI();
|
const { mutateAsync: editRow } = useMutationAPI();
|
||||||
const { isMobile } = useCommonHooks();
|
const { isMobile } = useCommonHooks();
|
||||||
|
|||||||
@@ -14,14 +14,15 @@ import { IconTrash } from '@tabler/icons-react';
|
|||||||
import { useCommonHooks, useMutationAPI } from 'hooks';
|
import { useCommonHooks, useMutationAPI } from 'hooks';
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { cardClasses, modalClasses, textInputClasses } from 'styles';
|
import { cardClasses, modalClasses, textInputClasses } from 'styles';
|
||||||
|
import type { Provider } from 'types';
|
||||||
|
|
||||||
function DebouncedSearchProvider({ searchProvider, handleDelete }: any) {
|
function DebouncedSearchProvider({ searchProvider }: any) {
|
||||||
const { theme, isMobile } = useCommonHooks();
|
const { theme, isMobile, modalStyle, handleDelete } = useCommonHooks();
|
||||||
const [modalOpened, { open: openModal, close: closeModal }] = useDisclosure(false);
|
const [modalOpened, { open: openModal, close: closeModal }] = useDisclosure(false);
|
||||||
const { mutateAsync } = useMutationAPI();
|
const { mutateAsync } = useMutationAPI();
|
||||||
|
|
||||||
const [provider, setProvider] = useState<any>(searchProvider);
|
const [provider, setProvider] = useState<Provider>(searchProvider);
|
||||||
const [update, setUpdate] = useState({});
|
const [update, setUpdate] = useState<any>({});
|
||||||
const [debounced] = useDebouncedValue(update, 1000);
|
const [debounced] = useDebouncedValue(update, 1000);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -47,14 +48,7 @@ function DebouncedSearchProvider({ searchProvider, handleDelete }: any) {
|
|||||||
onClose={() => {
|
onClose={() => {
|
||||||
closeModal();
|
closeModal();
|
||||||
}}
|
}}
|
||||||
style={{
|
style={modalStyle}
|
||||||
'--color-text-pri': theme.primaryColor,
|
|
||||||
'--color-text-acc': theme.accentColor,
|
|
||||||
'--color-background': theme.backgroundColor,
|
|
||||||
'--color-border': theme.borderColor,
|
|
||||||
'--color-search-background': theme.searchColor,
|
|
||||||
'--image-background': `url(${theme.backgroundImage})`,
|
|
||||||
}}
|
|
||||||
closeOnEscape
|
closeOnEscape
|
||||||
closeOnClickOutside
|
closeOnClickOutside
|
||||||
>
|
>
|
||||||
@@ -84,7 +78,7 @@ function DebouncedSearchProvider({ searchProvider, handleDelete }: any) {
|
|||||||
color={'red'}
|
color={'red'}
|
||||||
styles={{ label: { color: 'black' } }}
|
styles={{ label: { color: 'black' } }}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
handleDelete(provider);
|
handleDelete(provider, 'api/providers');
|
||||||
closeModal();
|
closeModal();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import {
|
|||||||
textClasses,
|
textClasses,
|
||||||
textInputClasses,
|
textInputClasses,
|
||||||
} from 'styles';
|
} from 'styles';
|
||||||
|
import type { Provider } from 'types';
|
||||||
import DebouncedSearchProvider from './DebouncedSearchProvider';
|
import DebouncedSearchProvider from './DebouncedSearchProvider';
|
||||||
import SearchProviderSettingsItem from './SearchProviderSettingsItem';
|
import SearchProviderSettingsItem from './SearchProviderSettingsItem';
|
||||||
|
|
||||||
@@ -32,20 +33,23 @@ const SearchProviderSettings = () => {
|
|||||||
const { data: providers, isFetched: providersIsFetched } = useQueryAPI({
|
const { data: providers, isFetched: providersIsFetched } = useQueryAPI({
|
||||||
endpoint: endpoint,
|
endpoint: endpoint,
|
||||||
});
|
});
|
||||||
const [providerData, setProviderData] = useState<any>([]);
|
const [providerData, setProviderData] = useState<Provider[]>([]);
|
||||||
const { theme, isMobile } = useCommonHooks();
|
const { theme, isMobile, modalStyle } = useCommonHooks();
|
||||||
const { mutateAsync } = useMutationAPI();
|
const { mutateAsync } = useMutationAPI();
|
||||||
const [newProvider, setNewProvider] = useState<any>({});
|
const [newProvider, setNewProvider] = useState<Provider>({
|
||||||
|
id: undefined,
|
||||||
|
name: '',
|
||||||
|
url: '',
|
||||||
|
prefix: '',
|
||||||
|
});
|
||||||
const [modalOpened, { open: openModal, close: closeModal }] = useDisclosure(false);
|
const [modalOpened, { open: openModal, close: closeModal }] = useDisclosure(false);
|
||||||
const [searchValue, setSearchValue] = useState('');
|
const [searchValue, setSearchValue] = useState('');
|
||||||
const [debouncedSearch] = useDebouncedValue(searchValue, 500);
|
const [debouncedSearch] = useDebouncedValue(searchValue, 500);
|
||||||
const handleDelete = (application: any) => {
|
|
||||||
mutateAsync({ method: 'DELETE', endpoint: endpoint, body: application });
|
|
||||||
};
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (providers && providersIsFetched) {
|
if (providers && providersIsFetched) {
|
||||||
setProviderData(
|
setProviderData(
|
||||||
providers.filter((a: any) =>
|
providers.filter((a: Provider) =>
|
||||||
a.name.toLowerCase().includes(debouncedSearch.toLowerCase()),
|
a.name.toLowerCase().includes(debouncedSearch.toLowerCase()),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -63,14 +67,7 @@ const SearchProviderSettings = () => {
|
|||||||
onClose={() => {
|
onClose={() => {
|
||||||
closeModal();
|
closeModal();
|
||||||
}}
|
}}
|
||||||
style={{
|
style={modalStyle}
|
||||||
'--color-text-pri': theme.primaryColor,
|
|
||||||
'--color-text-acc': theme.accentColor,
|
|
||||||
'--color-background': theme.backgroundColor,
|
|
||||||
'--color-border': theme.borderColor,
|
|
||||||
'--color-search-background': theme.searchColor,
|
|
||||||
'--image-background': `url(${theme.backgroundImage})`,
|
|
||||||
}}
|
|
||||||
closeOnEscape
|
closeOnEscape
|
||||||
closeOnClickOutside
|
closeOnClickOutside
|
||||||
>
|
>
|
||||||
@@ -224,7 +221,7 @@ const SearchProviderSettings = () => {
|
|||||||
</Group>
|
</Group>
|
||||||
<Stack w={'100%'} align='center'>
|
<Stack w={'100%'} align='center'>
|
||||||
<Grid columns={18} w={'75%'}>
|
<Grid columns={18} w={'75%'}>
|
||||||
{providerData?.map((provider: any) => (
|
{providerData?.map((provider: Provider) => (
|
||||||
<GridCol span={isMobile ? 18 : 6} key={provider.id}>
|
<GridCol span={isMobile ? 18 : 6} key={provider.id}>
|
||||||
<Popover withArrow withOverlay withinPortal={false}>
|
<Popover withArrow withOverlay withinPortal={false}>
|
||||||
<Popover.Target>
|
<Popover.Target>
|
||||||
@@ -237,10 +234,7 @@ const SearchProviderSettings = () => {
|
|||||||
</Box>
|
</Box>
|
||||||
</Popover.Target>
|
</Popover.Target>
|
||||||
<Popover.Dropdown>
|
<Popover.Dropdown>
|
||||||
<DebouncedSearchProvider
|
<DebouncedSearchProvider searchProvider={provider} />
|
||||||
searchProvider={provider}
|
|
||||||
handleDelete={handleDelete}
|
|
||||||
/>
|
|
||||||
</Popover.Dropdown>
|
</Popover.Dropdown>
|
||||||
</Popover>
|
</Popover>
|
||||||
</GridCol>
|
</GridCol>
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import { useCommonHooks, useMutationAPI, useQueryAPI } from 'hooks';
|
|||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { FiEdit, FiShuffle, FiTrash, FiX } from 'react-icons/fi';
|
import { FiEdit, FiShuffle, FiTrash, FiX } from 'react-icons/fi';
|
||||||
import { actionIconClasses, modalClasses } from 'styles';
|
import { actionIconClasses, modalClasses } from 'styles';
|
||||||
|
import type { ThemePlaylist } from 'types';
|
||||||
|
|
||||||
function ThemeCard({ cardTheme, handleOpen, allThemes }: any) {
|
function ThemeCard({ cardTheme, handleOpen, allThemes }: any) {
|
||||||
const { data: themePlaylists } = useQueryAPI({
|
const { data: themePlaylists } = useQueryAPI({
|
||||||
@@ -31,10 +32,9 @@ function ThemeCard({ cardTheme, handleOpen, allThemes }: any) {
|
|||||||
isMobile,
|
isMobile,
|
||||||
currentThemePlaylist,
|
currentThemePlaylist,
|
||||||
setCurrentThemePlaylist,
|
setCurrentThemePlaylist,
|
||||||
|
modalStyle,
|
||||||
|
handleDelete,
|
||||||
} = useCommonHooks();
|
} = useCommonHooks();
|
||||||
const handleDelete = (application: any) => {
|
|
||||||
mutateAsync({ method: 'DELETE', endpoint: 'api/themes', body: application });
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Group
|
<Group
|
||||||
@@ -55,14 +55,7 @@ function ThemeCard({ cardTheme, handleOpen, allThemes }: any) {
|
|||||||
onClose={() => {
|
onClose={() => {
|
||||||
closeModal();
|
closeModal();
|
||||||
}}
|
}}
|
||||||
style={{
|
style={modalStyle}
|
||||||
'--color-text-pri': theme.primaryColor,
|
|
||||||
'--color-text-acc': theme.accentColor,
|
|
||||||
'--color-background': theme.backgroundColor,
|
|
||||||
'--color-border': theme.borderColor,
|
|
||||||
'--color-search-background': theme.searchColor,
|
|
||||||
'--image-background': `url(${theme.backgroundImage})`,
|
|
||||||
}}
|
|
||||||
closeOnEscape
|
closeOnEscape
|
||||||
closeOnClickOutside
|
closeOnClickOutside
|
||||||
>
|
>
|
||||||
@@ -92,7 +85,7 @@ function ThemeCard({ cardTheme, handleOpen, allThemes }: any) {
|
|||||||
color={'red'}
|
color={'red'}
|
||||||
styles={{ label: { color: 'black' } }}
|
styles={{ label: { color: 'black' } }}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
handleDelete(cardTheme);
|
handleDelete(cardTheme, 'api/themes');
|
||||||
closeModal();
|
closeModal();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
@@ -299,8 +292,9 @@ function ThemeCard({ cardTheme, handleOpen, allThemes }: any) {
|
|||||||
<FiShuffle
|
<FiShuffle
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
const themeList = JSON.parse(
|
const themeList = JSON.parse(
|
||||||
themePlaylists.find((t: any) => t.name === currentThemePlaylist)
|
themePlaylists.find(
|
||||||
.themeList,
|
(t: ThemePlaylist) => t.name === currentThemePlaylist,
|
||||||
|
).themeList,
|
||||||
);
|
);
|
||||||
const filteredThemes = allThemes.filter((t: any) =>
|
const filteredThemes = allThemes.filter((t: any) =>
|
||||||
themeList.includes(t.id),
|
themeList.includes(t.id),
|
||||||
|
|||||||
@@ -17,16 +17,21 @@ import ThemeMiniCard from './ThemeMiniCard';
|
|||||||
|
|
||||||
function ThemePlaylistCard({ cardPlaylist, handleOpen, allThemes }: any) {
|
function ThemePlaylistCard({ cardPlaylist, handleOpen, allThemes }: any) {
|
||||||
const [hover, setHover] = useState(false);
|
const [hover, setHover] = useState(false);
|
||||||
const { setThemeName, setCurrentThemePlaylist, theme, isMobile } = useCommonHooks();
|
const {
|
||||||
|
setThemeName,
|
||||||
|
setCurrentThemePlaylist,
|
||||||
|
theme,
|
||||||
|
isMobile,
|
||||||
|
modalStyle,
|
||||||
|
handleDelete,
|
||||||
|
} = useCommonHooks();
|
||||||
const syncableLists = ['All', 'Backgrounds', 'No Backgrounds'];
|
const syncableLists = ['All', 'Backgrounds', 'No Backgrounds'];
|
||||||
const { mutateAsync } = useMutationAPI();
|
const { mutateAsync } = useMutationAPI();
|
||||||
const [modalOpened, { open: openModal, close: closeModal }] = useDisclosure(false);
|
const [modalOpened, { open: openModal, close: closeModal }] = useDisclosure(false);
|
||||||
const themeList = JSON.parse(
|
const themeList = JSON.parse(
|
||||||
cardPlaylist.themeList.name === 'Time of Day' ? '[]' : cardPlaylist.themeList,
|
cardPlaylist.themeList.name === 'Time of Day' ? '[]' : cardPlaylist.themeList,
|
||||||
);
|
);
|
||||||
const handleDelete = (application: any) => {
|
|
||||||
mutateAsync({ method: 'DELETE', endpoint: 'api/themePlaylists', body: application });
|
|
||||||
};
|
|
||||||
return (
|
return (
|
||||||
<Group
|
<Group
|
||||||
gap={0}
|
gap={0}
|
||||||
@@ -46,14 +51,7 @@ function ThemePlaylistCard({ cardPlaylist, handleOpen, allThemes }: any) {
|
|||||||
onClose={() => {
|
onClose={() => {
|
||||||
closeModal();
|
closeModal();
|
||||||
}}
|
}}
|
||||||
style={{
|
style={modalStyle}
|
||||||
'--color-text-pri': theme.primaryColor,
|
|
||||||
'--color-text-acc': theme.accentColor,
|
|
||||||
'--color-background': theme.backgroundColor,
|
|
||||||
'--color-border': theme.borderColor,
|
|
||||||
'--color-search-background': theme.searchColor,
|
|
||||||
'--image-background': `url(${theme.backgroundImage})`,
|
|
||||||
}}
|
|
||||||
closeOnEscape
|
closeOnEscape
|
||||||
closeOnClickOutside
|
closeOnClickOutside
|
||||||
>
|
>
|
||||||
@@ -83,7 +81,7 @@ function ThemePlaylistCard({ cardPlaylist, handleOpen, allThemes }: any) {
|
|||||||
color={'red'}
|
color={'red'}
|
||||||
styles={{ label: { color: 'black' } }}
|
styles={{ label: { color: 'black' } }}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
handleDelete(cardPlaylist);
|
handleDelete(cardPlaylist, 'api/themePlaylists');
|
||||||
closeModal();
|
closeModal();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import { useCommonHooks, useMutationAPI, useQueryAPI } from 'hooks';
|
|||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { FiChevronRight, FiHelpCircle, FiPlus } from 'react-icons/fi';
|
import { FiChevronRight, FiHelpCircle, FiPlus } from 'react-icons/fi';
|
||||||
import { actionIconClasses, buttonClasses, textClasses, textInputClasses } from 'styles';
|
import { actionIconClasses, buttonClasses, textClasses, textInputClasses } from 'styles';
|
||||||
|
import type { ThemePlaylist } from 'types';
|
||||||
import ThemePlaylistCard from './ThemePlaylistCard';
|
import ThemePlaylistCard from './ThemePlaylistCard';
|
||||||
import ThemePlaylistModal from './ThemePlaylistModal';
|
import ThemePlaylistModal from './ThemePlaylistModal';
|
||||||
|
|
||||||
@@ -140,11 +141,11 @@ function ThemePlaylists() {
|
|||||||
</Group>
|
</Group>
|
||||||
<Group justify='center' align='center' pos={'relative'}>
|
<Group justify='center' align='center' pos={'relative'}>
|
||||||
{themePlaylists
|
{themePlaylists
|
||||||
?.filter((playlist: any) => playlist.default === 1)
|
?.filter((playlist: ThemePlaylist) => playlist.default === 1)
|
||||||
?.filter((a: any) =>
|
?.filter((a: ThemePlaylist) =>
|
||||||
a.name.toLowerCase().includes(debouncedSearch.toLowerCase()),
|
a.name.toLowerCase().includes(debouncedSearch.toLowerCase()),
|
||||||
)
|
)
|
||||||
.map((cardPlaylist: any) => {
|
.map((cardPlaylist: ThemePlaylist) => {
|
||||||
return (
|
return (
|
||||||
<Group key={cardPlaylist.name} pos={'relative'}>
|
<Group key={cardPlaylist.name} pos={'relative'}>
|
||||||
{cardPlaylist.name === currentThemePlaylist && (
|
{cardPlaylist.name === currentThemePlaylist && (
|
||||||
@@ -184,11 +185,11 @@ function ThemePlaylists() {
|
|||||||
</Group>
|
</Group>
|
||||||
<Group justify='center' align='center' pos={'relative'}>
|
<Group justify='center' align='center' pos={'relative'}>
|
||||||
{themePlaylists
|
{themePlaylists
|
||||||
?.filter((playlist: any) => playlist.default === 0)
|
?.filter((playlist: ThemePlaylist) => playlist.default === 0)
|
||||||
?.filter((a: any) =>
|
?.filter((a: ThemePlaylist) =>
|
||||||
a.name.toLowerCase().includes(debouncedSearch.toLowerCase()),
|
a.name.toLowerCase().includes(debouncedSearch.toLowerCase()),
|
||||||
)
|
)
|
||||||
.map((cardPlaylist: any) => {
|
.map((cardPlaylist: ThemePlaylist) => {
|
||||||
return (
|
return (
|
||||||
<Group key={cardPlaylist.name} pos={'relative'}>
|
<Group key={cardPlaylist.name} pos={'relative'}>
|
||||||
{cardPlaylist.name === currentThemePlaylist && (
|
{cardPlaylist.name === currentThemePlaylist && (
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import '@mantine/core/styles/ModalBase.css';
|
|||||||
import '@mantine/core/styles/Modal.css';
|
import '@mantine/core/styles/Modal.css';
|
||||||
import { FaDice } from 'react-icons/fa';
|
import { FaDice } from 'react-icons/fa';
|
||||||
import { actionIconClasses, buttonClasses, textClasses, textInputClasses } from 'styles';
|
import { actionIconClasses, buttonClasses, textClasses, textInputClasses } from 'styles';
|
||||||
|
import type { Theme } from 'types';
|
||||||
import ThemeCard from './ThemeCard';
|
import ThemeCard from './ThemeCard';
|
||||||
import ThemeModal from './ThemeModal';
|
import ThemeModal from './ThemeModal';
|
||||||
function ThemesSettings() {
|
function ThemesSettings() {
|
||||||
@@ -32,7 +33,7 @@ function ThemesSettings() {
|
|||||||
const [opened, { open, close }] = useDisclosure(false);
|
const [opened, { open, close }] = useDisclosure(false);
|
||||||
const [colorId, setColorId] = useState<string>('');
|
const [colorId, setColorId] = useState<string>('');
|
||||||
const [colorValue, setColorValue] = useState('#000000');
|
const [colorValue, setColorValue] = useState('#000000');
|
||||||
const [backgroundList, setBackgroundList] = useState<any>(['None']);
|
const [backgroundList, setBackgroundList] = useState<string[]>(['None']);
|
||||||
const [selectedTheme, setSelectedTheme] = useState<any>({});
|
const [selectedTheme, setSelectedTheme] = useState<any>({});
|
||||||
const [pickerOpen, { open: openPicker, close: closePicker }] = useDisclosure(false);
|
const [pickerOpen, { open: openPicker, close: closePicker }] = useDisclosure(false);
|
||||||
const [searchValue, setSearchValue] = useState('');
|
const [searchValue, setSearchValue] = useState('');
|
||||||
@@ -40,7 +41,7 @@ function ThemesSettings() {
|
|||||||
const { currentTheme, setCurrentTheme, theme, isMobile, setCurrentThemePlaylist } =
|
const { currentTheme, setCurrentTheme, theme, isMobile, setCurrentThemePlaylist } =
|
||||||
useCommonHooks();
|
useCommonHooks();
|
||||||
|
|
||||||
const handleOpen = (theme: any) => {
|
const handleOpen = (theme: Theme) => {
|
||||||
setSelectedTheme(theme);
|
setSelectedTheme(theme);
|
||||||
open();
|
open();
|
||||||
};
|
};
|
||||||
@@ -192,10 +193,10 @@ function ThemesSettings() {
|
|||||||
pos={'absolute'}
|
pos={'absolute'}
|
||||||
/>
|
/>
|
||||||
{allThemes
|
{allThemes
|
||||||
?.filter((a: any) =>
|
?.filter((a: Theme) =>
|
||||||
a.name.toLowerCase().includes(debouncedSearch.toLowerCase()),
|
a.name.toLowerCase().includes(debouncedSearch.toLowerCase()),
|
||||||
)
|
)
|
||||||
.map((cardTheme: any) => (
|
.map((cardTheme: Theme) => (
|
||||||
<Group key={cardTheme.name} pos={'relative'}>
|
<Group key={cardTheme.name} pos={'relative'}>
|
||||||
{cardTheme.name === currentTheme && (
|
{cardTheme.name === currentTheme && (
|
||||||
<FiChevronRight
|
<FiChevronRight
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ import { useCommonHooks, useMutationAPI } from 'hooks';
|
|||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { cardClasses, modalClasses, textInputClasses } from 'styles';
|
import { cardClasses, modalClasses, textInputClasses } from 'styles';
|
||||||
|
|
||||||
function DebouncedWolClient({ wolClient, handleDelete }: any) {
|
function DebouncedWolClient({ wolClient }: any) {
|
||||||
const { theme, isMobile } = useCommonHooks();
|
const { theme, isMobile, modalStyle, handleDelete } = useCommonHooks();
|
||||||
const [modalOpened, { open: openModal, close: closeModal }] = useDisclosure(false);
|
const [modalOpened, { open: openModal, close: closeModal }] = useDisclosure(false);
|
||||||
const { mutateAsync } = useMutationAPI();
|
const { mutateAsync } = useMutationAPI();
|
||||||
|
|
||||||
@@ -47,14 +47,7 @@ function DebouncedWolClient({ wolClient, handleDelete }: any) {
|
|||||||
onClose={() => {
|
onClose={() => {
|
||||||
closeModal();
|
closeModal();
|
||||||
}}
|
}}
|
||||||
style={{
|
style={modalStyle}
|
||||||
'--color-text-pri': theme.primaryColor,
|
|
||||||
'--color-text-acc': theme.accentColor,
|
|
||||||
'--color-background': theme.backgroundColor,
|
|
||||||
'--color-border': theme.borderColor,
|
|
||||||
'--color-search-background': theme.searchColor,
|
|
||||||
'--image-background': `url(${theme.backgroundImage})`,
|
|
||||||
}}
|
|
||||||
closeOnEscape
|
closeOnEscape
|
||||||
closeOnClickOutside
|
closeOnClickOutside
|
||||||
>
|
>
|
||||||
@@ -84,7 +77,7 @@ function DebouncedWolClient({ wolClient, handleDelete }: any) {
|
|||||||
color={'red'}
|
color={'red'}
|
||||||
styles={{ label: { color: 'black' } }}
|
styles={{ label: { color: 'black' } }}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
handleDelete(client);
|
handleDelete(client, 'api/WolClients');
|
||||||
closeModal();
|
closeModal();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import {
|
|||||||
textClasses,
|
textClasses,
|
||||||
textInputClasses,
|
textInputClasses,
|
||||||
} from 'styles';
|
} from 'styles';
|
||||||
|
import type { WolClient } from 'types';
|
||||||
import DebouncedWolClient from './DebouncedWolClient';
|
import DebouncedWolClient from './DebouncedWolClient';
|
||||||
import WolClientSettingsItem from './WolClientSettingsItem';
|
import WolClientSettingsItem from './WolClientSettingsItem';
|
||||||
|
|
||||||
@@ -32,23 +33,22 @@ const WolClientSettings = () => {
|
|||||||
const { data: wolClientsData, isFetched: wolClientsIsFetched } = useQueryAPI({
|
const { data: wolClientsData, isFetched: wolClientsIsFetched } = useQueryAPI({
|
||||||
endpoint: endpoint,
|
endpoint: endpoint,
|
||||||
});
|
});
|
||||||
const [wolClients, setWolClients] = useState<any>([]);
|
const [wolClients, setWolClients] = useState<WolClient[]>([]);
|
||||||
const { mutateAsync } = useMutationAPI();
|
const { mutateAsync } = useMutationAPI();
|
||||||
const { theme, isMobile } = useCommonHooks();
|
const { theme, isMobile, modalStyle } = useCommonHooks();
|
||||||
const [newWolClient, setNewWolClient] = useState<any>({
|
const [newWolClient, setNewWolClient] = useState<WolClient>({
|
||||||
|
id: undefined,
|
||||||
hostname: '',
|
hostname: '',
|
||||||
macAddress: '',
|
macAddress: '',
|
||||||
});
|
});
|
||||||
const [modalOpened, { open: openModal, close: closeModal }] = useDisclosure(false);
|
const [modalOpened, { open: openModal, close: closeModal }] = useDisclosure(false);
|
||||||
const [searchValue, setSearchValue] = useState('');
|
const [searchValue, setSearchValue] = useState('');
|
||||||
const [debouncedSearch] = useDebouncedValue(searchValue, 500);
|
const [debouncedSearch] = useDebouncedValue(searchValue, 500);
|
||||||
const handleDelete = (application: any) => {
|
|
||||||
mutateAsync({ method: 'DELETE', endpoint: endpoint, body: application });
|
|
||||||
};
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (wolClientsData && wolClientsIsFetched) {
|
if (wolClientsData && wolClientsIsFetched) {
|
||||||
setWolClients(
|
setWolClients(
|
||||||
wolClientsData.filter((a: any) =>
|
wolClientsData.filter((a: WolClient) =>
|
||||||
a.hostname.toLowerCase().includes(debouncedSearch.toLowerCase()),
|
a.hostname.toLowerCase().includes(debouncedSearch.toLowerCase()),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -66,14 +66,7 @@ const WolClientSettings = () => {
|
|||||||
onClose={() => {
|
onClose={() => {
|
||||||
closeModal();
|
closeModal();
|
||||||
}}
|
}}
|
||||||
style={{
|
style={modalStyle}
|
||||||
'--color-text-pri': theme.primaryColor,
|
|
||||||
'--color-text-acc': theme.accentColor,
|
|
||||||
'--color-background': theme.backgroundColor,
|
|
||||||
'--color-border': theme.borderColor,
|
|
||||||
'--color-search-background': theme.searchColor,
|
|
||||||
'--image-background': `url(${theme.backgroundImage})`,
|
|
||||||
}}
|
|
||||||
closeOnEscape
|
closeOnEscape
|
||||||
closeOnClickOutside
|
closeOnClickOutside
|
||||||
>
|
>
|
||||||
@@ -210,7 +203,7 @@ const WolClientSettings = () => {
|
|||||||
</Group>
|
</Group>
|
||||||
<Stack w={'100%'} align='center'>
|
<Stack w={'100%'} align='center'>
|
||||||
<Grid columns={18} w={'75%'}>
|
<Grid columns={18} w={'75%'}>
|
||||||
{wolClients?.map((client: any) => (
|
{wolClients?.map((client: WolClient) => (
|
||||||
<GridCol span={isMobile ? 18 : 6} key={client.id}>
|
<GridCol span={isMobile ? 18 : 6} key={client.id}>
|
||||||
<Popover withArrow withOverlay withinPortal={false}>
|
<Popover withArrow withOverlay withinPortal={false}>
|
||||||
<Popover.Target>
|
<Popover.Target>
|
||||||
@@ -223,7 +216,7 @@ const WolClientSettings = () => {
|
|||||||
</Box>
|
</Box>
|
||||||
</Popover.Target>
|
</Popover.Target>
|
||||||
<Popover.Dropdown>
|
<Popover.Dropdown>
|
||||||
<DebouncedWolClient wolClient={client} handleDelete={handleDelete} />
|
<DebouncedWolClient wolClient={client} />
|
||||||
</Popover.Dropdown>
|
</Popover.Dropdown>
|
||||||
</Popover>
|
</Popover>
|
||||||
</GridCol>
|
</GridCol>
|
||||||
|
|||||||
@@ -19,23 +19,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.editButton {
|
|
||||||
&.root {
|
|
||||||
background-color: var(--color-text-acc) !important;
|
|
||||||
color: var(--color-text-pri) !important;
|
|
||||||
.icon {
|
|
||||||
font-size: 24px;
|
|
||||||
}
|
|
||||||
.loader {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
:hover {
|
|
||||||
background-color: var(--color-text-pri) !important;
|
|
||||||
color: var(--color-text-acc) !important;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.themeEditButton {
|
.themeEditButton {
|
||||||
&.root {
|
&.root {
|
||||||
background-color: white !important;
|
background-color: white !important;
|
||||||
|
|||||||
@@ -19,20 +19,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.themeButton {
|
|
||||||
&.root {
|
|
||||||
font-size: 1em;
|
|
||||||
font-weight: 500;
|
|
||||||
margin: 10px;
|
|
||||||
width: 128px;
|
|
||||||
line-height: 3rem;
|
|
||||||
text-align: center;
|
|
||||||
text-transform: uppercase;
|
|
||||||
border-radius: 1em;
|
|
||||||
height: 3.5rem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.wakeButton {
|
.wakeButton {
|
||||||
&.root {
|
&.root {
|
||||||
font-size: 1em;
|
font-size: 1em;
|
||||||
|
|||||||
@@ -1,22 +0,0 @@
|
|||||||
.defaultNavLink {
|
|
||||||
&.root {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: space-between;
|
|
||||||
border-radius: 4px;
|
|
||||||
color: var(--color-text-pri);
|
|
||||||
background-color: var(--color-background);
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
&.root:hover {
|
|
||||||
border-radius: 4px;
|
|
||||||
color: var(--color-background);
|
|
||||||
background-color: var(--color-text-acc);
|
|
||||||
}
|
|
||||||
|
|
||||||
&.chevron {
|
|
||||||
width: 10px !important;
|
|
||||||
height: 10px !important;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -47,46 +47,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.settingsContainer {
|
|
||||||
align-items: stretch;
|
|
||||||
display: grid;
|
|
||||||
grid-column-gap: 20px;
|
|
||||||
grid-row-gap: 1vh;
|
|
||||||
grid-template-columns: 25% 100%;
|
|
||||||
grid-template-rows: 8vh auto;
|
|
||||||
justify-items: stretch;
|
|
||||||
margin-left: auto;
|
|
||||||
margin-right: auto;
|
|
||||||
margin-top: 2vh;
|
|
||||||
margin-bottom: 0px;
|
|
||||||
width: 75%;
|
|
||||||
padding-top: .3em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.settingsNav {
|
|
||||||
align-items: stretch;
|
|
||||||
display: grid !important;
|
|
||||||
grid-column-gap: 20px;
|
|
||||||
grid-row-gap: 1vh;
|
|
||||||
grid-template-columns: 1fr;
|
|
||||||
grid-template-rows: 1fr 14fr 1fr;
|
|
||||||
justify-items: center;
|
|
||||||
margin-left: 0em;
|
|
||||||
margin-right: 0em;
|
|
||||||
height: 95vh;
|
|
||||||
background-color: var(--color-search-background);
|
|
||||||
border-radius: 1em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.navItem {
|
|
||||||
gap: 0;
|
|
||||||
line-height: 1.5rem;
|
|
||||||
margin: 0;
|
|
||||||
width: 100%;
|
|
||||||
text-align: center;
|
|
||||||
display: flex;
|
|
||||||
}
|
|
||||||
|
|
||||||
.menuStack {
|
.menuStack {
|
||||||
width: 40%;
|
width: 40%;
|
||||||
height: 150px;
|
height: 150px;
|
||||||
|
|||||||
@@ -87,6 +87,9 @@
|
|||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
line-height: 2;
|
line-height: 2;
|
||||||
color: var(--color-text-pri);
|
color: var(--color-text-pri);
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
&:hover {
|
&:hover {
|
||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
}
|
}
|
||||||
@@ -110,28 +113,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.settingsLink {
|
|
||||||
&.root {
|
|
||||||
font-size: 1.25em;
|
|
||||||
display: block;
|
|
||||||
margin-left: 0;
|
|
||||||
margin-right: 0;
|
|
||||||
line-height: 2;
|
|
||||||
justify-self: center;
|
|
||||||
color: var(--color-text-pri);
|
|
||||||
border-radius: 1em;
|
|
||||||
&:hover {
|
|
||||||
background-color: var(--color-text-acc);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
a {
|
a {
|
||||||
color: var(--color-text-pri);
|
color: var(--color-text-pri);
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
a:hover #app-address {
|
|
||||||
text-decoration: underline;
|
|
||||||
text-decoration-color: var(--color-border);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import cardClasses from './Card.module.css';
|
|||||||
import menuClasses from './Menu.module.css';
|
import menuClasses from './Menu.module.css';
|
||||||
import modalClasses from './Modal.module.css';
|
import modalClasses from './Modal.module.css';
|
||||||
import multiSelectClasses from './MultiSelect.module.css';
|
import multiSelectClasses from './MultiSelect.module.css';
|
||||||
import navLinkClasses from './NavLink.module.css';
|
|
||||||
import popoverClasses from './Popover.module.css';
|
import popoverClasses from './Popover.module.css';
|
||||||
import selectClasses from './Select.module.css';
|
import selectClasses from './Select.module.css';
|
||||||
import stackClasses from './Stack.module.css';
|
import stackClasses from './Stack.module.css';
|
||||||
@@ -21,7 +20,6 @@ export {
|
|||||||
menuClasses,
|
menuClasses,
|
||||||
modalClasses,
|
modalClasses,
|
||||||
multiSelectClasses,
|
multiSelectClasses,
|
||||||
navLinkClasses,
|
|
||||||
popoverClasses,
|
popoverClasses,
|
||||||
selectClasses,
|
selectClasses,
|
||||||
stackClasses,
|
stackClasses,
|
||||||
|
|||||||
13
src/types/application.ts
Normal file
13
src/types/application.ts
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
export interface Application {
|
||||||
|
id: number | undefined;
|
||||||
|
name: string;
|
||||||
|
url: string;
|
||||||
|
icon: string;
|
||||||
|
baseUrl: string;
|
||||||
|
filterName: string;
|
||||||
|
index: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AppCategory {
|
||||||
|
filterName: string;
|
||||||
|
}
|
||||||
7
src/types/bookmark.ts
Normal file
7
src/types/bookmark.ts
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
export interface Bookmark {
|
||||||
|
id: number | undefined;
|
||||||
|
name: string;
|
||||||
|
url: string;
|
||||||
|
index: number;
|
||||||
|
category: string;
|
||||||
|
}
|
||||||
6
src/types/bookmarkGroup.ts
Normal file
6
src/types/bookmarkGroup.ts
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
export interface BookmarkGroup {
|
||||||
|
id: number | undefined;
|
||||||
|
categoryName: string;
|
||||||
|
categoryIndex: number;
|
||||||
|
filterName: string;
|
||||||
|
}
|
||||||
@@ -1 +1,10 @@
|
|||||||
export type { CurrentWeather, OutlookWeather } from './weather';
|
export type { CurrentWeather, OutlookWeather, ExtendedForecast } from './weather';
|
||||||
|
export type { Application, AppCategory } from './application';
|
||||||
|
export type { Bookmark } from './bookmark';
|
||||||
|
export type { BookmarkGroup } from './bookmarkGroup';
|
||||||
|
export type { PersonalData } from './personalData';
|
||||||
|
export type { Message } from './message';
|
||||||
|
export type { Provider } from './provider';
|
||||||
|
export type { Theme, ThemePlaylist } from './theme';
|
||||||
|
export type { WolClient } from './wolClient';
|
||||||
|
export type { SearchHistoryItem } from './searchHistory';
|
||||||
|
|||||||
5
src/types/message.ts
Normal file
5
src/types/message.ts
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
export interface Message {
|
||||||
|
id: number;
|
||||||
|
message: string;
|
||||||
|
customGreeting: number;
|
||||||
|
}
|
||||||
6
src/types/personalData.ts
Normal file
6
src/types/personalData.ts
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
export interface PersonalData {
|
||||||
|
firstName: string;
|
||||||
|
lastName: string;
|
||||||
|
email: string;
|
||||||
|
physicalAddress: string;
|
||||||
|
}
|
||||||
6
src/types/provider.ts
Normal file
6
src/types/provider.ts
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
export interface Provider {
|
||||||
|
id: number | undefined;
|
||||||
|
name: string;
|
||||||
|
url: string;
|
||||||
|
prefix: string;
|
||||||
|
}
|
||||||
7
src/types/searchHistory.ts
Normal file
7
src/types/searchHistory.ts
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
export interface SearchHistoryItem {
|
||||||
|
id: number | undefined;
|
||||||
|
prefix: string;
|
||||||
|
provider: string;
|
||||||
|
searchTerm: string;
|
||||||
|
dateTimeStamp: string;
|
||||||
|
}
|
||||||
18
src/types/theme.ts
Normal file
18
src/types/theme.ts
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
export interface Theme {
|
||||||
|
id: number | undefined;
|
||||||
|
name: string;
|
||||||
|
backgroundImage: string;
|
||||||
|
backgroundColor: string;
|
||||||
|
primaryColor: string;
|
||||||
|
accentColor: string;
|
||||||
|
borderColor: string;
|
||||||
|
searchColor: string;
|
||||||
|
randomEnabled: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ThemePlaylist {
|
||||||
|
id: number | undefined;
|
||||||
|
name: string;
|
||||||
|
default: number;
|
||||||
|
themeList: number[];
|
||||||
|
}
|
||||||
5
src/types/wolClient.ts
Normal file
5
src/types/wolClient.ts
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
export interface WolClient {
|
||||||
|
id: number | undefined;
|
||||||
|
hostname: string;
|
||||||
|
macAddress: string;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user