From e61e986028dded6a9493a8f2cf1e745ddd5dbc57 Mon Sep 17 00:00:00 2001 From: Aj - Thomas Date: Thu, 12 May 2022 23:04:59 +0200 Subject: [PATCH 01/11] Styling modules --- components/modules/calendar/CalendarModule.tsx | 3 +++ components/modules/calendar/MediaDisplay.tsx | 9 ++++++++- components/modules/moduleWrapper.tsx | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/components/modules/calendar/CalendarModule.tsx b/components/modules/calendar/CalendarModule.tsx index 951cae590..0af7a9a92 100644 --- a/components/modules/calendar/CalendarModule.tsx +++ b/components/modules/calendar/CalendarModule.tsx @@ -121,6 +121,9 @@ function DayComponent(props: any) { {sonarrFiltered.length > 0 && } setOpened(false)} opened={opened} diff --git a/components/modules/calendar/MediaDisplay.tsx b/components/modules/calendar/MediaDisplay.tsx index dcea62458..1cc876a3e 100644 --- a/components/modules/calendar/MediaDisplay.tsx +++ b/components/modules/calendar/MediaDisplay.tsx @@ -15,7 +15,14 @@ function MediaDisplay(props: { media: IMedia }) { const { media }: { media: IMedia } = props; return ( - {media.title} + {media.title} ({ diff --git a/components/modules/moduleWrapper.tsx b/components/modules/moduleWrapper.tsx index 91be8a7ff..52170c7be 100644 --- a/components/modules/moduleWrapper.tsx +++ b/components/modules/moduleWrapper.tsx @@ -20,7 +20,7 @@ export default function ModuleWrapper(props: any) { shadow="sm" style={{ // Make background color of the card depend on the theme - backgroundColor: theme.colorScheme === 'dark' ? theme.colors.dark[6] : 'white', + backgroundColor: theme.colorScheme === 'dark' ? theme.colors.dark[5] : 'white', }} > From 91f636ca9775c3288c283f49f18b40e7584c8a83 Mon Sep 17 00:00:00 2001 From: Aj - Thomas Date: Thu, 12 May 2022 19:28:10 +0200 Subject: [PATCH 02/11] Basic backend support and config loading from file --- components/Config/SelectConfig.tsx | 16 ++++++ data/configs/default.json | 16 ++++++ package.json | 1 + pages/_app.tsx | 4 +- pages/api/configs/[slug].ts | 61 +++++++++++++++++++++++ pages/api/configs/index.ts | 28 +++++++++++ pages/tryconfig.tsx | 52 +++++++++++++++++++ tools/state.tsx | 80 ++++++++++++++---------------- tools/types.ts | 1 + yarn.lock | 22 ++++++++ 10 files changed, 235 insertions(+), 46 deletions(-) create mode 100644 components/Config/SelectConfig.tsx create mode 100644 data/configs/default.json create mode 100644 pages/api/configs/[slug].ts create mode 100644 pages/api/configs/index.ts create mode 100644 pages/tryconfig.tsx diff --git a/components/Config/SelectConfig.tsx b/components/Config/SelectConfig.tsx new file mode 100644 index 000000000..4abd659fb --- /dev/null +++ b/components/Config/SelectConfig.tsx @@ -0,0 +1,16 @@ +import { Select } from '@mantine/core'; +import { useState } from 'react'; + +export default function SelectConfig(props: any) { + const [value, setValue] = useState(''); + return ( + { + loadConfig(e ?? 'default'); + }} + data={ + // If config list is empty, return the current config + configList.length === 0 ? [config.name] : configList + } + /> + + + ); } diff --git a/tools/state.tsx b/tools/state.tsx index 6c1d25754..64a99b48d 100644 --- a/tools/state.tsx +++ b/tools/state.tsx @@ -9,6 +9,7 @@ type configContextType = { config: Config; setConfig: (newconfig: Config) => void; loadConfig: (name: string) => void; + getConfigs: () => Promise; }; const configContext = createContext({ @@ -23,6 +24,7 @@ const configContext = createContext({ }, setConfig: () => {}, loadConfig: async (name: string) => {}, + getConfigs: async () => [], }); export function useConfig() { @@ -40,14 +42,7 @@ type Props = { export function ConfigProvider({ children }: Props) { const [config, setConfigInternal] = useState({ name: 'default', - services: [ - { - type: 'Other', - name: 'example', - icon: 'https://c.tenor.com/o656qFKDzeUAAAAC/rick-astley-never-gonna-give-you-up.gif', - url: 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', - }, - ], + services: [], settings: { searchBar: true, searchUrl: 'https://www.google.com/search?q=', @@ -58,7 +53,6 @@ export function ConfigProvider({ children }: Props) { async function loadConfig(configName: string) { try { const response = await axios.get(`/api/configs/${configName}`); - console.log('response', response); setConfigInternal(response.data); showNotification({ title: 'Config', @@ -85,10 +79,16 @@ export function ConfigProvider({ children }: Props) { setConfigInternal(newconfig); } + async function getConfigs(): Promise { + const response = await axios.get('/api/configs'); + return response.data; + } + const value = { config, setConfig, loadConfig, + getConfigs, }; return {children}; } From 98e4da5a3b6f92a3dbba02bfd0fdba1ea41fc2d0 Mon Sep 17 00:00:00 2001 From: Aj - Thomas Date: Thu, 12 May 2022 21:57:01 +0200 Subject: [PATCH 04/11] =?UTF-8?q?Remove=20JSON=20and=20add=20=F0=9F=8D=AA?= =?UTF-8?q?=20Tryconfig=20save=20cookies?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data/configs/default.json | 2 +- data/configs/low.json | 16 ---------------- data/configs/undefined.json | 3 --- pages/tryconfig.tsx | 1 + 4 files changed, 2 insertions(+), 20 deletions(-) delete mode 100644 data/configs/low.json delete mode 100644 data/configs/undefined.json diff --git a/data/configs/default.json b/data/configs/default.json index 57f8faa53..9e1d1669a 100644 --- a/data/configs/default.json +++ b/data/configs/default.json @@ -2,7 +2,7 @@ "name": "default", "services": [ { - "type": "Other hello", + "type": "Other", "name": "example", "icon": "https://c.tenor.com/o656qFKDzeUAAAAC/rick-astley-never-gonna-give-you-up.gif", "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ" diff --git a/data/configs/low.json b/data/configs/low.json deleted file mode 100644 index c3482808d..000000000 --- a/data/configs/low.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "low", - "services": [ - { - "type": "I am ", - "name": "example", - "icon": "https://c.tenor.com/o656qFKDzeUAAAAC/rick-astley-never-gonna-give-you-up.gif", - "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ" - } - ], - "settings": { - "searchBar": true, - "searchUrl": "https://www.google.com/search?q=", - "enabledModules": [] - } -} \ No newline at end of file diff --git a/data/configs/undefined.json b/data/configs/undefined.json deleted file mode 100644 index c92e56872..000000000 --- a/data/configs/undefined.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "true": "" -} \ No newline at end of file diff --git a/pages/tryconfig.tsx b/pages/tryconfig.tsx index 37d2c2565..6fb38734c 100644 --- a/pages/tryconfig.tsx +++ b/pages/tryconfig.tsx @@ -79,6 +79,7 @@ export default function TryConfig(props: any) { label="Config loader" onChange={(e) => { loadConfig(e ?? 'default'); + setCookies('config-name', e ?? 'default', { maxAge: 60 * 60 * 24 * 30 }); }} data={ // If config list is empty, return the current config From 84b7d4bbdcd1840d798a11e6a8a22b89f048290d Mon Sep 17 00:00:00 2001 From: Aj - Thomas Date: Thu, 12 May 2022 22:11:28 +0200 Subject: [PATCH 05/11] Fix cookie in Upload form and fix download name --- components/Config/LoadConfig.tsx | 11 +++++++++-- components/Config/SaveConfig.tsx | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/components/Config/LoadConfig.tsx b/components/Config/LoadConfig.tsx index a590e20ac..d36fecd19 100644 --- a/components/Config/LoadConfig.tsx +++ b/components/Config/LoadConfig.tsx @@ -4,6 +4,7 @@ import { DropzoneStatus, FullScreenDropzone } from '@mantine/dropzone'; import { showNotification } from '@mantine/notifications'; import { useRef } from 'react'; import { useRouter } from 'next/router'; +import { setCookies } from 'cookies-next'; import { useConfig } from '../../tools/state'; import { Config } from '../../tools/types'; @@ -69,15 +70,21 @@ export default function LoadConfigComponent(props: any) { }); return; } + const newConfig: Config = JSON.parse(e); showNotification({ autoClose: 5000, radius: 'md', - title: Config loaded successfully, + title: ( + + Config {newConfig.name} loaded successfully + + ), color: 'green', icon: , message: undefined, }); - setConfig(JSON.parse(e)); + setCookies('config-name', newConfig.name, { maxAge: 60 * 60 * 24 * 30 }); + setConfig(newConfig); }); }} accept={['application/json']} diff --git a/components/Config/SaveConfig.tsx b/components/Config/SaveConfig.tsx index d12f7ad22..cfaf196d4 100644 --- a/components/Config/SaveConfig.tsx +++ b/components/Config/SaveConfig.tsx @@ -7,7 +7,7 @@ export default function SaveConfigComponent(props: any) { const { config } = useConfig(); function onClick(e: any) { if (config) { - fileDownload(JSON.stringify(config, null, '\t'), 'config.json'); + fileDownload(JSON.stringify(config, null, '\t'), `${config.name}.json`); } } return ( From ff2fd2febdedfdfb5a3adf8be5dc1e33796fa58a Mon Sep 17 00:00:00 2001 From: Aj - Thomas Date: Thu, 12 May 2022 22:16:22 +0200 Subject: [PATCH 06/11] Add a ConfigChanger in the settings menu --- components/Config/ConfigChanger.tsx | 31 ++++++++++++++++++++++++++++ components/Settings/SettingsMenu.tsx | 2 ++ 2 files changed, 33 insertions(+) create mode 100644 components/Config/ConfigChanger.tsx diff --git a/components/Config/ConfigChanger.tsx b/components/Config/ConfigChanger.tsx new file mode 100644 index 000000000..0fc531b05 --- /dev/null +++ b/components/Config/ConfigChanger.tsx @@ -0,0 +1,31 @@ +import { Loader, Select } from '@mantine/core'; +import { setCookies } from 'cookies-next'; +import { useEffect, useState } from 'react'; +import { useConfig } from '../../tools/state'; + +export default function ConfigChanger() { + const { config, loadConfig, setConfig, getConfigs } = useConfig(); + const [configList, setConfigList] = useState([] as string[]); + useEffect(() => { + getConfigs().then((configs) => setConfigList(configs)); + // setConfig(initialConfig); + }, [config]); + // If configlist is empty, return a loading indicator + if (configList.length === 0) { + return ; + } + return ( + Date: Thu, 12 May 2022 22:35:21 +0200 Subject: [PATCH 08/11] Fix default search engine in settings menu --- components/Settings/SettingsMenu.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/Settings/SettingsMenu.tsx b/components/Settings/SettingsMenu.tsx index 99afc8a98..b8fed02eb 100644 --- a/components/Settings/SettingsMenu.tsx +++ b/components/Settings/SettingsMenu.tsx @@ -42,9 +42,9 @@ function SettingsMenu(props: any) { match.value === config.settings.searchUrl)?.value || 'Google' + matches.find((match) => match.value === config.settings.searchUrl)?.value ?? 'Google' } onChange={ // Set config.settings.searchUrl to the value of the selected item From 770b19243d06bf2f30271cd55922ef69f88eba3f Mon Sep 17 00:00:00 2001 From: Aj - Thomas Date: Thu, 12 May 2022 23:53:29 +0200 Subject: [PATCH 09/11] Changing the torrent search url For @WalkxCode --- components/SearchBar/SearchBar.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/SearchBar/SearchBar.tsx b/components/SearchBar/SearchBar.tsx index efe88f806..fec0dffe4 100644 --- a/components/SearchBar/SearchBar.tsx +++ b/components/SearchBar/SearchBar.tsx @@ -48,7 +48,7 @@ export default function SearchBar(props: any) { if (isYoutube) { window.open(`https://www.youtube.com/results?search_query=${querry.substring(3)}`); } else if (isTorrent) { - window.open(`https://thepiratebay.org/search.php?q=${querry.substring(3)}`); + window.open(`https://bitsearch.to/search?q=${querry.substring(3)}`); } else { window.open(`${querryUrl}${values.querry}`); } From c587bd4bf12a671cbba2b064b42b9d7bcc14f09d Mon Sep 17 00:00:00 2001 From: Chris <15677803+c00ldude1oo@users.noreply.github.com> Date: Thu, 12 May 2022 19:43:04 -0400 Subject: [PATCH 10/11] Fix docker build --- .dockerignore | 6 ++++++ .github/workflows/docker.yml | 28 ++++++++++++++++------------ Dockerfile | 22 ++++++++++++++++++++-- 3 files changed, 42 insertions(+), 14 deletions(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..125cd198c --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +Dockerfile +.dockerignore +node_modules +npm-debug.log +README.md +.git diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 8bc8a13f5..9cd1d766b 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -41,12 +41,18 @@ jobs: # If source files changed but packages didn't, rebuild from a prior cache. restore-keys: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}- - run: yarn install --frozen-lockfile - - run: yarn export + - run: yarn build - name: Cache build output uses: actions/cache@v2 id: restore-build with: - path: ./out/ + path: | + ./next.config.js + ./pages/ + ./public/ + ./.next/static/ + ./.next/standalone/ + ./packages.jsan key: ${{ github.sha }} docker: @@ -61,16 +67,20 @@ jobs: - uses: actions/cache@v2 id: restore-build with: - path: ./out/ + path: | + ./next.config.js + ./pages/ + ./public/ + ./.next/static/ + ./.next/standalone/ + ./packages.jsan key: ${{ github.sha }} - name: Docker meta id: meta uses: docker/metadata-action@v4 with: # list of Docker images to use as base name for tags - images: | - ajnart/homarr - ghcr.io/ajnart/homarr + images: ghcr.io/${{ github.repository }} # generate Docker tags based on the following events/attributes tags: | type=raw,value=latest,enable={{is_default_branch}} @@ -79,12 +89,6 @@ jobs: uses: docker/setup-qemu-action@v2 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - - name: Login to DockerHub - if: github.event_name != 'pull_request' - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Login to GHCR if: github.event_name != 'pull_request' uses: docker/login-action@v2 diff --git a/Dockerfile b/Dockerfile index d59093471..5d13c04aa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,2 +1,20 @@ -FROM nginx:alpine -COPY ./out /usr/share/nginx/html +FROM node:16-alpine +WORKDIR /app +ENV NODE_ENV production +RUN addgroup --system --gid 1001 nodejs +RUN adduser --system --uid 1001 nextjs + +COPY /next.config.js ./ +COPY /public ./public +COPY /package.json ./package.json + +# Automatically leverage output traces to reduce image size +# https://nextjs.org/docs/advanced-features/output-file-tracing +COPY --chown=nextjs:nodejs /.next/standalone ./ +COPY --chown=nextjs:nodejs /.next/static ./.next/static + +USER nextjs +EXPOSE 7575 +ENV PORT 7575 +VOLUME /app/data/configs +CMD ["node", "server.js"] From a822e44b1656a413aed9815b59f66e57519ae8f2 Mon Sep 17 00:00:00 2001 From: Walkx Date: Thu, 12 May 2022 14:36:04 +0200 Subject: [PATCH 11/11] feat: Add link to discussions page --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5cabbbdc6..c27a3f265 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,7 @@ _Requirements_: **[⤴️ Back to Top](#-table-of-contents)** # 💖 Contributing -You can contribute by [Submitting Bugs](https://github.com/ajnart/homarr/issues/new), [Requesting Features](https://github.com/ajnart/homarr/issues/new), or [Making a pull request](https://github.com/ajnart/homarr/compare)! +You can contribute by [Starting a discussion](https://github.com/ajnart/homarr/discussions), [Submitting Bugs](https://github.com/ajnart/homarr/issues/new), [Requesting Features](https://github.com/ajnart/homarr/issues/new), or [Making a pull request](https://github.com/ajnart/homarr/compare)! All contributions are highly appreciated.