mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-11 16:05:47 +01:00
✨ Made addable integrations dynamic
This commit is contained in:
@@ -1,69 +0,0 @@
|
|||||||
import { Grid, Text } from '@mantine/core';
|
|
||||||
import {
|
|
||||||
IconArrowsUpDown,
|
|
||||||
IconCalendarTime,
|
|
||||||
IconClock,
|
|
||||||
IconCloudRain,
|
|
||||||
IconFileDownload,
|
|
||||||
} from '@tabler/icons';
|
|
||||||
import { useTranslation } from 'next-i18next';
|
|
||||||
import { GenericAvailableElementType } from '../Shared/GenericElementType';
|
|
||||||
import { SelectorBackArrow } from '../Shared/SelectorBackArrow';
|
|
||||||
|
|
||||||
interface AvailableIntegrationElementsProps {
|
|
||||||
onClickBack: () => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const AvailableIntegrationElements = ({
|
|
||||||
onClickBack,
|
|
||||||
}: AvailableIntegrationElementsProps) => {
|
|
||||||
const { t } = useTranslation('layout/element-selector/selector');
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<SelectorBackArrow onClickBack={onClickBack} />
|
|
||||||
|
|
||||||
<Text mb="md" color="dimmed">
|
|
||||||
Integrations interact with your apps, to provide you with more control over your
|
|
||||||
applications. They usually require a few configurations before use.
|
|
||||||
</Text>
|
|
||||||
|
|
||||||
<Grid>
|
|
||||||
<GenericAvailableElementType
|
|
||||||
name="Usenet downloads"
|
|
||||||
description="Display and manage your Usenet downloads directly from Homarr"
|
|
||||||
image={<IconFileDownload />}
|
|
||||||
/>
|
|
||||||
<GenericAvailableElementType
|
|
||||||
name="BitTorrent downloads"
|
|
||||||
description="Display and manage your Torrent downloads directly from Homarr"
|
|
||||||
image={<IconFileDownload />}
|
|
||||||
/>
|
|
||||||
<GenericAvailableElementType
|
|
||||||
name="Calendar"
|
|
||||||
description="Integrate your Sonarr, Radarr, Lidarr and Readarr releases in a calendar"
|
|
||||||
image={<IconCalendarTime />}
|
|
||||||
/>
|
|
||||||
<GenericAvailableElementType
|
|
||||||
name="Date & Time"
|
|
||||||
description="Display the current date & time"
|
|
||||||
image={<IconClock />}
|
|
||||||
/>
|
|
||||||
<GenericAvailableElementType
|
|
||||||
name="Weather"
|
|
||||||
description="Display the current weather of a specified location"
|
|
||||||
image={<IconCloudRain />}
|
|
||||||
/>
|
|
||||||
<GenericAvailableElementType
|
|
||||||
name="Dash."
|
|
||||||
description="Display hardware data in realtime on your dashboard"
|
|
||||||
image="https://cdn.jsdelivr.net/gh/walkxcode/dashboard-icons/png/dashdot.png"
|
|
||||||
/>
|
|
||||||
<GenericAvailableElementType
|
|
||||||
name="Torrrent network traffic"
|
|
||||||
description="Display the current download & upload of your torrent clients"
|
|
||||||
image={<IconArrowsUpDown />}
|
|
||||||
/>
|
|
||||||
</Grid>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
@@ -1,13 +1,13 @@
|
|||||||
import { Box, Button, Card, Center, Grid, Stack, Text, UnstyledButton } from '@mantine/core';
|
import { Button, Card, Center, Grid, Stack, Text } from '@mantine/core';
|
||||||
import { IconChevronRight } from '@tabler/icons';
|
import { TablerIcon } from '@tabler/icons';
|
||||||
import Image from 'next/image';
|
import Image from 'next/image';
|
||||||
import React, { ReactNode } from 'react';
|
import React from 'react';
|
||||||
import { useStyles } from './styles';
|
import { useStyles } from './styles';
|
||||||
|
|
||||||
interface GenericAvailableElementTypeProps {
|
interface GenericAvailableElementTypeProps {
|
||||||
name: string;
|
name: string;
|
||||||
description?: string;
|
description?: string;
|
||||||
image: string | ReactNode;
|
image: string | TablerIcon;
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -19,13 +19,8 @@ export const GenericAvailableElementType = ({
|
|||||||
}: GenericAvailableElementTypeProps) => {
|
}: GenericAvailableElementTypeProps) => {
|
||||||
const { classes } = useStyles();
|
const { classes } = useStyles();
|
||||||
|
|
||||||
const Icon = () => {
|
const Icon =
|
||||||
if (React.isValidElement(image)) {
|
typeof image === 'string' ? () => <Image src={image} width={24} height={24} /> : image;
|
||||||
return <>{image}</>;
|
|
||||||
}
|
|
||||||
|
|
||||||
return <Image src={image as string} width={24} height={24} />;
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Grid.Col span={3}>
|
<Grid.Col span={3}>
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ export const AvailableStaticTypes = ({ onClickBack }: AvailableStaticTypesProps)
|
|||||||
<GenericAvailableElementType
|
<GenericAvailableElementType
|
||||||
name="Static Text"
|
name="Static Text"
|
||||||
description="Display a fixed string on your dashboard"
|
description="Display a fixed string on your dashboard"
|
||||||
image={<IconCursorText />}
|
image={IconCursorText}
|
||||||
/>
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
import { Grid, Text } from '@mantine/core';
|
||||||
|
import {
|
||||||
|
IconArrowsUpDown,
|
||||||
|
IconCalendarTime,
|
||||||
|
IconClock,
|
||||||
|
IconCloudRain,
|
||||||
|
IconFileDownload,
|
||||||
|
} from '@tabler/icons';
|
||||||
|
import { useTranslation } from 'next-i18next';
|
||||||
|
import widgets from '../../../../../../widgets';
|
||||||
|
import { GenericAvailableElementType } from '../Shared/GenericElementType';
|
||||||
|
import { SelectorBackArrow } from '../Shared/SelectorBackArrow';
|
||||||
|
import { WidgetElementType } from './WidgetElementType';
|
||||||
|
|
||||||
|
interface AvailableIntegrationElementsProps {
|
||||||
|
onClickBack: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const AvailableIntegrationElements = ({
|
||||||
|
onClickBack,
|
||||||
|
}: AvailableIntegrationElementsProps) => {
|
||||||
|
const { t } = useTranslation('layout/element-selector/selector');
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<SelectorBackArrow onClickBack={onClickBack} />
|
||||||
|
|
||||||
|
<Text mb="md" color="dimmed">
|
||||||
|
Widgets interact with your apps, to provide you with more control over your applications.
|
||||||
|
They usually require a few configurations before use.
|
||||||
|
</Text>
|
||||||
|
|
||||||
|
<Grid>
|
||||||
|
{Object.entries(widgets).map(([k, v]) => (
|
||||||
|
<WidgetElementType key={k} id={k} image={v.icon} />
|
||||||
|
))}
|
||||||
|
</Grid>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
import { Button, Card, Center, Grid, Stack, Text } from '@mantine/core';
|
||||||
|
import { TablerIcon } from '@tabler/icons';
|
||||||
|
import { useTranslation } from 'next-i18next';
|
||||||
|
import Image from 'next/image';
|
||||||
|
import React, { ReactNode } from 'react';
|
||||||
|
import { AvailableElementTypes } from '../Overview/AvailableElementsOverview';
|
||||||
|
import { GenericAvailableElementType } from '../Shared/GenericElementType';
|
||||||
|
|
||||||
|
interface WidgetElementTypeProps {
|
||||||
|
id: string;
|
||||||
|
image: string | TablerIcon;
|
||||||
|
disabled?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const WidgetElementType = ({ id, image, disabled }: WidgetElementTypeProps) => {
|
||||||
|
const { t } = useTranslation(`modules/${id}`);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<GenericAvailableElementType
|
||||||
|
name={t('descriptor.name')}
|
||||||
|
description={t('descriptor.description')}
|
||||||
|
image={image}
|
||||||
|
disabled={disabled}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { ContextModalProps } from '@mantine/modals';
|
import { ContextModalProps } from '@mantine/modals';
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { AvailableIntegrationElements } from './Components/IntegrationsTab/AvailableIntegrationsTab';
|
import { AvailableIntegrationElements } from './Components/WidgetsTab/AvailableWidgetsTab';
|
||||||
import { AvailableElementTypes } from './Components/Overview/AvailableElementsOverview';
|
import { AvailableElementTypes } from './Components/Overview/AvailableElementsOverview';
|
||||||
import { AvailableStaticTypes } from './Components/StaticElementsTab/AvailableStaticElementsTab';
|
import { AvailableStaticTypes } from './Components/StaticElementsTab/AvailableStaticElementsTab';
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { IconClock } from '@tabler/icons';
|
import { IconClock, IconFileDownload } from '@tabler/icons';
|
||||||
import { HomarrCardWrapper } from '../../components/Dashboard/Tiles/HomarrCardWrapper';
|
import { HomarrCardWrapper } from '../../components/Dashboard/Tiles/HomarrCardWrapper';
|
||||||
import { BaseTileProps } from '../../components/Dashboard/Tiles/type';
|
import { BaseTileProps } from '../../components/Dashboard/Tiles/type';
|
||||||
import { defineWidget } from '../helper';
|
import { defineWidget } from '../helper';
|
||||||
@@ -6,7 +6,7 @@ import { IWidget } from '../widgets';
|
|||||||
|
|
||||||
const definition = defineWidget({
|
const definition = defineWidget({
|
||||||
id: 'torrents-status',
|
id: 'torrents-status',
|
||||||
icon: IconClock,
|
icon: IconFileDownload,
|
||||||
options: {},
|
options: {},
|
||||||
gridstack: {
|
gridstack: {
|
||||||
minWidth: 2,
|
minWidth: 2,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { IconClock } from '@tabler/icons';
|
import { IconArrowsUpDown, IconClock } from '@tabler/icons';
|
||||||
import { HomarrCardWrapper } from '../../components/Dashboard/Tiles/HomarrCardWrapper';
|
import { HomarrCardWrapper } from '../../components/Dashboard/Tiles/HomarrCardWrapper';
|
||||||
import { BaseTileProps } from '../../components/Dashboard/Tiles/type';
|
import { BaseTileProps } from '../../components/Dashboard/Tiles/type';
|
||||||
import { defineWidget } from '../helper';
|
import { defineWidget } from '../helper';
|
||||||
@@ -6,7 +6,7 @@ import { IWidget } from '../widgets';
|
|||||||
|
|
||||||
const definition = defineWidget({
|
const definition = defineWidget({
|
||||||
id: 'dlspeed',
|
id: 'dlspeed',
|
||||||
icon: IconClock,
|
icon: IconArrowsUpDown,
|
||||||
options: {},
|
options: {},
|
||||||
|
|
||||||
gridstack: {
|
gridstack: {
|
||||||
|
|||||||
Reference in New Issue
Block a user