Compare commits
144 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dab394d3c4 | ||
|
|
5b1437552d | ||
|
|
e8a8fbe6ac | ||
|
|
5c0a074219 | ||
|
|
58ec74bb68 | ||
|
|
6ac82bda40 | ||
|
|
2c6e86840a | ||
|
|
df85fc6b7d | ||
|
|
89804dafd1 | ||
|
|
98eaee1234 | ||
|
|
433edafddd | ||
|
|
e39d5741b6 | ||
|
|
21c08cbe63 | ||
|
|
ec92a1d89c | ||
|
|
0f2c5dbce2 | ||
|
|
8eae5a908c | ||
|
|
a37f0fdee6 | ||
|
|
08799aac18 | ||
|
|
06531e0fb8 | ||
|
|
0f56ead24f | ||
|
|
922caa76da | ||
|
|
0acb1f6b6d | ||
|
|
8d645ca404 | ||
|
|
a5c4f30f57 | ||
|
|
562a05adf5 | ||
|
|
de77e06b18 | ||
|
|
03c499d822 | ||
|
|
169d08f3b6 | ||
|
|
437807a9e0 | ||
|
|
4866fd74b5 | ||
|
|
426ba69afd | ||
|
|
74f87b570d | ||
|
|
fed5f6df52 | ||
|
|
5cc160473c | ||
|
|
4833157061 | ||
|
|
a0c8518d22 | ||
|
|
c0c816d3db | ||
|
|
ac47de72ee | ||
|
|
d631865f71 | ||
|
|
4ee6562e35 | ||
|
|
19f80b9b4c | ||
|
|
949deacd6d | ||
|
|
b0f4a91878 | ||
|
|
68f2e79056 | ||
|
|
43e68e1bbf | ||
|
|
5033323b7c | ||
|
|
7519b4a6b2 | ||
|
|
e6eedefec4 | ||
|
|
845d6a3d87 | ||
|
|
f75da289c2 | ||
|
|
063a6447c0 | ||
|
|
4dac730412 | ||
|
|
de6e0f645f | ||
|
|
b26ab50c8d | ||
|
|
423f8110b9 | ||
|
|
84ae49ed2a | ||
|
|
fb291c5411 | ||
|
|
901798055b | ||
|
|
d32d599098 | ||
|
|
76e02cf148 | ||
|
|
f19b4675ad | ||
|
|
4f1640b70a | ||
|
|
c1d17ec8b2 | ||
|
|
d2f1268520 | ||
|
|
b72afc2270 | ||
|
|
de0c625f88 | ||
|
|
29c9f3ecac | ||
|
|
a321095daf | ||
|
|
ced18da65a | ||
|
|
1a642ad7b4 | ||
|
|
838f196937 | ||
|
|
6af5166aa5 | ||
|
|
7935fb6616 | ||
|
|
ed567065b4 | ||
|
|
06035fb6f0 | ||
|
|
c1af0a087d | ||
|
|
6067c5dfcf | ||
|
|
bf7b9637f7 | ||
|
|
c552104413 | ||
|
|
6fd23cf6a0 | ||
|
|
e2f59383d6 | ||
|
|
8b92135a80 | ||
|
|
aef4a30512 | ||
|
|
ace8bd75e7 | ||
|
|
2e461b4e7a | ||
|
|
3f87e939c9 | ||
|
|
1d9dfc5102 | ||
|
|
80a94d3778 | ||
|
|
39d66faf4e | ||
|
|
c50e11c75b | ||
|
|
9a3ebb56cb | ||
|
|
1d1495453a | ||
|
|
26cfc485c2 | ||
|
|
83b4da282a | ||
|
|
ea972effb4 | ||
|
|
9686761c3d | ||
|
|
13a5a4a263 | ||
|
|
339919cfff | ||
|
|
2594a7caa5 | ||
|
|
2966be4fc4 | ||
|
|
5e21a7df9c | ||
|
|
64eb00f2ee | ||
|
|
00928ae709 | ||
|
|
bbb912479b | ||
|
|
5b16589360 | ||
|
|
39674fc769 | ||
|
|
e718fd6b80 | ||
|
|
bdaf70f26b | ||
|
|
44a7df5ae0 | ||
|
|
25fa376c2d | ||
|
|
de3792fb6b | ||
|
|
64b1679b03 | ||
|
|
8da0b38662 | ||
|
|
13fd1a9fc0 | ||
|
|
04c1b41015 | ||
|
|
6a32b80098 | ||
|
|
759e02f74a | ||
|
|
5758019923 | ||
|
|
cad160010d | ||
|
|
56b6347824 | ||
|
|
c258003ec5 | ||
|
|
5ac5098a2a | ||
|
|
3c96053b7f | ||
|
|
67a89ba61a | ||
|
|
4c0a3ce48c | ||
|
|
2d2f9d8d19 | ||
|
|
0a7f98dd80 | ||
|
|
5b4d302c17 | ||
|
|
31d23852f7 | ||
|
|
a9e8db5018 | ||
|
|
f3d1767daf | ||
|
|
b229aacba5 | ||
|
|
174ed140ae | ||
|
|
62635bffe9 | ||
|
|
63e6efab1f | ||
|
|
ad1af0e07d | ||
|
|
cfd9eb94b5 | ||
|
|
c6762281ef | ||
|
|
7d09a0064a | ||
|
|
2d6b9522c5 | ||
|
|
1a2e752281 | ||
|
|
c7c76ee22b | ||
|
|
0457c91ede | ||
|
|
1a420c3b8b |
7
.github/pull_request_template.md
vendored
7
.github/pull_request_template.md
vendored
@@ -14,10 +14,3 @@
|
|||||||
|
|
||||||
### Screenshot _(if applicable)_
|
### Screenshot _(if applicable)_
|
||||||
> If you've introduced any significant UI changes, please include a screenshot.
|
> If you've introduced any significant UI changes, please include a screenshot.
|
||||||
|
|
||||||
### Code Quality Checklist _(Please complete)_
|
|
||||||
- [ ] All changes are backwards compatible
|
|
||||||
- [ ] There are no (new) build warnings or errors
|
|
||||||
- [ ] _(If a new config option is added)_ Attribute is outlined in the schema and documented
|
|
||||||
- [ ] _(If a new dependency is added)_ Package is essential, and has been checked out for security or performance
|
|
||||||
- [ ] Bumps version, if new feature added
|
|
||||||
|
|||||||
2
.github/workflows/docker.yml
vendored
2
.github/workflows/docker.yml
vendored
@@ -52,7 +52,7 @@ jobs:
|
|||||||
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
|
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
|
||||||
# If source files changed but packages didn't, rebuild from a prior cache.
|
# If source files changed but packages didn't, rebuild from a prior cache.
|
||||||
restore-keys: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-
|
restore-keys: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-
|
||||||
- run: yarn install --frozen-lockfile
|
- run: yarn install --immutable
|
||||||
- run: yarn build
|
- run: yarn build
|
||||||
- name: Cache build output
|
- name: Cache build output
|
||||||
# to copy needed files to docker build job
|
# to copy needed files to docker build job
|
||||||
|
|||||||
4
.github/workflows/docker_dev.yml
vendored
4
.github/workflows/docker_dev.yml
vendored
@@ -16,7 +16,7 @@ on:
|
|||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
inputs:
|
||||||
tags:
|
tags:
|
||||||
requierd: true
|
required: true
|
||||||
description: 'Tags to deploy to'
|
description: 'Tags to deploy to'
|
||||||
|
|
||||||
env:
|
env:
|
||||||
@@ -62,7 +62,7 @@ jobs:
|
|||||||
# If source files changed but packages didn't, rebuild from a prior cache.
|
# If source files changed but packages didn't, rebuild from a prior cache.
|
||||||
restore-keys: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-
|
restore-keys: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-
|
||||||
|
|
||||||
- run: yarn install --frozen-lockfile
|
- run: yarn install --immutable
|
||||||
- run: yarn build
|
- run: yarn build
|
||||||
|
|
||||||
- name: Cache build output
|
- name: Cache build output
|
||||||
|
|||||||
10
.gitignore
vendored
10
.gitignore
vendored
@@ -37,3 +37,13 @@ yarn-error.log*
|
|||||||
# storybook
|
# storybook
|
||||||
storybook-static
|
storybook-static
|
||||||
data/configs
|
data/configs
|
||||||
|
|
||||||
|
# https://yarnpkg.com/getting-started/qa#which-files-should-be-gitignored
|
||||||
|
# Yarn v2
|
||||||
|
.pnp.*
|
||||||
|
.yarn/*
|
||||||
|
!.yarn/patches
|
||||||
|
!.yarn/plugins
|
||||||
|
!.yarn/releases
|
||||||
|
!.yarn/sdks
|
||||||
|
!.yarn/versions
|
||||||
786
.yarn/releases/yarn-3.2.1.cjs
vendored
Normal file
786
.yarn/releases/yarn-3.2.1.cjs
vendored
Normal file
File diff suppressed because one or more lines are too long
5
.yarnrc
Normal file
5
.yarnrc
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||||
|
# yarn lockfile v1
|
||||||
|
|
||||||
|
|
||||||
|
yarn-path ".yarn/releases/yarn-1.22.19.cjs"
|
||||||
3
.yarnrc.yml
Normal file
3
.yarnrc.yml
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
nodeLinker: node-modules
|
||||||
|
|
||||||
|
yarnPath: .yarn/releases/yarn-3.2.1.cjs
|
||||||
@@ -9,5 +9,6 @@ COPY /.next/standalone ./
|
|||||||
COPY /.next/static ./.next/static
|
COPY /.next/static ./.next/static
|
||||||
EXPOSE 7575
|
EXPOSE 7575
|
||||||
ENV PORT 7575
|
ENV PORT 7575
|
||||||
|
RUN apk add tzdata
|
||||||
VOLUME /app/data/configs
|
VOLUME /app/data/configs
|
||||||
CMD ["node", "server.js"]
|
CMD ["node", "server.js"]
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
<i>Join the discord! — Don't forget to star the repo if you are enjoying the project!</i>
|
<i>Join the discord! — Don't forget to star the repo if you are enjoying the project!</i>
|
||||||
</p>
|
</p>
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<a href="https://homarr.netlify.app/"><strong> Demo ↗️ </strong></a> • <a href="#-installation"><strong> Install ➡️ </strong></a> • <a href="https://github.com/ajnart/homarr/wiki"><strong> Read the Wiki 📄 </strong></a>
|
<a href="https://homarr.ajnart.fr/"><strong> Demo ↗️ </strong></a> • <a href="#-installation"><strong> Install ➡️ </strong></a> • <a href="https://github.com/ajnart/homarr/wiki"><strong> Read the Wiki 📄 </strong></a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
export const REPO_URL = 'ajnart/homarr';
|
export const REPO_URL = 'ajnart/homarr';
|
||||||
export const CURRENT_VERSION = 'v0.5.2';
|
export const CURRENT_VERSION = 'v0.7.0';
|
||||||
|
|||||||
34
package.json
34
package.json
@@ -1,7 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "homarr",
|
"name": "homarr",
|
||||||
"version": "0.5.2",
|
"version": "0.7.0",
|
||||||
"private": "false",
|
|
||||||
"description": "Homarr - A homepage for your server.",
|
"description": "Homarr - A homepage for your server.",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@@ -25,28 +24,34 @@
|
|||||||
"ci": "yarn test && yarn lint --fix && yarn typecheck && yarn prettier:write"
|
"ci": "yarn test && yarn lint --fix && yarn typecheck && yarn prettier:write"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ctrl/deluge": "^4.0.0",
|
"@ctrl/deluge": "^4.1.0",
|
||||||
"@ctrl/qbittorrent": "^4.0.0",
|
"@ctrl/qbittorrent": "^4.0.0",
|
||||||
|
"@ctrl/shared-torrent": "^4.1.0",
|
||||||
|
"@ctrl/transmission": "^4.1.1",
|
||||||
"@dnd-kit/core": "^6.0.1",
|
"@dnd-kit/core": "^6.0.1",
|
||||||
"@dnd-kit/sortable": "^7.0.0",
|
"@dnd-kit/sortable": "^7.0.0",
|
||||||
"@mantine/core": "^4.2.6",
|
"@dnd-kit/utilities": "^3.2.0",
|
||||||
"@mantine/dates": "^4.2.6",
|
"@mantine/core": "^4.2.8",
|
||||||
"@mantine/dropzone": "^4.2.6",
|
"@mantine/dates": "^4.2.8",
|
||||||
"@mantine/form": "^4.2.6",
|
"@mantine/dropzone": "^4.2.8",
|
||||||
"@mantine/hooks": "^4.2.6",
|
"@mantine/form": "^4.2.8",
|
||||||
"@mantine/next": "^4.2.6",
|
"@mantine/hooks": "^4.2.8",
|
||||||
"@mantine/notifications": "^4.2.6",
|
"@mantine/next": "^4.2.8",
|
||||||
"@mantine/prism": "^4.2.6",
|
"@mantine/notifications": "^4.2.8",
|
||||||
|
"@mantine/prism": "^4.2.8",
|
||||||
|
"@nivo/core": "^0.79.0",
|
||||||
|
"@nivo/line": "^0.79.1",
|
||||||
|
"@tabler/icons": "^1.68.0",
|
||||||
"axios": "^0.27.2",
|
"axios": "^0.27.2",
|
||||||
"cookies-next": "^2.0.4",
|
"cookies-next": "^2.0.4",
|
||||||
"dayjs": "^1.11.2",
|
"dayjs": "^1.11.3",
|
||||||
"framer-motion": "^6.3.1",
|
"framer-motion": "^6.3.1",
|
||||||
"js-file-download": "^0.4.12",
|
"js-file-download": "^0.4.12",
|
||||||
"next": "12.1.6",
|
"next": "12.1.6",
|
||||||
"prism-react-renderer": "^1.3.1",
|
"prism-react-renderer": "^1.3.1",
|
||||||
"react": "^17.0.1",
|
"react": "^17.0.1",
|
||||||
"react-dom": "^17.0.1",
|
"react-dom": "^17.0.1",
|
||||||
"tabler-icons-react": "^1.46.0",
|
"systeminformation": "^5.11.16",
|
||||||
"uuid": "^8.3.2"
|
"uuid": "^8.3.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@@ -78,5 +83,6 @@
|
|||||||
},
|
},
|
||||||
"resolutions": {
|
"resolutions": {
|
||||||
"@types/react": "17.0.30"
|
"@types/react": "17.0.30"
|
||||||
}
|
},
|
||||||
|
"packageManager": "yarn@3.2.1"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,11 +10,14 @@ import {
|
|||||||
ActionIcon,
|
ActionIcon,
|
||||||
Tooltip,
|
Tooltip,
|
||||||
Title,
|
Title,
|
||||||
|
Anchor,
|
||||||
|
Text,
|
||||||
} from '@mantine/core';
|
} from '@mantine/core';
|
||||||
import { useForm } from '@mantine/form';
|
import { useForm } from '@mantine/form';
|
||||||
import { useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { Apps } from 'tabler-icons-react';
|
import { IconApps as Apps } from '@tabler/icons';
|
||||||
import { v4 as uuidv4 } from 'uuid';
|
import { v4 as uuidv4 } from 'uuid';
|
||||||
|
import { useDebouncedValue } from '@mantine/hooks';
|
||||||
import { useConfig } from '../../tools/state';
|
import { useConfig } from '../../tools/state';
|
||||||
import { ServiceTypeList } from '../../tools/types';
|
import { ServiceTypeList } from '../../tools/types';
|
||||||
|
|
||||||
@@ -61,21 +64,55 @@ function MatchIcon(name: string, form: any) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function MatchService(name: string, form: any) {
|
||||||
|
const service = ServiceTypeList.find((s) => s.toLowerCase() === name.toLowerCase());
|
||||||
|
if (service) {
|
||||||
|
form.setFieldValue('type', service);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function MatchPort(name: string, form: any) {
|
||||||
|
const portmap = [
|
||||||
|
{ name: 'qbittorrent', value: '8080' },
|
||||||
|
{ name: 'sonarr', value: '8989' },
|
||||||
|
{ name: 'radarr', value: '7878' },
|
||||||
|
{ name: 'lidarr', value: '8686' },
|
||||||
|
{ name: 'readarr', value: '8686' },
|
||||||
|
{ name: 'deluge', value: '8112' },
|
||||||
|
{ name: 'transmission', value: '9091' },
|
||||||
|
];
|
||||||
|
// Match name with portmap key
|
||||||
|
const port = portmap.find((p) => p.name === name.toLowerCase());
|
||||||
|
if (port) {
|
||||||
|
form.setFieldValue('url', `http://localhost:${port.value}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export function AddAppShelfItemForm(props: { setOpened: (b: boolean) => void } & any) {
|
export function AddAppShelfItemForm(props: { setOpened: (b: boolean) => void } & any) {
|
||||||
const { setOpened } = props;
|
const { setOpened } = props;
|
||||||
const { config, setConfig } = useConfig();
|
const { config, setConfig } = useConfig();
|
||||||
const [isLoading, setLoading] = useState(false);
|
const [isLoading, setLoading] = useState(false);
|
||||||
|
|
||||||
|
// Extract all the categories from the services in config
|
||||||
|
const categoryList = config.services.reduce((acc, cur) => {
|
||||||
|
if (cur.category && !acc.includes(cur.category)) {
|
||||||
|
acc.push(cur.category);
|
||||||
|
}
|
||||||
|
return acc;
|
||||||
|
}, [] as string[]);
|
||||||
|
|
||||||
const form = useForm({
|
const form = useForm({
|
||||||
initialValues: {
|
initialValues: {
|
||||||
id: props.id ?? uuidv4(),
|
id: props.id ?? uuidv4(),
|
||||||
type: props.type ?? 'Other',
|
type: props.type ?? 'Other',
|
||||||
|
category: props.category ?? undefined,
|
||||||
name: props.name ?? '',
|
name: props.name ?? '',
|
||||||
icon: props.icon ?? '/favicon.svg',
|
icon: props.icon ?? '/favicon.svg',
|
||||||
url: props.url ?? '',
|
url: props.url ?? '',
|
||||||
apiKey: props.apiKey ?? (undefined as unknown as string),
|
apiKey: props.apiKey ?? (undefined as unknown as string),
|
||||||
username: props.username ?? (undefined as unknown as string),
|
username: props.username ?? (undefined as unknown as string),
|
||||||
password: props.password ?? (undefined as unknown as string),
|
password: props.password ?? (undefined as unknown as string),
|
||||||
|
openedUrl: props.openedUrl ?? (undefined as unknown as string),
|
||||||
},
|
},
|
||||||
validate: {
|
validate: {
|
||||||
apiKey: () => null,
|
apiKey: () => null,
|
||||||
@@ -99,6 +136,23 @@ export function AddAppShelfItemForm(props: { setOpened: (b: boolean) => void } &
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const [debounced, cancel] = useDebouncedValue(form.values.name, 250);
|
||||||
|
useEffect(() => {
|
||||||
|
if (form.values.name !== debounced || props.name || props.type) return;
|
||||||
|
MatchIcon(form.values.name, form);
|
||||||
|
MatchService(form.values.name, form);
|
||||||
|
MatchPort(form.values.name, form);
|
||||||
|
}, [debounced]);
|
||||||
|
|
||||||
|
// Try to set const hostname to new URL(form.values.url).hostname)
|
||||||
|
// If it fails, set it to the form.values.url
|
||||||
|
let hostname = form.values.url;
|
||||||
|
try {
|
||||||
|
hostname = new URL(form.values.url).origin;
|
||||||
|
} catch (e) {
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Center>
|
<Center>
|
||||||
@@ -142,31 +196,28 @@ export function AddAppShelfItemForm(props: { setOpened: (b: boolean) => void } &
|
|||||||
required
|
required
|
||||||
label="Service name"
|
label="Service name"
|
||||||
placeholder="Plex"
|
placeholder="Plex"
|
||||||
value={form.values.name}
|
{...form.getInputProps('name')}
|
||||||
onChange={(event) => {
|
|
||||||
form.setFieldValue('name', event.currentTarget.value);
|
|
||||||
const match = MatchIcon(event.currentTarget.value, form);
|
|
||||||
if (match) {
|
|
||||||
form.setFieldValue('icon', match);
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
error={form.errors.name && 'Invalid icon url'}
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<TextInput
|
<TextInput
|
||||||
required
|
required
|
||||||
label="Icon url"
|
label="Icon URL"
|
||||||
placeholder="https://i.gifer.com/ANPC.gif"
|
placeholder="/favicon.svg"
|
||||||
{...form.getInputProps('icon')}
|
{...form.getInputProps('icon')}
|
||||||
/>
|
/>
|
||||||
<TextInput
|
<TextInput
|
||||||
required
|
required
|
||||||
label="Service url"
|
label="Service URL"
|
||||||
placeholder="http://localhost:7575"
|
placeholder="http://localhost:7575"
|
||||||
{...form.getInputProps('url')}
|
{...form.getInputProps('url')}
|
||||||
/>
|
/>
|
||||||
|
<TextInput
|
||||||
|
label="New tab URL"
|
||||||
|
placeholder="http://sonarr.example.com"
|
||||||
|
{...form.getInputProps('openedUrl')}
|
||||||
|
/>
|
||||||
<Select
|
<Select
|
||||||
label="Select the type of service (used for API calls)"
|
label="Service type"
|
||||||
defaultValue="Other"
|
defaultValue="Other"
|
||||||
placeholder="Pick one"
|
placeholder="Pick one"
|
||||||
required
|
required
|
||||||
@@ -174,11 +225,27 @@ export function AddAppShelfItemForm(props: { setOpened: (b: boolean) => void } &
|
|||||||
data={ServiceTypeList}
|
data={ServiceTypeList}
|
||||||
{...form.getInputProps('type')}
|
{...form.getInputProps('type')}
|
||||||
/>
|
/>
|
||||||
|
<Select
|
||||||
|
label="Category"
|
||||||
|
data={categoryList}
|
||||||
|
placeholder="Select a category or create a new one"
|
||||||
|
nothingFound="Nothing found"
|
||||||
|
searchable
|
||||||
|
clearable
|
||||||
|
creatable
|
||||||
|
onClick={(e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
}}
|
||||||
|
getCreateLabel={(query) => `+ Create "${query}"`}
|
||||||
|
onCreate={(query) => {}}
|
||||||
|
{...form.getInputProps('category')}
|
||||||
|
/>
|
||||||
<LoadingOverlay visible={isLoading} />
|
<LoadingOverlay visible={isLoading} />
|
||||||
{(form.values.type === 'Sonarr' ||
|
{(form.values.type === 'Sonarr' ||
|
||||||
form.values.type === 'Radarr' ||
|
form.values.type === 'Radarr' ||
|
||||||
form.values.type === 'Lidarr' ||
|
form.values.type === 'Lidarr' ||
|
||||||
form.values.type === 'Readarr') && (
|
form.values.type === 'Readarr') && (
|
||||||
|
<>
|
||||||
<TextInput
|
<TextInput
|
||||||
required
|
required
|
||||||
label="API key"
|
label="API key"
|
||||||
@@ -189,6 +256,25 @@ export function AddAppShelfItemForm(props: { setOpened: (b: boolean) => void } &
|
|||||||
}}
|
}}
|
||||||
error={form.errors.apiKey && 'Invalid API key'}
|
error={form.errors.apiKey && 'Invalid API key'}
|
||||||
/>
|
/>
|
||||||
|
<Text
|
||||||
|
style={{
|
||||||
|
alignSelf: 'center',
|
||||||
|
fontSize: '0.75rem',
|
||||||
|
textAlign: 'center',
|
||||||
|
color: 'gray',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Tip: Get your API key{' '}
|
||||||
|
<Anchor
|
||||||
|
target="_blank"
|
||||||
|
weight="bold"
|
||||||
|
style={{ fontStyle: 'inherit', fontSize: 'inherit' }}
|
||||||
|
href={`${hostname}/settings/general`}
|
||||||
|
>
|
||||||
|
here.
|
||||||
|
</Anchor>
|
||||||
|
</Text>
|
||||||
|
</>
|
||||||
)}
|
)}
|
||||||
{form.values.type === 'qBittorrent' && (
|
{form.values.type === 'qBittorrent' && (
|
||||||
<>
|
<>
|
||||||
@@ -214,12 +300,12 @@ export function AddAppShelfItemForm(props: { setOpened: (b: boolean) => void } &
|
|||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{form.values.type === 'Deluge' && (
|
{(form.values.type === 'Deluge' || form.values.type === 'Transmission') && (
|
||||||
<>
|
<>
|
||||||
<TextInput
|
<TextInput
|
||||||
required
|
required
|
||||||
label="Password"
|
label="Password"
|
||||||
placeholder="deluge"
|
placeholder="password"
|
||||||
value={form.values.password}
|
value={form.values.password}
|
||||||
onChange={(event) => {
|
onChange={(event) => {
|
||||||
form.setFieldValue('password', event.currentTarget.value);
|
form.setFieldValue('password', event.currentTarget.value);
|
||||||
|
|||||||
@@ -1,22 +1,50 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import { Grid } from '@mantine/core';
|
import { Accordion, createStyles, Grid, Group, Paper, useMantineColorScheme } from '@mantine/core';
|
||||||
import {
|
import {
|
||||||
closestCenter,
|
closestCenter,
|
||||||
DndContext,
|
DndContext,
|
||||||
DragOverlay,
|
DragOverlay,
|
||||||
MouseSensor,
|
MouseSensor,
|
||||||
|
TouchSensor,
|
||||||
useSensor,
|
useSensor,
|
||||||
useSensors,
|
useSensors,
|
||||||
} from '@dnd-kit/core';
|
} from '@dnd-kit/core';
|
||||||
import { arrayMove, SortableContext } from '@dnd-kit/sortable';
|
import { arrayMove, SortableContext } from '@dnd-kit/sortable';
|
||||||
|
import { useLocalStorage } from '@mantine/hooks';
|
||||||
import { useConfig } from '../../tools/state';
|
import { useConfig } from '../../tools/state';
|
||||||
|
|
||||||
import { SortableAppShelfItem, AppShelfItem } from './AppShelfItem';
|
import { SortableAppShelfItem, AppShelfItem } from './AppShelfItem';
|
||||||
|
import { ModuleMenu, ModuleWrapper } from '../modules/moduleWrapper';
|
||||||
|
import { DownloadsModule } from '../modules';
|
||||||
|
import DownloadComponent from '../modules/downloads/DownloadsModule';
|
||||||
|
|
||||||
|
const useStyles = createStyles((theme, _params) => ({
|
||||||
|
item: {
|
||||||
|
borderBottom: 0,
|
||||||
|
overflow: 'hidden',
|
||||||
|
border: '1px solid transparent',
|
||||||
|
borderRadius: theme.radius.lg,
|
||||||
|
marginTop: theme.spacing.md,
|
||||||
|
},
|
||||||
|
|
||||||
|
itemOpened: {
|
||||||
|
borderColor: theme.colorScheme === 'dark' ? theme.colors.dark[5] : theme.colors.gray[3],
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
const AppShelf = (props: any) => {
|
const AppShelf = (props: any) => {
|
||||||
|
const { classes, cx } = useStyles(props);
|
||||||
|
const [toggledCategories, settoggledCategories] = useLocalStorage({
|
||||||
|
key: 'app-shelf-toggled',
|
||||||
|
// This is a bit of a hack to get the 5 first categories to be toggled on by default
|
||||||
|
defaultValue: { 0: true, 1: true, 2: true, 3: true, 4: true } as Record<string, boolean>,
|
||||||
|
});
|
||||||
const [activeId, setActiveId] = useState(null);
|
const [activeId, setActiveId] = useState(null);
|
||||||
const { config, setConfig } = useConfig();
|
const { config, setConfig } = useConfig();
|
||||||
|
const { colorScheme } = useMantineColorScheme();
|
||||||
|
|
||||||
const sensors = useSensors(
|
const sensors = useSensors(
|
||||||
|
useSensor(TouchSensor, {}),
|
||||||
useSensor(MouseSensor, {
|
useSensor(MouseSensor, {
|
||||||
// Require the mouse to move by 10 pixels before activating
|
// Require the mouse to move by 10 pixels before activating
|
||||||
activationConstraint: {
|
activationConstraint: {
|
||||||
@@ -45,6 +73,23 @@ const AppShelf = (props: any) => {
|
|||||||
|
|
||||||
setActiveId(null);
|
setActiveId(null);
|
||||||
}
|
}
|
||||||
|
// Extract all the categories from the services in config
|
||||||
|
const categoryList = config.services.reduce((acc, cur) => {
|
||||||
|
if (cur.category && !acc.includes(cur.category)) {
|
||||||
|
acc.push(cur.category);
|
||||||
|
}
|
||||||
|
return acc;
|
||||||
|
}, [] as string[]);
|
||||||
|
|
||||||
|
const item = (filter?: string) => {
|
||||||
|
// If filter is not set, return all the services without a category or a null category
|
||||||
|
let filtered = config.services;
|
||||||
|
if (!filter) {
|
||||||
|
filtered = config.services.filter((e) => !e.category || e.category === null);
|
||||||
|
}
|
||||||
|
if (filter) {
|
||||||
|
filtered = config.services.filter((e) => e.category === filter);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DndContext
|
<DndContext
|
||||||
@@ -55,7 +100,7 @@ const AppShelf = (props: any) => {
|
|||||||
>
|
>
|
||||||
<SortableContext items={config.services}>
|
<SortableContext items={config.services}>
|
||||||
<Grid gutter="xl" align="center">
|
<Grid gutter="xl" align="center">
|
||||||
{config.services.map((service) => (
|
{filtered.map((service) => (
|
||||||
<Grid.Col key={service.id} span={6} xl={2} xs={4} sm={3} md={3}>
|
<Grid.Col key={service.id} span={6} xl={2} xs={4} sm={3} md={3}>
|
||||||
<SortableAppShelfItem service={service} key={service.id} id={service.id} />
|
<SortableAppShelfItem service={service} key={service.id} id={service.id} />
|
||||||
</Grid.Col>
|
</Grid.Col>
|
||||||
@@ -76,4 +121,64 @@ const AppShelf = (props: any) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (categoryList.length > 0) {
|
||||||
|
const noCategory = config.services.filter(
|
||||||
|
(e) => e.category === undefined || e.category === null
|
||||||
|
);
|
||||||
|
// Create an item with 0: true, 1: true, 2: true... For each category
|
||||||
|
return (
|
||||||
|
// Return one item for each category
|
||||||
|
<Group grow direction="column">
|
||||||
|
<Accordion
|
||||||
|
disableIconRotation
|
||||||
|
classNames={classes}
|
||||||
|
order={2}
|
||||||
|
iconPosition="right"
|
||||||
|
multiple
|
||||||
|
styles={{
|
||||||
|
item: {
|
||||||
|
borderRadius: '20px',
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
initialState={toggledCategories}
|
||||||
|
onChange={(idx) => settoggledCategories(idx)}
|
||||||
|
>
|
||||||
|
{categoryList.map((category, idx) => (
|
||||||
|
<Accordion.Item key={category} label={category}>
|
||||||
|
{item(category)}
|
||||||
|
</Accordion.Item>
|
||||||
|
))}
|
||||||
|
{/* Return the item for all services without category */}
|
||||||
|
{noCategory && noCategory.length > 0 ? (
|
||||||
|
<Accordion.Item key="Other" label="Other">
|
||||||
|
{item()}
|
||||||
|
</Accordion.Item>
|
||||||
|
) : null}
|
||||||
|
<Accordion.Item key="Downloads" label="Your downloads">
|
||||||
|
<Paper
|
||||||
|
p="lg"
|
||||||
|
radius="lg"
|
||||||
|
style={{
|
||||||
|
background: `rgba(${colorScheme === 'dark' ? '37, 38, 43,' : '255, 255, 255,'} \
|
||||||
|
${(config.settings.appOpacity || 100) / 100}`,
|
||||||
|
borderColor: `rgba(${colorScheme === 'dark' ? '37, 38, 43,' : '233, 236, 239,'} \
|
||||||
|
${(config.settings.appOpacity || 100) / 100}`,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<ModuleMenu module={DownloadsModule} />
|
||||||
|
<DownloadComponent />
|
||||||
|
</Paper>
|
||||||
|
</Accordion.Item>
|
||||||
|
</Accordion>
|
||||||
|
</Group>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<Group grow direction="column">
|
||||||
|
{item()}
|
||||||
|
<ModuleWrapper mt="xl" module={DownloadsModule} />
|
||||||
|
</Group>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
export default AppShelf;
|
export default AppShelf;
|
||||||
|
|||||||
@@ -1,4 +1,13 @@
|
|||||||
import { Text, Card, Anchor, AspectRatio, Image, Center, createStyles } from '@mantine/core';
|
import {
|
||||||
|
Text,
|
||||||
|
Card,
|
||||||
|
Anchor,
|
||||||
|
AspectRatio,
|
||||||
|
Image,
|
||||||
|
Center,
|
||||||
|
createStyles,
|
||||||
|
useMantineColorScheme,
|
||||||
|
} from '@mantine/core';
|
||||||
import { motion } from 'framer-motion';
|
import { motion } from 'framer-motion';
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { useSortable } from '@dnd-kit/sortable';
|
import { useSortable } from '@dnd-kit/sortable';
|
||||||
@@ -6,6 +15,7 @@ import { CSS } from '@dnd-kit/utilities';
|
|||||||
import { serviceItem } from '../../tools/types';
|
import { serviceItem } from '../../tools/types';
|
||||||
import PingComponent from '../modules/ping/PingModule';
|
import PingComponent from '../modules/ping/PingModule';
|
||||||
import AppShelfMenu from './AppShelfMenu';
|
import AppShelfMenu from './AppShelfMenu';
|
||||||
|
import { useConfig } from '../../tools/state';
|
||||||
|
|
||||||
const useStyles = createStyles((theme) => ({
|
const useStyles = createStyles((theme) => ({
|
||||||
item: {
|
item: {
|
||||||
@@ -15,6 +25,9 @@ const useStyles = createStyles((theme) => ({
|
|||||||
boxShadow: `${theme.shadows.md} !important`,
|
boxShadow: `${theme.shadows.md} !important`,
|
||||||
transform: 'scale(1.05)',
|
transform: 'scale(1.05)',
|
||||||
},
|
},
|
||||||
|
[theme.fn.smallerThan('sm')]: {
|
||||||
|
WebkitUserSelect: 'none',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@@ -38,7 +51,9 @@ export function SortableAppShelfItem(props: any) {
|
|||||||
export function AppShelfItem(props: any) {
|
export function AppShelfItem(props: any) {
|
||||||
const { service }: { service: serviceItem } = props;
|
const { service }: { service: serviceItem } = props;
|
||||||
const [hovering, setHovering] = useState(false);
|
const [hovering, setHovering] = useState(false);
|
||||||
const { classes, theme } = useStyles();
|
const { config } = useConfig();
|
||||||
|
const { colorScheme } = useMantineColorScheme();
|
||||||
|
const { classes } = useStyles();
|
||||||
return (
|
return (
|
||||||
<motion.div
|
<motion.div
|
||||||
animate={{
|
animate={{
|
||||||
@@ -54,7 +69,18 @@ export function AppShelfItem(props: any) {
|
|||||||
setHovering(false);
|
setHovering(false);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Card withBorder radius="lg" shadow="md" className={classes.item}>
|
<Card
|
||||||
|
withBorder
|
||||||
|
radius="lg"
|
||||||
|
shadow="md"
|
||||||
|
className={classes.item}
|
||||||
|
style={{
|
||||||
|
background: `rgba(${colorScheme === 'dark' ? '37, 38, 43,' : '255, 255, 255,'} \
|
||||||
|
${(config.settings.appOpacity || 100) / 100}`,
|
||||||
|
borderColor: `rgba(${colorScheme === 'dark' ? '37, 38, 43,' : '233, 236, 239,'} \
|
||||||
|
${(config.settings.appOpacity || 100) / 100}`,
|
||||||
|
}}
|
||||||
|
>
|
||||||
<Card.Section>
|
<Card.Section>
|
||||||
<Anchor
|
<Anchor
|
||||||
target="_blank"
|
target="_blank"
|
||||||
@@ -91,17 +117,18 @@ export function AppShelfItem(props: any) {
|
|||||||
>
|
>
|
||||||
<motion.i
|
<motion.i
|
||||||
whileHover={{
|
whileHover={{
|
||||||
cursor: 'pointer',
|
|
||||||
scale: 1.1,
|
scale: 1.1,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Image
|
<Image
|
||||||
|
styles={{ root: { cursor: 'pointer' } }}
|
||||||
width={80}
|
width={80}
|
||||||
height={80}
|
height={80}
|
||||||
src={service.icon}
|
src={service.icon}
|
||||||
fit="contain"
|
fit="contain"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
window.open(service.url);
|
if (service.openedUrl) window.open(service.openedUrl, '_blank');
|
||||||
|
else window.open(service.url);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</motion.i>
|
</motion.i>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { Menu, Modal, Text, useMantineTheme } from '@mantine/core';
|
import { Menu, Modal, Text, useMantineTheme } from '@mantine/core';
|
||||||
import { showNotification } from '@mantine/notifications';
|
import { showNotification } from '@mantine/notifications';
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { Check, Edit, Trash } from 'tabler-icons-react';
|
import { IconCheck as Check, IconEdit as Edit, IconTrash as Trash } from '@tabler/icons';
|
||||||
import { useConfig } from '../../tools/state';
|
import { useConfig } from '../../tools/state';
|
||||||
import { serviceItem } from '../../tools/types';
|
import { serviceItem } from '../../tools/types';
|
||||||
import { AddAppShelfItemForm } from './AddAppShelfItem';
|
import { AddAppShelfItemForm } from './AddAppShelfItem';
|
||||||
@@ -24,29 +24,32 @@ export default function AppShelfMenu(props: any) {
|
|||||||
setOpened={setOpened}
|
setOpened={setOpened}
|
||||||
name={service.name}
|
name={service.name}
|
||||||
id={service.id}
|
id={service.id}
|
||||||
|
category={service.category}
|
||||||
type={service.type}
|
type={service.type}
|
||||||
url={service.url}
|
url={service.url}
|
||||||
icon={service.icon}
|
icon={service.icon}
|
||||||
apiKey={service.apiKey}
|
apiKey={service.apiKey}
|
||||||
username={service.username}
|
username={service.username}
|
||||||
password={service.password}
|
password={service.password}
|
||||||
|
openedUrl={service.openedUrl}
|
||||||
message="Save service"
|
message="Save service"
|
||||||
/>
|
/>
|
||||||
</Modal>
|
</Modal>
|
||||||
<Menu
|
<Menu
|
||||||
position="right"
|
position="right"
|
||||||
radius="md"
|
radius="md"
|
||||||
|
shadow="xl"
|
||||||
styles={{
|
styles={{
|
||||||
body: {
|
body: {
|
||||||
backgroundColor:
|
// Add shadow and elevation to the body
|
||||||
theme.colorScheme === 'dark' ? theme.colors.dark[5] : theme.colors.gray[1],
|
boxShadow: '0 0 14px 14px rgba(0, 0, 0, 0.05)',
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Menu.Label>Settings</Menu.Label>
|
<Menu.Label>Settings</Menu.Label>
|
||||||
<Menu.Item
|
<Menu.Item
|
||||||
color="primary"
|
color="primary"
|
||||||
icon={<Edit size={14} />}
|
icon={<Edit />}
|
||||||
// TODO: #2 Add the ability to edit the service.
|
// TODO: #2 Add the ability to edit the service.
|
||||||
onClick={() => setOpened(true)}
|
onClick={() => setOpened(true)}
|
||||||
>
|
>
|
||||||
@@ -64,7 +67,7 @@ export default function AppShelfMenu(props: any) {
|
|||||||
autoClose: 5000,
|
autoClose: 5000,
|
||||||
title: (
|
title: (
|
||||||
<Text>
|
<Text>
|
||||||
Service <b>{service.name}</b> removed successfully
|
Service <b>{service.name}</b> removed successfully!
|
||||||
</Text>
|
</Text>
|
||||||
),
|
),
|
||||||
color: 'green',
|
color: 'green',
|
||||||
@@ -72,7 +75,7 @@ export default function AppShelfMenu(props: any) {
|
|||||||
message: undefined,
|
message: undefined,
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
icon={<Trash size={14} />}
|
icon={<Trash />}
|
||||||
>
|
>
|
||||||
Delete
|
Delete
|
||||||
</Menu.Item>
|
</Menu.Item>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { createStyles, Switch, Group, useMantineColorScheme, Kbd } from '@mantine/core';
|
import { createStyles, Switch, Group, useMantineColorScheme, Kbd } from '@mantine/core';
|
||||||
import { Sun, MoonStars } from 'tabler-icons-react';
|
import { IconSun as Sun, IconMoonStars as MoonStars } from '@tabler/icons';
|
||||||
|
import { useConfig } from '../../tools/state';
|
||||||
|
|
||||||
const useStyles = createStyles((theme) => ({
|
const useStyles = createStyles((theme) => ({
|
||||||
root: {
|
root: {
|
||||||
@@ -29,6 +30,7 @@ const useStyles = createStyles((theme) => ({
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
export function ColorSchemeSwitch() {
|
export function ColorSchemeSwitch() {
|
||||||
|
const { config } = useConfig();
|
||||||
const { colorScheme, toggleColorScheme } = useMantineColorScheme();
|
const { colorScheme, toggleColorScheme } = useMantineColorScheme();
|
||||||
const { classes, cx } = useStyles();
|
const { classes, cx } = useStyles();
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Box, useMantineColorScheme } from '@mantine/core';
|
import { Box, useMantineColorScheme } from '@mantine/core';
|
||||||
import { Sun, MoonStars } from 'tabler-icons-react';
|
import { IconSun as Sun, IconMoonStars as MoonStars } from '@tabler/icons';
|
||||||
import { motion } from 'framer-motion';
|
import { motion } from 'framer-motion';
|
||||||
|
|
||||||
export function ColorSchemeToggle() {
|
export function ColorSchemeToggle() {
|
||||||
|
|||||||
@@ -26,7 +26,10 @@ export default function ConfigChanger() {
|
|||||||
label="Config loader"
|
label="Config loader"
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
loadConfig(e ?? 'default');
|
loadConfig(e ?? 'default');
|
||||||
setCookies('config-name', e ?? 'default', { maxAge: 60 * 60 * 24 * 30 });
|
setCookies('config-name', e ?? 'default', {
|
||||||
|
maxAge: 60 * 60 * 24 * 30,
|
||||||
|
sameSite: 'strict',
|
||||||
|
});
|
||||||
}}
|
}}
|
||||||
data={
|
data={
|
||||||
// If config list is empty, return the current config
|
// If config list is empty, return the current config
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
import { Group, Text, useMantineTheme, MantineTheme } from '@mantine/core';
|
import { Group, Text, useMantineTheme, MantineTheme } from '@mantine/core';
|
||||||
import { Upload, Photo, X, Icon as TablerIcon, Check } from 'tabler-icons-react';
|
import {
|
||||||
|
IconUpload as Upload,
|
||||||
|
IconPhoto as Photo,
|
||||||
|
IconX as X,
|
||||||
|
IconCheck as Check,
|
||||||
|
TablerIcon,
|
||||||
|
} from '@tabler/icons';
|
||||||
import { DropzoneStatus, FullScreenDropzone } from '@mantine/dropzone';
|
import { DropzoneStatus, FullScreenDropzone } from '@mantine/dropzone';
|
||||||
import { showNotification } from '@mantine/notifications';
|
import { showNotification } from '@mantine/notifications';
|
||||||
import { useRef } from 'react';
|
import { useRef } from 'react';
|
||||||
@@ -84,7 +90,10 @@ export default function LoadConfigComponent(props: any) {
|
|||||||
icon: <Check />,
|
icon: <Check />,
|
||||||
message: undefined,
|
message: undefined,
|
||||||
});
|
});
|
||||||
setCookies('config-name', newConfig.name, { maxAge: 60 * 60 * 24 * 30 });
|
setCookies('config-name', newConfig.name, {
|
||||||
|
maxAge: 60 * 60 * 24 * 30,
|
||||||
|
sameSite: 'strict',
|
||||||
|
});
|
||||||
const migratedConfig = migrateToIdConfig(newConfig);
|
const migratedConfig = migrateToIdConfig(newConfig);
|
||||||
setConfig(migratedConfig);
|
setConfig(migratedConfig);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -4,7 +4,13 @@ import { showNotification } from '@mantine/notifications';
|
|||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import fileDownload from 'js-file-download';
|
import fileDownload from 'js-file-download';
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { Check, Download, Plus, Trash, X } from 'tabler-icons-react';
|
import {
|
||||||
|
IconCheck as Check,
|
||||||
|
IconDownload as Download,
|
||||||
|
IconPlus as Plus,
|
||||||
|
IconTrash as Trash,
|
||||||
|
IconX as X,
|
||||||
|
} from '@tabler/icons';
|
||||||
import { useConfig } from '../../tools/state';
|
import { useConfig } from '../../tools/state';
|
||||||
|
|
||||||
export default function SaveConfigComponent(props: any) {
|
export default function SaveConfigComponent(props: any) {
|
||||||
@@ -21,7 +27,7 @@ export default function SaveConfigComponent(props: any) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<Group>
|
<Group spacing="xs">
|
||||||
<Modal
|
<Modal
|
||||||
radius="md"
|
radius="md"
|
||||||
opened={opened}
|
opened={opened}
|
||||||
@@ -53,10 +59,11 @@ export default function SaveConfigComponent(props: any) {
|
|||||||
</Group>
|
</Group>
|
||||||
</form>
|
</form>
|
||||||
</Modal>
|
</Modal>
|
||||||
<Button leftIcon={<Download />} variant="outline" onClick={onClick}>
|
<Button size="xs" leftIcon={<Download />} variant="outline" onClick={onClick}>
|
||||||
Download your config
|
Download config
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
|
size="xs"
|
||||||
leftIcon={<Trash />}
|
leftIcon={<Trash />}
|
||||||
variant="outline"
|
variant="outline"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
@@ -85,10 +92,10 @@ export default function SaveConfigComponent(props: any) {
|
|||||||
setConfig({ ...config, name: 'default' });
|
setConfig({ ...config, name: 'default' });
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Delete current config
|
Delete config
|
||||||
</Button>
|
</Button>
|
||||||
<Button leftIcon={<Plus />} variant="outline" onClick={() => setOpened(true)}>
|
<Button size="xs" leftIcon={<Plus />} variant="outline" onClick={() => setOpened(true)}>
|
||||||
Save a copy of your config
|
Save a copy
|
||||||
</Button>
|
</Button>
|
||||||
</Group>
|
</Group>
|
||||||
);
|
);
|
||||||
|
|||||||
63
src/components/Settings/AdvancedSettings.tsx
Normal file
63
src/components/Settings/AdvancedSettings.tsx
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
import { TextInput, Group, Button } from '@mantine/core';
|
||||||
|
import { useForm } from '@mantine/form';
|
||||||
|
import { useConfig } from '../../tools/state';
|
||||||
|
import { ColorSelector } from './ColorSelector';
|
||||||
|
import { OpacitySelector } from './OpacitySelector';
|
||||||
|
import { ShadeSelector } from './ShadeSelector';
|
||||||
|
|
||||||
|
export default function TitleChanger() {
|
||||||
|
const { config, setConfig } = useConfig();
|
||||||
|
|
||||||
|
const form = useForm({
|
||||||
|
initialValues: {
|
||||||
|
title: config.settings.title,
|
||||||
|
logo: config.settings.logo,
|
||||||
|
favicon: config.settings.favicon,
|
||||||
|
background: config.settings.background,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const saveChanges = (values: {
|
||||||
|
title?: string;
|
||||||
|
logo?: string;
|
||||||
|
favicon?: string;
|
||||||
|
background?: string;
|
||||||
|
}) => {
|
||||||
|
setConfig({
|
||||||
|
...config,
|
||||||
|
settings: {
|
||||||
|
...config.settings,
|
||||||
|
title: values.title,
|
||||||
|
logo: values.logo,
|
||||||
|
favicon: values.favicon,
|
||||||
|
background: values.background,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Group direction="column" grow>
|
||||||
|
<form onSubmit={form.onSubmit((values) => saveChanges(values))}>
|
||||||
|
<Group grow direction="column">
|
||||||
|
<TextInput label="Page title" placeholder="Homarr 🦞" {...form.getInputProps('title')} />
|
||||||
|
<TextInput label="Logo" placeholder="/img/logo.png" {...form.getInputProps('logo')} />
|
||||||
|
<TextInput
|
||||||
|
label="Favicon"
|
||||||
|
placeholder="/favicon.svg"
|
||||||
|
{...form.getInputProps('favicon')}
|
||||||
|
/>
|
||||||
|
<TextInput
|
||||||
|
label="Background"
|
||||||
|
placeholder="/img/background.png"
|
||||||
|
{...form.getInputProps('background')}
|
||||||
|
/>
|
||||||
|
<Button type="submit">Save</Button>
|
||||||
|
</Group>
|
||||||
|
</form>
|
||||||
|
<ColorSelector type="primary" />
|
||||||
|
<ColorSelector type="secondary" />
|
||||||
|
<ShadeSelector />
|
||||||
|
<OpacitySelector />
|
||||||
|
</Group>
|
||||||
|
);
|
||||||
|
}
|
||||||
96
src/components/Settings/ColorSelector.tsx
Normal file
96
src/components/Settings/ColorSelector.tsx
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
import React, { useState } from 'react';
|
||||||
|
import { ColorSwatch, Group, Popover, Text, useMantineTheme } from '@mantine/core';
|
||||||
|
import { useConfig } from '../../tools/state';
|
||||||
|
import { useColorTheme } from '../../tools/color';
|
||||||
|
|
||||||
|
interface ColorControlProps {
|
||||||
|
type: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function ColorSelector({ type }: ColorControlProps) {
|
||||||
|
const { config, setConfig } = useConfig();
|
||||||
|
const [opened, setOpened] = useState(false);
|
||||||
|
|
||||||
|
const { primaryColor, secondaryColor, setPrimaryColor, setSecondaryColor } = useColorTheme();
|
||||||
|
|
||||||
|
const theme = useMantineTheme();
|
||||||
|
const colors = Object.keys(theme.colors).map((color) => ({
|
||||||
|
swatch: theme.colors[color][6],
|
||||||
|
color,
|
||||||
|
}));
|
||||||
|
|
||||||
|
const configColor = type === 'primary' ? primaryColor : secondaryColor;
|
||||||
|
|
||||||
|
const setConfigColor = (color: string) => {
|
||||||
|
if (type === 'primary') {
|
||||||
|
setPrimaryColor(color);
|
||||||
|
setConfig({
|
||||||
|
...config,
|
||||||
|
settings: {
|
||||||
|
...config.settings,
|
||||||
|
primaryColor: color,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
setSecondaryColor(color);
|
||||||
|
setConfig({
|
||||||
|
...config,
|
||||||
|
settings: {
|
||||||
|
...config.settings,
|
||||||
|
secondaryColor: color,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const swatches = colors.map(({ color, swatch }) => (
|
||||||
|
<ColorSwatch
|
||||||
|
component="button"
|
||||||
|
type="button"
|
||||||
|
onClick={() => setConfigColor(color)}
|
||||||
|
key={color}
|
||||||
|
color={swatch}
|
||||||
|
size={22}
|
||||||
|
style={{ color: theme.white, cursor: 'pointer' }}
|
||||||
|
/>
|
||||||
|
));
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Group direction="row" spacing={3}>
|
||||||
|
<Popover
|
||||||
|
opened={opened}
|
||||||
|
onClose={() => setOpened(false)}
|
||||||
|
transitionDuration={0}
|
||||||
|
target={
|
||||||
|
<ColorSwatch
|
||||||
|
component="button"
|
||||||
|
type="button"
|
||||||
|
color={theme.colors[configColor][6]}
|
||||||
|
onClick={() => setOpened((o) => !o)}
|
||||||
|
size={22}
|
||||||
|
style={{ display: 'block', cursor: 'pointer' }}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
styles={{
|
||||||
|
root: {
|
||||||
|
marginRight: theme.spacing.xs,
|
||||||
|
},
|
||||||
|
body: {
|
||||||
|
width: 152,
|
||||||
|
backgroundColor: theme.colorScheme === 'dark' ? theme.colors.dark[8] : theme.white,
|
||||||
|
},
|
||||||
|
arrow: {
|
||||||
|
backgroundColor: theme.colorScheme === 'dark' ? theme.colors.dark[8] : theme.white,
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
position="bottom"
|
||||||
|
placement="end"
|
||||||
|
withArrow
|
||||||
|
arrowSize={3}
|
||||||
|
>
|
||||||
|
<Group spacing="xs">{swatches}</Group>
|
||||||
|
</Popover>
|
||||||
|
<Text>{type[0].toUpperCase() + type.slice(1)} color</Text>
|
||||||
|
</Group>
|
||||||
|
);
|
||||||
|
}
|
||||||
119
src/components/Settings/CommonSettings.tsx
Normal file
119
src/components/Settings/CommonSettings.tsx
Normal file
@@ -0,0 +1,119 @@
|
|||||||
|
import { ActionIcon, Group, Text, SegmentedControl, TextInput, Anchor } from '@mantine/core';
|
||||||
|
import { useState } from 'react';
|
||||||
|
import { IconBrandGithub as BrandGithub } from '@tabler/icons';
|
||||||
|
import { CURRENT_VERSION } from '../../../data/constants';
|
||||||
|
import { useConfig } from '../../tools/state';
|
||||||
|
import { ColorSchemeSwitch } from '../ColorSchemeToggle/ColorSchemeSwitch';
|
||||||
|
import { WidgetsPositionSwitch } from '../WidgetsPositionSwitch/WidgetsPositionSwitch';
|
||||||
|
import ConfigChanger from '../Config/ConfigChanger';
|
||||||
|
import SaveConfigComponent from '../Config/SaveConfig';
|
||||||
|
import ModuleEnabler from './ModuleEnabler';
|
||||||
|
|
||||||
|
export default function CommonSettings(args: any) {
|
||||||
|
const { config, setConfig } = useConfig();
|
||||||
|
|
||||||
|
const matches = [
|
||||||
|
{ label: 'Google', value: 'https://google.com/search?q=' },
|
||||||
|
{ label: 'DuckDuckGo', value: 'https://duckduckgo.com/?q=' },
|
||||||
|
{ label: 'Bing', value: 'https://bing.com/search?q=' },
|
||||||
|
{ label: 'Custom', value: 'Custom' },
|
||||||
|
];
|
||||||
|
|
||||||
|
const [customSearchUrl, setCustomSearchUrl] = useState(config.settings.searchUrl);
|
||||||
|
const [searchUrl, setSearchUrl] = useState(
|
||||||
|
matches.find((match) => match.value === config.settings.searchUrl)?.value ?? 'Custom'
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Group direction="column" grow>
|
||||||
|
<Group grow direction="column" spacing={0}>
|
||||||
|
<Text>Search engine</Text>
|
||||||
|
<SegmentedControl
|
||||||
|
fullWidth
|
||||||
|
title="Search engine"
|
||||||
|
value={
|
||||||
|
// Match config.settings.searchUrl with a key in the matches array
|
||||||
|
searchUrl
|
||||||
|
}
|
||||||
|
onChange={
|
||||||
|
// Set config.settings.searchUrl to the value of the selected item
|
||||||
|
(e) => {
|
||||||
|
setSearchUrl(e);
|
||||||
|
setConfig({
|
||||||
|
...config,
|
||||||
|
settings: {
|
||||||
|
...config.settings,
|
||||||
|
searchUrl: e,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
data={matches}
|
||||||
|
/>
|
||||||
|
{searchUrl === 'Custom' && (
|
||||||
|
<TextInput
|
||||||
|
label="Query URL"
|
||||||
|
placeholder="Custom query url"
|
||||||
|
value={customSearchUrl}
|
||||||
|
onChange={(event) => {
|
||||||
|
setCustomSearchUrl(event.currentTarget.value);
|
||||||
|
setConfig({
|
||||||
|
...config,
|
||||||
|
settings: {
|
||||||
|
...config.settings,
|
||||||
|
searchUrl: event.currentTarget.value,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</Group>
|
||||||
|
<ColorSchemeSwitch />
|
||||||
|
<WidgetsPositionSwitch />
|
||||||
|
<ModuleEnabler />
|
||||||
|
<ConfigChanger />
|
||||||
|
<SaveConfigComponent />
|
||||||
|
<Text
|
||||||
|
style={{
|
||||||
|
alignSelf: 'center',
|
||||||
|
fontSize: '0.75rem',
|
||||||
|
textAlign: 'center',
|
||||||
|
color: 'gray',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Tip: You can upload your config file by dragging and dropping it onto the page!
|
||||||
|
</Text>
|
||||||
|
<Group position="center" direction="row" mr="xs">
|
||||||
|
<Group spacing={0}>
|
||||||
|
<ActionIcon<'a'> component="a" href="https://github.com/ajnart/homarr" size="lg">
|
||||||
|
<BrandGithub size={18} />
|
||||||
|
</ActionIcon>
|
||||||
|
<Text
|
||||||
|
style={{
|
||||||
|
position: 'relative',
|
||||||
|
fontSize: '0.90rem',
|
||||||
|
color: 'gray',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{CURRENT_VERSION}
|
||||||
|
</Text>
|
||||||
|
</Group>
|
||||||
|
<Text
|
||||||
|
style={{
|
||||||
|
fontSize: '0.90rem',
|
||||||
|
textAlign: 'center',
|
||||||
|
color: 'gray',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Made with ❤️ by @
|
||||||
|
<Anchor
|
||||||
|
href="https://github.com/ajnart"
|
||||||
|
style={{ color: 'inherit', fontStyle: 'inherit', fontSize: 'inherit' }}
|
||||||
|
>
|
||||||
|
ajnart
|
||||||
|
</Anchor>
|
||||||
|
</Text>
|
||||||
|
</Group>
|
||||||
|
</Group>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Group, Switch } from '@mantine/core';
|
import { Checkbox, Group, SimpleGrid, Title } from '@mantine/core';
|
||||||
import * as Modules from '../modules';
|
import * as Modules from '../modules';
|
||||||
import { useConfig } from '../../tools/state';
|
import { useConfig } from '../../tools/state';
|
||||||
|
|
||||||
@@ -7,12 +7,14 @@ export default function ModuleEnabler(props: any) {
|
|||||||
const modules = Object.values(Modules).map((module) => module);
|
const modules = Object.values(Modules).map((module) => module);
|
||||||
return (
|
return (
|
||||||
<Group direction="column">
|
<Group direction="column">
|
||||||
|
<Title order={4}>Module enabler</Title>
|
||||||
|
<SimpleGrid cols={2} spacing="md">
|
||||||
{modules.map((module) => (
|
{modules.map((module) => (
|
||||||
<Switch
|
<Checkbox
|
||||||
key={module.title}
|
key={module.title}
|
||||||
size="md"
|
size="md"
|
||||||
checked={config.modules?.[module.title]?.enabled ?? false}
|
checked={config.modules?.[module.title]?.enabled ?? false}
|
||||||
label={`Enable ${module.title} module`}
|
label={`${module.title}`}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
setConfig({
|
setConfig({
|
||||||
...config,
|
...config,
|
||||||
@@ -27,6 +29,7 @@ export default function ModuleEnabler(props: any) {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
|
</SimpleGrid>
|
||||||
</Group>
|
</Group>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
44
src/components/Settings/OpacitySelector.tsx
Normal file
44
src/components/Settings/OpacitySelector.tsx
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { Group, Text, Slider } from '@mantine/core';
|
||||||
|
import { useConfig } from '../../tools/state';
|
||||||
|
|
||||||
|
export function OpacitySelector() {
|
||||||
|
const { config, setConfig } = useConfig();
|
||||||
|
|
||||||
|
const MARKS = [
|
||||||
|
{ value: 10, label: '10' },
|
||||||
|
{ value: 20, label: '20' },
|
||||||
|
{ value: 30, label: '30' },
|
||||||
|
{ value: 40, label: '40' },
|
||||||
|
{ value: 50, label: '50' },
|
||||||
|
{ value: 60, label: '60' },
|
||||||
|
{ value: 70, label: '70' },
|
||||||
|
{ value: 80, label: '80' },
|
||||||
|
{ value: 90, label: '90' },
|
||||||
|
{ value: 100, label: '100' },
|
||||||
|
];
|
||||||
|
|
||||||
|
const setConfigOpacity = (opacity: number) => {
|
||||||
|
setConfig({
|
||||||
|
...config,
|
||||||
|
settings: {
|
||||||
|
...config.settings,
|
||||||
|
appOpacity: opacity,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Group direction="column" spacing="xs" grow>
|
||||||
|
<Text>App Opacity</Text>
|
||||||
|
<Slider
|
||||||
|
defaultValue={config.settings.appOpacity || 100}
|
||||||
|
step={10}
|
||||||
|
min={10}
|
||||||
|
marks={MARKS}
|
||||||
|
styles={{ markLabel: { fontSize: 'xx-small' } }}
|
||||||
|
onChange={(value) => setConfigOpacity(value)}
|
||||||
|
/>
|
||||||
|
</Group>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,131 +1,20 @@
|
|||||||
import {
|
import { ActionIcon, Title, Tooltip, Drawer, Tabs } from '@mantine/core';
|
||||||
ActionIcon,
|
import { useHotkeys } from '@mantine/hooks';
|
||||||
Group,
|
|
||||||
Title,
|
|
||||||
Text,
|
|
||||||
Tooltip,
|
|
||||||
SegmentedControl,
|
|
||||||
TextInput,
|
|
||||||
Drawer,
|
|
||||||
Anchor,
|
|
||||||
} from '@mantine/core';
|
|
||||||
import { useColorScheme, useHotkeys } from '@mantine/hooks';
|
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { BrandGithub, Settings as SettingsIcon } from 'tabler-icons-react';
|
import { IconSettings } from '@tabler/icons';
|
||||||
import { CURRENT_VERSION } from '../../../data/constants';
|
import AdvancedSettings from './AdvancedSettings';
|
||||||
import { useConfig } from '../../tools/state';
|
import CommonSettings from './CommonSettings';
|
||||||
import { ColorSchemeSwitch } from '../ColorSchemeToggle/ColorSchemeSwitch';
|
|
||||||
import ConfigChanger from '../Config/ConfigChanger';
|
|
||||||
import SaveConfigComponent from '../Config/SaveConfig';
|
|
||||||
import ModuleEnabler from './ModuleEnabler';
|
|
||||||
|
|
||||||
function SettingsMenu(props: any) {
|
function SettingsMenu(props: any) {
|
||||||
const { config, setConfig } = useConfig();
|
|
||||||
const colorScheme = useColorScheme();
|
|
||||||
const { current, latest } = props;
|
|
||||||
|
|
||||||
const matches = [
|
|
||||||
{ label: 'Google', value: 'https://google.com/search?q=' },
|
|
||||||
{ label: 'DuckDuckGo', value: 'https://duckduckgo.com/?q=' },
|
|
||||||
{ label: 'Bing', value: 'https://bing.com/search?q=' },
|
|
||||||
{ label: 'Custom', value: 'Custom' },
|
|
||||||
];
|
|
||||||
|
|
||||||
const [customSearchUrl, setCustomSearchUrl] = useState(config.settings.searchUrl);
|
|
||||||
const [searchUrl, setSearchUrl] = useState(
|
|
||||||
matches.find((match) => match.value === config.settings.searchUrl)?.value ?? 'Custom'
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Group direction="column" grow>
|
<Tabs grow>
|
||||||
<Group grow direction="column" spacing={0}>
|
<Tabs.Tab data-autofocus label="Common">
|
||||||
<Text>Search engine</Text>
|
<CommonSettings />
|
||||||
<SegmentedControl
|
</Tabs.Tab>
|
||||||
fullWidth
|
<Tabs.Tab label="Customizations">
|
||||||
title="Search engine"
|
<AdvancedSettings />
|
||||||
value={
|
</Tabs.Tab>
|
||||||
// Match config.settings.searchUrl with a key in the matches array
|
</Tabs>
|
||||||
searchUrl
|
|
||||||
}
|
|
||||||
onChange={
|
|
||||||
// Set config.settings.searchUrl to the value of the selected item
|
|
||||||
(e) => {
|
|
||||||
setSearchUrl(e);
|
|
||||||
setConfig({
|
|
||||||
...config,
|
|
||||||
settings: {
|
|
||||||
...config.settings,
|
|
||||||
searchUrl: e,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
data={matches}
|
|
||||||
/>
|
|
||||||
{searchUrl === 'Custom' && (
|
|
||||||
<TextInput
|
|
||||||
label="Query URL"
|
|
||||||
placeholder="Custom query url"
|
|
||||||
value={customSearchUrl}
|
|
||||||
onChange={(event) => {
|
|
||||||
setCustomSearchUrl(event.currentTarget.value);
|
|
||||||
setConfig({
|
|
||||||
...config,
|
|
||||||
settings: {
|
|
||||||
...config.settings,
|
|
||||||
searchUrl: event.currentTarget.value,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</Group>
|
|
||||||
<ModuleEnabler />
|
|
||||||
<ColorSchemeSwitch />
|
|
||||||
<ConfigChanger />
|
|
||||||
<SaveConfigComponent />
|
|
||||||
<Text
|
|
||||||
style={{
|
|
||||||
alignSelf: 'center',
|
|
||||||
fontSize: '0.75rem',
|
|
||||||
textAlign: 'center',
|
|
||||||
color: '#a0aec0',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
tip: You can upload your config file by dragging and dropping it onto the page
|
|
||||||
</Text>
|
|
||||||
<Group position="center" direction="row" mr="xs">
|
|
||||||
<Group spacing={0}>
|
|
||||||
<ActionIcon<'a'> component="a" href="https://github.com/ajnart/homarr" size="lg">
|
|
||||||
<BrandGithub size={18} />
|
|
||||||
</ActionIcon>
|
|
||||||
<Text
|
|
||||||
style={{
|
|
||||||
position: 'relative',
|
|
||||||
fontSize: '0.90rem',
|
|
||||||
color: 'gray',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{CURRENT_VERSION}
|
|
||||||
</Text>
|
|
||||||
</Group>
|
|
||||||
<Text
|
|
||||||
style={{
|
|
||||||
fontSize: '0.90rem',
|
|
||||||
textAlign: 'center',
|
|
||||||
color: '#a0aec0',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Made with ❤️ by @
|
|
||||||
<Anchor
|
|
||||||
href="https://github.com/ajnart"
|
|
||||||
style={{ color: 'inherit', fontStyle: 'inherit', fontSize: 'inherit' }}
|
|
||||||
>
|
|
||||||
ajnart
|
|
||||||
</Anchor>
|
|
||||||
</Text>
|
|
||||||
</Group>
|
|
||||||
</Group>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,7 +25,7 @@ export function SettingsMenuButton(props: any) {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Drawer
|
<Drawer
|
||||||
size="auto"
|
size="xl"
|
||||||
padding="xl"
|
padding="xl"
|
||||||
position="right"
|
position="right"
|
||||||
title={<Title order={3}>Settings</Title>}
|
title={<Title order={3}>Settings</Title>}
|
||||||
@@ -154,7 +43,7 @@ export function SettingsMenuButton(props: any) {
|
|||||||
onClick={() => setOpened(true)}
|
onClick={() => setOpened(true)}
|
||||||
>
|
>
|
||||||
<Tooltip label="Settings">
|
<Tooltip label="Settings">
|
||||||
<SettingsIcon />
|
<IconSettings />
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</ActionIcon>
|
</ActionIcon>
|
||||||
</>
|
</>
|
||||||
|
|||||||
97
src/components/Settings/ShadeSelector.tsx
Normal file
97
src/components/Settings/ShadeSelector.tsx
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
import React, { useState } from 'react';
|
||||||
|
import { ColorSwatch, Group, Popover, Text, useMantineTheme, MantineTheme } from '@mantine/core';
|
||||||
|
import { useConfig } from '../../tools/state';
|
||||||
|
import { useColorTheme } from '../../tools/color';
|
||||||
|
|
||||||
|
export function ShadeSelector() {
|
||||||
|
const { config, setConfig } = useConfig();
|
||||||
|
const [opened, setOpened] = useState(false);
|
||||||
|
|
||||||
|
const { primaryColor, secondaryColor, primaryShade, setPrimaryShade } = useColorTheme();
|
||||||
|
|
||||||
|
const theme = useMantineTheme();
|
||||||
|
const primaryShades = theme.colors[primaryColor].map((s, i) => ({
|
||||||
|
swatch: theme.colors[primaryColor][i],
|
||||||
|
shade: i as MantineTheme['primaryShade'],
|
||||||
|
}));
|
||||||
|
const secondaryShades = theme.colors[secondaryColor].map((s, i) => ({
|
||||||
|
swatch: theme.colors[secondaryColor][i],
|
||||||
|
shade: i as MantineTheme['primaryShade'],
|
||||||
|
}));
|
||||||
|
|
||||||
|
const setConfigShade = (shade: MantineTheme['primaryShade']) => {
|
||||||
|
setPrimaryShade(shade);
|
||||||
|
setConfig({
|
||||||
|
...config,
|
||||||
|
settings: {
|
||||||
|
...config.settings,
|
||||||
|
primaryShade: shade,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const primarySwatches = primaryShades.map(({ swatch, shade }) => (
|
||||||
|
<ColorSwatch
|
||||||
|
component="button"
|
||||||
|
type="button"
|
||||||
|
onClick={() => setConfigShade(shade)}
|
||||||
|
key={Number(shade)}
|
||||||
|
color={swatch}
|
||||||
|
size={22}
|
||||||
|
style={{ color: theme.white, cursor: 'pointer' }}
|
||||||
|
/>
|
||||||
|
));
|
||||||
|
|
||||||
|
const secondarySwatches = secondaryShades.map(({ swatch, shade }) => (
|
||||||
|
<ColorSwatch
|
||||||
|
component="button"
|
||||||
|
type="button"
|
||||||
|
onClick={() => setConfigShade(shade)}
|
||||||
|
key={Number(shade)}
|
||||||
|
color={swatch}
|
||||||
|
size={22}
|
||||||
|
style={{ color: theme.white, cursor: 'pointer' }}
|
||||||
|
/>
|
||||||
|
));
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Group direction="row" spacing={3}>
|
||||||
|
<Popover
|
||||||
|
opened={opened}
|
||||||
|
onClose={() => setOpened(false)}
|
||||||
|
transitionDuration={0}
|
||||||
|
target={
|
||||||
|
<ColorSwatch
|
||||||
|
component="button"
|
||||||
|
type="button"
|
||||||
|
color={theme.colors[primaryColor][Number(primaryShade)]}
|
||||||
|
onClick={() => setOpened((o) => !o)}
|
||||||
|
size={22}
|
||||||
|
style={{ display: 'block', cursor: 'pointer' }}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
styles={{
|
||||||
|
root: {
|
||||||
|
marginRight: theme.spacing.xs,
|
||||||
|
},
|
||||||
|
body: {
|
||||||
|
backgroundColor: theme.colorScheme === 'dark' ? theme.colors.dark[8] : theme.white,
|
||||||
|
},
|
||||||
|
arrow: {
|
||||||
|
backgroundColor: theme.colorScheme === 'dark' ? theme.colors.dark[8] : theme.white,
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
position="bottom"
|
||||||
|
placement="end"
|
||||||
|
withArrow
|
||||||
|
arrowSize={3}
|
||||||
|
>
|
||||||
|
<Group direction="column" spacing="xs">
|
||||||
|
<Group spacing="xs">{primarySwatches}</Group>
|
||||||
|
<Group spacing="xs">{secondarySwatches}</Group>
|
||||||
|
</Group>
|
||||||
|
</Popover>
|
||||||
|
<Text>Shade</Text>
|
||||||
|
</Group>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
import React, { useState } from 'react';
|
||||||
|
import { createStyles, Switch, Group } from '@mantine/core';
|
||||||
|
import { useConfig } from '../../tools/state';
|
||||||
|
|
||||||
|
const useStyles = createStyles((theme) => ({
|
||||||
|
root: {
|
||||||
|
position: 'relative',
|
||||||
|
'& *': {
|
||||||
|
cursor: 'pointer',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
icon: {
|
||||||
|
pointerEvents: 'none',
|
||||||
|
position: 'absolute',
|
||||||
|
zIndex: 1,
|
||||||
|
top: 3,
|
||||||
|
},
|
||||||
|
|
||||||
|
iconLight: {
|
||||||
|
left: 4,
|
||||||
|
color: theme.white,
|
||||||
|
},
|
||||||
|
|
||||||
|
iconDark: {
|
||||||
|
right: 4,
|
||||||
|
color: theme.colors.gray[6],
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
|
export function WidgetsPositionSwitch() {
|
||||||
|
const { config, setConfig } = useConfig();
|
||||||
|
const { classes, cx } = useStyles();
|
||||||
|
const defaultPosition = config?.settings?.widgetPosition || 'right';
|
||||||
|
const [widgetPosition, setWidgetPosition] = useState(defaultPosition);
|
||||||
|
const toggleWidgetPosition = () => {
|
||||||
|
const position = widgetPosition === 'right' ? 'left' : 'right';
|
||||||
|
setWidgetPosition(position);
|
||||||
|
setConfig({
|
||||||
|
...config,
|
||||||
|
settings: {
|
||||||
|
...config.settings,
|
||||||
|
widgetPosition: position,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Group>
|
||||||
|
<div className={classes.root}>
|
||||||
|
<Switch
|
||||||
|
checked={widgetPosition === 'left'}
|
||||||
|
onChange={() => toggleWidgetPosition()}
|
||||||
|
size="md"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
Position widgets on left
|
||||||
|
</Group>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,25 +1,36 @@
|
|||||||
import { Aside as MantineAside, Group } from '@mantine/core';
|
import { Aside as MantineAside, createStyles } from '@mantine/core';
|
||||||
import { WeatherModule, DateModule, CalendarModule } from '../modules';
|
import Widgets from './Widgets';
|
||||||
import { ModuleWrapper } from '../modules/moduleWrapper';
|
|
||||||
|
const useStyles = createStyles((theme) => ({
|
||||||
|
hide: {
|
||||||
|
[theme.fn.smallerThan('xs')]: {
|
||||||
|
display: 'none',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
burger: {
|
||||||
|
[theme.fn.largerThan('sm')]: {
|
||||||
|
display: 'none',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
export default function Aside(props: any) {
|
export default function Aside(props: any) {
|
||||||
|
const { classes, cx } = useStyles();
|
||||||
return (
|
return (
|
||||||
<MantineAside
|
<MantineAside
|
||||||
pr="md"
|
pr="md"
|
||||||
hiddenBreakpoint="md"
|
hiddenBreakpoint="sm"
|
||||||
hidden
|
hidden
|
||||||
|
className={cx(classes.hide)}
|
||||||
style={{
|
style={{
|
||||||
border: 'none',
|
border: 'none',
|
||||||
|
background: 'none',
|
||||||
}}
|
}}
|
||||||
width={{
|
width={{
|
||||||
base: 'auto',
|
base: 'auto',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Group mt="sm" grow direction="column">
|
<Widgets />
|
||||||
<ModuleWrapper module={CalendarModule} />
|
|
||||||
<ModuleWrapper module={DateModule} />
|
|
||||||
<ModuleWrapper module={WeatherModule} />
|
|
||||||
</Group>
|
|
||||||
</MantineAside>
|
</MantineAside>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
20
src/components/layout/Background.tsx
Normal file
20
src/components/layout/Background.tsx
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
import { Global } from '@mantine/core';
|
||||||
|
import { useConfig } from '../../tools/state';
|
||||||
|
|
||||||
|
export function Background() {
|
||||||
|
const { config } = useConfig();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Global
|
||||||
|
styles={{
|
||||||
|
body: {
|
||||||
|
minHeight: '100vh',
|
||||||
|
backgroundImage: `url('${config.settings.background}')` || '',
|
||||||
|
backgroundPosition: 'center center',
|
||||||
|
backgroundSize: 'cover',
|
||||||
|
backgroundRepeat: 'no-repeat',
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
import React, { useEffect } from 'react';
|
import React, { useEffect } from 'react';
|
||||||
import { createStyles, Footer as FooterComponent } from '@mantine/core';
|
import { createStyles, Footer as FooterComponent } from '@mantine/core';
|
||||||
import { showNotification } from '@mantine/notifications';
|
import { showNotification } from '@mantine/notifications';
|
||||||
|
import { IconAlertCircle as AlertCircle } from '@tabler/icons';
|
||||||
import { CURRENT_VERSION, REPO_URL } from '../../../data/constants';
|
import { CURRENT_VERSION, REPO_URL } from '../../../data/constants';
|
||||||
|
|
||||||
const useStyles = createStyles((theme) => ({
|
const useStyles = createStyles((theme) => ({
|
||||||
@@ -38,12 +39,21 @@ export function Footer({ links }: FooterCenteredProps) {
|
|||||||
// Fetch Data here when component first mounted
|
// Fetch Data here when component first mounted
|
||||||
fetch(`https://api.github.com/repos/${REPO_URL}/releases/latest`).then((res) => {
|
fetch(`https://api.github.com/repos/${REPO_URL}/releases/latest`).then((res) => {
|
||||||
res.json().then((data) => {
|
res.json().then((data) => {
|
||||||
if (data.tag_name !== CURRENT_VERSION) {
|
if (data.tag_name > CURRENT_VERSION) {
|
||||||
showNotification({
|
showNotification({
|
||||||
color: 'yellow',
|
color: 'yellow',
|
||||||
autoClose: false,
|
autoClose: false,
|
||||||
title: 'New version available',
|
title: 'New version available',
|
||||||
message: `Version ${data.tag_name} is available, update now! 😡`,
|
icon: <AlertCircle />,
|
||||||
|
message: `Version ${data.tag_name} is available, update now!`,
|
||||||
|
});
|
||||||
|
} else if (data.tag_name < CURRENT_VERSION) {
|
||||||
|
showNotification({
|
||||||
|
color: 'orange',
|
||||||
|
autoClose: 5000,
|
||||||
|
title: 'You are using a development version',
|
||||||
|
icon: <AlertCircle />,
|
||||||
|
message: 'This version of Homarr is still in development! Bugs are expected 🐛',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,9 +1,23 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { createStyles, Header as Head, Group, Box } from '@mantine/core';
|
import {
|
||||||
|
createStyles,
|
||||||
|
Header as Head,
|
||||||
|
Group,
|
||||||
|
Box,
|
||||||
|
Burger,
|
||||||
|
Drawer,
|
||||||
|
Title,
|
||||||
|
ScrollArea,
|
||||||
|
ActionIcon,
|
||||||
|
Transition,
|
||||||
|
} from '@mantine/core';
|
||||||
|
import { useBooleanToggle } from '@mantine/hooks';
|
||||||
import { Logo } from './Logo';
|
import { Logo } from './Logo';
|
||||||
import SearchBar from '../modules/search/SearchModule';
|
import SearchBar from '../modules/search/SearchModule';
|
||||||
import { AddItemShelfButton } from '../AppShelf/AddAppShelfItem';
|
import { AddItemShelfButton } from '../AppShelf/AddAppShelfItem';
|
||||||
import { SettingsMenuButton } from '../Settings/SettingsMenu';
|
import { SettingsMenuButton } from '../Settings/SettingsMenu';
|
||||||
|
import { ModuleWrapper } from '../modules/moduleWrapper';
|
||||||
|
import { CalendarModule, TotalDownloadsModule, WeatherModule, DateModule } from '../modules';
|
||||||
|
|
||||||
const HEADER_HEIGHT = 60;
|
const HEADER_HEIGHT = 60;
|
||||||
|
|
||||||
@@ -13,14 +27,21 @@ const useStyles = createStyles((theme) => ({
|
|||||||
display: 'none',
|
display: 'none',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
burger: {
|
||||||
|
[theme.fn.largerThan('sm')]: {
|
||||||
|
display: 'none',
|
||||||
|
},
|
||||||
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
export function Header(props: any) {
|
export function Header(props: any) {
|
||||||
|
const [opened, toggleOpened] = useBooleanToggle(false);
|
||||||
const { classes, cx } = useStyles();
|
const { classes, cx } = useStyles();
|
||||||
|
const [hidden, toggleHidden] = useBooleanToggle(true);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Head height="auto">
|
<Head height="auto">
|
||||||
<Group m="xs" position="apart">
|
<Group p="xs" position="apart">
|
||||||
<Box className={classes.hide}>
|
<Box className={classes.hide}>
|
||||||
<Logo style={{ fontSize: 22 }} />
|
<Logo style={{ fontSize: 22 }} />
|
||||||
</Box>
|
</Box>
|
||||||
@@ -28,6 +49,47 @@ export function Header(props: any) {
|
|||||||
<SearchBar />
|
<SearchBar />
|
||||||
<SettingsMenuButton />
|
<SettingsMenuButton />
|
||||||
<AddItemShelfButton />
|
<AddItemShelfButton />
|
||||||
|
<ActionIcon className={classes.burger} variant="default" radius="md" size="xl">
|
||||||
|
<Burger
|
||||||
|
opened={!hidden}
|
||||||
|
onClick={(_) => {
|
||||||
|
toggleHidden();
|
||||||
|
toggleOpened();
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</ActionIcon>
|
||||||
|
<Drawer
|
||||||
|
size="auto"
|
||||||
|
padding="xl"
|
||||||
|
position="right"
|
||||||
|
hidden={hidden}
|
||||||
|
title={<Title order={3}>Modules</Title>}
|
||||||
|
opened
|
||||||
|
onClose={() => {
|
||||||
|
toggleHidden();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Transition
|
||||||
|
mounted={opened}
|
||||||
|
transition="pop-top-right"
|
||||||
|
duration={300}
|
||||||
|
timingFunction="ease"
|
||||||
|
onExit={() => toggleOpened()}
|
||||||
|
>
|
||||||
|
{(styles) => (
|
||||||
|
<div style={styles}>
|
||||||
|
<ScrollArea style={{ height: '90vh' }}>
|
||||||
|
<Group my="sm" grow direction="column" style={{ width: 300 }}>
|
||||||
|
<ModuleWrapper module={CalendarModule} />
|
||||||
|
<ModuleWrapper module={TotalDownloadsModule} />
|
||||||
|
<ModuleWrapper module={WeatherModule} />
|
||||||
|
<ModuleWrapper module={DateModule} />
|
||||||
|
</Group>
|
||||||
|
</ScrollArea>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</Transition>
|
||||||
|
</Drawer>
|
||||||
</Group>
|
</Group>
|
||||||
</Group>
|
</Group>
|
||||||
</Head>
|
</Head>
|
||||||
|
|||||||
14
src/components/layout/HeaderConfig.tsx
Normal file
14
src/components/layout/HeaderConfig.tsx
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import Head from 'next/head';
|
||||||
|
import { useConfig } from '../../tools/state';
|
||||||
|
|
||||||
|
export function HeaderConfig(props: any) {
|
||||||
|
const { config } = useConfig();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Head>
|
||||||
|
<title>{config.settings.title || 'Homarr 🦞'}</title>
|
||||||
|
<link rel="shortcut icon" href={config.settings.favicon || '/favicon.svg'} />
|
||||||
|
</Head>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -2,6 +2,10 @@ import { AppShell, createStyles } from '@mantine/core';
|
|||||||
import { Header } from './Header';
|
import { Header } from './Header';
|
||||||
import { Footer } from './Footer';
|
import { Footer } from './Footer';
|
||||||
import Aside from './Aside';
|
import Aside from './Aside';
|
||||||
|
import Navbar from './Navbar';
|
||||||
|
import { HeaderConfig } from './HeaderConfig';
|
||||||
|
import { Background } from './Background';
|
||||||
|
import { useConfig } from '../../tools/state';
|
||||||
|
|
||||||
const useStyles = createStyles((theme) => ({
|
const useStyles = createStyles((theme) => ({
|
||||||
main: {},
|
main: {},
|
||||||
@@ -9,8 +13,18 @@ const useStyles = createStyles((theme) => ({
|
|||||||
|
|
||||||
export default function Layout({ children, style }: any) {
|
export default function Layout({ children, style }: any) {
|
||||||
const { classes, cx } = useStyles();
|
const { classes, cx } = useStyles();
|
||||||
|
const { config } = useConfig();
|
||||||
|
const widgetPosition = config?.settings?.widgetPosition === 'left';
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AppShell aside={<Aside />} header={<Header />} footer={<Footer links={[]} />}>
|
<AppShell
|
||||||
|
header={<Header />}
|
||||||
|
navbar={widgetPosition ? <Navbar /> : <></>}
|
||||||
|
aside={widgetPosition ? <></> : <Aside />}
|
||||||
|
footer={<Footer links={[]} />}
|
||||||
|
>
|
||||||
|
<HeaderConfig />
|
||||||
|
<Background />
|
||||||
<main
|
<main
|
||||||
className={cx(classes.main)}
|
className={cx(classes.main)}
|
||||||
style={{
|
style={{
|
||||||
|
|||||||
@@ -1,31 +1,40 @@
|
|||||||
import { Group, Image, Text } from '@mantine/core';
|
import { Group, Image, Text } from '@mantine/core';
|
||||||
import { NextLink } from '@mantine/next';
|
import { NextLink } from '@mantine/next';
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
|
import { useColorTheme } from '../../tools/color';
|
||||||
|
import { useConfig } from '../../tools/state';
|
||||||
|
|
||||||
export function Logo({ style }: any) {
|
export function Logo({ style }: any) {
|
||||||
|
const { config } = useConfig();
|
||||||
|
const { primaryColor, secondaryColor } = useColorTheme();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Group spacing="xs">
|
<Group spacing="xs">
|
||||||
<Image
|
<Image
|
||||||
width={50}
|
width={50}
|
||||||
src="/imgs/logo.png"
|
src={config.settings.logo || '/imgs/logo.png'}
|
||||||
style={{
|
style={{
|
||||||
position: 'relative',
|
position: 'relative',
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<NextLink
|
<NextLink
|
||||||
|
href="/"
|
||||||
style={{
|
style={{
|
||||||
textDecoration: 'none',
|
textDecoration: 'none',
|
||||||
position: 'relative',
|
position: 'relative',
|
||||||
}}
|
}}
|
||||||
href="/"
|
|
||||||
>
|
>
|
||||||
<Text
|
<Text
|
||||||
sx={style}
|
sx={style}
|
||||||
weight="bold"
|
weight="bold"
|
||||||
variant="gradient"
|
variant="gradient"
|
||||||
gradient={{ from: 'red', to: 'orange', deg: 145 }}
|
gradient={{
|
||||||
|
from: primaryColor,
|
||||||
|
to: secondaryColor,
|
||||||
|
deg: 145,
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
Homarr
|
{config.settings.title || 'Homarr'}
|
||||||
</Text>
|
</Text>
|
||||||
</NextLink>
|
</NextLink>
|
||||||
</Group>
|
</Group>
|
||||||
|
|||||||
@@ -1,24 +1,37 @@
|
|||||||
import { Group, Navbar as MantineNavbar } from '@mantine/core';
|
import { createStyles, Navbar as MantineNavbar } from '@mantine/core';
|
||||||
import { WeatherModule, DateModule } from '../modules';
|
import Widgets from './Widgets';
|
||||||
import { ModuleWrapper } from '../modules/moduleWrapper';
|
|
||||||
|
const useStyles = createStyles((theme) => ({
|
||||||
|
hide: {
|
||||||
|
[theme.fn.smallerThan('xs')]: {
|
||||||
|
display: 'none',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
burger: {
|
||||||
|
[theme.fn.largerThan('sm')]: {
|
||||||
|
display: 'none',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
export default function Navbar() {
|
export default function Navbar() {
|
||||||
|
const { classes, cx } = useStyles();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<MantineNavbar
|
<MantineNavbar
|
||||||
hiddenBreakpoint="lg"
|
pl="md"
|
||||||
|
hiddenBreakpoint="sm"
|
||||||
hidden
|
hidden
|
||||||
|
className={cx(classes.hide)}
|
||||||
style={{
|
style={{
|
||||||
border: 'none',
|
border: 'none',
|
||||||
|
background: 'none',
|
||||||
}}
|
}}
|
||||||
width={{
|
width={{
|
||||||
base: 'auto',
|
base: 'auto',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Group mt="sm" direction="column" align="center">
|
<Widgets />
|
||||||
<ModuleWrapper module={DateModule} />
|
|
||||||
<ModuleWrapper module={WeatherModule} />
|
|
||||||
<ModuleWrapper module={WeatherModule} />
|
|
||||||
</Group>
|
|
||||||
</MantineNavbar>
|
</MantineNavbar>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
21
src/components/layout/Widgets.tsx
Normal file
21
src/components/layout/Widgets.tsx
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
import { Group } from '@mantine/core';
|
||||||
|
import { useMediaQuery } from '@mantine/hooks';
|
||||||
|
import { CalendarModule, DateModule, TotalDownloadsModule, WeatherModule } from '../modules';
|
||||||
|
import { ModuleWrapper } from '../modules/moduleWrapper';
|
||||||
|
|
||||||
|
export default function Widgets(props: any) {
|
||||||
|
const matches = useMediaQuery('(min-width: 800px)');
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{matches && (
|
||||||
|
<Group my="sm" grow direction="column" style={{ width: 300 }}>
|
||||||
|
<ModuleWrapper module={CalendarModule} />
|
||||||
|
<ModuleWrapper module={TotalDownloadsModule} />
|
||||||
|
<ModuleWrapper module={WeatherModule} />
|
||||||
|
<ModuleWrapper module={DateModule} />
|
||||||
|
</Group>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,9 +1,17 @@
|
|||||||
/* eslint-disable react/no-children-prop */
|
/* eslint-disable react/no-children-prop */
|
||||||
import { Box, Divider, Indicator, Popover, ScrollArea, useMantineTheme } from '@mantine/core';
|
import {
|
||||||
|
Box,
|
||||||
|
Divider,
|
||||||
|
Indicator,
|
||||||
|
Popover,
|
||||||
|
ScrollArea,
|
||||||
|
createStyles,
|
||||||
|
useMantineTheme,
|
||||||
|
} from '@mantine/core';
|
||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import { Calendar } from '@mantine/dates';
|
import { Calendar } from '@mantine/dates';
|
||||||
import { showNotification } from '@mantine/notifications';
|
import { IconCalendar as CalendarIcon } from '@tabler/icons';
|
||||||
import { Calendar as CalendarIcon, Check } from 'tabler-icons-react';
|
import axios from 'axios';
|
||||||
import { useConfig } from '../../../tools/state';
|
import { useConfig } from '../../../tools/state';
|
||||||
import { IModule } from '../modules';
|
import { IModule } from '../modules';
|
||||||
import {
|
import {
|
||||||
@@ -11,7 +19,9 @@ import {
|
|||||||
RadarrMediaDisplay,
|
RadarrMediaDisplay,
|
||||||
LidarrMediaDisplay,
|
LidarrMediaDisplay,
|
||||||
ReadarrMediaDisplay,
|
ReadarrMediaDisplay,
|
||||||
} from './MediaDisplay';
|
} from '../common';
|
||||||
|
import { serviceItem } from '../../../tools/types';
|
||||||
|
import { useColorTheme } from '../../../tools/color';
|
||||||
|
|
||||||
export const CalendarModule: IModule = {
|
export const CalendarModule: IModule = {
|
||||||
title: 'Calendar',
|
title: 'Calendar',
|
||||||
@@ -23,111 +33,89 @@ export const CalendarModule: IModule = {
|
|||||||
|
|
||||||
export default function CalendarComponent(props: any) {
|
export default function CalendarComponent(props: any) {
|
||||||
const { config } = useConfig();
|
const { config } = useConfig();
|
||||||
|
const theme = useMantineTheme();
|
||||||
|
const { secondaryColor } = useColorTheme();
|
||||||
|
const useStyles = createStyles((theme) => ({
|
||||||
|
weekend: {
|
||||||
|
color: `${secondaryColor} !important`,
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
const [sonarrMedias, setSonarrMedias] = useState([] as any);
|
const [sonarrMedias, setSonarrMedias] = useState([] as any);
|
||||||
const [lidarrMedias, setLidarrMedias] = useState([] as any);
|
const [lidarrMedias, setLidarrMedias] = useState([] as any);
|
||||||
const [radarrMedias, setRadarrMedias] = useState([] as any);
|
const [radarrMedias, setRadarrMedias] = useState([] as any);
|
||||||
const [readarrMedias, setReadarrMedias] = useState([] as any);
|
const [readarrMedias, setReadarrMedias] = useState([] as any);
|
||||||
|
const sonarrServices = config.services.filter((service) => service.type === 'Sonarr');
|
||||||
|
const radarrServices = config.services.filter((service) => service.type === 'Radarr');
|
||||||
|
const lidarrServices = config.services.filter((service) => service.type === 'Lidarr');
|
||||||
|
const readarrServices = config.services.filter((service) => service.type === 'Readarr');
|
||||||
|
const today = new Date();
|
||||||
|
|
||||||
|
const { classes, cx } = useStyles();
|
||||||
|
|
||||||
|
function getMedias(service: serviceItem | undefined, type: string) {
|
||||||
|
if (!service || !service.apiKey) {
|
||||||
|
return Promise.resolve({ data: [] });
|
||||||
|
}
|
||||||
|
return axios.post(`/api/modules/calendar?type=${type}`, { ...service });
|
||||||
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// Filter only sonarr and radarr services
|
// Create each Sonarr service and get the medias
|
||||||
const filtered = config.services.filter(
|
const currentSonarrMedias: any[] = [...sonarrMedias];
|
||||||
(service) =>
|
Promise.all(
|
||||||
service.type === 'Sonarr' ||
|
sonarrServices.map((service) =>
|
||||||
service.type === 'Radarr' ||
|
getMedias(service, 'sonarr').then((res) => {
|
||||||
service.type === 'Lidarr' ||
|
currentSonarrMedias.push(...res.data);
|
||||||
service.type === 'Readarr'
|
})
|
||||||
);
|
)
|
||||||
|
).then(() => {
|
||||||
// Get the url and apiKey for all Sonarr and Radarr services
|
setSonarrMedias(currentSonarrMedias);
|
||||||
const sonarrService = filtered.filter((service) => service.type === 'Sonarr').at(0);
|
|
||||||
const radarrService = filtered.filter((service) => service.type === 'Radarr').at(0);
|
|
||||||
const lidarrService = filtered.filter((service) => service.type === 'Lidarr').at(0);
|
|
||||||
const readarrService = filtered.filter((service) => service.type === 'Readarr').at(0);
|
|
||||||
const nextMonth = new Date(new Date().setMonth(new Date().getMonth() + 2)).toISOString();
|
|
||||||
if (sonarrService && sonarrService.apiKey) {
|
|
||||||
const baseUrl = new URL(sonarrService.url).origin;
|
|
||||||
fetch(`${baseUrl}/api/calendar?apikey=${sonarrService?.apiKey}&end=${nextMonth}`).then(
|
|
||||||
(response) => {
|
|
||||||
response.ok &&
|
|
||||||
response.json().then((data) => {
|
|
||||||
setSonarrMedias(data);
|
|
||||||
showNotification({
|
|
||||||
title: 'Sonarr',
|
|
||||||
icon: <Check />,
|
|
||||||
color: 'green',
|
|
||||||
autoClose: 1500,
|
|
||||||
radius: 'md',
|
|
||||||
message: `Loaded ${data.length} releases`,
|
|
||||||
});
|
});
|
||||||
|
const currentRadarrMedias: any[] = [...radarrMedias];
|
||||||
|
Promise.all(
|
||||||
|
radarrServices.map((service) =>
|
||||||
|
getMedias(service, 'radarr').then((res) => {
|
||||||
|
currentRadarrMedias.push(...res.data);
|
||||||
|
})
|
||||||
|
)
|
||||||
|
).then(() => {
|
||||||
|
setRadarrMedias(currentRadarrMedias);
|
||||||
});
|
});
|
||||||
}
|
const currentLidarrMedias: any[] = [...lidarrMedias];
|
||||||
);
|
Promise.all(
|
||||||
}
|
lidarrServices.map((service) =>
|
||||||
if (radarrService && radarrService.apiKey) {
|
getMedias(service, 'lidarr').then((res) => {
|
||||||
const baseUrl = new URL(radarrService.url).origin;
|
currentLidarrMedias.push(...res.data);
|
||||||
fetch(`${baseUrl}/api/v3/calendar?apikey=${radarrService?.apiKey}&end=${nextMonth}`).then(
|
})
|
||||||
(response) => {
|
)
|
||||||
response.ok &&
|
).then(() => {
|
||||||
response.json().then((data) => {
|
setLidarrMedias(currentLidarrMedias);
|
||||||
setRadarrMedias(data);
|
|
||||||
showNotification({
|
|
||||||
title: 'Radarr',
|
|
||||||
icon: <Check />,
|
|
||||||
color: 'green',
|
|
||||||
autoClose: 1500,
|
|
||||||
radius: 'md',
|
|
||||||
message: `Loaded ${data.length} releases`,
|
|
||||||
});
|
});
|
||||||
|
const currentReadarrMedias: any[] = [...readarrMedias];
|
||||||
|
Promise.all(
|
||||||
|
readarrServices.map((service) =>
|
||||||
|
getMedias(service, 'readarr').then((res) => {
|
||||||
|
currentReadarrMedias.push(...res.data);
|
||||||
|
})
|
||||||
|
)
|
||||||
|
).then(() => {
|
||||||
|
setReadarrMedias(currentReadarrMedias);
|
||||||
});
|
});
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (lidarrService && lidarrService.apiKey) {
|
|
||||||
const baseUrl = new URL(lidarrService.url).origin;
|
|
||||||
fetch(`${baseUrl}/api/v1/calendar?apikey=${lidarrService?.apiKey}&end=${nextMonth}`).then(
|
|
||||||
(response) => {
|
|
||||||
response.ok &&
|
|
||||||
response.json().then((data) => {
|
|
||||||
setLidarrMedias(data);
|
|
||||||
showNotification({
|
|
||||||
title: 'Lidarr',
|
|
||||||
icon: <Check />,
|
|
||||||
color: 'green',
|
|
||||||
autoClose: 1500,
|
|
||||||
radius: 'md',
|
|
||||||
message: `Loaded ${data.length} releases`,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (readarrService && readarrService.apiKey) {
|
|
||||||
const baseUrl = new URL(readarrService.url).origin;
|
|
||||||
fetch(`${baseUrl}/api/v1/calendar?apikey=${readarrService?.apiKey}&end=${nextMonth}`).then(
|
|
||||||
(response) => {
|
|
||||||
response.ok &&
|
|
||||||
response.json().then((data) => {
|
|
||||||
setReadarrMedias(data);
|
|
||||||
showNotification({
|
|
||||||
title: 'Readarr',
|
|
||||||
icon: <Check />,
|
|
||||||
color: 'green',
|
|
||||||
autoClose: 1500,
|
|
||||||
radius: 'md',
|
|
||||||
message: `Loaded ${data.length} releases`,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}, [config.services]);
|
}, [config.services]);
|
||||||
|
|
||||||
if (sonarrMedias === undefined && radarrMedias === undefined) {
|
|
||||||
return <Calendar />;
|
|
||||||
}
|
|
||||||
return (
|
return (
|
||||||
<Calendar
|
<Calendar
|
||||||
onChange={(day: any) => {}}
|
onChange={(day: any) => {}}
|
||||||
|
dayStyle={(date) =>
|
||||||
|
date.getDay() === today.getDay() && date.getDate() === today.getDate()
|
||||||
|
? {
|
||||||
|
backgroundColor:
|
||||||
|
theme.colorScheme === 'dark' ? theme.colors.dark[5] : theme.colors.gray[0],
|
||||||
|
}
|
||||||
|
: {}
|
||||||
|
}
|
||||||
|
dayClassName={(date, modifiers) => cx({ [classes.weekend]: modifiers.weekend })}
|
||||||
renderDay={(renderdate) => (
|
renderDay={(renderdate) => (
|
||||||
<DayComponent
|
<DayComponent
|
||||||
renderdate={renderdate}
|
renderdate={renderdate}
|
||||||
@@ -151,29 +139,25 @@ function DayComponent(props: any) {
|
|||||||
}: { renderdate: Date; sonarrmedias: []; radarrmedias: []; lidarrmedias: []; readarrmedias: [] } =
|
}: { renderdate: Date; sonarrmedias: []; radarrmedias: []; lidarrmedias: []; readarrmedias: [] } =
|
||||||
props;
|
props;
|
||||||
const [opened, setOpened] = useState(false);
|
const [opened, setOpened] = useState(false);
|
||||||
const theme = useMantineTheme();
|
|
||||||
|
|
||||||
const day = renderdate.getDate();
|
const day = renderdate.getDate();
|
||||||
|
|
||||||
const readarrFiltered = readarrmedias.filter((media: any) => {
|
const readarrFiltered = readarrmedias.filter((media: any) => {
|
||||||
const date = new Date(media.releaseDate);
|
const date = new Date(media.releaseDate);
|
||||||
return date.getDate() === day && date.getMonth() === renderdate.getMonth();
|
return date.toDateString() === renderdate.toDateString();
|
||||||
});
|
});
|
||||||
|
|
||||||
const lidarrFiltered = lidarrmedias.filter((media: any) => {
|
const lidarrFiltered = lidarrmedias.filter((media: any) => {
|
||||||
const date = new Date(media.releaseDate);
|
const date = new Date(media.releaseDate);
|
||||||
// Return true if the date is renerdate without counting hours and minutes
|
return date.toDateString() === renderdate.toDateString();
|
||||||
return date.getDate() === day && date.getMonth() === renderdate.getMonth();
|
|
||||||
});
|
});
|
||||||
const sonarrFiltered = sonarrmedias.filter((media: any) => {
|
const sonarrFiltered = sonarrmedias.filter((media: any) => {
|
||||||
const date = new Date(media.airDate);
|
const date = new Date(media.airDateUtc);
|
||||||
// Return true if the date is renerdate without counting hours and minutes
|
return date.toDateString() === renderdate.toDateString();
|
||||||
return date.getDate() === day && date.getMonth() === renderdate.getMonth();
|
|
||||||
});
|
});
|
||||||
const radarrFiltered = radarrmedias.filter((media: any) => {
|
const radarrFiltered = radarrmedias.filter((media: any) => {
|
||||||
const date = new Date(media.inCinemas);
|
const date = new Date(media.inCinemas);
|
||||||
// Return true if the date is renerdate without counting hours and minutes
|
return date.toDateString() === renderdate.toDateString();
|
||||||
return date.getDate() === day && date.getMonth() === renderdate.getMonth();
|
|
||||||
});
|
});
|
||||||
if (
|
if (
|
||||||
sonarrFiltered.length === 0 &&
|
sonarrFiltered.length === 0 &&
|
||||||
@@ -243,11 +227,16 @@ function DayComponent(props: any) {
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
<Popover
|
<Popover
|
||||||
position="left"
|
position="bottom"
|
||||||
radius="lg"
|
radius="lg"
|
||||||
shadow="xl"
|
shadow="xl"
|
||||||
transition="pop"
|
transition="pop"
|
||||||
width={700}
|
styles={{
|
||||||
|
body: {
|
||||||
|
boxShadow: '0 0 14px 14px rgba(0, 0, 0, 0.1), 0 14px 11px rgba(0, 0, 0, 0.1)',
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
width="auto"
|
||||||
onClose={() => setOpened(false)}
|
onClose={() => setOpened(false)}
|
||||||
opened={opened}
|
opened={opened}
|
||||||
target={day}
|
target={day}
|
||||||
@@ -268,12 +257,18 @@ function DayComponent(props: any) {
|
|||||||
{index < radarrFiltered.length - 1 && <Divider variant="dashed" my="xl" />}
|
{index < radarrFiltered.length - 1 && <Divider variant="dashed" my="xl" />}
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
))}
|
))}
|
||||||
|
{sonarrFiltered.length > 0 && lidarrFiltered.length > 0 && (
|
||||||
|
<Divider variant="dashed" my="xl" />
|
||||||
|
)}
|
||||||
{lidarrFiltered.map((media: any, index: number) => (
|
{lidarrFiltered.map((media: any, index: number) => (
|
||||||
<React.Fragment key={index}>
|
<React.Fragment key={index}>
|
||||||
<LidarrMediaDisplay media={media} />
|
<LidarrMediaDisplay media={media} />
|
||||||
{index < lidarrFiltered.length - 1 && <Divider variant="dashed" my="xl" />}
|
{index < lidarrFiltered.length - 1 && <Divider variant="dashed" my="xl" />}
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
))}
|
))}
|
||||||
|
{lidarrFiltered.length > 0 && readarrFiltered.length > 0 && (
|
||||||
|
<Divider variant="dashed" my="xl" />
|
||||||
|
)}
|
||||||
{readarrFiltered.map((media: any, index: number) => (
|
{readarrFiltered.map((media: any, index: number) => (
|
||||||
<React.Fragment key={index}>
|
<React.Fragment key={index}>
|
||||||
<ReadarrMediaDisplay media={media} />
|
<ReadarrMediaDisplay media={media} />
|
||||||
|
|||||||
@@ -1,5 +1,16 @@
|
|||||||
import { Image, Group, Title, Badge, Text, ActionIcon, Anchor, ScrollArea } from '@mantine/core';
|
import {
|
||||||
import { Link } from 'tabler-icons-react';
|
Image,
|
||||||
|
Group,
|
||||||
|
Title,
|
||||||
|
Badge,
|
||||||
|
Text,
|
||||||
|
ActionIcon,
|
||||||
|
Anchor,
|
||||||
|
ScrollArea,
|
||||||
|
createStyles,
|
||||||
|
} from '@mantine/core';
|
||||||
|
import { useMediaQuery } from '@mantine/hooks';
|
||||||
|
import { IconLink as Link } from '@tabler/icons';
|
||||||
import { useConfig } from '../../../tools/state';
|
import { useConfig } from '../../../tools/state';
|
||||||
import { serviceItem } from '../../../tools/types';
|
import { serviceItem } from '../../../tools/types';
|
||||||
|
|
||||||
@@ -14,13 +25,25 @@ export interface IMedia {
|
|||||||
episodeNumber?: number;
|
episodeNumber?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
function MediaDisplay(props: { media: IMedia }) {
|
const useStyles = createStyles((theme) => ({
|
||||||
|
overview: {
|
||||||
|
[theme.fn.largerThan('sm')]: {
|
||||||
|
width: 400,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
|
export function MediaDisplay(props: { media: IMedia }) {
|
||||||
const { media }: { media: IMedia } = props;
|
const { media }: { media: IMedia } = props;
|
||||||
|
const { classes, cx } = useStyles();
|
||||||
|
const phone = useMediaQuery('(min-width: 800px)');
|
||||||
return (
|
return (
|
||||||
<Group position="apart">
|
<Group position="apart">
|
||||||
<Text>
|
<Text>
|
||||||
{media.poster && (
|
{media.poster && (
|
||||||
<Image
|
<Image
|
||||||
|
width={phone ? 250 : 100}
|
||||||
|
height={phone ? 400 : 160}
|
||||||
style={{
|
style={{
|
||||||
float: 'right',
|
float: 'right',
|
||||||
}}
|
}}
|
||||||
@@ -28,12 +51,10 @@ function MediaDisplay(props: { media: IMedia }) {
|
|||||||
fit="cover"
|
fit="cover"
|
||||||
src={media.poster}
|
src={media.poster}
|
||||||
alt={media.title}
|
alt={media.title}
|
||||||
width={250}
|
|
||||||
height={400}
|
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
<Group direction="column">
|
<Group direction="column" style={{ minWidth: phone ? 450 : '65vw' }}>
|
||||||
<Group style={{ minWidth: 400 }}>
|
<Group noWrap mr="sm" className={classes.overview}>
|
||||||
<Title order={3}>{media.title}</Title>
|
<Title order={3}>{media.title}</Title>
|
||||||
{media.imdbId && (
|
{media.imdbId && (
|
||||||
<Anchor href={`https://www.imdb.com/title/${media.imdbId}`} target="_blank">
|
<Anchor href={`https://www.imdb.com/title/${media.imdbId}`} target="_blank">
|
||||||
@@ -47,7 +68,7 @@ function MediaDisplay(props: { media: IMedia }) {
|
|||||||
<Text
|
<Text
|
||||||
style={{
|
style={{
|
||||||
textAlign: 'center',
|
textAlign: 'center',
|
||||||
color: '#a0aec0',
|
color: 'gray',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
New release from {media.artist}
|
New release from {media.artist}
|
||||||
@@ -57,7 +78,7 @@ function MediaDisplay(props: { media: IMedia }) {
|
|||||||
<Text
|
<Text
|
||||||
style={{
|
style={{
|
||||||
textAlign: 'center',
|
textAlign: 'center',
|
||||||
color: '#a0aec0',
|
color: 'gray',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Season {media.seasonNumber} episode {media.episodeNumber}
|
Season {media.seasonNumber} episode {media.episodeNumber}
|
||||||
@@ -65,9 +86,9 @@ function MediaDisplay(props: { media: IMedia }) {
|
|||||||
)}
|
)}
|
||||||
</Group>
|
</Group>
|
||||||
<Group direction="column" position="apart">
|
<Group direction="column" position="apart">
|
||||||
<ScrollArea style={{ height: 250 }}>{media.overview}</ScrollArea>
|
<ScrollArea style={{ height: 280, maxWidth: 700 }}>{media.overview}</ScrollArea>
|
||||||
<Group align="center" position="center" spacing="xs">
|
<Group align="center" position="center" spacing="xs">
|
||||||
{media.genres.map((genre: string, i: number) => (
|
{media.genres.slice(-5).map((genre: string, i: number) => (
|
||||||
<Badge size="sm" key={i}>
|
<Badge size="sm" key={i}>
|
||||||
{genre}
|
{genre}
|
||||||
</Badge>
|
</Badge>
|
||||||
@@ -118,7 +139,7 @@ export function LidarrMediaDisplay(props: any) {
|
|||||||
}
|
}
|
||||||
const baseUrl = new URL(lidarr.url).origin;
|
const baseUrl = new URL(lidarr.url).origin;
|
||||||
// Remove '/' from the end of the lidarr url
|
// Remove '/' from the end of the lidarr url
|
||||||
const fullLink = `${baseUrl}${poster.url}`;
|
const fullLink = poster ? `${baseUrl}${poster.url}` : undefined;
|
||||||
// Return a movie poster containting the title and the description
|
// Return a movie poster containting the title and the description
|
||||||
return (
|
return (
|
||||||
<MediaDisplay
|
<MediaDisplay
|
||||||
1
src/components/modules/common/index.ts
Normal file
1
src/components/modules/common/index.ts
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export * from './MediaDisplay';
|
||||||
@@ -1,9 +1,10 @@
|
|||||||
import { Group, Text, Title } from '@mantine/core';
|
import { Group, Text, Title } from '@mantine/core';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { Clock } from 'tabler-icons-react';
|
import { IconClock as Clock } from '@tabler/icons';
|
||||||
import { useConfig } from '../../../tools/state';
|
import { useConfig } from '../../../tools/state';
|
||||||
import { IModule } from '../modules';
|
import { IModule } from '../modules';
|
||||||
|
import { useSetSafeInterval } from '../../../tools/hooks/useSetSafeInterval';
|
||||||
|
|
||||||
export const DateModule: IModule = {
|
export const DateModule: IModule = {
|
||||||
title: 'Date',
|
title: 'Date',
|
||||||
@@ -20,13 +21,14 @@ export const DateModule: IModule = {
|
|||||||
|
|
||||||
export default function DateComponent(props: any) {
|
export default function DateComponent(props: any) {
|
||||||
const [date, setDate] = useState(new Date());
|
const [date, setDate] = useState(new Date());
|
||||||
|
const setSafeInterval = useSetSafeInterval();
|
||||||
const { config } = useConfig();
|
const { config } = useConfig();
|
||||||
const isFullTime = config?.modules?.[DateModule.title]?.options?.full?.value ?? false;
|
const isFullTime = config?.modules?.[DateModule.title]?.options?.full?.value ?? false;
|
||||||
const formatString = isFullTime ? 'HH:mm' : 'h:mm A';
|
const formatString = isFullTime ? 'HH:mm' : 'h:mm A';
|
||||||
// Change date on minute change
|
// Change date on minute change
|
||||||
// Note: Using 10 000ms instead of 1000ms to chill a little :)
|
// Note: Using 10 000ms instead of 1000ms to chill a little :)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setInterval(() => {
|
setSafeInterval(() => {
|
||||||
setDate(new Date());
|
setDate(new Date());
|
||||||
}, 1000 * 60);
|
}, 1000 * 60);
|
||||||
}, []);
|
}, []);
|
||||||
|
|||||||
@@ -1,11 +1,25 @@
|
|||||||
import { Loader, Table, Text, Tooltip, Title, Group, Progress, Center } from '@mantine/core';
|
import {
|
||||||
import { Download } from 'tabler-icons-react';
|
Table,
|
||||||
|
Text,
|
||||||
|
Tooltip,
|
||||||
|
Title,
|
||||||
|
Group,
|
||||||
|
Progress,
|
||||||
|
Skeleton,
|
||||||
|
ScrollArea,
|
||||||
|
Center,
|
||||||
|
Image,
|
||||||
|
} from '@mantine/core';
|
||||||
|
import { IconDownload as Download } from '@tabler/icons';
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { NormalizedTorrent } from '@ctrl/shared-torrent';
|
import { NormalizedTorrent } from '@ctrl/shared-torrent';
|
||||||
|
import { useViewportSize } from '@mantine/hooks';
|
||||||
import { IModule } from '../modules';
|
import { IModule } from '../modules';
|
||||||
import { useConfig } from '../../../tools/state';
|
import { useConfig } from '../../../tools/state';
|
||||||
import { AddItemShelfButton } from '../../AppShelf/AddAppShelfItem';
|
import { AddItemShelfButton } from '../../AppShelf/AddAppShelfItem';
|
||||||
|
import { useSetSafeInterval } from '../../../tools/hooks/useSetSafeInterval';
|
||||||
|
import { humanFileSize } from '../../../tools/humanFileSize';
|
||||||
|
|
||||||
export const DownloadsModule: IModule = {
|
export const DownloadsModule: IModule = {
|
||||||
title: 'Torrent',
|
title: 'Torrent',
|
||||||
@@ -22,74 +36,88 @@ export const DownloadsModule: IModule = {
|
|||||||
|
|
||||||
export default function DownloadComponent() {
|
export default function DownloadComponent() {
|
||||||
const { config } = useConfig();
|
const { config } = useConfig();
|
||||||
const qBittorrentService = config.services
|
const { height, width } = useViewportSize();
|
||||||
.filter((service) => service.type === 'qBittorrent')
|
const downloadServices =
|
||||||
.at(0);
|
config.services.filter(
|
||||||
const delugeService = config.services.filter((service) => service.type === 'Deluge').at(0);
|
(service) =>
|
||||||
|
service.type === 'qBittorrent' ||
|
||||||
|
service.type === 'Transmission' ||
|
||||||
|
service.type === 'Deluge'
|
||||||
|
) ?? [];
|
||||||
const hideComplete: boolean =
|
const hideComplete: boolean =
|
||||||
(config?.modules?.[DownloadsModule.title]?.options?.hidecomplete?.value as boolean) ?? false;
|
(config?.modules?.[DownloadsModule.title]?.options?.hidecomplete?.value as boolean) ?? false;
|
||||||
|
const [torrents, setTorrents] = useState<NormalizedTorrent[]>([]);
|
||||||
const [delugeTorrents, setDelugeTorrents] = useState<NormalizedTorrent[]>([]);
|
const setSafeInterval = useSetSafeInterval();
|
||||||
const [qBittorrentTorrents, setqBittorrentTorrents] = useState<NormalizedTorrent[]>([]);
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (qBittorrentService) {
|
setIsLoading(true);
|
||||||
setInterval(() => {
|
if (downloadServices.length === 0) return;
|
||||||
axios
|
setSafeInterval(() => {
|
||||||
.post('/api/modules/downloads?dlclient=qbit', { ...qBittorrentService })
|
// Send one request with each download service inside
|
||||||
.then((res) => {
|
axios.post('/api/modules/downloads', { config }).then((response) => {
|
||||||
setqBittorrentTorrents(res.data.torrents);
|
setTorrents(response.data);
|
||||||
|
setIsLoading(false);
|
||||||
});
|
});
|
||||||
}, 3000);
|
}, 5000);
|
||||||
}
|
}, [config.services]);
|
||||||
if (delugeService) {
|
|
||||||
setInterval(() => {
|
|
||||||
axios.post('/api/modules/downloads?dlclient=deluge', { ...delugeService }).then((res) => {
|
|
||||||
setDelugeTorrents(res.data.torrents);
|
|
||||||
});
|
|
||||||
}, 3000);
|
|
||||||
}
|
|
||||||
}, [config.modules]);
|
|
||||||
|
|
||||||
if (!qBittorrentService && !delugeService) {
|
if (downloadServices.length === 0) {
|
||||||
return (
|
return (
|
||||||
<Group direction="column">
|
<Group direction="column">
|
||||||
<Title>Critical: No qBittorrent/Deluge instance found in services.</Title>
|
<Title order={3}>No supported download clients found!</Title>
|
||||||
<Group>
|
<Group>
|
||||||
<Title order={3}>Add a qBittorrent/Deluge service to view current downloads</Title>
|
<Text>Add a download service to view your current downloads...</Text>
|
||||||
<AddItemShelfButton />
|
<AddItemShelfButton />
|
||||||
</Group>
|
</Group>
|
||||||
</Group>
|
</Group>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qBittorrentTorrents.length === 0 && delugeTorrents.length === 0) {
|
if (isLoading) {
|
||||||
return (
|
return (
|
||||||
<Center>
|
<>
|
||||||
<Loader />
|
<Skeleton height={40} mt={10} />
|
||||||
</Center>
|
<Skeleton height={40} mt={10} />
|
||||||
|
<Skeleton height={40} mt={10} />
|
||||||
|
<Skeleton height={40} mt={10} />
|
||||||
|
<Skeleton height={40} mt={10} />
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
const DEVICE_WIDTH = 576;
|
||||||
const ths = (
|
const ths = (
|
||||||
<tr>
|
<tr>
|
||||||
<th>Name</th>
|
<th>Name</th>
|
||||||
<th>Download</th>
|
<th>Size</th>
|
||||||
<th>Upload</th>
|
{width > 576 ? <th>Down</th> : ''}
|
||||||
|
{width > 576 ? <th>Up</th> : ''}
|
||||||
|
<th>ETA</th>
|
||||||
<th>Progress</th>
|
<th>Progress</th>
|
||||||
</tr>
|
</tr>
|
||||||
);
|
);
|
||||||
// Loop over qBittorrent torrents merging with deluge torrents
|
// Convert Seconds to readable format.
|
||||||
const torrents: NormalizedTorrent[] = [];
|
function calculateETA(givenSeconds: number) {
|
||||||
delugeTorrents.forEach((torrent) => torrents.push(torrent));
|
// If its superior than one day return > 1 day
|
||||||
qBittorrentTorrents.forEach((torrent) => torrents.push(torrent));
|
if (givenSeconds > 86400) {
|
||||||
|
return '> 1 day';
|
||||||
const rows = torrents.map((torrent) => {
|
|
||||||
if (torrent.progress === 1 && hideComplete) {
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
// Transform the givenSeconds into a readable format. e.g. 1h 2m 3s
|
||||||
|
const hours = Math.floor(givenSeconds / 3600);
|
||||||
|
const minutes = Math.floor((givenSeconds % 3600) / 60);
|
||||||
|
const seconds = Math.floor(givenSeconds % 60);
|
||||||
|
// Only show hours if it's greater than 0.
|
||||||
|
const hoursString = hours > 0 ? `${hours}h ` : '';
|
||||||
|
const minutesString = minutes > 0 ? `${minutes}m ` : '';
|
||||||
|
const secondsString = seconds > 0 ? `${seconds}s` : '';
|
||||||
|
return `${hoursString}${minutesString}${secondsString}`;
|
||||||
|
}
|
||||||
|
// Loop over qBittorrent torrents merging with deluge torrents
|
||||||
|
const rows = torrents
|
||||||
|
.filter((torrent) => !(torrent.progress === 1 && hideComplete))
|
||||||
|
.map((torrent) => {
|
||||||
const downloadSpeed = torrent.downloadSpeed / 1024 / 1024;
|
const downloadSpeed = torrent.downloadSpeed / 1024 / 1024;
|
||||||
const uploadSpeed = torrent.uploadSpeed / 1024 / 1024;
|
const uploadSpeed = torrent.uploadSpeed / 1024 / 1024;
|
||||||
|
const size = torrent.totalSelected;
|
||||||
return (
|
return (
|
||||||
<tr key={torrent.id}>
|
<tr key={torrent.id}>
|
||||||
<td>
|
<td>
|
||||||
@@ -105,17 +133,33 @@ export default function DownloadComponent() {
|
|||||||
</Text>
|
</Text>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</td>
|
</td>
|
||||||
|
<td>
|
||||||
|
<Text size="xs">{humanFileSize(size)}</Text>
|
||||||
|
</td>
|
||||||
|
{width > 576 ? (
|
||||||
<td>
|
<td>
|
||||||
<Text size="xs">{downloadSpeed > 0 ? `${downloadSpeed.toFixed(1)} Mb/s` : '-'}</Text>
|
<Text size="xs">{downloadSpeed > 0 ? `${downloadSpeed.toFixed(1)} Mb/s` : '-'}</Text>
|
||||||
</td>
|
</td>
|
||||||
|
) : (
|
||||||
|
''
|
||||||
|
)}
|
||||||
|
{width > 576 ? (
|
||||||
<td>
|
<td>
|
||||||
<Text size="xs">{uploadSpeed > 0 ? `${uploadSpeed.toFixed(1)} Mb/s` : '-'}</Text>
|
<Text size="xs">{uploadSpeed > 0 ? `${uploadSpeed.toFixed(1)} Mb/s` : '-'}</Text>
|
||||||
</td>
|
</td>
|
||||||
|
) : (
|
||||||
|
''
|
||||||
|
)}
|
||||||
|
<td>
|
||||||
|
<Text size="xs">{torrent.eta <= 0 ? '∞' : calculateETA(torrent.eta)}</Text>
|
||||||
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<Text>{(torrent.progress * 100).toFixed(1)}%</Text>
|
<Text>{(torrent.progress * 100).toFixed(1)}%</Text>
|
||||||
<Progress
|
<Progress
|
||||||
radius="lg"
|
radius="lg"
|
||||||
color={torrent.progress === 1 ? 'green' : 'blue'}
|
color={
|
||||||
|
torrent.state === 'paused' ? 'yellow' : torrent.progress === 1 ? 'green' : 'blue'
|
||||||
|
}
|
||||||
value={torrent.progress * 100}
|
value={torrent.progress * 100}
|
||||||
size="lg"
|
size="lg"
|
||||||
/>
|
/>
|
||||||
@@ -124,13 +168,23 @@ export default function DownloadComponent() {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const easteregg = (
|
||||||
|
<Center style={{ display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
|
||||||
|
<Image fit="cover" height={300} src="https://danjohnvelasco.github.io/images/empty.png" />
|
||||||
|
</Center>
|
||||||
|
);
|
||||||
return (
|
return (
|
||||||
<Group noWrap direction="column">
|
<Group noWrap grow direction="column" mt="xl">
|
||||||
<Title order={4}>Your torrents</Title>
|
<ScrollArea sx={{ height: 300 }}>
|
||||||
|
{rows.length > 0 ? (
|
||||||
<Table highlightOnHover>
|
<Table highlightOnHover>
|
||||||
<thead>{ths}</thead>
|
<thead>{ths}</thead>
|
||||||
<tbody>{rows}</tbody>
|
<tbody>{rows}</tbody>
|
||||||
</Table>
|
</Table>
|
||||||
|
) : (
|
||||||
|
easteregg
|
||||||
|
)}
|
||||||
|
</ScrollArea>
|
||||||
</Group>
|
</Group>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
168
src/components/modules/downloads/TotalDownloadsModule.tsx
Normal file
168
src/components/modules/downloads/TotalDownloadsModule.tsx
Normal file
@@ -0,0 +1,168 @@
|
|||||||
|
import { Text, Title, Group, useMantineTheme, Box, Card, ColorSwatch } from '@mantine/core';
|
||||||
|
import { IconDownload as Download } from '@tabler/icons';
|
||||||
|
import { useEffect, useState } from 'react';
|
||||||
|
import axios from 'axios';
|
||||||
|
import { NormalizedTorrent } from '@ctrl/shared-torrent';
|
||||||
|
import { linearGradientDef } from '@nivo/core';
|
||||||
|
import { Datum, ResponsiveLine } from '@nivo/line';
|
||||||
|
import { useListState } from '@mantine/hooks';
|
||||||
|
import { AddItemShelfButton } from '../../AppShelf/AddAppShelfItem';
|
||||||
|
import { useConfig } from '../../../tools/state';
|
||||||
|
import { humanFileSize } from '../../../tools/humanFileSize';
|
||||||
|
import { IModule } from '../modules';
|
||||||
|
import { useSetSafeInterval } from '../../../tools/hooks/useSetSafeInterval';
|
||||||
|
|
||||||
|
export const TotalDownloadsModule: IModule = {
|
||||||
|
title: 'Download Speed',
|
||||||
|
description: 'Show the current download speed of supported services',
|
||||||
|
icon: Download,
|
||||||
|
component: TotalDownloadsComponent,
|
||||||
|
};
|
||||||
|
|
||||||
|
interface torrentHistory {
|
||||||
|
x: number;
|
||||||
|
up: number;
|
||||||
|
down: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function TotalDownloadsComponent() {
|
||||||
|
const setSafeInterval = useSetSafeInterval();
|
||||||
|
const { config } = useConfig();
|
||||||
|
const downloadServices =
|
||||||
|
config.services.filter(
|
||||||
|
(service) =>
|
||||||
|
service.type === 'qBittorrent' ||
|
||||||
|
service.type === 'Transmission' ||
|
||||||
|
service.type === 'Deluge'
|
||||||
|
) ?? [];
|
||||||
|
|
||||||
|
const [torrentHistory, torrentHistoryHandlers] = useListState<torrentHistory>([]);
|
||||||
|
const [torrents, setTorrents] = useState<NormalizedTorrent[]>([]);
|
||||||
|
|
||||||
|
const totalDownloadSpeed = torrents.reduce((acc, torrent) => acc + torrent.downloadSpeed, 0);
|
||||||
|
const totalUploadSpeed = torrents.reduce((acc, torrent) => acc + torrent.uploadSpeed, 0);
|
||||||
|
useEffect(() => {
|
||||||
|
if (downloadServices.length === 0) return;
|
||||||
|
setSafeInterval(() => {
|
||||||
|
axios.post('/api/modules/downloads', { config }).then((response) => {
|
||||||
|
setTorrents(response.data);
|
||||||
|
});
|
||||||
|
}, 1000);
|
||||||
|
}, [config.services]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
torrentHistoryHandlers.append({
|
||||||
|
x: Date.now(),
|
||||||
|
down: totalDownloadSpeed,
|
||||||
|
up: totalUploadSpeed,
|
||||||
|
});
|
||||||
|
}, [totalDownloadSpeed, totalUploadSpeed]);
|
||||||
|
|
||||||
|
if (downloadServices.length === 0) {
|
||||||
|
return (
|
||||||
|
<Group direction="column">
|
||||||
|
<Title order={4}>No supported download clients found!</Title>
|
||||||
|
<Group noWrap>
|
||||||
|
<Text>Add a download service to view your current downloads...</Text>
|
||||||
|
<AddItemShelfButton />
|
||||||
|
</Group>
|
||||||
|
</Group>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const theme = useMantineTheme();
|
||||||
|
// Load the last 10 values from the history
|
||||||
|
const history = torrentHistory.slice(-10);
|
||||||
|
const chartDataUp = history.map((load, i) => ({
|
||||||
|
x: load.x,
|
||||||
|
y: load.up,
|
||||||
|
})) as Datum[];
|
||||||
|
const chartDataDown = history.map((load, i) => ({
|
||||||
|
x: load.x,
|
||||||
|
y: load.down,
|
||||||
|
})) as Datum[];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Group noWrap direction="column" grow>
|
||||||
|
<Title order={4}>Current download speed</Title>
|
||||||
|
<Group direction="column">
|
||||||
|
<Group>
|
||||||
|
<ColorSwatch size={12} color={theme.colors.green[5]} />
|
||||||
|
<Text>Download: {humanFileSize(totalDownloadSpeed)}/s</Text>
|
||||||
|
</Group>
|
||||||
|
<Group>
|
||||||
|
<ColorSwatch size={12} color={theme.colors.blue[5]} />
|
||||||
|
<Text>Upload: {humanFileSize(totalUploadSpeed)}/s</Text>
|
||||||
|
</Group>
|
||||||
|
</Group>
|
||||||
|
<Box
|
||||||
|
style={{
|
||||||
|
height: 200,
|
||||||
|
width: '100%',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<ResponsiveLine
|
||||||
|
isInteractive
|
||||||
|
enableSlices="x"
|
||||||
|
sliceTooltip={({ slice }) => {
|
||||||
|
const Download = slice.points[0].data.y as number;
|
||||||
|
const Upload = slice.points[1].data.y as number;
|
||||||
|
// Get the number of seconds since the last update.
|
||||||
|
const seconds = (Date.now() - (slice.points[0].data.x as number)) / 1000;
|
||||||
|
// Round to the nearest second.
|
||||||
|
const roundedSeconds = Math.round(seconds);
|
||||||
|
return (
|
||||||
|
<Card p="sm" radius="md" withBorder>
|
||||||
|
<Text size="md">{roundedSeconds} seconds ago</Text>
|
||||||
|
<Card.Section p="sm">
|
||||||
|
<Group direction="column">
|
||||||
|
<Group>
|
||||||
|
<ColorSwatch size={10} color={theme.colors.green[5]} />
|
||||||
|
<Text size="md">Download: {humanFileSize(Download)}</Text>
|
||||||
|
</Group>
|
||||||
|
<Group>
|
||||||
|
<ColorSwatch size={10} color={theme.colors.blue[5]} />
|
||||||
|
<Text size="md">Upload: {humanFileSize(Upload)}</Text>
|
||||||
|
</Group>
|
||||||
|
</Group>
|
||||||
|
</Card.Section>
|
||||||
|
</Card>
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
data={[
|
||||||
|
{
|
||||||
|
id: 'downloads',
|
||||||
|
data: chartDataUp,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'uploads',
|
||||||
|
data: chartDataDown,
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
curve="monotoneX"
|
||||||
|
yFormat=" >-.2f"
|
||||||
|
axisTop={null}
|
||||||
|
axisRight={null}
|
||||||
|
enablePoints={false}
|
||||||
|
animate={false}
|
||||||
|
enableGridX={false}
|
||||||
|
enableGridY={false}
|
||||||
|
enableArea
|
||||||
|
defs={[
|
||||||
|
linearGradientDef('gradientA', [
|
||||||
|
{ offset: 0, color: 'inherit' },
|
||||||
|
{ offset: 100, color: 'inherit', opacity: 0 },
|
||||||
|
]),
|
||||||
|
]}
|
||||||
|
fill={[{ match: '*', id: 'gradientA' }]}
|
||||||
|
colors={[
|
||||||
|
// Blue
|
||||||
|
theme.colors.blue[5],
|
||||||
|
// Green
|
||||||
|
theme.colors.green[5],
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
|
</Group>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1 +1,2 @@
|
|||||||
export { DownloadsModule } from './DownloadsModule';
|
export { DownloadsModule } from './DownloadsModule';
|
||||||
|
export { TotalDownloadsModule } from './TotalDownloadsModule';
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Button, Card, Group, Menu, Switch, TextInput, useMantineTheme } from '@mantine/core';
|
import { Button, Card, Group, Menu, Switch, TextInput, useMantineColorScheme } from '@mantine/core';
|
||||||
import { useConfig } from '../../tools/state';
|
import { useConfig } from '../../tools/state';
|
||||||
import { IModule } from './modules';
|
import { IModule } from './modules';
|
||||||
|
|
||||||
@@ -91,18 +91,50 @@ function getItems(module: IModule) {
|
|||||||
|
|
||||||
export function ModuleWrapper(props: any) {
|
export function ModuleWrapper(props: any) {
|
||||||
const { module }: { module: IModule } = props;
|
const { module }: { module: IModule } = props;
|
||||||
|
const { colorScheme } = useMantineColorScheme();
|
||||||
const { config, setConfig } = useConfig();
|
const { config, setConfig } = useConfig();
|
||||||
const enabledModules = config.modules ?? {};
|
const enabledModules = config.modules ?? {};
|
||||||
// Remove 'Module' from enabled modules titles
|
// Remove 'Module' from enabled modules titles
|
||||||
const isShown = enabledModules[module.title]?.enabled ?? false;
|
const isShown = enabledModules[module.title]?.enabled ?? false;
|
||||||
const theme = useMantineTheme();
|
|
||||||
const items: JSX.Element[] = getItems(module);
|
|
||||||
|
|
||||||
if (!isShown) {
|
if (!isShown) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card {...props} hidden={!isShown} withBorder radius="lg" shadow="sm">
|
<Card
|
||||||
|
{...props}
|
||||||
|
hidden={!isShown}
|
||||||
|
withBorder
|
||||||
|
radius="lg"
|
||||||
|
shadow="sm"
|
||||||
|
style={{
|
||||||
|
background: `rgba(${colorScheme === 'dark' ? '37, 38, 43,' : '255, 255, 255,'} \
|
||||||
|
${(config.settings.appOpacity || 100) / 100}`,
|
||||||
|
borderColor: `rgba(${colorScheme === 'dark' ? '37, 38, 43,' : '233, 236, 239,'} \
|
||||||
|
${(config.settings.appOpacity || 100) / 100}`,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<ModuleMenu
|
||||||
|
module={module}
|
||||||
|
styles={{
|
||||||
|
root: {
|
||||||
|
position: 'absolute',
|
||||||
|
top: 15,
|
||||||
|
right: 15,
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<module.component />
|
||||||
|
</Card>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function ModuleMenu(props: any) {
|
||||||
|
const { module, styles } = props;
|
||||||
|
const items: JSX.Element[] = getItems(module);
|
||||||
|
return (
|
||||||
|
<>
|
||||||
{module.options && (
|
{module.options && (
|
||||||
<Menu
|
<Menu
|
||||||
size="lg"
|
size="lg"
|
||||||
@@ -112,13 +144,11 @@ export function ModuleWrapper(props: any) {
|
|||||||
position="left"
|
position="left"
|
||||||
styles={{
|
styles={{
|
||||||
root: {
|
root: {
|
||||||
position: 'absolute',
|
...props?.styles?.root,
|
||||||
top: 15,
|
|
||||||
right: 15,
|
|
||||||
},
|
},
|
||||||
body: {
|
body: {
|
||||||
backgroundColor:
|
// Add shadow and elevation to the body
|
||||||
theme.colorScheme === 'dark' ? theme.colors.dark[5] : theme.colors.gray[1],
|
boxShadow: '0 0 14px 14px rgba(0, 0, 0, 0.05)',
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
@@ -128,7 +158,6 @@ export function ModuleWrapper(props: any) {
|
|||||||
))}
|
))}
|
||||||
</Menu>
|
</Menu>
|
||||||
)}
|
)}
|
||||||
<module.component />
|
</>
|
||||||
</Card>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { Indicator, Tooltip } from '@mantine/core';
|
|||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { motion } from 'framer-motion';
|
import { motion } from 'framer-motion';
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { Plug } from 'tabler-icons-react';
|
import { IconPlug as Plug } from '@tabler/icons';
|
||||||
import { useConfig } from '../../../tools/state';
|
import { useConfig } from '../../../tools/state';
|
||||||
import { IModule } from '../modules';
|
import { IModule } from '../modules';
|
||||||
|
|
||||||
@@ -32,7 +32,7 @@ export default function PingComponent(props: any) {
|
|||||||
.catch(() => {
|
.catch(() => {
|
||||||
setOnline('down');
|
setOnline('down');
|
||||||
});
|
});
|
||||||
}, []);
|
}, [config.modules?.[PingModule.title]?.enabled]);
|
||||||
if (!exists) {
|
if (!exists) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,12 @@
|
|||||||
import { TextInput, Kbd, createStyles, Text, Popover } from '@mantine/core';
|
import { Kbd, createStyles, Text, Popover, Autocomplete } from '@mantine/core';
|
||||||
import { useForm, useHotkeys } from '@mantine/hooks';
|
import { useDebouncedValue, useForm, useHotkeys } from '@mantine/hooks';
|
||||||
import { useRef, useState } from 'react';
|
import { useEffect, useRef, useState } from 'react';
|
||||||
import { Search, BrandYoutube, Download } from 'tabler-icons-react';
|
import {
|
||||||
|
IconSearch as Search,
|
||||||
|
IconBrandYoutube as BrandYoutube,
|
||||||
|
IconDownload as Download,
|
||||||
|
} from '@tabler/icons';
|
||||||
|
import axios from 'axios';
|
||||||
import { useConfig } from '../../../tools/state';
|
import { useConfig } from '../../../tools/state';
|
||||||
import { IModule } from '../modules';
|
import { IModule } from '../modules';
|
||||||
|
|
||||||
@@ -28,8 +33,22 @@ export default function SearchBar(props: any) {
|
|||||||
const [icon, setIcon] = useState(<Search />);
|
const [icon, setIcon] = useState(<Search />);
|
||||||
const queryUrl = config.settings.searchUrl ?? 'https://www.google.com/search?q=';
|
const queryUrl = config.settings.searchUrl ?? 'https://www.google.com/search?q=';
|
||||||
const textInput = useRef<HTMLInputElement>();
|
const textInput = useRef<HTMLInputElement>();
|
||||||
useHotkeys([['ctrl+K', () => textInput.current && textInput.current.focus()]]);
|
// Find a service with the type of 'Overseerr'
|
||||||
|
const form = useForm({
|
||||||
|
initialValues: {
|
||||||
|
query: '',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const [debounced, cancel] = useDebouncedValue(form.values.query, 250);
|
||||||
|
const [results, setResults] = useState<any[]>([]);
|
||||||
|
useEffect(() => {
|
||||||
|
if (form.values.query !== debounced || form.values.query === '') return;
|
||||||
|
axios
|
||||||
|
.get(`/api/modules/search?q=${form.values.query}`)
|
||||||
|
.then((res) => setResults(res.data ?? []));
|
||||||
|
}, [debounced]);
|
||||||
|
useHotkeys([['ctrl+K', () => textInput.current && textInput.current.focus()]]);
|
||||||
const { classes, cx } = useStyles();
|
const { classes, cx } = useStyles();
|
||||||
const rightSection = (
|
const rightSection = (
|
||||||
<div className={classes.hide}>
|
<div className={classes.hide}>
|
||||||
@@ -39,12 +58,6 @@ export default function SearchBar(props: any) {
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
const form = useForm({
|
|
||||||
initialValues: {
|
|
||||||
query: '',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
// If enabled modules doesn't contain the module, return null
|
// If enabled modules doesn't contain the module, return null
|
||||||
// If module in enabled
|
// If module in enabled
|
||||||
|
|
||||||
@@ -53,6 +66,10 @@ export default function SearchBar(props: any) {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const autocompleteData = results.map((result) => ({
|
||||||
|
label: result.phrase,
|
||||||
|
value: result.phrase,
|
||||||
|
}));
|
||||||
return (
|
return (
|
||||||
<form
|
<form
|
||||||
onChange={() => {
|
onChange={() => {
|
||||||
@@ -96,8 +113,9 @@ export default function SearchBar(props: any) {
|
|||||||
onFocusCapture={() => setOpened(true)}
|
onFocusCapture={() => setOpened(true)}
|
||||||
onBlurCapture={() => setOpened(false)}
|
onBlurCapture={() => setOpened(false)}
|
||||||
target={
|
target={
|
||||||
<TextInput
|
<Autocomplete
|
||||||
variant="filled"
|
variant="filled"
|
||||||
|
data={autocompleteData}
|
||||||
icon={icon}
|
icon={icon}
|
||||||
ref={textInput}
|
ref={textInput}
|
||||||
rightSectionWidth={90}
|
rightSectionWidth={90}
|
||||||
@@ -112,7 +130,7 @@ export default function SearchBar(props: any) {
|
|||||||
}
|
}
|
||||||
>
|
>
|
||||||
<Text>
|
<Text>
|
||||||
tip: Use the prefixes <b>!yt</b> and <b>!t</b> in front of your query to search on YouTube
|
Tip: Use the prefixes <b>!yt</b> and <b>!t</b> in front of your query to search on YouTube
|
||||||
or for a Torrent respectively.
|
or for a Torrent respectively.
|
||||||
</Text>
|
</Text>
|
||||||
</Popover>
|
</Popover>
|
||||||
|
|||||||
59
src/components/modules/system/SystemModule.tsx
Normal file
59
src/components/modules/system/SystemModule.tsx
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
import { Center, Group, RingProgress, Title, useMantineTheme } from '@mantine/core';
|
||||||
|
import { IconCpu } from '@tabler/icons';
|
||||||
|
import { useEffect, useState } from 'react';
|
||||||
|
import axios from 'axios';
|
||||||
|
import si from 'systeminformation';
|
||||||
|
import { useListState } from '@mantine/hooks';
|
||||||
|
import { IModule } from '../modules';
|
||||||
|
import { useSetSafeInterval } from '../../../tools/hooks/useSetSafeInterval';
|
||||||
|
|
||||||
|
export const SystemModule: IModule = {
|
||||||
|
title: 'System info',
|
||||||
|
description: 'Show the current CPU usage and memory usage',
|
||||||
|
icon: IconCpu,
|
||||||
|
component: SystemInfo,
|
||||||
|
};
|
||||||
|
|
||||||
|
interface ApiResponse {
|
||||||
|
cpu: si.Systeminformation.CpuData;
|
||||||
|
os: si.Systeminformation.OsData;
|
||||||
|
memory: si.Systeminformation.MemData;
|
||||||
|
load: si.Systeminformation.CurrentLoadData;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function SystemInfo(args: any) {
|
||||||
|
const [data, setData] = useState<ApiResponse>();
|
||||||
|
const setSafeInterval = useSetSafeInterval();
|
||||||
|
// Refresh data every second
|
||||||
|
useEffect(() => {
|
||||||
|
setSafeInterval(() => {
|
||||||
|
axios.get('/api/modules/systeminfo').then((res) => setData(res.data));
|
||||||
|
}, 1000);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
// Update data every time data changes
|
||||||
|
const [cpuLoadHistory, cpuLoadHistoryHandlers] =
|
||||||
|
useListState<si.Systeminformation.CurrentLoadData>([]);
|
||||||
|
|
||||||
|
// useEffect(() => {
|
||||||
|
|
||||||
|
// }, [data]);
|
||||||
|
|
||||||
|
const theme = useMantineTheme();
|
||||||
|
const currentLoad = data?.load?.currentLoad ?? 0;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Center>
|
||||||
|
<Group p="sm" direction="column" align="center">
|
||||||
|
<Title order={3}>Current CPU load</Title>
|
||||||
|
<RingProgress
|
||||||
|
size={150}
|
||||||
|
label={<Center>{`${currentLoad.toFixed(2)}%`}</Center>}
|
||||||
|
thickness={15}
|
||||||
|
roundCaps
|
||||||
|
sections={[{ value: currentLoad ?? 0, color: 'cyan' }]}
|
||||||
|
/>
|
||||||
|
</Group>
|
||||||
|
</Center>
|
||||||
|
);
|
||||||
|
}
|
||||||
1
src/components/modules/system/index.ts
Normal file
1
src/components/modules/system/index.ts
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export { SystemModule } from './SystemModule';
|
||||||
@@ -2,23 +2,23 @@ import { Group, Space, Title, Tooltip } from '@mantine/core';
|
|||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import {
|
import {
|
||||||
ArrowDownRight,
|
IconArrowDownRight as ArrowDownRight,
|
||||||
ArrowUpRight,
|
IconArrowUpRight as ArrowUpRight,
|
||||||
Cloud,
|
IconCloud as Cloud,
|
||||||
CloudFog,
|
IconCloudFog as CloudFog,
|
||||||
CloudRain,
|
IconCloudRain as CloudRain,
|
||||||
CloudSnow,
|
IconCloudSnow as CloudSnow,
|
||||||
CloudStorm,
|
IconCloudStorm as CloudStorm,
|
||||||
QuestionMark,
|
IconQuestionMark as QuestionMark,
|
||||||
Snowflake,
|
IconSnowflake as Snowflake,
|
||||||
Sun,
|
IconSun as Sun,
|
||||||
} from 'tabler-icons-react';
|
} from '@tabler/icons';
|
||||||
import { useConfig } from '../../../tools/state';
|
import { useConfig } from '../../../tools/state';
|
||||||
import { IModule } from '../modules';
|
import { IModule } from '../modules';
|
||||||
import { WeatherResponse } from './WeatherInterface';
|
import { WeatherResponse } from './WeatherInterface';
|
||||||
|
|
||||||
export const WeatherModule: IModule = {
|
export const WeatherModule: IModule = {
|
||||||
title: 'Weather (beta)',
|
title: 'Weather',
|
||||||
description: 'Look up the current weather in your location',
|
description: 'Look up the current weather in your location',
|
||||||
icon: Sun,
|
icon: Sun,
|
||||||
component: WeatherComponent,
|
component: WeatherComponent,
|
||||||
@@ -160,7 +160,7 @@ export default function WeatherComponent(props: any) {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
function usePerferedUnit(value: number): string {
|
function usePerferedUnit(value: number): string {
|
||||||
return isFahrenheit ? `${(value * (9 / 5)).toFixed(1)}°F` : `${value.toFixed(1)}°C`;
|
return isFahrenheit ? `${(value * (9 / 5) + 32).toFixed(1)}°F` : `${value.toFixed(1)}°C`;
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<Group p="sm" spacing="xs" direction="column">
|
<Group p="sm" spacing="xs" direction="column">
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import AppShelf from '../components/AppShelf/AppShelf';
|
|||||||
import LoadConfigComponent from '../components/Config/LoadConfig';
|
import LoadConfigComponent from '../components/Config/LoadConfig';
|
||||||
import { Config } from '../tools/types';
|
import { Config } from '../tools/types';
|
||||||
import { useConfig } from '../tools/state';
|
import { useConfig } from '../tools/state';
|
||||||
|
import Layout from '../components/layout/Layout';
|
||||||
|
|
||||||
export async function getServerSideProps(
|
export async function getServerSideProps(
|
||||||
context: GetServerSidePropsContext
|
context: GetServerSidePropsContext
|
||||||
@@ -46,9 +47,9 @@ export default function HomePage(props: any) {
|
|||||||
setConfig(initialConfig);
|
setConfig(initialConfig);
|
||||||
}, [initialConfig]);
|
}, [initialConfig]);
|
||||||
return (
|
return (
|
||||||
<>
|
<Layout>
|
||||||
<AppShelf />
|
<AppShelf />
|
||||||
<LoadConfigComponent />
|
<LoadConfigComponent />
|
||||||
</>
|
</Layout>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,17 +3,30 @@ import { useState } from 'react';
|
|||||||
import { AppProps } from 'next/app';
|
import { AppProps } from 'next/app';
|
||||||
import { getCookie, setCookies } from 'cookies-next';
|
import { getCookie, setCookies } from 'cookies-next';
|
||||||
import Head from 'next/head';
|
import Head from 'next/head';
|
||||||
import { MantineProvider, ColorScheme, ColorSchemeProvider } from '@mantine/core';
|
import { MantineProvider, ColorScheme, ColorSchemeProvider, MantineTheme } from '@mantine/core';
|
||||||
import { NotificationsProvider } from '@mantine/notifications';
|
import { NotificationsProvider } from '@mantine/notifications';
|
||||||
import { useHotkeys } from '@mantine/hooks';
|
import { useHotkeys } from '@mantine/hooks';
|
||||||
import Layout from '../components/layout/Layout';
|
|
||||||
import { ConfigProvider } from '../tools/state';
|
import { ConfigProvider } from '../tools/state';
|
||||||
import { theme } from '../tools/theme';
|
import { theme } from '../tools/theme';
|
||||||
|
import { styles } from '../tools/styles';
|
||||||
|
import { ColorTheme } from '../tools/color';
|
||||||
|
|
||||||
export default function App(props: AppProps & { colorScheme: ColorScheme }) {
|
export default function App(this: any, props: AppProps & { colorScheme: ColorScheme }) {
|
||||||
const { Component, pageProps } = props;
|
const { Component, pageProps } = props;
|
||||||
const [colorScheme, setColorScheme] = useState<ColorScheme>(props.colorScheme);
|
const [colorScheme, setColorScheme] = useState<ColorScheme>(props.colorScheme);
|
||||||
|
|
||||||
|
const [primaryColor, setPrimaryColor] = useState<MantineTheme['primaryColor']>('red');
|
||||||
|
const [secondaryColor, setSecondaryColor] = useState<MantineTheme['primaryColor']>('orange');
|
||||||
|
const [primaryShade, setPrimaryShade] = useState<MantineTheme['primaryShade']>(6);
|
||||||
|
const colorTheme = {
|
||||||
|
primaryColor,
|
||||||
|
secondaryColor,
|
||||||
|
setPrimaryColor,
|
||||||
|
setSecondaryColor,
|
||||||
|
primaryShade,
|
||||||
|
setPrimaryShade,
|
||||||
|
};
|
||||||
|
|
||||||
const toggleColorScheme = (value?: ColorScheme) => {
|
const toggleColorScheme = (value?: ColorScheme) => {
|
||||||
const nextColorScheme = value || (colorScheme === 'dark' ? 'light' : 'dark');
|
const nextColorScheme = value || (colorScheme === 'dark' ? 'light' : 'dark');
|
||||||
setColorScheme(nextColorScheme);
|
setColorScheme(nextColorScheme);
|
||||||
@@ -24,28 +37,31 @@ export default function App(props: AppProps & { colorScheme: ColorScheme }) {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Head>
|
<Head>
|
||||||
<title>Homarr 🦞</title>
|
|
||||||
<meta name="viewport" content="minimum-scale=1, initial-scale=1, width=device-width" />
|
<meta name="viewport" content="minimum-scale=1, initial-scale=1, width=device-width" />
|
||||||
<link rel="shortcut icon" href="/favicon.svg" />
|
|
||||||
</Head>
|
</Head>
|
||||||
|
|
||||||
<ColorSchemeProvider colorScheme={colorScheme} toggleColorScheme={toggleColorScheme}>
|
<ColorSchemeProvider colorScheme={colorScheme} toggleColorScheme={toggleColorScheme}>
|
||||||
|
<ColorTheme.Provider value={colorTheme}>
|
||||||
<MantineProvider
|
<MantineProvider
|
||||||
theme={{
|
theme={{
|
||||||
...theme,
|
...theme,
|
||||||
|
primaryColor,
|
||||||
|
primaryShade,
|
||||||
colorScheme,
|
colorScheme,
|
||||||
}}
|
}}
|
||||||
|
styles={{
|
||||||
|
...styles,
|
||||||
|
}}
|
||||||
withGlobalStyles
|
withGlobalStyles
|
||||||
withNormalizeCSS
|
withNormalizeCSS
|
||||||
>
|
>
|
||||||
<NotificationsProvider limit={4} position="bottom-left">
|
<NotificationsProvider limit={4} position="bottom-left">
|
||||||
<ConfigProvider>
|
<ConfigProvider>
|
||||||
<Layout>
|
|
||||||
<Component {...pageProps} />
|
<Component {...pageProps} />
|
||||||
</Layout>
|
|
||||||
</ConfigProvider>
|
</ConfigProvider>
|
||||||
</NotificationsProvider>
|
</NotificationsProvider>
|
||||||
</MantineProvider>
|
</MantineProvider>
|
||||||
|
</ColorTheme.Provider>
|
||||||
</ColorSchemeProvider>
|
</ColorSchemeProvider>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
15
src/pages/_middleware.ts
Normal file
15
src/pages/_middleware.ts
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
import { NextFetchEvent, NextRequest, NextResponse } from 'next/server';
|
||||||
|
|
||||||
|
export function middleware(req: NextRequest, ev: NextFetchEvent) {
|
||||||
|
const ok = req.cookies.password === process.env.PASSWORD;
|
||||||
|
const url = req.nextUrl.clone();
|
||||||
|
if (
|
||||||
|
!ok &&
|
||||||
|
url.pathname !== '/login' &&
|
||||||
|
process.env.PASSWORD &&
|
||||||
|
url.pathname !== '/api/configs/tryPassword'
|
||||||
|
) {
|
||||||
|
url.pathname = '/login';
|
||||||
|
}
|
||||||
|
return NextResponse.rewrite(url);
|
||||||
|
}
|
||||||
25
src/pages/api/configs/tryPassword.tsx
Normal file
25
src/pages/api/configs/tryPassword.tsx
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
import { NextApiRequest, NextApiResponse } from 'next';
|
||||||
|
|
||||||
|
function Post(req: NextApiRequest, res: NextApiResponse) {
|
||||||
|
const { tried } = req.body;
|
||||||
|
// Try to match the password with the PASSWORD env variable
|
||||||
|
if (tried === process.env.PASSWORD) {
|
||||||
|
return res.status(200).json({
|
||||||
|
success: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return res.status(200).json({
|
||||||
|
success: false,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export default async (req: NextApiRequest, res: NextApiResponse) => {
|
||||||
|
// Filter out if the reuqest is a POST or a GET
|
||||||
|
if (req.method === 'POST') {
|
||||||
|
return Post(req, res);
|
||||||
|
}
|
||||||
|
return res.status(405).json({
|
||||||
|
statusCode: 405,
|
||||||
|
message: 'Method not allowed',
|
||||||
|
});
|
||||||
|
};
|
||||||
67
src/pages/api/modules/calendar.ts
Normal file
67
src/pages/api/modules/calendar.ts
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
import axios from 'axios';
|
||||||
|
import { NextApiRequest, NextApiResponse } from 'next';
|
||||||
|
import { serviceItem } from '../../../tools/types';
|
||||||
|
|
||||||
|
async function Post(req: NextApiRequest, res: NextApiResponse) {
|
||||||
|
// Parse req.body as a ServiceItem
|
||||||
|
const nextMonth = new Date(new Date().setMonth(new Date().getMonth() + 2)).toISOString();
|
||||||
|
const lastMonth = new Date(new Date().setMonth(new Date().getMonth() - 2)).toISOString();
|
||||||
|
const TypeToUrl: { service: string; url: string }[] = [
|
||||||
|
{
|
||||||
|
service: 'sonarr',
|
||||||
|
url: '/api/calendar',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
service: 'radarr',
|
||||||
|
url: '/api/v3/calendar',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
service: 'lidarr',
|
||||||
|
url: '/api/v1/calendar',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
service: 'readarr',
|
||||||
|
url: '/api/v1/calendar',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
const service: serviceItem = req.body;
|
||||||
|
const { type } = req.query;
|
||||||
|
if (!type) {
|
||||||
|
return res.status(400).json({
|
||||||
|
message: 'Missing required parameter in url: type',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (!service) {
|
||||||
|
return res.status(400).json({
|
||||||
|
message: 'Missing required parameter in body: service',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// Match the type to the correct url
|
||||||
|
const url = TypeToUrl.find((x) => x.service === type);
|
||||||
|
if (!url) {
|
||||||
|
return res.status(400).json({
|
||||||
|
message: 'Invalid type',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// Get the origin URL
|
||||||
|
const { origin } = new URL(service.url);
|
||||||
|
const pined = `${origin}${url?.url}?apiKey=${service.apiKey}&end=${nextMonth}&start=${lastMonth}`;
|
||||||
|
const data = await axios.get(
|
||||||
|
`${origin}${url?.url}?apiKey=${service.apiKey}&end=${nextMonth}&start=${lastMonth}`
|
||||||
|
);
|
||||||
|
return res.status(200).json(data.data);
|
||||||
|
// // Make a request to the URL
|
||||||
|
// const response = await axios.get(url);
|
||||||
|
// // Return the response
|
||||||
|
}
|
||||||
|
|
||||||
|
export default async (req: NextApiRequest, res: NextApiResponse) => {
|
||||||
|
// Filter out if the reuqest is a POST or a GET
|
||||||
|
if (req.method === 'POST') {
|
||||||
|
return Post(req, res);
|
||||||
|
}
|
||||||
|
return res.status(405).json({
|
||||||
|
statusCode: 405,
|
||||||
|
message: 'Method not allowed',
|
||||||
|
});
|
||||||
|
};
|
||||||
@@ -1,42 +1,60 @@
|
|||||||
import { Deluge } from '@ctrl/deluge';
|
import { Deluge } from '@ctrl/deluge';
|
||||||
import { QBittorrent } from '@ctrl/qbittorrent';
|
import { QBittorrent } from '@ctrl/qbittorrent';
|
||||||
|
import { NormalizedTorrent } from '@ctrl/shared-torrent';
|
||||||
|
import { Transmission } from '@ctrl/transmission';
|
||||||
import { NextApiRequest, NextApiResponse } from 'next';
|
import { NextApiRequest, NextApiResponse } from 'next';
|
||||||
|
import { Config } from '../../../tools/types';
|
||||||
|
|
||||||
async function Post(req: NextApiRequest, res: NextApiResponse) {
|
async function Post(req: NextApiRequest, res: NextApiResponse) {
|
||||||
// Get the type of service from the request url
|
// Get the type of service from the request url
|
||||||
const { dlclient } = req.query;
|
const torrents: NormalizedTorrent[] = [];
|
||||||
const { body } = req;
|
const { config }: { config: Config } = req.body;
|
||||||
// Get login, password and url from the body
|
const qBittorrentService = config.services
|
||||||
const { username, password, url } = body;
|
.filter((service) => service.type === 'qBittorrent')
|
||||||
if (!dlclient || (!username && !password) || !url) {
|
.at(0);
|
||||||
return res.status(400).json({
|
const delugeService = config.services.filter((service) => service.type === 'Deluge').at(0);
|
||||||
error: 'Wrong request',
|
const transmissionService = config.services
|
||||||
|
.filter((service) => service.type === 'Transmission')
|
||||||
|
.at(0);
|
||||||
|
if (!qBittorrentService && !delugeService && !transmissionService) {
|
||||||
|
return res.status(500).json({
|
||||||
|
statusCode: 500,
|
||||||
|
message: 'Missing service',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
let client: Deluge | QBittorrent;
|
if (qBittorrentService) {
|
||||||
switch (dlclient) {
|
torrents.push(
|
||||||
case 'qbit':
|
...(
|
||||||
client = new QBittorrent({
|
await new QBittorrent({
|
||||||
baseUrl: new URL(url).origin,
|
baseUrl: qBittorrentService.url,
|
||||||
username,
|
username: qBittorrentService.username,
|
||||||
password,
|
password: qBittorrentService.password,
|
||||||
});
|
}).getAllData()
|
||||||
break;
|
).torrents
|
||||||
case 'deluge':
|
);
|
||||||
client = new Deluge({
|
|
||||||
baseUrl: new URL(url).origin,
|
|
||||||
password,
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return res.status(400).json({
|
|
||||||
error: 'Wrong request',
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
const data = await client.getAllData();
|
if (delugeService) {
|
||||||
res.status(200).json({
|
torrents.push(
|
||||||
torrents: data.torrents,
|
...(
|
||||||
});
|
await new Deluge({
|
||||||
|
baseUrl: delugeService.url,
|
||||||
|
password: delugeService.password,
|
||||||
|
}).getAllData()
|
||||||
|
).torrents
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (transmissionService) {
|
||||||
|
torrents.push(
|
||||||
|
...(
|
||||||
|
await new Transmission({
|
||||||
|
baseUrl: transmissionService.url,
|
||||||
|
username: transmissionService.username,
|
||||||
|
password: transmissionService.password,
|
||||||
|
}).getAllData()
|
||||||
|
).torrents
|
||||||
|
);
|
||||||
|
}
|
||||||
|
res.status(200).json(torrents);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default async (req: NextApiRequest, res: NextApiResponse) => {
|
export default async (req: NextApiRequest, res: NextApiResponse) => {
|
||||||
|
|||||||
19
src/pages/api/modules/search.ts
Normal file
19
src/pages/api/modules/search.ts
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
import axios from 'axios';
|
||||||
|
import { NextApiRequest, NextApiResponse } from 'next';
|
||||||
|
|
||||||
|
async function Get(req: NextApiRequest, res: NextApiResponse) {
|
||||||
|
const { q } = req.query;
|
||||||
|
const response = await axios.get(`https://duckduckgo.com/ac/?q=${q}`);
|
||||||
|
res.status(200).json(response.data);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default async (req: NextApiRequest, res: NextApiResponse) => {
|
||||||
|
// Filter out if the reuqest is a POST or a GET
|
||||||
|
if (req.method === 'GET') {
|
||||||
|
return Get(req, res);
|
||||||
|
}
|
||||||
|
return res.status(405).json({
|
||||||
|
statusCode: 405,
|
||||||
|
message: 'Method not allowed',
|
||||||
|
});
|
||||||
|
};
|
||||||
30
src/pages/api/modules/systeminfo.ts
Normal file
30
src/pages/api/modules/systeminfo.ts
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
import { NextApiRequest, NextApiResponse } from 'next';
|
||||||
|
import si from 'systeminformation';
|
||||||
|
|
||||||
|
async function Get(req: NextApiRequest, res: NextApiResponse) {
|
||||||
|
const [osInfo, cpuInfo, memInfo, cpuLoad] = await Promise.all([
|
||||||
|
si.osInfo(),
|
||||||
|
si.cpu(),
|
||||||
|
si.mem(),
|
||||||
|
si.currentLoad(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
const sysinfo = {
|
||||||
|
cpu: cpuInfo,
|
||||||
|
os: osInfo,
|
||||||
|
mem: memInfo,
|
||||||
|
load: cpuLoad,
|
||||||
|
};
|
||||||
|
res.status(200).json(sysinfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default async (req: NextApiRequest, res: NextApiResponse) => {
|
||||||
|
// Filter out if the reuqest is a POST or a GET
|
||||||
|
if (req.method === 'GET') {
|
||||||
|
return Get(req, res);
|
||||||
|
}
|
||||||
|
return res.status(405).json({
|
||||||
|
statusCode: 405,
|
||||||
|
message: 'Method not allowed',
|
||||||
|
});
|
||||||
|
};
|
||||||
@@ -1,15 +1,14 @@
|
|||||||
import { getCookie, setCookies } from 'cookies-next';
|
import { getCookie, setCookies } from 'cookies-next';
|
||||||
import { GetServerSidePropsContext } from 'next';
|
import { GetServerSidePropsContext } from 'next';
|
||||||
import path from 'path';
|
|
||||||
import fs from 'fs';
|
|
||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
import AppShelf from '../components/AppShelf/AppShelf';
|
import AppShelf from '../components/AppShelf/AppShelf';
|
||||||
import LoadConfigComponent from '../components/Config/LoadConfig';
|
import LoadConfigComponent from '../components/Config/LoadConfig';
|
||||||
import { Config } from '../tools/types';
|
import { Config } from '../tools/types';
|
||||||
import { useConfig } from '../tools/state';
|
import { useConfig } from '../tools/state';
|
||||||
import { migrateToIdConfig } from '../tools/migrate';
|
import { migrateToIdConfig } from '../tools/migrate';
|
||||||
import { ModuleWrapper } from '../components/modules/moduleWrapper';
|
import { getConfig } from '../tools/getConfig';
|
||||||
import { DownloadsModule } from '../components/modules';
|
import { useColorTheme } from '../tools/color';
|
||||||
|
import Layout from '../components/layout/Layout';
|
||||||
|
|
||||||
export async function getServerSideProps({
|
export async function getServerSideProps({
|
||||||
req,
|
req,
|
||||||
@@ -17,47 +16,31 @@ export async function getServerSideProps({
|
|||||||
}: GetServerSidePropsContext): Promise<{ props: { config: Config } }> {
|
}: GetServerSidePropsContext): Promise<{ props: { config: Config } }> {
|
||||||
let cookie = getCookie('config-name', { req, res });
|
let cookie = getCookie('config-name', { req, res });
|
||||||
if (!cookie) {
|
if (!cookie) {
|
||||||
setCookies('config-name', 'default', { req, res, maxAge: 60 * 60 * 24 * 30 });
|
setCookies('config-name', 'default', {
|
||||||
|
req,
|
||||||
|
res,
|
||||||
|
maxAge: 60 * 60 * 24 * 30,
|
||||||
|
sameSite: 'strict',
|
||||||
|
});
|
||||||
cookie = 'default';
|
cookie = 'default';
|
||||||
}
|
}
|
||||||
// Check if the config file exists
|
return getConfig(cookie as string);
|
||||||
const configPath = path.join(process.cwd(), 'data/configs', `${cookie}.json`);
|
|
||||||
if (!fs.existsSync(configPath)) {
|
|
||||||
return {
|
|
||||||
props: {
|
|
||||||
config: {
|
|
||||||
name: cookie.toString(),
|
|
||||||
services: [],
|
|
||||||
settings: {
|
|
||||||
searchUrl: 'https://www.google.com/search?q=',
|
|
||||||
},
|
|
||||||
modules: {},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
const config = fs.readFileSync(configPath, 'utf8');
|
|
||||||
// Print loaded config
|
|
||||||
return {
|
|
||||||
props: {
|
|
||||||
config: JSON.parse(config),
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function HomePage(props: any) {
|
export default function HomePage(props: any) {
|
||||||
const { config: initialConfig }: { config: Config } = props;
|
const { config: initialConfig }: { config: Config } = props;
|
||||||
const { config, loadConfig, setConfig, getConfigs } = useConfig();
|
const { setConfig } = useConfig();
|
||||||
|
const { setPrimaryColor, setSecondaryColor } = useColorTheme();
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const migratedConfig = migrateToIdConfig(initialConfig);
|
const migratedConfig = migrateToIdConfig(initialConfig);
|
||||||
|
setPrimaryColor(migratedConfig.settings.primaryColor || 'red');
|
||||||
|
setSecondaryColor(migratedConfig.settings.secondaryColor || 'orange');
|
||||||
setConfig(migratedConfig);
|
setConfig(migratedConfig);
|
||||||
}, [initialConfig]);
|
}, [initialConfig]);
|
||||||
return (
|
return (
|
||||||
<>
|
<Layout>
|
||||||
<AppShelf />
|
<AppShelf />
|
||||||
<LoadConfigComponent />
|
<LoadConfigComponent />
|
||||||
<ModuleWrapper mt="xl" module={DownloadsModule} />
|
</Layout>
|
||||||
</>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
111
src/pages/login.tsx
Normal file
111
src/pages/login.tsx
Normal file
@@ -0,0 +1,111 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { PasswordInput, Anchor, Paper, Title, Text, Container, Group, Button } from '@mantine/core';
|
||||||
|
import { setCookies } from 'cookies-next';
|
||||||
|
import { useForm } from '@mantine/hooks';
|
||||||
|
import { showNotification, updateNotification } from '@mantine/notifications';
|
||||||
|
import axios from 'axios';
|
||||||
|
import { IconCheck, IconX } from '@tabler/icons';
|
||||||
|
|
||||||
|
// TODO: Add links to the wiki articles about the login process.
|
||||||
|
export default function AuthenticationTitle() {
|
||||||
|
const form = useForm({
|
||||||
|
initialValues: {
|
||||||
|
password: '',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
return (
|
||||||
|
<Container
|
||||||
|
size={420}
|
||||||
|
style={{
|
||||||
|
height: '100vh',
|
||||||
|
display: 'flex',
|
||||||
|
width: 420,
|
||||||
|
flexDirection: 'column',
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'center',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Title
|
||||||
|
align="center"
|
||||||
|
sx={(theme) => ({ fontFamily: `Greycliff CF, ${theme.fontFamily}`, fontWeight: 900 })}
|
||||||
|
>
|
||||||
|
Welcome back!
|
||||||
|
</Title>
|
||||||
|
<Text color="dimmed" size="sm" align="center" mt={5}>
|
||||||
|
Please enter the{' '}
|
||||||
|
<Anchor<'a'> href="#" size="sm" onClick={(event) => event.preventDefault()}>
|
||||||
|
password
|
||||||
|
</Anchor>
|
||||||
|
</Text>
|
||||||
|
|
||||||
|
<Paper withBorder shadow="md" p={30} mt={30} radius="md" style={{ width: 420 }}>
|
||||||
|
<form
|
||||||
|
onSubmit={form.onSubmit((values) => {
|
||||||
|
setCookies('password', values.password, {
|
||||||
|
maxAge: 60 * 60 * 24 * 30,
|
||||||
|
sameSite: 'lax',
|
||||||
|
});
|
||||||
|
showNotification({
|
||||||
|
id: 'load-data',
|
||||||
|
loading: true,
|
||||||
|
title: 'Checking your password',
|
||||||
|
message: 'Your password is being checked...',
|
||||||
|
autoClose: false,
|
||||||
|
disallowClose: true,
|
||||||
|
});
|
||||||
|
axios
|
||||||
|
.post('/api/configs/tryPassword', {
|
||||||
|
tried: values.password,
|
||||||
|
})
|
||||||
|
.then((res) => {
|
||||||
|
setTimeout(() => {
|
||||||
|
if (res.data.success === true) {
|
||||||
|
updateNotification({
|
||||||
|
id: 'load-data',
|
||||||
|
color: 'teal',
|
||||||
|
title: 'Password correct',
|
||||||
|
message:
|
||||||
|
'Notification will close in 2 seconds, you can close this notification now',
|
||||||
|
icon: <IconCheck />,
|
||||||
|
autoClose: 300,
|
||||||
|
onClose: () => {
|
||||||
|
window.location.reload();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (res.data.success === false) {
|
||||||
|
updateNotification({
|
||||||
|
id: 'load-data',
|
||||||
|
color: 'red',
|
||||||
|
title: 'Password is wrong, please try again.',
|
||||||
|
message:
|
||||||
|
'Notification will close in 2 seconds, you can close this notification now',
|
||||||
|
icon: <IconX />,
|
||||||
|
autoClose: 2000,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, 500);
|
||||||
|
});
|
||||||
|
})}
|
||||||
|
>
|
||||||
|
<PasswordInput
|
||||||
|
id="password"
|
||||||
|
label="Password"
|
||||||
|
placeholder="Your password"
|
||||||
|
required
|
||||||
|
mt="md"
|
||||||
|
{...form.getInputProps('password')}
|
||||||
|
/>
|
||||||
|
<Group position="apart" mt="md">
|
||||||
|
<Anchor<'a'> onClick={(event) => event.preventDefault()} href="#" size="sm">
|
||||||
|
Forgot password?
|
||||||
|
</Anchor>
|
||||||
|
</Group>
|
||||||
|
<Button fullWidth type="submit" mt="xl">
|
||||||
|
Sign in
|
||||||
|
</Button>
|
||||||
|
</form>
|
||||||
|
</Paper>
|
||||||
|
</Container>
|
||||||
|
);
|
||||||
|
}
|
||||||
28
src/tools/color.ts
Normal file
28
src/tools/color.ts
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
import { createContext, useContext } from 'react';
|
||||||
|
import { MantineTheme } from '@mantine/core';
|
||||||
|
|
||||||
|
type colorThemeContextType = {
|
||||||
|
primaryColor: MantineTheme['primaryColor'];
|
||||||
|
secondaryColor: MantineTheme['primaryColor'];
|
||||||
|
primaryShade: MantineTheme['primaryShade'];
|
||||||
|
setPrimaryColor: (color: MantineTheme['primaryColor']) => void;
|
||||||
|
setSecondaryColor: (color: MantineTheme['primaryColor']) => void;
|
||||||
|
setPrimaryShade: (shade: MantineTheme['primaryShade']) => void;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const ColorTheme = createContext<colorThemeContextType>({
|
||||||
|
primaryColor: 'red',
|
||||||
|
secondaryColor: 'orange',
|
||||||
|
primaryShade: 6,
|
||||||
|
setPrimaryColor: () => {},
|
||||||
|
setSecondaryColor: () => {},
|
||||||
|
setPrimaryShade: () => {},
|
||||||
|
});
|
||||||
|
|
||||||
|
export function useColorTheme() {
|
||||||
|
const context = useContext(ColorTheme);
|
||||||
|
if (context === undefined) {
|
||||||
|
throw new Error('useColorTheme must be used within a ColorTheme.Provider');
|
||||||
|
}
|
||||||
|
return context;
|
||||||
|
}
|
||||||
31
src/tools/getConfig.ts
Normal file
31
src/tools/getConfig.ts
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
import path from 'path';
|
||||||
|
import fs from 'fs';
|
||||||
|
|
||||||
|
export function getConfig(name: string) {
|
||||||
|
// Check if the config file exists
|
||||||
|
const configPath = path.join(process.cwd(), 'data/configs', `${name}.json`);
|
||||||
|
if (!fs.existsSync(configPath)) {
|
||||||
|
return {
|
||||||
|
props: {
|
||||||
|
configName: name,
|
||||||
|
config: {
|
||||||
|
name: name.toString(),
|
||||||
|
services: [],
|
||||||
|
settings: {
|
||||||
|
searchUrl: 'https://www.google.com/search?q=',
|
||||||
|
},
|
||||||
|
modules: {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const config = fs.readFileSync(configPath, 'utf8');
|
||||||
|
// Print loaded config
|
||||||
|
return {
|
||||||
|
props: {
|
||||||
|
configName: name,
|
||||||
|
config: JSON.parse(config),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
22
src/tools/hooks/useSetSafeInterval.tsx
Normal file
22
src/tools/hooks/useSetSafeInterval.tsx
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
import { useEffect, useRef } from 'react';
|
||||||
|
|
||||||
|
export function useSetSafeInterval() {
|
||||||
|
const timers = useRef<NodeJS.Timer[]>([]);
|
||||||
|
|
||||||
|
function setSafeInterval(callback: () => void, delay: number) {
|
||||||
|
const newInterval = setInterval(callback, delay);
|
||||||
|
timers.current.push(newInterval);
|
||||||
|
return newInterval;
|
||||||
|
}
|
||||||
|
|
||||||
|
useEffect(
|
||||||
|
() => () => {
|
||||||
|
timers.current.forEach((t) => {
|
||||||
|
clearInterval(t);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
[]
|
||||||
|
);
|
||||||
|
|
||||||
|
return setSafeInterval;
|
||||||
|
}
|
||||||
31
src/tools/humanFileSize.ts
Normal file
31
src/tools/humanFileSize.ts
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
/**
|
||||||
|
* Format bytes as human-readable text.
|
||||||
|
*
|
||||||
|
* @param bytes Number of bytes.
|
||||||
|
* @param si True to use metric (SI) units, aka powers of 1000. False to use
|
||||||
|
* binary (IEC), aka powers of 1024.
|
||||||
|
* @param dp Number of decimal places to display.
|
||||||
|
*
|
||||||
|
* @return Formatted string.
|
||||||
|
*/
|
||||||
|
export function humanFileSize(initialBytes: number, si = true, dp = 1) {
|
||||||
|
const thresh = si ? 1000 : 1024;
|
||||||
|
let bytes = initialBytes;
|
||||||
|
|
||||||
|
if (Math.abs(bytes) < thresh) {
|
||||||
|
return `${bytes} B`;
|
||||||
|
}
|
||||||
|
|
||||||
|
const units = si
|
||||||
|
? ['kb', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']
|
||||||
|
: ['KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'];
|
||||||
|
let u = -1;
|
||||||
|
const r = 10 ** dp;
|
||||||
|
|
||||||
|
do {
|
||||||
|
bytes /= thresh;
|
||||||
|
u += 1;
|
||||||
|
} while (Math.round(Math.abs(bytes) * r) / r >= thresh && u < units.length - 1);
|
||||||
|
|
||||||
|
return `${bytes.toFixed(dp)} ${units[u]}`;
|
||||||
|
}
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
import { showNotification } from '@mantine/notifications';
|
import { showNotification } from '@mantine/notifications';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { createContext, ReactNode, useContext, useState } from 'react';
|
import { createContext, ReactNode, useContext, useState } from 'react';
|
||||||
import { Check, X } from 'tabler-icons-react';
|
import { IconCheck as Check, IconX as X } from '@tabler/icons';
|
||||||
import { Config } from './types';
|
import { Config } from './types';
|
||||||
|
|
||||||
type configContextType = {
|
type configContextType = {
|
||||||
|
|||||||
12
src/tools/styles.ts
Normal file
12
src/tools/styles.ts
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
import { MantineProviderProps } from '@mantine/core';
|
||||||
|
|
||||||
|
export const styles: MantineProviderProps['styles'] = {
|
||||||
|
Checkbox: {
|
||||||
|
input: { cursor: 'pointer' },
|
||||||
|
label: { cursor: 'pointer' },
|
||||||
|
},
|
||||||
|
Switch: {
|
||||||
|
input: { cursor: 'pointer' },
|
||||||
|
label: { cursor: 'pointer' },
|
||||||
|
},
|
||||||
|
};
|
||||||
@@ -1,7 +1,17 @@
|
|||||||
|
import { MantineTheme } from '@mantine/core';
|
||||||
import { OptionValues } from '../components/modules/modules';
|
import { OptionValues } from '../components/modules/modules';
|
||||||
|
|
||||||
export interface Settings {
|
export interface Settings {
|
||||||
searchUrl: string;
|
searchUrl: string;
|
||||||
|
title?: string;
|
||||||
|
logo?: string;
|
||||||
|
favicon?: string;
|
||||||
|
primaryColor?: MantineTheme['primaryColor'];
|
||||||
|
secondaryColor?: MantineTheme['primaryColor'];
|
||||||
|
primaryShade?: MantineTheme['primaryShade'];
|
||||||
|
background?: string;
|
||||||
|
appOpacity?: number;
|
||||||
|
widgetPosition?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Config {
|
export interface Config {
|
||||||
@@ -31,6 +41,7 @@ export const ServiceTypeList = [
|
|||||||
'Readarr',
|
'Readarr',
|
||||||
'Sonarr',
|
'Sonarr',
|
||||||
'qBittorrent',
|
'qBittorrent',
|
||||||
|
'Transmission',
|
||||||
];
|
];
|
||||||
export type ServiceType =
|
export type ServiceType =
|
||||||
| 'Other'
|
| 'Other'
|
||||||
@@ -41,7 +52,8 @@ export type ServiceType =
|
|||||||
| 'Radarr'
|
| 'Radarr'
|
||||||
| 'Readarr'
|
| 'Readarr'
|
||||||
| 'Sonarr'
|
| 'Sonarr'
|
||||||
| 'qBittorrent';
|
| 'qBittorrent'
|
||||||
|
| 'Transmission';
|
||||||
|
|
||||||
export interface serviceItem {
|
export interface serviceItem {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -49,7 +61,9 @@ export interface serviceItem {
|
|||||||
type: string;
|
type: string;
|
||||||
url: string;
|
url: string;
|
||||||
icon: string;
|
icon: string;
|
||||||
|
category?: string;
|
||||||
apiKey?: string;
|
apiKey?: string;
|
||||||
password?: string;
|
password?: string;
|
||||||
username?: string;
|
username?: string;
|
||||||
|
openedUrl?: string;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"target": "es5",
|
"target": "es5",
|
||||||
"lib": ["dom", "dom.iterable", "esnext"],
|
"lib": [
|
||||||
|
"dom",
|
||||||
|
"dom.iterable",
|
||||||
|
"esnext"
|
||||||
|
],
|
||||||
"allowJs": true,
|
"allowJs": true,
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
"strict": true,
|
"strict": true,
|
||||||
@@ -15,6 +19,13 @@
|
|||||||
"jsx": "preserve",
|
"jsx": "preserve",
|
||||||
"incremental": true
|
"incremental": true
|
||||||
},
|
},
|
||||||
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "next.config.js"],
|
"include": [
|
||||||
"exclude": ["node_modules"]
|
"next-env.d.ts",
|
||||||
|
"**/*.ts",
|
||||||
|
"**/*.tsx",
|
||||||
|
"next.config.js"
|
||||||
|
],
|
||||||
|
"exclude": [
|
||||||
|
"node_modules"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user