diff --git a/src/components/AppShelf/AppShelf.tsx b/src/components/AppShelf/AppShelf.tsx deleted file mode 100644 index 798d81cf2..000000000 --- a/src/components/AppShelf/AppShelf.tsx +++ /dev/null @@ -1,163 +0,0 @@ -import React, { useState } from 'react'; -import { Accordion, Grid, Stack, Title, useMantineColorScheme } from '@mantine/core'; -import { - closestCenter, - DndContext, - DragOverlay, - MouseSensor, - TouchSensor, - useSensor, - useSensors, -} from '@dnd-kit/core'; - -import { arrayMove, SortableContext } from '@dnd-kit/sortable'; -import { useLocalStorage } from '@mantine/hooks'; -import * as Modules from '../../modules'; -import { useConfig } from '../../tools/state'; - -import { AppShelfItem, SortableItem } from './AppShelfItem'; -import { ModuleWrapper } from '../../modules/moduleWrapper'; -import { UsenetModule, TorrentsModule } from '../../modules'; - -const AppShelf = (props: any) => { - const { config, setConfig } = useConfig(); - // Extract all the categories from the services in config - const categoryList = config.apps.reduce((acc, cur) => { - if (cur.category && !acc.includes(cur.category)) { - acc.push(cur.category); - } - return acc; - }, [] as string[]); - - const [toggledCategories, setToggledCategories] = useLocalStorage({ - key: 'app-shelf-toggled', - // This is a bit of a hack to toggle the categories on the first load, return a string[] of the categories - defaultValue: categoryList, - }); - const [activeId, setActiveId] = useState(null); - const { colorScheme } = useMantineColorScheme(); - - const sensors = useSensors( - useSensor(TouchSensor, { - activationConstraint: { - delay: 500, - tolerance: 5, - }, - }), - useSensor(MouseSensor, { - // Require the mouse to move by 10 pixels before activating - activationConstraint: { - delay: 500, - tolerance: 5, - }, - }) - ); - - function handleDragStart(event: any) { - const { active } = event; - - setActiveId(active.id); - } - - function handleDragEnd(event: any) { - const { active, over } = event; - - if (active.id !== over.id) { - const newConfig = { ...config }; - const activeIndex = newConfig.apps.findIndex((e) => e.id === active.id); - const overIndex = newConfig.apps.findIndex((e) => e.id === over.id); - newConfig.apps = arrayMove(newConfig.apps, activeIndex, overIndex); - setConfig(newConfig); - } - - setActiveId(null); - } - - const getItems = (filter?: string) => { - // If filter is not set, return all the services without a category or a null category - let filtered = config.apps; - const modules = Object.values(Modules).map((module) => module); - - if (!filter) { - filtered = config.apps.filter((e) => !e.category || e.category === null); - } - if (filter) { - filtered = config.apps.filter((e) => e.category === filter); - } - return ( - - - - {filtered.map((service) => ( - - - - - - ))} - - - - {activeId ? ( - e.id === activeId)} id={activeId} /> - ) : null} - - - ); - }; - - return ( - - { - setToggledCategories([...state]); - }} - > - {categoryList.map((category, idx) => ( - - - - {category} - - - {getItems(category)} - - ))} - - {getItems()} - - - - ); -}; - -export default AppShelf; diff --git a/src/components/AppShelf/AppShelfItem.tsx b/src/components/AppShelf/AppShelfItem.tsx deleted file mode 100644 index dfbd890fd..000000000 --- a/src/components/AppShelf/AppShelfItem.tsx +++ /dev/null @@ -1,144 +0,0 @@ -import { useSortable } from '@dnd-kit/sortable'; -import { CSS } from '@dnd-kit/utilities'; -import { - Anchor, - AspectRatio, - Card, - Center, - createStyles, - Image, - Text, - useMantineColorScheme, -} from '@mantine/core'; -import { motion } from 'framer-motion'; -import { useState } from 'react'; -import PingComponent from '../../modules/ping/PingModule'; -import { useConfig } from '../../tools/state'; -import { serviceItem } from '../../tools/types'; - -const useStyles = createStyles((theme) => ({ - item: { - transition: 'box-shadow 150ms ease, transform 100ms ease', - - '&:hover': { - boxShadow: `${theme.shadows.md} !important`, - transform: 'scale(1.05)', - }, - [theme.fn.smallerThan('sm')]: { - WebkitUserSelect: 'none', - }, - }, -})); - -export function SortableItem(props: any) { - const { attributes, listeners, setNodeRef, transform, transition } = useSortable({ - id: props.id, - }); - - const style = { - transform: CSS.Transform.toString(transform), - transition, - }; - - return ( -
- {props.children} -
- ); -} - -export function AppShelfItem(props: any) { - const { service }: { service: serviceItem } = props; - const [hovering, setHovering] = useState(false); - const { config } = useConfig(); - const { colorScheme } = useMantineColorScheme(); - const { classes } = useStyles(); - return ( - { - setHovering(true); - }} - onHoverEnd={() => { - setHovering(false); - }} - > - - - - - {service.name} - - - - {/* TODO: Remove this component */} - - - -
- - - - - - - - {service.ping !== false && } -
-
-
-
- ); -} diff --git a/src/components/AppShelf/apiKeyPaths.json b/src/components/AppShelf/apiKeyPaths.json deleted file mode 100644 index 3ecd0f338..000000000 --- a/src/components/AppShelf/apiKeyPaths.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "Jellyseerr": "settings", - "Overseerr": "settings", - "Sonarr": "settings/general", - "Radarr": "settings/general", - "Readarr": "settings/general", - "Lidarr": "settings/general", - "Sabnzbd": "sabnzbd/config/general" -} diff --git a/src/components/AppShelf/index.ts b/src/components/AppShelf/index.ts deleted file mode 100644 index fd496bd5b..000000000 --- a/src/components/AppShelf/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { default as AppShelf } from './AppShelf'; -export * from './AppShelfItem'; diff --git a/src/components/Dashboard/Modals/SelectElement/Components/WidgetsTab/WidgetElementType.tsx b/src/components/Dashboard/Modals/SelectElement/Components/WidgetsTab/WidgetElementType.tsx index a2262164f..db486cfae 100644 --- a/src/components/Dashboard/Modals/SelectElement/Components/WidgetsTab/WidgetElementType.tsx +++ b/src/components/Dashboard/Modals/SelectElement/Components/WidgetsTab/WidgetElementType.tsx @@ -33,8 +33,9 @@ export const WidgetElementType = ({ id, image, disabled, widget }: WidgetElement { id: widget.id, properties: Object.entries(widget.options).reduce((prev, [k, v]) => { - prev[k] = v.defaultValue; - return prev; + const newPrev = prev; + newPrev[k] = v.defaultValue; + return newPrev; }, {} as IWidget['properties']), area: { type: 'wrapper', diff --git a/src/components/Dashboard/Tiles/Apps/AppIcon.tsx b/src/components/Dashboard/Tiles/Apps/AppIcon.tsx index 69f356de8..9775b9849 100644 --- a/src/components/Dashboard/Tiles/Apps/AppIcon.tsx +++ b/src/components/Dashboard/Tiles/Apps/AppIcon.tsx @@ -1,6 +1,5 @@ interface ServiceIconProps { size: '100%' | number; - service: string; } export const AppIcon = ({ size }: ServiceIconProps) => null; diff --git a/src/components/Dashboard/Wrappers/gridstack/init-gridstack.ts b/src/components/Dashboard/Wrappers/gridstack/init-gridstack.ts index 550d62d91..31a6e4a52 100644 --- a/src/components/Dashboard/Wrappers/gridstack/init-gridstack.ts +++ b/src/components/Dashboard/Wrappers/gridstack/init-gridstack.ts @@ -22,7 +22,8 @@ export const initializeGridstack = ( const columnCount = areaType === 'sidebar' ? 4 : Math.floor(wrapperRef.current.offsetWidth / 64); const minRow = areaType !== 'sidebar' ? 1 : Math.floor(wrapperRef.current.offsetHeight / 64); // initialize gridstack - gridRef.current = GridStack.init( + const newGrid = gridRef; + newGrid.current = GridStack.init( { column: columnCount, margin: 10, @@ -37,7 +38,7 @@ export const initializeGridstack = ( // selector of the gridstack item (it's eather category or wrapper) `.grid-stack-${areaType}[data-${areaType}='${areaId}']` ); - const grid = gridRef.current; + const grid = newGrid.current; // Add listener for moving items around in a wrapper grid.on('change', (_, el) => { diff --git a/src/pages/index.tsx b/src/pages/index.tsx index 4d636bc83..81e5207af 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -1,6 +1,5 @@ import { getCookie, setCookie } from 'cookies-next'; import { GetServerSidePropsContext } from 'next'; -import { SSRConfig } from 'next-i18next'; import { serverSideTranslations } from 'next-i18next/serverSideTranslations'; import LoadConfigComponent from '../components/Config/LoadConfig'; diff --git a/src/widgets/index.ts b/src/widgets/index.ts index 935cecb11..977302b88 100644 --- a/src/widgets/index.ts +++ b/src/widgets/index.ts @@ -5,6 +5,7 @@ import usenet from './useNet/UseNetTile'; import weather from './weather/WeatherTile'; import bitTorrent from './bitTorrent/BitTorrentTile'; import torrentNetworkTraffic from './torrentNetworkTraffic/TorrentNetworkTrafficTile'; + export default { calendar, dashdot, diff --git a/src/widgets/weather/WeatherTile.tsx b/src/widgets/weather/WeatherTile.tsx index b24b3df48..118e1a584 100644 --- a/src/widgets/weather/WeatherTile.tsx +++ b/src/widgets/weather/WeatherTile.tsx @@ -1,8 +1,5 @@ import { Center, Group, Skeleton, Stack, Text, Title } from '@mantine/core'; import { IconArrowDownRight, IconArrowUpRight, IconCloudRain } from '@tabler/icons'; -import { HomarrCardWrapper } from '../../components/Dashboard/Tiles/HomarrCardWrapper'; -import { BaseTileProps } from '../../components/Dashboard/Tiles/type'; -import { WidgetsMenu } from '../../components/Dashboard/Tiles/Widgets/WidgetsMenu'; import { defineWidget } from '../helper'; import { IWidget } from '../widgets'; import { useWeatherForCity } from './useWeatherForCity';