Skip to content

Commit

Permalink
feat: add settings ui
Browse files Browse the repository at this point in the history
  • Loading branch information
oae committed Nov 4, 2022
1 parent 7d6fe34 commit 45980ec
Show file tree
Hide file tree
Showing 13 changed files with 923 additions and 8 deletions.
5 changes: 0 additions & 5 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,3 @@ DATABASE_URL=postgresql://${DATABASE_USER}:${DATABASE_PASSWORD}@${DATABASE_HOST}
# Redis
REDIS_HOST=localhost
REDIS_PORT=6379

# Notification
TELEGRAM_TOKEN=
TELEGRAM_CHAT_ID=
TELEGRAM_SEND_SILENTLY=0
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"@typescript-eslint/no-unused-vars": [
"error",
{
"ignoreRestSiblings": true,
"argsIgnorePattern": "^_",
"varsIgnorePattern": "^_",
"caughtErrorsIgnorePattern": "^_"
Expand Down
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ services:
- KAIZOKU_PORT=3000
- REDIS_HOST=redis
- REDIS_PORT=6379
- TELEGRAM_TOKEN=<token> # Don't set if you don't want telegram notifications.
- TELEGRAM_CHAT_ID=<chat_id>
- TELEGRAM_SEND_SILENTLY=0
- PUID=<host user puid>
- PGID=<host user guid>
- TZ=Europe/Istanbul
Expand Down
4 changes: 4 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,7 @@ services:
- db:/var/lib/postgresql/data
ports:
- "${DATABASE_PORT:-5432}:5432"
apprise:
image: caronc/apprise:latest
ports:
- "9292:8000"
Binary file added public/brand/apprise.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/brand/komga.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/brand/telegram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
176 changes: 176 additions & 0 deletions src/components/settings/integration.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
import { Accordion, Box, Breadcrumbs, createStyles, Group, Image, Text } from '@mantine/core';
import { trpc } from '../../utils/trpc';
import { SwitchItem, TextItem } from './mangal';

const useStyles = createStyles((theme) => ({
item: {
'&': {
paddingTop: theme.spacing.sm,
marginTop: theme.spacing.sm,
borderTop: `1px solid ${theme.colorScheme === 'dark' ? theme.colors.dark[4] : theme.colors.gray[2]}`,
},
},

switch: {
'& *': {
cursor: 'pointer',
},
},

numberInput: {
maxWidth: 60,
},

textInput: {
maxWidth: 120,
},

title: {
lineHeight: 1,
},
}));

export function IntegrationSettings() {
const { classes } = useStyles();
const update = trpc.settings.update.useMutation();
const settings = trpc.settings.query.useQuery();

const handleUpdate = async (key: string, value: boolean | string | number) => {
await update.mutateAsync({
key,
value,
updateType: 'app',
});
await settings.refetch();
};

if (settings.isLoading || !settings.data) {
return null;
}

return (
<Accordion variant="contained">
<Accordion.Item value="komga">
<Accordion.Control icon={<Image src="/brand/komga.png" width={20} height={20} />}>Komga</Accordion.Control>
<Accordion.Panel>
<Group position="apart" className={classes.item} spacing="xl" noWrap>
<Box>
<Breadcrumbs
separator="/"
styles={{
separator: {
marginLeft: 4,
marginRight: 4,
},
breadcrumb: {
textTransform: 'capitalize',
fontSize: 13,
fontWeight: 500,
},
root: {
marginBottom: 5,
},
}}
>
Enabled
</Breadcrumbs>
<Text size="xs" color="dimmed">
Enable Komga integration to trigger library scan and metadata refresh tasks
</Text>
</Box>
<SwitchItem
configKey="komgaEnabled"
onUpdate={handleUpdate}
initialValue={settings.data.appConfig.komgaEnabled}
/>
</Group>
<Group position="apart" className={classes.item} spacing="xl" noWrap>
<Box>
<Breadcrumbs
separator="/"
styles={{
separator: {
marginLeft: 4,
marginRight: 4,
},
breadcrumb: {
textTransform: 'capitalize',
fontSize: 13,
fontWeight: 500,
},
root: {
marginBottom: 5,
},
}}
>
Host
</Breadcrumbs>
<Text size="xs" color="dimmed">
Komga host or ip
</Text>
</Box>
<TextItem configKey="komgaHost" onUpdate={handleUpdate} initialValue={settings.data.appConfig.komgaHost} />
</Group>
<Group position="apart" className={classes.item} spacing="xl" noWrap>
<Box>
<Breadcrumbs
separator="/"
styles={{
separator: {
marginLeft: 4,
marginRight: 4,
},
breadcrumb: {
textTransform: 'capitalize',
fontSize: 13,
fontWeight: 500,
},
root: {
marginBottom: 5,
},
}}
>
Email
</Breadcrumbs>
<Text size="xs" color="dimmed">
Komga user
</Text>
</Box>
<TextItem configKey="komgaUser" onUpdate={handleUpdate} initialValue={settings.data.appConfig.komgaUser} />
</Group>
<Group position="apart" className={classes.item} spacing="xl" noWrap>
<Box>
<Breadcrumbs
separator="/"
styles={{
separator: {
marginLeft: 4,
marginRight: 4,
},
breadcrumb: {
textTransform: 'capitalize',
fontSize: 13,
fontWeight: 500,
},
root: {
marginBottom: 5,
},
}}
>
Password
</Breadcrumbs>
<Text size="xs" color="dimmed">
Komga user password
</Text>
</Box>
<TextItem
configKey="komgaPassword"
onUpdate={handleUpdate}
initialValue={settings.data.appConfig.komgaPassword}
/>
</Group>
</Accordion.Panel>
</Accordion.Item>
</Accordion>
);
}
Loading

0 comments on commit 45980ec

Please sign in to comment.