Compare commits

...

37 Commits

Author SHA1 Message Date
Thomas Camlong
1d734633f0 🚑 Merge pull request #301 from ajnart/dev
🚑 Hotfix Docker image with new NextJS version
2022-07-23 00:25:45 +02:00
ajnart
2186756535 🚑 Hotfix Docker image with new NextJS version 2022-07-22 22:27:02 +02:00
Thomas Camlong
702428d24f 🚀 v0.8.2 🐋 Docker fixes and quality of life changes
https://github.com/ajnart/homarr/compare/v0.8.0...v0.8.2
2022-07-22 18:45:13 +02:00
ajnart
c8b0e7013d Improve Calendar module error handling 2022-07-22 18:30:15 +02:00
ajnart
385b4a3b24 🐛 Fix Docker integration actions timeouts 2022-07-22 18:08:32 +02:00
ajnart
5ccdf735ae Hide calendar module sensitive data
Working towards #259
2022-07-22 18:07:36 +02:00
ajnart
81a7789f9c Hide downloads module sensitive data
Working thowards #259
2022-07-22 17:18:33 +02:00
ajnart
a4defd330c 🔥 Remove console.log() statement 2022-07-22 16:21:15 +02:00
ajnart
4628d1d1d7 🚚 Change setCookies to setCookie 2022-07-22 16:20:59 +02:00
ajnart
7b719c2273 🐛 Fix bugs with async events from dockerode 2022-07-22 16:19:56 +02:00
ajnart
a9b840452e ✏️ Fix async data gathering with Dockerode 2022-07-22 16:19:28 +02:00
ajnart
3b0658fee2 Use tryMatchPort 2022-07-22 16:19:07 +02:00
ajnart
b5f1491fbb Add TryMatchPort function and update MatchingImages 2022-07-22 16:18:36 +02:00
ajnart
539903f053 ✏️ Remove resolutions in packagelock 2022-07-22 16:16:09 +02:00
Thomas Camlong
f7aa6338f1 🔀 Merge pull request #296 from RichyHBM/adding-docker-images
Adding docker images to match thanks to @RichyHBM !
2022-07-22 15:18:20 +02:00
Thomas "ajnart" Camlong
f20c2d4472 🔖 Bump version to v0.8.2 2022-07-22 13:20:34 +02:00
Thomas "ajnart" Camlong
d1d13396f8 💄 Linting and prettier 2022-07-22 13:20:02 +02:00
Thomas "ajnart" Camlong
bed08c84de ⬆️ Upgrade layout for new React and NextJS versions 2022-07-22 13:18:46 +02:00
Thomas "ajnart" Camlong
c0e1747e09 Make logo text togglable on/off 2022-07-22 13:18:46 +02:00
Thomas "ajnart" Camlong
ea8df25620 Add searching feature in docker table 2022-07-22 13:18:46 +02:00
Thomas "ajnart" Camlong
cd9e844001 🐛 Fix docker not getting all containers
Turned off containers will not be shown
2022-07-22 13:18:46 +02:00
Thomas "ajnart" Camlong
8eac0bed84 Improve login page
Styling and responsiveness
2022-07-22 13:18:46 +02:00
Thomas "ajnart" Camlong
d2eb31f510 ⬆️ Upgrade 404 page for NextJS latest 2022-07-22 13:18:46 +02:00
Thomas "ajnart" Camlong
ed72ab6ec7 🐛 Fix middleware due to new NextJS version
Fixes #297
2022-07-22 13:18:46 +02:00
Thomas "ajnart" Camlong
02d3766d60 ⬆️ Upgrade next.config.js for new NextJS version 2022-07-22 13:18:46 +02:00
Thomas "ajnart" Camlong
5b4f166216 📦 Upgrade to React18 2022-07-22 13:18:46 +02:00
Thomas "ajnart" Camlong
75ceab0cf1 🐛 Fix fetching images in MatchIcon 2022-07-22 13:18:46 +02:00
Thomas "ajnart" Camlong
91181aed13 🔧 Add vscode debug files 2022-07-22 13:18:46 +02:00
Thomas "ajnart" Camlong
3234f06a2d 🐛 Make docker container list scrollable
Fixes #295
2022-07-22 13:18:46 +02:00
Thomas Camlong
cac1059c16 Update feature-request.yml 2022-07-22 13:10:47 +02:00
RichyHBM
632376bed5 Additional hotio images 2022-07-21 18:50:27 +01:00
RichyHBM
64a29e7f4c Put qbittorrent in alphabetical order 2022-07-21 18:47:13 +01:00
RichyHBM
c6d8c9b2d8 Add hotio + other high usage images 2022-07-21 18:43:42 +01:00
RichyHBM
6915a1bfaf Add dashdot and linuxserver docker images to image to match list 2022-07-21 18:29:35 +01:00
Thomas "ajnart" Camlong
00751eeca5 Make discord integration a module
This allows for an error message if the docker integration fails to load
2022-07-21 11:43:43 +02:00
Thomas Camlong
715a4bd6c7 Merge pull request #292 from arghyadipchak/master
Fix Dash. compact view storage
2022-07-21 09:08:00 +02:00
Arghyadip Chakraborty
5df2c67c2f Fix Dash. compact view storage 2022-07-21 00:39:08 +05:30
55 changed files with 1835 additions and 11003 deletions

View File

@@ -3,7 +3,6 @@ module.exports = {
'mantine', 'mantine',
'plugin:@next/next/recommended', 'plugin:@next/next/recommended',
'plugin:jest/recommended', 'plugin:jest/recommended',
'plugin:storybook/recommended',
"eslint:recommended", "eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended", "plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended" "plugin:@typescript-eslint/recommended"

View File

@@ -22,13 +22,3 @@ body:
- High (App breaking feature) - High (App breaking feature)
validations: validations:
required: true required: true
- type: checkboxes
id: idiot-check
attributes:
label: Please tick the boxes
description: Before submitting, please ensure that
options:
- label: You've read the [docs](https://github.com/ajnart/homarr#readme)
required: true
- label: You've checked for [duplicate issues](https://github.com/ajnart/homarr/issues)
required: true

View File

@@ -1,6 +1,8 @@
name: Master docker CI name: Master CI
# Workflow to build and publish docker image # This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
on: on:
push: push:
branches: [master] branches: [master]
@@ -22,72 +24,46 @@ jobs:
# Push image to GitHub Packages. # Push image to GitHub Packages.
# See also https://docs.docker.com/docker-hub/builds/ # See also https://docs.docker.com/docker-hub/builds/
yarn_install_and_build: yarn_install_and_build:
# Will run yarn install && yarn build
runs-on: ubuntu-latest
steps:
- name: Setup
uses: actions/setup-node@v3
- name: Checkout
uses: actions/checkout@v3
- name: Get yarn cache directory path
# to help speed up build times
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Yarn cache
# to help speed up build times
uses: actions/cache@v3
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: ${{ runner.os }}-yarn-
- name: Nextjs cache
uses: actions/cache@v2
with:
# See here for caching with `yarn` https://github.com/actions/cache/blob/main/examples.md#node---yarn or you can leverage caching with actions/setup-node https://github.com/actions/setup-node
path: |
~/.npm
${{ github.workspace }}/.next/cache
# Generate a new cache whenever packages or source files change.
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.
restore-keys: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-
- run: yarn install --immutable
- run: yarn build
- name: Cache build output
# to copy needed files to docker build job
uses: actions/cache@v2
id: restore-build
with:
path: |
./next.config.js
./pages/
./public/
./.next/static/
./.next/standalone/
./packages.json
key: ${{ github.sha }}
docker_image_build_and_push:
needs: [yarn_install_and_build]
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions: permissions:
packages: write packages: write
contents: read contents: read
steps: steps:
- name: Setup
uses: actions/setup-node@v3
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v3
- uses: actions/cache@v2
id: restore-build - name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
- uses: actions/cache@v3
id: yarn-cache
with: with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Restore NextJS cache
uses: actions/cache@v2
with:
# See here for caching with `yarn` https://github.com/actions/cache/blob/main/examples.md#node---yarn or you can leverage caching with actions/setup-node https://github.com/actions/setup-node
path: | path: |
./next.config.js ${{ github.workspace }}/.next/cache
./pages/ # Generate a new cache whenever packages or source files change.
./public/ key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
./.next/static/ # If source files changed but packages didn't, rebuild from a prior cache.
./.next/standalone/ restore-keys: |
./packages.json ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-
key: ${{ github.sha }}
- run: yarn install --immutable
- run: yarn build
- name: Docker meta - name: Docker meta
id: meta id: meta
uses: docker/metadata-action@v4 uses: docker/metadata-action@v4
@@ -98,10 +74,13 @@ jobs:
tags: | tags: |
type=raw,value=latest type=raw,value=latest
type=pep440,pattern={{version}} type=pep440,pattern={{version}}
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@v2 uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2 uses: docker/setup-buildx-action@v2
- name: Login to GHCR - name: Login to GHCR
uses: docker/login-action@v2 uses: docker/login-action@v2
with: with:
@@ -117,3 +96,5 @@ jobs:
push: true push: true
tags: ${{ steps.meta.outputs.tags }} tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }} labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

View File

@@ -30,6 +30,9 @@ jobs:
# See also https://docs.docker.com/docker-hub/builds/ # See also https://docs.docker.com/docker-hub/builds/
yarn_install_and_build: yarn_install_and_build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps: steps:
- name: Setup - name: Setup
@@ -40,67 +43,32 @@ jobs:
- name: Get yarn cache directory path - name: Get yarn cache directory path
id: yarn-cache-dir-path id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)" run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
- name: Yarn cache - uses: actions/cache@v3
uses: actions/cache@v3 id: yarn-cache
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with: with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: ${{ runner.os }}-yarn- restore-keys: |
${{ runner.os }}-yarn-
- name: Nextjs cache - name: Restore NextJS cache
uses: actions/cache@v2 uses: actions/cache@v2
with: with:
# See here for caching with `yarn` https://github.com/actions/cache/blob/main/examples.md#node---yarn or you can leverage caching with actions/setup-node https://github.com/actions/setup-node # See here for caching with `yarn` https://github.com/actions/cache/blob/main/examples.md#node---yarn or you can leverage caching with actions/setup-node https://github.com/actions/setup-node
path: | path: |
~/.npm
${{ github.workspace }}/.next/cache ${{ github.workspace }}/.next/cache
# Generate a new cache whenever packages or source files change. # Generate a new cache whenever packages or source files change.
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 --immutable - run: yarn install --immutable
- run: yarn build - run: yarn build
- name: Cache build output
uses: actions/cache@v2
id: restore-build
with:
path: |
./next.config.js
./pages/
./public/
./.next/static/
./.next/standalone/
./packages.json
key: ${{ github.sha }}
docker_image_build_and_push:
needs: [yarn_install_and_build]
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: actions/cache@v2
id: restore-build
with:
path: |
./next.config.js
./pages/
./public/
./.next/static/
./.next/standalone/
./packages.json
key: ${{ github.sha }}
- name: Docker meta - name: Docker meta
id: meta id: meta
uses: docker/metadata-action@v4 uses: docker/metadata-action@v4
@@ -134,3 +102,5 @@ jobs:
push: ${{ github.event_name != 'pull_request' }} push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }} tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }} labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

View File

@@ -1,30 +0,0 @@
module.exports = {
stories: ['../src/components/**/*.story.mdx', '../src/components/**/*.story.*'],
addons: [
'@storybook/addon-links',
'storybook-addon-mock/register',
'@storybook/addon-essentials',
],
typescript: {
check: false,
reactDocgen: false,
},
framework: '@storybook/react',
features: { emotionAlias: false },
webpackFinal: async (config, { configType }) => {
// `configType` has a value of 'DEVELOPMENT' or 'PRODUCTION'
// You can change the configuration based on that.
// 'PRODUCTION' is used when building the static version of storybook.
// https://github.com/polkadot-js/extension/issues/621#issuecomment-759341776
// framer-motion uses the .mjs notation and we need to include it so that webpack will
// transpile it for us correctly (enables using a CJS module inside an ESM).
config.module.rules.push({
test: /\.mjs$/,
include: /node_modules/,
type: 'javascript/auto',
});
// Return the altered config
return config;
},
};

View File

@@ -1,16 +0,0 @@
import { MantineProvider, ColorSchemeProvider } from '@mantine/core';
import { NotificationsProvider } from '@mantine/notifications';
export const parameters = { layout: 'fullscreen' };
function ThemeWrapper(props: { children: React.ReactNode }) {
return (
<ColorSchemeProvider colorScheme="light" toggleColorScheme={() => {}}>
<MantineProvider withGlobalStyles withNormalizeCSS>
<NotificationsProvider>{props.children}</NotificationsProvider>
</MantineProvider>
</ColorSchemeProvider>
);
}
export const decorators = [(renderStory: Function) => <ThemeWrapper>{renderStory()}</ThemeWrapper>];

28
.vscode/launch.json vendored Normal file
View File

@@ -0,0 +1,28 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Next.js: debug server-side",
"type": "node-terminal",
"request": "launch",
"command": "yarn dev"
},
{
"name": "Next.js: debug client-side",
"type": "chrome",
"request": "launch",
"url": "http://localhost:3000"
},
{
"name": "Next.js: debug full stack",
"type": "node-terminal",
"request": "launch",
"command": "yarn dev",
"serverReadyAction": {
"pattern": "started server on .+, url: (https?://.+)",
"uriFormat": "%s",
"action": "debugWithChrome"
}
}
]
}

View File

@@ -1,14 +1,23 @@
FROM node:16-alpine FROM node:16-alpine
WORKDIR /app WORKDIR /app
ENV NODE_ENV production
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 /.next/standalone ./
COPY /.next/static ./.next/static
EXPOSE 7575
ENV PORT 7575
RUN apk add tzdata RUN apk add tzdata
VOLUME /app/data/configs
ENV NEXT_TELEMETRY_DISABLED 1
ENV NODE_ENV production
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 .next/standalone ./
COPY .next/static ./.next/static
EXPOSE 7575
ENV PORT 7575
CMD ["node", "server.js"] CMD ["node", "server.js"]

View File

@@ -18,6 +18,9 @@
}, },
"Date": { "Date": {
"enabled": false "enabled": false
},
"Docker": {
"enabled": true
} }
} }
} }

View File

@@ -1,2 +1,2 @@
export const REPO_URL = 'ajnart/homarr'; export const REPO_URL = 'ajnart/homarr';
export const CURRENT_VERSION = 'v0.8.0'; export const CURRENT_VERSION = 'v0.8.2';

View File

@@ -6,9 +6,5 @@ const withBundleAnalyzer = require('@next/bundle-analyzer')({
module.exports = withBundleAnalyzer({ module.exports = withBundleAnalyzer({
reactStrictMode: false, reactStrictMode: false,
eslint: {
ignoreDuringBuilds: true,
},
output: 'standalone', output: 'standalone',
basePath: env.BASE_URL,
}); });

View File

@@ -1,7 +1,8 @@
{ {
"name": "homarr", "name": "homarr",
"version": "0.8.0", "version": "0.8.2",
"description": "Homarr - A homepage for your server.", "description": "Homarr - A homepage for your server.",
"license": "MIT",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/ajnart/homarr" "url": "https://github.com/ajnart/homarr"
@@ -19,72 +20,63 @@
"prettier:check": "prettier --check \"**/*.{ts,tsx}\"", "prettier:check": "prettier --check \"**/*.{ts,tsx}\"",
"prettier:write": "prettier --write \"**/*.{ts,tsx}\"", "prettier:write": "prettier --write \"**/*.{ts,tsx}\"",
"test": "npm run prettier:check && npm run lint && npm run typecheck && npm run jest", "test": "npm run prettier:check && npm run lint && npm run typecheck && npm run jest",
"storybook": "start-storybook -p 7001",
"storybook:build": "build-storybook",
"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.1.0", "@ctrl/deluge": "^4.1.0",
"@ctrl/qbittorrent": "^4.0.0", "@ctrl/qbittorrent": "^4.1.0",
"@ctrl/shared-torrent": "^4.1.0", "@ctrl/shared-torrent": "^4.1.1",
"@ctrl/transmission": "^4.1.1", "@ctrl/transmission": "^4.1.1",
"@dnd-kit/core": "^6.0.1", "@dnd-kit/core": "^6.0.5",
"@dnd-kit/sortable": "^7.0.0", "@dnd-kit/sortable": "^7.0.1",
"@dnd-kit/utilities": "^3.2.0", "@dnd-kit/utilities": "^3.2.0",
"@mantine/core": "^4.2.8", "@mantine/core": "^4.2.12",
"@mantine/dates": "^4.2.8", "@mantine/dates": "^4.2.12",
"@mantine/dropzone": "^4.2.8", "@mantine/dropzone": "^4.2.12",
"@mantine/form": "^4.2.8", "@mantine/form": "^4.2.12",
"@mantine/hooks": "^4.2.8", "@mantine/hooks": "^4.2.12",
"@mantine/next": "^4.2.8", "@mantine/next": "^4.2.12",
"@mantine/notifications": "^4.2.8", "@mantine/notifications": "^4.2.12",
"@mantine/prism": "^4.2.8", "@mantine/prism": "^4.2.12",
"@nivo/core": "^0.79.0", "@nivo/core": "^0.79.0",
"@nivo/line": "^0.79.1", "@nivo/line": "^0.79.1",
"@tabler/icons": "^1.68.0", "@tabler/icons": "^1.76.0",
"axios": "^0.27.2", "axios": "^0.27.2",
"cookies-next": "^2.1.1", "cookies-next": "^2.1.1",
"dayjs": "^1.11.3", "dayjs": "^1.11.4",
"dockerode": "^3.3.2", "dockerode": "^3.3.2",
"framer-motion": "^6.3.1", "framer-motion": "^6.5.1",
"js-file-download": "^0.4.12", "js-file-download": "^0.4.12",
"next": "^12.2.0", "next": "12.2.0",
"prism-react-renderer": "^1.3.1", "prism-react-renderer": "^1.3.5",
"react": "^17.0.1", "react": "^18.2.0",
"react-dom": "^17.0.1", "react-dom": "^18.2.0",
"systeminformation": "^5.11.16", "systeminformation": "^5.12.1",
"uuid": "^8.3.2" "uuid": "^8.3.2"
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.17.8", "@next/bundle-analyzer": "12.2.0",
"@next/bundle-analyzer": "^12.2.0", "@next/eslint-plugin-next": "12.2.0",
"@next/eslint-plugin-next": "^12.2.0",
"@storybook/react": "^6.5.4",
"@types/dockerode": "^3.3.9", "@types/dockerode": "^3.3.9",
"@types/node": "^17.0.23", "@types/node": "^18.0.6",
"@types/react": "17.0.43", "@types/react": "^18.0.15",
"@types/uuid": "^8.3.4", "@types/uuid": "^8.3.4",
"@typescript-eslint/eslint-plugin": "^5.16.0", "@typescript-eslint/eslint-plugin": "^5.30.7",
"@typescript-eslint/parser": "^5.16.0", "@typescript-eslint/parser": "^5.30.7",
"eslint": "^8.11.0", "eslint": "^8.20.0",
"eslint-config-airbnb": "^19.0.4", "eslint-config-airbnb": "^19.0.4",
"eslint-config-airbnb-typescript": "^16.1.0", "eslint-config-airbnb-typescript": "^17.0.0",
"eslint-config-mantine": "1.1.0", "eslint-config-mantine": "^2.0.0",
"eslint-plugin-import": "^2.25.4", "eslint-plugin-import": "^2.26.0",
"eslint-plugin-jest": "^26.1.3", "eslint-plugin-jest": "^26.6.0",
"eslint-plugin-jsx-a11y": "^6.5.1", "eslint-plugin-jsx-a11y": "^6.6.1",
"eslint-plugin-react": "^7.29.4", "eslint-plugin-react": "^7.30.1",
"eslint-plugin-react-hooks": "^4.3.0", "eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-storybook": "^0.5.11", "eslint-plugin-testing-library": "^5.5.1",
"eslint-plugin-testing-library": "^5.2.0",
"eslint-plugin-unused-imports": "^2.0.0", "eslint-plugin-unused-imports": "^2.0.0",
"jest": "^28.1.0", "jest": "^28.1.3",
"prettier": "^2.6.2", "prettier": "^2.7.1",
"require-from-string": "^2.0.2", "typescript": "^4.7.4"
"typescript": "4.6.4"
},
"resolutions": {
"@types/react": "17.0.30"
}, },
"packageManager": "yarn@3.2.1" "packageManager": "yarn@3.2.1"
} }

View File

@@ -12,7 +12,6 @@ import {
Select, Select,
Switch, Switch,
Tabs, Tabs,
Text,
TextInput, TextInput,
Title, Title,
Tooltip, Tooltip,
@@ -23,7 +22,7 @@ import { IconApps as Apps } from '@tabler/icons';
import { useEffect, useState } from 'react'; import { useEffect, useState } from 'react';
import { v4 as uuidv4 } from 'uuid'; import { v4 as uuidv4 } from 'uuid';
import { useConfig } from '../../tools/state'; import { useConfig } from '../../tools/state';
import { ServiceTypeList, StatusCodes } from '../../tools/types'; import { tryMatchPort, ServiceTypeList, StatusCodes } from '../../tools/types';
import Tip from '../layout/Tip'; import Tip from '../layout/Tip';
export function AddItemShelfButton(props: any) { export function AddItemShelfButton(props: any) {
@@ -55,7 +54,8 @@ export function AddItemShelfButton(props: any) {
); );
} }
function MatchIcon(name: string, form: any) { function MatchIcon(name: string | undefined, form: any) {
if (name === undefined || name === '') return null;
fetch( fetch(
`https://cdn.jsdelivr.net/gh/walkxhub/dashboard-icons/png/${name `https://cdn.jsdelivr.net/gh/walkxhub/dashboard-icons/png/${name
.replace(/\s+/g, '-') .replace(/\s+/g, '-')
@@ -77,24 +77,6 @@ function MatchService(name: string, form: any) {
} }
} }
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: '8787' },
{ name: 'deluge', value: '8112' },
{ name: 'transmission', value: '9091' },
{ name: 'dash.', value: '3001' },
];
// Match name with portmap key
const port = portmap.find((p) => p.name === name.toLowerCase());
if (port) {
form.setFieldValue('url', `http://localhost:${port.value}`);
}
}
const DEFAULT_ICON = '/favicon.svg'; const DEFAULT_ICON = '/favicon.svg';
export function AddAppShelfItemForm(props: { setOpened: (b: boolean) => void } & any) { export function AddAppShelfItemForm(props: { setOpened: (b: boolean) => void } & any) {
@@ -154,7 +136,7 @@ export function AddAppShelfItemForm(props: { setOpened: (b: boolean) => void } &
if (form.values.name !== debounced || form.values.icon !== DEFAULT_ICON) return; if (form.values.name !== debounced || form.values.icon !== DEFAULT_ICON) return;
MatchIcon(form.values.name, form); MatchIcon(form.values.name, form);
MatchService(form.values.name, form); MatchService(form.values.name, form);
MatchPort(form.values.name, form); tryMatchPort(form.values.name, form);
}, [debounced]); }, [debounced]);
// Try to set const hostname to new URL(form.values.url).hostname) // Try to set const hostname to new URL(form.values.url).hostname)

View File

@@ -1,27 +0,0 @@
import { SimpleGrid } from '@mantine/core';
import AppShelf from './AppShelf';
import { AppShelfItem } from './AppShelfItem';
export default {
title: 'Item Shelf',
component: AppShelf,
args: {
service: {
name: 'qBittorrent',
url: 'http://',
icon: 'https://cdn.jsdelivr.net/gh/IceWhaleTech/CasaOS-AppStore@main/Apps/qBittorrent/icon.png',
type: 'qBittorrent',
apiKey: '',
},
},
};
export const Default = (args: any) => <AppShelf {...args} />;
export const One = (args: any) => <AppShelfItem {...args} />;
export const Ten = (args: any) => (
<SimpleGrid>
{Array.from(Array(10)).map((_, i) => (
<AppShelfItem {...args} key={i} />
))}
</SimpleGrid>
);

View File

@@ -178,21 +178,21 @@ const AppShelf = (props: any) => {
</Accordion.Item> </Accordion.Item>
) : null} ) : null}
{downloadEnabled ? ( {downloadEnabled ? (
<Accordion.Item key="Downloads" label="Your downloads"> <Accordion.Item key="Downloads" label="Your downloads">
<Paper <Paper
p="lg" p="lg"
radius="lg" radius="lg"
style={{ style={{
background: `rgba(${colorScheme === 'dark' ? '37, 38, 43,' : '255, 255, 255,'} \ background: `rgba(${colorScheme === 'dark' ? '37, 38, 43,' : '255, 255, 255,'} \
${(config.settings.appOpacity || 100) / 100}`, ${(config.settings.appOpacity || 100) / 100}`,
borderColor: `rgba(${colorScheme === 'dark' ? '37, 38, 43,' : '233, 236, 239,'} \ borderColor: `rgba(${colorScheme === 'dark' ? '37, 38, 43,' : '233, 236, 239,'} \
${(config.settings.appOpacity || 100) / 100}`, ${(config.settings.appOpacity || 100) / 100}`,
}} }}
> >
<ModuleMenu module={DownloadsModule} /> <ModuleMenu module={DownloadsModule} />
<DownloadComponent /> <DownloadComponent />
</Paper> </Paper>
</Accordion.Item> </Accordion.Item>
) : null} ) : null}
</Accordion> </Accordion>
</Group> </Group>

View File

@@ -1,5 +1,5 @@
import { Center, Loader, Select, Tooltip } from '@mantine/core'; import { Center, Loader, Select, Tooltip } from '@mantine/core';
import { setCookies } from 'cookies-next'; import { setCookie } from 'cookies-next';
import { useEffect, useState } from 'react'; import { useEffect, useState } from 'react';
import { useConfig } from '../../tools/state'; import { useConfig } from '../../tools/state';
@@ -26,7 +26,7 @@ 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', { setCookie('config-name', e ?? 'default', {
maxAge: 60 * 60 * 24 * 30, maxAge: 60 * 60 * 24 * 30,
sameSite: 'strict', sameSite: 'strict',
}); });

View File

@@ -10,7 +10,7 @@ import { DropzoneStatus, FullScreenDropzone } from '@mantine/dropzone';
import { showNotification } from '@mantine/notifications'; import { showNotification } from '@mantine/notifications';
import { useRef } from 'react'; import { useRef } from 'react';
import { useRouter } from 'next/router'; import { useRouter } from 'next/router';
import { setCookies } from 'cookies-next'; import { setCookie } from 'cookies-next';
import { useConfig } from '../../tools/state'; import { useConfig } from '../../tools/state';
import { Config } from '../../tools/types'; import { Config } from '../../tools/types';
import { migrateToIdConfig } from '../../tools/migrate'; import { migrateToIdConfig } from '../../tools/migrate';
@@ -90,7 +90,7 @@ export default function LoadConfigComponent(props: any) {
icon: <Check />, icon: <Check />,
message: undefined, message: undefined,
}); });
setCookies('config-name', newConfig.name, { setCookie('config-name', newConfig.name, {
maxAge: 60 * 60 * 24 * 30, maxAge: 60 * 60 * 24 * 30,
sameSite: 'strict', sameSite: 'strict',
}); });

View File

@@ -1,91 +0,0 @@
import { Menu, Text, useMantineTheme } from '@mantine/core';
import { showNotification, updateNotification } from '@mantine/notifications';
import {
IconCheck,
IconCodePlus,
IconPlayerPlay,
IconPlayerStop,
IconRotateClockwise,
IconX,
} from '@tabler/icons';
import axios from 'axios';
import Dockerode from 'dockerode';
function sendNotification(action: string, containerId: string, containerName: string) {
showNotification({
id: 'load-data',
loading: true,
title: `${action}ing container ${containerName}`,
message: 'Your password is being checked...',
autoClose: false,
disallowClose: true,
});
axios.get(`/api/docker/container/${containerId}?action=${action}`).then((res) => {
setTimeout(() => {
if (res.data.success === true) {
updateNotification({
id: 'load-data',
title: 'Container restarted',
message: 'Your container was successfully restarted',
icon: <IconCheck />,
autoClose: 2000,
});
}
if (res.data.success === false) {
updateNotification({
id: 'load-data',
color: 'red',
title: 'There was an error restarting your container.',
message: 'Your container has encountered issues while restarting.',
icon: <IconX />,
autoClose: 2000,
});
}
}, 500);
});
}
function restart(container: Dockerode.ContainerInfo) {
sendNotification('restart', container.Id, container.Names[0]);
}
function stop(container: Dockerode.ContainerInfo) {
console.log('stoping container', container.Id);
}
function start(container: Dockerode.ContainerInfo) {
console.log('starting container', container.Id);
}
export default function DockerMenu(props: any) {
const { container }: { container: Dockerode.ContainerInfo } = props;
const theme = useMantineTheme();
if (container === undefined) {
return null;
}
return (
<Menu shadow="lg" radius="md">
<Menu.Label>Actions</Menu.Label>
<Menu.Item icon={<IconRotateClockwise color="orange" />} onClick={() => restart(container)}>
<Text>Restart</Text>
</Menu.Item>
{container.State === 'running' ? (
<Menu.Item icon={<IconPlayerStop color="red" />}>
<Text>Stop</Text>
</Menu.Item>
) : (
<Menu.Item icon={<IconPlayerPlay color="green" />}>
<Text>Start</Text>
</Menu.Item>
)}
{/* <Menu.Item icon={<IconDownload color="blue" />}>
<Text>Pull latest image </Text>
</Menu.Item>
<Menu.Item icon={<IconFileText color="grey" />}>
<Text>Logs</Text>
</Menu.Item> */}
<Menu.Label>Homarr</Menu.Label>
<Menu.Item icon={<IconCodePlus color={theme.primaryColor} />}>
<Text>Add to Homarr</Text>
</Menu.Item>
</Menu>
);
}

View File

@@ -1,90 +0,0 @@
import { Table, Checkbox, Group, Badge, createStyles } from '@mantine/core';
import Dockerode from 'dockerode';
import ContainerState from './ContainerState';
const useStyles = createStyles((theme) => ({
rowSelected: {
backgroundColor:
theme.colorScheme === 'dark'
? theme.fn.rgba(theme.colors[theme.primaryColor][7], 0.2)
: theme.colors[theme.primaryColor][0],
},
}));
export default function DockerTable({
containers,
selection,
setSelection,
}: {
setSelection: any;
containers: Dockerode.ContainerInfo[];
selection: Dockerode.ContainerInfo[];
}) {
const { classes, cx } = useStyles();
const toggleRow = (container: Dockerode.ContainerInfo) =>
setSelection((current: Dockerode.ContainerInfo[]) =>
current.includes(container) ? current.filter((c) => c !== container) : [...current, container]
);
const toggleAll = () =>
setSelection((current: any) =>
current.length === containers.length ? [] : containers.map((c) => c)
);
const rows = containers.map((element) => {
const selected = selection.includes(element);
return (
<tr key={element.Id} className={cx({ [classes.rowSelected]: selected })}>
<td>
<Checkbox
checked={selection.includes(element)}
onChange={() => toggleRow(element)}
transitionDuration={0}
/>
</td>
<td>{element.Names[0].replace('/', '')}</td>
<td>{element.Image}</td>
<td>
<Group>
{element.Ports.sort((a, b) => a.PrivatePort - b.PrivatePort)
.slice(-3)
.map((port) => (
<Badge key={port.PrivatePort} variant="outline">
{port.PrivatePort}:{port.PublicPort}
</Badge>
))}
{element.Ports.length > 3 && (
<Badge variant="filled">{element.Ports.length - 3} more</Badge>
)}
</Group>
</td>
<td>
<ContainerState state={element.State} />
</td>
</tr>
);
});
return (
<Table captionSide="bottom" highlightOnHover sx={{ minWidth: 800 }} verticalSpacing="sm">
<caption>your docker containers</caption>
<thead>
<tr>
<th style={{ width: 40 }}>
<Checkbox
onChange={toggleAll}
checked={selection.length === containers.length}
indeterminate={selection.length > 0 && selection.length !== containers.length}
transitionDuration={0}
/>
</th>
<th>Name</th>
<th>Image</th>
<th>Ports</th>
<th>State</th>
</tr>
</thead>
<tbody>{rows}</tbody>
</Table>
);
}

View File

@@ -1,10 +0,0 @@
import { SettingsMenuButton } from './SettingsMenu';
export default {
title: ' menu',
args: {
opened: false,
},
};
export const Default = (args: any) => <SettingsMenuButton {...args} />;

View File

@@ -1,26 +1,8 @@
import { import { Box, createStyles, Group, Header as Head } from '@mantine/core';
ActionIcon,
Box,
Burger,
createStyles,
Drawer,
Group,
Header as Head,
ScrollArea,
Title,
Transition,
} from '@mantine/core';
import { useBooleanToggle } from '@mantine/hooks'; import { useBooleanToggle } from '@mantine/hooks';
import { AddItemShelfButton } from '../AppShelf/AddAppShelfItem'; import { AddItemShelfButton } from '../AppShelf/AddAppShelfItem';
import {
CalendarModule, import DockerMenuButton from '../modules/docker/DockerModule';
DateModule,
TotalDownloadsModule,
WeatherModule,
DashdotModule,
} from '../modules';
import { ModuleWrapper } from '../modules/moduleWrapper';
import DockerDrawer from '../Docker/DockerDrawer';
import SearchBar from '../modules/search/SearchModule'; import SearchBar from '../modules/search/SearchModule';
import { SettingsMenuButton } from '../Settings/SettingsMenu'; import { SettingsMenuButton } from '../Settings/SettingsMenu';
import { Logo } from './Logo'; import { Logo } from './Logo';
@@ -53,51 +35,9 @@ export function Header(props: any) {
</Box> </Box>
<Group noWrap> <Group noWrap>
<SearchBar /> <SearchBar />
<DockerDrawer /> <DockerMenuButton />
<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 offsetScrollbars style={{ height: '90vh' }}>
<Group my="sm" grow direction="column" style={{ width: 300 }}>
<ModuleWrapper module={CalendarModule} />
<ModuleWrapper module={TotalDownloadsModule} />
<ModuleWrapper module={WeatherModule} />
<ModuleWrapper module={DateModule} />
<ModuleWrapper module={DashdotModule} />
</Group>
</ScrollArea>
</div>
)}
</Transition>
</Drawer>
</Group> </Group>
</Group> </Group>
</Head> </Head>

View File

@@ -19,8 +19,8 @@ export default function Layout({ children, style }: any) {
return ( return (
<AppShell <AppShell
header={<Header />} header={<Header />}
navbar={widgetPosition ? <Navbar /> : <></>} navbar={widgetPosition ? <Navbar /> : undefined}
aside={widgetPosition ? <></> : <Aside />} aside={widgetPosition ? undefined : <Aside />}
footer={<Footer links={[]} />} footer={<Footer links={[]} />}
> >
<HeaderConfig /> <HeaderConfig />

View File

@@ -4,7 +4,7 @@ import * as React from 'react';
import { useColorTheme } from '../../tools/color'; import { useColorTheme } from '../../tools/color';
import { useConfig } from '../../tools/state'; import { useConfig } from '../../tools/state';
export function Logo({ style }: any) { export function Logo({ style, withoutText }: any) {
const { config } = useConfig(); const { config } = useConfig();
const { primaryColor, secondaryColor } = useColorTheme(); const { primaryColor, secondaryColor } = useColorTheme();
@@ -17,26 +17,28 @@ export function Logo({ style }: any) {
position: 'relative', position: 'relative',
}} }}
/> />
<NextLink {withoutText ? null : (
href="/" <NextLink
style={{ href="/"
textDecoration: 'none', style={{
position: 'relative', textDecoration: 'none',
}} position: 'relative',
>
<Text
sx={style}
weight="bold"
variant="gradient"
gradient={{
from: primaryColor,
to: secondaryColor,
deg: 145,
}} }}
> >
{config.settings.title || 'Homarr'} <Text
</Text> sx={style}
</NextLink> weight="bold"
variant="gradient"
gradient={{
from: primaryColor,
to: secondaryColor,
deg: 145,
}}
>
{config.settings.title || 'Homarr'}
</Text>
</NextLink>
)}
</Group> </Group>
); );
} }

View File

@@ -1,23 +1,16 @@
import { Group } from '@mantine/core'; import { Group } from '@mantine/core';
import { useMediaQuery } from '@mantine/hooks';
import { CalendarModule, DateModule, TotalDownloadsModule, WeatherModule } from '../modules'; import { CalendarModule, DateModule, TotalDownloadsModule, WeatherModule } from '../modules';
import { DashdotModule } from '../modules/dash.'; import { DashdotModule } from '../modules/dash.';
import { ModuleWrapper } from '../modules/moduleWrapper'; import { ModuleWrapper } from '../modules/moduleWrapper';
export default function Widgets(props: any) { export default function Widgets(props: any) {
const matches = useMediaQuery('(min-width: 800px)');
return ( return (
<> <Group my="sm" grow direction="column" style={{ width: 300 }}>
{matches && ( <ModuleWrapper module={CalendarModule} />
<Group my="sm" grow direction="column" style={{ width: 300 }}> <ModuleWrapper module={TotalDownloadsModule} />
<ModuleWrapper module={CalendarModule} /> <ModuleWrapper module={WeatherModule} />
<ModuleWrapper module={TotalDownloadsModule} /> <ModuleWrapper module={DateModule} />
<ModuleWrapper module={WeatherModule} /> <ModuleWrapper module={DashdotModule} />
<ModuleWrapper module={DateModule} /> </Group>
<ModuleWrapper module={DashdotModule} />
</Group>
)}
</>
); );
} }

View File

@@ -1,7 +0,0 @@
import CalendarComponent from './CalendarModule';
export default {
title: 'Calendar component',
};
export const Default = (args: any) => <CalendarComponent {...args} />;

View File

@@ -63,7 +63,7 @@ export default function CalendarComponent(props: any) {
if (!service || !service.apiKey) { if (!service || !service.apiKey) {
return Promise.resolve({ data: [] }); return Promise.resolve({ data: [] });
} }
return axios.post(`/api/modules/calendar?type=${type}`, { ...service }); return axios.post(`/api/modules/calendar?type=${type}`, { id: service.id });
} }
useEffect(() => { useEffect(() => {

View File

@@ -1,67 +0,0 @@
import { RadarrMediaDisplay } from './MediaDisplay';
export default {
title: 'Media display component',
args: {
media: {
title: 'Doctor Strange in the Multiverse of Madness',
originalTitle: 'Doctor Strange in the Multiverse of Madness',
originalLanguage: {
id: 1,
name: 'English',
},
secondaryYearSourceId: 0,
sortTitle: 'doctor strange in multiverse madness',
sizeOnDisk: 0,
status: 'announced',
overview:
'Doctor Strange, with the help of mystical allies both old and new, traverses the mind-bending and dangerous alternate realities of the Multiverse to confront a mysterious new adversary.',
inCinemas: '2022-05-04T00:00:00Z',
images: [
{
coverType: 'poster',
url: 'https://image.tmdb.org/t/p/original/wRnbWt44nKjsFPrqSmwYki5vZtF.jpg',
},
{
coverType: 'fanart',
url: 'https://image.tmdb.org/t/p/original/ndCSoasjIZAMMDIuMxuGnNWu4DU.jpg',
},
],
website: 'https://www.marvel.com/movies/doctor-strange-in-the-multiverse-of-madness',
year: 2022,
hasFile: false,
youTubeTrailerId: 'aWzlQ2N6qqg',
studio: 'Marvel Studios',
path: '/config/Doctor Strange in the Multiverse of Madness (2022)',
qualityProfileId: 1,
monitored: true,
minimumAvailability: 'announced',
isAvailable: true,
folderName: '/config/Doctor Strange in the Multiverse of Madness (2022)',
runtime: 126,
cleanTitle: 'doctorstrangeinmultiversemadness',
imdbId: 'tt9419884',
tmdbId: 453395,
titleSlug: '453395',
certification: 'PG-13',
genres: ['Fantasy', 'Action', 'Adventure'],
tags: [],
added: '2022-04-29T20:52:33Z',
ratings: {
tmdb: {
votes: 0,
value: 0,
type: 'user',
},
},
collection: {
name: 'Doctor Strange Collection',
tmdbId: 618529,
images: [],
},
id: 1,
},
},
};
export const Default = (args: any) => <RadarrMediaDisplay {...args} />;

View File

@@ -181,7 +181,7 @@ export function DashdotComponent() {
<div className={classes.tableRow}> <div className={classes.tableRow}>
<p className={classes.tableLabel}>Storage:</p> <p className={classes.tableLabel}>Storage:</p>
<p className={classes.tableValue}> <p className={classes.tableValue}>
{(totalUsed / (totalSize || 1)).toFixed(1)}%{'\n'} {((100 * totalUsed) / (totalSize || 1)).toFixed(1)}%{'\n'}
{bytePrettyPrint(totalUsed)} / {bytePrettyPrint(totalSize)} {bytePrettyPrint(totalUsed)} / {bytePrettyPrint(totalSize)}
</p> </p>
</div> </div>

View File

@@ -1,7 +0,0 @@
import DateComponent from './DateModule';
export default {
title: 'Date module',
};
export const Default = (args: any) => <DateComponent {...args} />;

View File

@@ -9,46 +9,49 @@ import {
IconRefresh, IconRefresh,
IconRotateClockwise, IconRotateClockwise,
IconTrash, IconTrash,
IconX,
} from '@tabler/icons'; } from '@tabler/icons';
import axios from 'axios'; import axios from 'axios';
import Dockerode from 'dockerode'; import Dockerode from 'dockerode';
import { tryMatchService } from '../../tools/addToHomarr'; import { tryMatchService } from '../../../tools/addToHomarr';
import { useConfig } from '../../tools/state'; import { AddAppShelfItemForm } from '../../AppShelf/AddAppShelfItem';
import { AddAppShelfItemForm } from '../AppShelf/AddAppShelfItem';
function sendDockerCommand(action: string, containerId: string, containerName: string) { function sendDockerCommand(
action: string,
containerId: string,
containerName: string,
reload: () => void
) {
showNotification({ showNotification({
id: containerId, id: containerId,
loading: true, loading: true,
title: `${action}ing container ${containerName.substring(1)}`, title: `${action}ing container ${containerName}`,
message: undefined, message: undefined,
autoClose: false, autoClose: false,
disallowClose: true, disallowClose: true,
}); });
axios.get(`/api/docker/container/${containerId}?action=${action}`).then((res) => { axios
setTimeout(() => { .get(`/api/docker/container/${containerId}?action=${action}`)
if (res.data.success === true) { .then((res) => {
updateNotification({ updateNotification({
id: containerId, id: containerId,
title: `Container ${containerName} ${action}ed`, title: `Container ${containerName} ${action}ed`,
message: `Your container was successfully ${action}ed`, message: `Your container was successfully ${action}ed`,
icon: <IconCheck />, icon: <IconCheck />,
autoClose: 2000, autoClose: 2000,
}); });
} })
if (res.data.success === false) { .catch((err) => {
updateNotification({ updateNotification({
id: containerId, id: containerId,
color: 'red', color: 'red',
title: 'There was an error with your container.', title: 'There was an error',
message: undefined, message: err.response.data.reason,
icon: <IconX />, autoClose: 2000,
autoClose: 2000, });
}); })
} .finally(() => {
}, 500); reload();
}); });
} }
export interface ContainerActionBarProps { export interface ContainerActionBarProps {
@@ -57,7 +60,6 @@ export interface ContainerActionBarProps {
} }
export default function ContainerActionBar({ selected, reload }: ContainerActionBarProps) { export default function ContainerActionBar({ selected, reload }: ContainerActionBarProps) {
const { config, setConfig } = useConfig();
const [opened, setOpened] = useBooleanToggle(false); const [opened, setOpened] = useBooleanToggle(false);
return ( return (
<Group> <Group>
@@ -79,9 +81,9 @@ export default function ContainerActionBar({ selected, reload }: ContainerAction
onClick={() => onClick={() =>
Promise.all( Promise.all(
selected.map((container) => selected.map((container) =>
sendDockerCommand('restart', container.Id, container.Names[0].substring(1)) sendDockerCommand('restart', container.Id, container.Names[0].substring(1), reload)
) )
).then(() => reload()) )
} }
variant="light" variant="light"
color="orange" color="orange"
@@ -93,22 +95,10 @@ export default function ContainerActionBar({ selected, reload }: ContainerAction
leftIcon={<IconPlayerStop />} leftIcon={<IconPlayerStop />}
onClick={() => onClick={() =>
Promise.all( Promise.all(
selected.map((container) => { selected.map((container) =>
if ( sendDockerCommand('stop', container.Id, container.Names[0].substring(1), reload)
container.State === 'stopped' || )
container.State === 'created' || )
container.State === 'exited'
) {
return showNotification({
id: container.Id,
title: `Failed to stop ${container.Names[0].substring(1)}`,
message: "You can't stop a stopped container",
autoClose: 1000,
});
}
return sendDockerCommand('stop', container.Id, container.Names[0].substring(1));
})
).then(() => reload())
} }
variant="light" variant="light"
color="red" color="red"
@@ -121,9 +111,9 @@ export default function ContainerActionBar({ selected, reload }: ContainerAction
onClick={() => onClick={() =>
Promise.all( Promise.all(
selected.map((container) => selected.map((container) =>
sendDockerCommand('start', container.Id, container.Names[0].substring(1)) sendDockerCommand('start', container.Id, container.Names[0].substring(1), reload)
) )
).then(() => reload()) )
} }
variant="light" variant="light"
color="green" color="green"
@@ -143,7 +133,7 @@ export default function ContainerActionBar({ selected, reload }: ContainerAction
if (selected.length !== 1) { if (selected.length !== 1) {
showNotification({ showNotification({
autoClose: 5000, autoClose: 5000,
title: <Title order={4}>Please only add one service at a time!</Title>, title: <Title order={5}>Please only add one service at a time!</Title>,
color: 'red', color: 'red',
message: undefined, message: undefined,
}); });
@@ -161,18 +151,10 @@ export default function ContainerActionBar({ selected, reload }: ContainerAction
radius="md" radius="md"
onClick={() => onClick={() =>
Promise.all( Promise.all(
selected.map((container) => { selected.map((container) =>
if (container.State === 'running') { sendDockerCommand('remove', container.Id, container.Names[0].substring(1), reload)
return showNotification({ )
id: container.Id, )
title: `Failed to delete ${container.Names[0].substring(1)}`,
message: "You can't delete a running container",
autoClose: 1000,
});
}
return sendDockerCommand('remove', container.Id, container.Names[0].substring(1));
})
).then(() => reload())
} }
> >
Remove Remove

View File

@@ -1,31 +1,62 @@
import { ActionIcon, Drawer, Group, LoadingOverlay } from '@mantine/core'; import { ActionIcon, Drawer, Group, LoadingOverlay, Text } from '@mantine/core';
import { IconBrandDocker } from '@tabler/icons';
import axios from 'axios'; import axios from 'axios';
import { useEffect, useState } from 'react'; import { useEffect, useState } from 'react';
import Docker from 'dockerode'; import Docker from 'dockerode';
import { IconBrandDocker, IconX } from '@tabler/icons';
import { showNotification } from '@mantine/notifications';
import ContainerActionBar from './ContainerActionBar'; import ContainerActionBar from './ContainerActionBar';
import DockerTable from './DockerTable'; import DockerTable from './DockerTable';
import { useConfig } from '../../../tools/state';
import { IModule } from '../modules';
export default function DockerDrawer(props: any) { export const DockerModule: IModule = {
title: 'Docker',
description: 'Allows you to easily manage your torrents',
icon: IconBrandDocker,
component: DockerMenuButton,
};
export default function DockerMenuButton(props: any) {
const [opened, setOpened] = useState(false); const [opened, setOpened] = useState(false);
const [containers, setContainers] = useState<Docker.ContainerInfo[]>([]); const [containers, setContainers] = useState<Docker.ContainerInfo[]>([]);
const [selection, setSelection] = useState<Docker.ContainerInfo[]>([]); const [selection, setSelection] = useState<Docker.ContainerInfo[]>([]);
const [visible, setVisible] = useState(false); const [visible, setVisible] = useState(false);
const { config } = useConfig();
function reload() { const moduleEnabled = config.modules?.[DockerModule.title]?.enabled ?? false;
setVisible(true);
setTimeout(() => {
axios.get('/api/docker/containers').then((res) => {
setContainers(res.data);
setSelection([]);
setVisible(false);
});
}, 300);
}
useEffect(() => { useEffect(() => {
reload(); reload();
}, []); }, [config.modules]);
function reload() {
if (!moduleEnabled) {
return;
}
setVisible(true);
setTimeout(() => {
axios
.get('/api/docker/containers')
.then((res) => {
setContainers(res.data);
setSelection([]);
setVisible(false);
})
.catch(() =>
// Send an Error notification
showNotification({
autoClose: 1500,
title: <Text>Docker integration failed</Text>,
color: 'red',
icon: <IconX />,
message: 'Did you forget to mount the docker socket ?',
})
);
}, 300);
}
const exists = config.modules?.[DockerModule.title]?.enabled ?? false;
if (!exists) {
return null;
}
// Check if the user has at least one container // Check if the user has at least one container
if (containers.length < 1) return null; if (containers.length < 1) return null;
return ( return (

View File

@@ -0,0 +1,125 @@
import { Table, Checkbox, Group, Badge, createStyles, ScrollArea, TextInput } from '@mantine/core';
import { IconSearch } from '@tabler/icons';
import Dockerode from 'dockerode';
import { useEffect, useState } from 'react';
import ContainerState from './ContainerState';
const useStyles = createStyles((theme) => ({
rowSelected: {
backgroundColor:
theme.colorScheme === 'dark'
? theme.fn.rgba(theme.colors[theme.primaryColor][7], 0.2)
: theme.colors[theme.primaryColor][0],
},
}));
export default function DockerTable({
containers,
selection,
setSelection,
}: {
setSelection: any;
containers: Dockerode.ContainerInfo[];
selection: Dockerode.ContainerInfo[];
}) {
const [usedContainers, setContainers] = useState<Dockerode.ContainerInfo[]>(containers);
const { classes, cx } = useStyles();
const [search, setSearch] = useState('');
useEffect(() => {
setContainers(containers);
}, [containers]);
const handleSearchChange = (event: React.ChangeEvent<HTMLInputElement>) => {
const { value } = event.currentTarget;
setSearch(value);
setContainers(filterContainers(containers, value));
};
function filterContainers(data: Dockerode.ContainerInfo[], search: string) {
const query = search.toLowerCase().trim();
return data.filter((item) =>
item.Names.some((name) => name.toLowerCase().includes(query) || item.Image.includes(query))
);
}
const toggleRow = (container: Dockerode.ContainerInfo) =>
setSelection((current: Dockerode.ContainerInfo[]) =>
current.includes(container) ? current.filter((c) => c !== container) : [...current, container]
);
const toggleAll = () =>
setSelection((current: any) =>
current.length === usedContainers.length ? [] : usedContainers.map((c) => c)
);
const rows = usedContainers.map((element) => {
const selected = selection.includes(element);
return (
<tr key={element.Id} className={cx({ [classes.rowSelected]: selected })}>
<td>
<Checkbox
checked={selection.includes(element)}
onChange={() => toggleRow(element)}
transitionDuration={0}
/>
</td>
<td>{element.Names[0].replace('/', '')}</td>
<td>{element.Image}</td>
<td>
<Group>
{element.Ports.sort((a, b) => a.PrivatePort - b.PrivatePort)
// Remove duplicates with filter function
.filter(
(port, index, self) =>
index === self.findIndex((t) => t.PrivatePort === port.PrivatePort)
)
.slice(-3)
.map((port) => (
<Badge key={port.PrivatePort} variant="outline">
{port.PrivatePort}:{port.PublicPort}
</Badge>
))}
{element.Ports.length > 3 && (
<Badge variant="filled">{element.Ports.length - 3} more</Badge>
)}
</Group>
</td>
<td>
<ContainerState state={element.State} />
</td>
</tr>
);
});
return (
<ScrollArea style={{ height: '80vh' }}>
<TextInput
placeholder="Search by container or image name"
mt="md"
icon={<IconSearch size={14} />}
value={search}
onChange={handleSearchChange}
/>
<Table captionSide="bottom" highlightOnHover sx={{ minWidth: 800 }} verticalSpacing="sm">
<caption>your docker containers</caption>
<thead>
<tr>
<th style={{ width: 40 }}>
<Checkbox
onChange={toggleAll}
checked={selection.length === usedContainers.length}
indeterminate={selection.length > 0 && selection.length !== usedContainers.length}
transitionDuration={0}
/>
</th>
<th>Name</th>
<th>Image</th>
<th>Ports</th>
<th>State</th>
</tr>
</thead>
<tbody>{rows}</tbody>
</Table>
</ScrollArea>
);
}

View File

@@ -0,0 +1 @@
export { DockerModule } from './DockerModule';

View File

@@ -15,6 +15,7 @@ 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 { useViewportSize } from '@mantine/hooks';
import { showNotification } from '@mantine/notifications';
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';
@@ -52,12 +53,30 @@ export default function DownloadComponent() {
useEffect(() => { useEffect(() => {
setIsLoading(true); setIsLoading(true);
if (downloadServices.length === 0) return; if (downloadServices.length === 0) return;
setSafeInterval(() => { const interval = setInterval(() => {
// Send one request with each download service inside // Send one request with each download service inside
axios.post('/api/modules/downloads', { config }).then((response) => { axios
setTorrents(response.data); .post('/api/modules/downloads')
setIsLoading(false); .then((response) => {
}); setTorrents(response.data);
setIsLoading(false);
})
.catch((error) => {
setTorrents([]);
// eslint-disable-next-line no-console
console.error('Error while fetching torrents', error.response.data);
setIsLoading(false);
showNotification({
title: 'Error fetching torrents',
autoClose: 1000,
disallowClose: true,
id: 'fail-torrent-downloads-module',
color: 'red',
message:
'Please check your config for any potential errors, check the console for more info',
});
clearInterval(interval);
});
}, 5000); }, 5000);
}, []); }, []);

View File

@@ -6,6 +6,7 @@ import { NormalizedTorrent } from '@ctrl/shared-torrent';
import { linearGradientDef } from '@nivo/core'; import { linearGradientDef } from '@nivo/core';
import { Datum, ResponsiveLine } from '@nivo/line'; import { Datum, ResponsiveLine } from '@nivo/line';
import { useListState } from '@mantine/hooks'; import { useListState } from '@mantine/hooks';
import { showNotification } from '@mantine/notifications';
import { AddItemShelfButton } from '../../AppShelf/AddAppShelfItem'; import { AddItemShelfButton } from '../../AppShelf/AddAppShelfItem';
import { useConfig } from '../../../tools/state'; import { useConfig } from '../../../tools/state';
import { humanFileSize } from '../../../tools/humanFileSize'; import { humanFileSize } from '../../../tools/humanFileSize';
@@ -42,11 +43,28 @@ export default function TotalDownloadsComponent() {
const totalDownloadSpeed = torrents.reduce((acc, torrent) => acc + torrent.downloadSpeed, 0); const totalDownloadSpeed = torrents.reduce((acc, torrent) => acc + torrent.downloadSpeed, 0);
const totalUploadSpeed = torrents.reduce((acc, torrent) => acc + torrent.uploadSpeed, 0); const totalUploadSpeed = torrents.reduce((acc, torrent) => acc + torrent.uploadSpeed, 0);
useEffect(() => { useEffect(() => {
if (downloadServices.length === 0) return; const interval = setSafeInterval(() => {
setSafeInterval(() => { // Send one request with each download service inside
axios.post('/api/modules/downloads', { config }).then((response) => { axios
setTorrents(response.data); .post('/api/modules/downloads')
}); .then((response) => {
setTorrents(response.data);
})
.catch((error) => {
setTorrents([]);
// eslint-disable-next-line no-console
console.error('Error while fetching torrents', error.response.data);
showNotification({
title: 'Torrent speed module failed to fetch torrents',
autoClose: 1000,
disallowClose: true,
id: 'fail-torrent-speed-module',
color: 'red',
message:
'Error fetching torrents, please check your config for any potential errors, check the console for more info',
});
clearInterval(interval);
});
}, 1000); }, 1000);
}, [config.services]); }, [config.services]);

View File

@@ -5,3 +5,4 @@ export * from './downloads';
export * from './ping'; export * from './ping';
export * from './search'; export * from './search';
export * from './weather'; export * from './weather';
export * from './docker';

View File

@@ -1,11 +1,14 @@
// This interface is to be used in all the modules of the project // This interface is to be used in all the modules of the project
// Each module should have its own interface and call the following function: // Each module should have its own interface and call the following function:
// TODO: Add a function to register a module // TODO: Add a function to register a module
import { TablerIcon } from '@tabler/icons';
// Note: Maybe use context to keep track of the modules // Note: Maybe use context to keep track of the modules
export interface IModule { export interface IModule {
title: string; title: string;
description: string; description: string;
icon: React.ReactNode; icon: TablerIcon;
component: React.ComponentType; component: React.ComponentType;
options?: Option; options?: Option;
} }

View File

@@ -1,18 +0,0 @@
import { serviceItem } from '../../../tools/types';
import PingComponent from './PingModule';
export default {
title: 'Modules/Search bar',
};
const service: serviceItem = {
id: '1',
type: 'Other',
name: 'YouTube',
icon: 'https://cdn.jsdelivr.net/gh/walkxhub/dashboard-icons/png/youtube.png',
url: 'https://youtube.com/',
status: ['200'],
newTab: false,
};
export const Default = (args: any) => <PingComponent service={service} />;

View File

@@ -1,10 +0,0 @@
import SearchBar from './SearchModule';
export default {
title: 'Search bar',
config: {
searchBar: false,
},
};
export const Default = (args: any) => <SearchBar {...args} />;

View File

@@ -1,4 +1,4 @@
import { Kbd, createStyles, Text, Popover, Autocomplete, Tooltip } from '@mantine/core'; import { Kbd, createStyles, Autocomplete } from '@mantine/core';
import { useDebouncedValue, useForm, useHotkeys } from '@mantine/hooks'; import { useDebouncedValue, useForm, useHotkeys } from '@mantine/hooks';
import { useEffect, useRef, useState } from 'react'; import { useEffect, useRef, useState } from 'react';
import { import {

View File

@@ -157,7 +157,7 @@ export default function WeatherComponent(props: any) {
}); });
}, [cityInput]); }, [cityInput]);
if (!weather.current_weather) { if (!weather.current_weather) {
return ( return (
<> <>
<Skeleton height={40} width={100} mb="xl" /> <Skeleton height={40} width={100} mb="xl" />
<Group noWrap direction="row"> <Group noWrap direction="row">

View File

@@ -1,15 +1,15 @@
import { NextFetchEvent, NextRequest, NextResponse } from 'next/server'; import { NextResponse } from 'next/server';
import type { NextRequest } from 'next/server';
export function middleware(req: NextRequest, ev: NextFetchEvent) { // eslint-disable-next-line consistent-return
const ok = req.cookies.get('password') === process.env.PASSWORD; export function middleware(request: NextRequest) {
const url = req.nextUrl.clone(); // const cookie = request.cookies.get('password');
if ( // const isPasswordCorrect = cookie === process.env.PASSWORD;
!ok && // if (
url.pathname !== '/login' && // !isPasswordCorrect &&
process.env.PASSWORD && // request.nextUrl.pathname !== '/login' &&
url.pathname !== '/api/configs/tryPassword' // request.nextUrl.pathname !== '/api/configs/trylogin'
) { // ) {
url.pathname = '/login'; // return NextResponse.redirect('/login');
} // }
return NextResponse.rewrite(url);
} }

View File

@@ -58,7 +58,7 @@ const useStyles = createStyles((theme) => ({
}, },
})); }));
export function Illustration(props: React.ComponentPropsWithoutRef<'svg'>) { function Illustration(props: React.ComponentPropsWithoutRef<'svg'>) {
const theme = useMantineTheme(); const theme = useMantineTheme();
return ( return (
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 362 145" {...props}> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 362 145" {...props}>
@@ -70,7 +70,7 @@ export function Illustration(props: React.ComponentPropsWithoutRef<'svg'>) {
); );
} }
export default function NothingFoundBackground() { export default function Custom404() {
const { classes } = useStyles(); const { classes } = useStyles();
return ( return (

View File

@@ -1,7 +1,7 @@
import { GetServerSidePropsContext } from 'next'; import { GetServerSidePropsContext } from 'next';
import { useState } from 'react'; import { useState } from 'react';
import { AppProps } from 'next/app'; import { AppProps } from 'next/app';
import { getCookie, setCookies } from 'cookies-next'; import { getCookie, setCookie } from 'cookies-next';
import Head from 'next/head'; import Head from 'next/head';
import { MantineProvider, ColorScheme, ColorSchemeProvider, MantineTheme } from '@mantine/core'; import { MantineProvider, ColorScheme, ColorSchemeProvider, MantineTheme } from '@mantine/core';
import { NotificationsProvider } from '@mantine/notifications'; import { NotificationsProvider } from '@mantine/notifications';
@@ -30,7 +30,7 @@ export default function App(this: any, props: AppProps & { colorScheme: ColorSch
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);
setCookies('color-scheme', nextColorScheme, { maxAge: 60 * 60 * 24 * 30 }); setCookie('color-scheme', nextColorScheme, { maxAge: 60 * 60 * 24 * 30 });
}; };
useHotkeys([['mod+J', () => toggleColorScheme()]]); useHotkeys([['mod+J', () => toggleColorScheme()]]);

View File

@@ -21,37 +21,31 @@ async function Get(req: NextApiRequest, res: NextApiResponse) {
} }
// Get the container with the ID // Get the container with the ID
const container = docker.getContainer(id); const container = docker.getContainer(id);
// Get the container info const startAction = async () => {
container.inspect((err, data) => {
if (err) {
res.status(500).json({
message: err,
});
}
});
try {
switch (action) { switch (action) {
case 'remove': case 'remove':
await container.remove(); return container.remove();
break;
case 'start': case 'start':
container.start(); return container.start();
break;
case 'stop': case 'stop':
container.stop(); return container.stop();
break;
case 'restart': case 'restart':
container.restart(); return container.restart();
break; default:
return Promise;
} }
} catch (err) { };
res.status(500).json({ try {
message: err, await startAction();
return res.status(200).json({
statusCode: 200,
message: `Container ${id} ${action}ed`,
}); });
} catch (err) {
return res.status(500).json(
err,
);
} }
return res.status(200).json({
success: true,
});
} }
export default async (req: NextApiRequest, res: NextApiResponse) => { export default async (req: NextApiRequest, res: NextApiResponse) => {

View File

@@ -2,11 +2,14 @@ import { NextApiRequest, NextApiResponse } from 'next';
import Docker from 'dockerode'; import Docker from 'dockerode';
const docker = new Docker();
async function Get(req: NextApiRequest, res: NextApiResponse) { async function Get(req: NextApiRequest, res: NextApiResponse) {
const containers = await docker.listContainers({ all: true }); try {
return res.status(200).json(containers); const docker = new Docker();
const containers = await docker.listContainers({ all: true });
res.status(200).json(containers);
} catch (err) {
res.status(500).json({ err });
}
} }
export default async (req: NextApiRequest, res: NextApiResponse) => { export default async (req: NextApiRequest, res: NextApiResponse) => {

View File

@@ -1,9 +1,24 @@
import axios from 'axios'; import axios from 'axios';
import { getCookie } from 'cookies-next';
import { NextApiRequest, NextApiResponse } from 'next'; import { NextApiRequest, NextApiResponse } from 'next';
import { serviceItem } from '../../../tools/types'; import { getConfig } from '../../../tools/getConfig';
import { Config } from '../../../tools/types';
async function Post(req: NextApiRequest, res: NextApiResponse) { async function Post(req: NextApiRequest, res: NextApiResponse) {
// Parse req.body as a ServiceItem // Parse req.body as a ServiceItem
const { id } = req.body;
const { type } = req.query;
const configName = getCookie('config-name', { req });
const { config }: { config: Config } = getConfig(configName?.toString() ?? 'default').props;
// Find service with serviceId in config
const service = config.services.find((service) => service.id === id);
if (!service) {
return res.status(500).json({
statusCode: 500,
message: 'Missing service',
});
}
const nextMonth = new Date(new Date().setMonth(new Date().getMonth() + 2)).toISOString(); 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 lastMonth = new Date(new Date().setMonth(new Date().getMonth() - 2)).toISOString();
const TypeToUrl: { service: string; url: string }[] = [ const TypeToUrl: { service: string; url: string }[] = [
@@ -24,8 +39,6 @@ async function Post(req: NextApiRequest, res: NextApiResponse) {
url: '/api/v1/calendar', url: '/api/v1/calendar',
}, },
]; ];
const service: serviceItem = req.body;
const { type } = req.query;
if (!type) { if (!type) {
return res.status(400).json({ return res.status(400).json({
message: 'Missing required parameter in url: type', message: 'Missing required parameter in url: type',
@@ -49,10 +62,10 @@ async function Post(req: NextApiRequest, res: NextApiResponse) {
origin = origin.slice(0, -1); origin = origin.slice(0, -1);
} }
const pined = `${origin}${url?.url}?apiKey=${service.apiKey}&end=${nextMonth}&start=${lastMonth}`; const pined = `${origin}${url?.url}?apiKey=${service.apiKey}&end=${nextMonth}&start=${lastMonth}`;
const data = await axios.get( return axios
`${origin}${url?.url}?apiKey=${service.apiKey}&end=${nextMonth}&start=${lastMonth}` .get(`${origin}${url?.url}?apiKey=${service.apiKey}&end=${nextMonth}&start=${lastMonth}`)
); .then((response) => res.status(200).json(response.data))
return res.status(200).json(data.data); .catch((e) => res.status(500).json(e));
// // Make a request to the URL // // Make a request to the URL
// const response = await axios.get(url); // const response = await axios.get(url);
// // Return the response // // Return the response

View File

@@ -2,12 +2,15 @@ import { Deluge } from '@ctrl/deluge';
import { QBittorrent } from '@ctrl/qbittorrent'; import { QBittorrent } from '@ctrl/qbittorrent';
import { NormalizedTorrent } from '@ctrl/shared-torrent'; import { NormalizedTorrent } from '@ctrl/shared-torrent';
import { Transmission } from '@ctrl/transmission'; import { Transmission } from '@ctrl/transmission';
import { getCookie } from 'cookies-next';
import { NextApiRequest, NextApiResponse } from 'next'; import { NextApiRequest, NextApiResponse } from 'next';
import { getConfig } from '../../../tools/getConfig';
import { Config } from '../../../tools/types'; 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 { config }: { config: Config } = req.body; const configName = getCookie('config-name', { req });
const { config }: { config: Config } = getConfig(configName?.toString() ?? 'default').props;
const qBittorrentServices = config.services.filter((service) => service.type === 'qBittorrent'); const qBittorrentServices = config.services.filter((service) => service.type === 'qBittorrent');
const delugeServices = config.services.filter((service) => service.type === 'Deluge'); const delugeServices = config.services.filter((service) => service.type === 'Deluge');
const transmissionServices = config.services.filter((service) => service.type === 'Transmission'); const transmissionServices = config.services.filter((service) => service.type === 'Transmission');
@@ -20,40 +23,44 @@ async function Post(req: NextApiRequest, res: NextApiResponse) {
message: 'Missing services', message: 'Missing services',
}); });
} }
await Promise.all( try {
qBittorrentServices.map((service) => await Promise.all(
new QBittorrent({ qBittorrentServices.map((service) =>
baseUrl: service.url, new QBittorrent({
username: service.username, baseUrl: service.url,
password: service.password, username: service.username,
}) password: service.password,
.getAllData() })
.then((e) => torrents.push(...e.torrents)) .getAllData()
) .then((e) => torrents.push(...e.torrents))
); )
await Promise.all( );
delugeServices.map((service) => await Promise.all(
new Deluge({ delugeServices.map((service) =>
baseUrl: service.url, new Deluge({
password: 'password' in service ? service.password : '', baseUrl: service.url,
}) password: 'password' in service ? service.password : '',
.getAllData() })
.then((e) => torrents.push(...e.torrents)) .getAllData()
) .then((e) => torrents.push(...e.torrents))
); )
// Map transmissionServices );
await Promise.all( // Map transmissionServices
transmissionServices.map((service) => await Promise.all(
new Transmission({ transmissionServices.map((service) =>
baseUrl: service.url, new Transmission({
username: 'username' in service ? service.username : '', baseUrl: service.url,
password: 'password' in service ? service.password : '', username: 'username' in service ? service.username : '',
}) password: 'password' in service ? service.password : '',
.getAllData() })
.then((e) => torrents.push(...e.torrents)) .getAllData()
) .then((e) => torrents.push(...e.torrents))
); )
res.status(200).json(torrents); );
} catch (e: any) {
return res.status(401).json(e);
}
return res.status(200).json(torrents);
} }
export default async (req: NextApiRequest, res: NextApiResponse) => { export default async (req: NextApiRequest, res: NextApiResponse) => {

View File

@@ -1,4 +1,4 @@
import { getCookie, setCookies } from 'cookies-next'; import { getCookie, setCookie } from 'cookies-next';
import { GetServerSidePropsContext } from 'next'; import { GetServerSidePropsContext } from 'next';
import { useEffect } from 'react'; import { useEffect } from 'react';
import AppShelf from '../components/AppShelf/AppShelf'; import AppShelf from '../components/AppShelf/AppShelf';
@@ -16,7 +16,7 @@ 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', { setCookie('config-name', 'default', {
req, req,
res, res,
maxAge: 60 * 60 * 24 * 30, maxAge: 60 * 60 * 24 * 30,

View File

@@ -1,10 +1,11 @@
import React from 'react'; import React from 'react';
import { PasswordInput, Anchor, Paper, Title, Text, Container, Group, Button } from '@mantine/core'; import { PasswordInput, Anchor, Paper, Title, Text, Container, Group, Button } from '@mantine/core';
import { setCookies } from 'cookies-next'; import { setCookie } from 'cookies-next';
import { useForm } from '@mantine/hooks'; import { useForm } from '@mantine/hooks';
import { showNotification, updateNotification } from '@mantine/notifications'; import { showNotification, updateNotification } from '@mantine/notifications';
import axios from 'axios'; import axios from 'axios';
import { IconCheck, IconX } from '@tabler/icons'; import { IconCheck, IconX } from '@tabler/icons';
import { Logo } from '../components/layout/Logo';
// TODO: Add links to the wiki articles about the login process. // TODO: Add links to the wiki articles about the login process.
export default function AuthenticationTitle() { export default function AuthenticationTitle() {
@@ -15,22 +16,26 @@ export default function AuthenticationTitle() {
}); });
return ( return (
<Container <Container
size={420} size="lg"
style={{ style={{
height: '100vh', height: '100vh',
display: 'flex', display: 'flex',
width: 420, width: '100%',
flexDirection: 'column', flexDirection: 'column',
alignItems: 'center', alignItems: 'center',
justifyContent: 'center', justifyContent: 'center',
}} }}
> >
<Title <Group>
align="center" <Title
sx={(theme) => ({ fontFamily: `Greycliff CF, ${theme.fontFamily}`, fontWeight: 900 })} align="center"
> sx={(theme) => ({ fontFamily: `Greycliff CF, ${theme.fontFamily}`, fontWeight: 900 })}
Welcome back! >
</Title> Welcome back!
</Title>
<Logo withoutText />
</Group>
<Text color="dimmed" size="sm" align="center" mt={5}> <Text color="dimmed" size="sm" align="center" mt={5}>
Please enter the{' '} Please enter the{' '}
<Anchor<'a'> href="#" size="sm" onClick={(event) => event.preventDefault()}> <Anchor<'a'> href="#" size="sm" onClick={(event) => event.preventDefault()}>
@@ -38,10 +43,17 @@ export default function AuthenticationTitle() {
</Anchor> </Anchor>
</Text> </Text>
<Paper withBorder shadow="md" p={30} mt={30} radius="md" style={{ width: 420 }}> <Paper
withBorder
shadow="md"
p={30}
mt={30}
radius="md"
style={{ width: '100%', maxWidth: 420 }}
>
<form <form
onSubmit={form.onSubmit((values) => { onSubmit={form.onSubmit((values) => {
setCookies('password', values.password, { setCookie('password', values.password, {
maxAge: 60 * 60 * 24 * 30, maxAge: 60 * 60 * 24 * 30,
sameSite: 'lax', sameSite: 'lax',
}); });
@@ -64,8 +76,7 @@ export default function AuthenticationTitle() {
id: 'load-data', id: 'load-data',
color: 'teal', color: 'teal',
title: 'Password correct', title: 'Password correct',
message: message: undefined,
'Notification will close in 2 seconds, you can close this notification now',
icon: <IconCheck />, icon: <IconCheck />,
autoClose: 300, autoClose: 300,
onClose: () => { onClose: () => {
@@ -78,8 +89,7 @@ export default function AuthenticationTitle() {
id: 'load-data', id: 'load-data',
color: 'red', color: 'red',
title: 'Password is wrong, please try again.', title: 'Password is wrong, please try again.',
message: message: undefined,
'Notification will close in 2 seconds, you can close this notification now',
icon: <IconX />, icon: <IconX />,
autoClose: 2000, autoClose: 2000,
}); });
@@ -93,14 +103,10 @@ export default function AuthenticationTitle() {
label="Password" label="Password"
placeholder="Your password" placeholder="Your password"
required required
autoFocus
mt="md" mt="md"
{...form.getInputProps('password')} {...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"> <Button fullWidth type="submit" mt="xl">
Sign in Sign in
</Button> </Button>

View File

@@ -1,5 +1,5 @@
import Dockerode from 'dockerode'; import Dockerode from 'dockerode';
import { Config, MatchingImages, ServiceType } from './types'; import { Config, MatchingImages, ServiceType, tryMatchPort } from './types';
async function MatchIcon(name: string) { async function MatchIcon(name: string) {
const res = await fetch( const res = await fetch(
@@ -23,11 +23,13 @@ function tryMatchType(imageName: string): ServiceType {
export function tryMatchService(container: Dockerode.ContainerInfo | undefined) { export function tryMatchService(container: Dockerode.ContainerInfo | undefined) {
if (container === undefined) return {}; if (container === undefined) return {};
const name = container.Names[0].substring(1); const name = container.Names[0].substring(1);
const type = tryMatchType(container.Image);
const port = tryMatchPort(type.toLowerCase());
return { return {
name, name,
id: container.Id, id: container.Id,
type: tryMatchType(container.Image), type: tryMatchType(container.Image),
url: `${container.Ports.at(0)?.IP}:${container.Ports.at(0)?.PublicPort}`, url: `localhost${port ? `:${port.value}` : ''}`,
icon: `https://cdn.jsdelivr.net/gh/walkxhub/dashboard-icons/png/${name icon: `https://cdn.jsdelivr.net/gh/walkxhub/dashboard-icons/png/${name
.replace(/\s+/g, '-') .replace(/\s+/g, '-')
.toLowerCase()}.png`, .toLowerCase()}.png`,

View File

@@ -14,7 +14,11 @@ export function getConfig(name: string) {
settings: { settings: {
searchUrl: 'https://www.google.com/search?q=', searchUrl: 'https://www.google.com/search?q=',
}, },
modules: {}, modules: {
'Search Bar': {
enabled: true,
},
},
}, },
}, },
}; };

View File

@@ -60,34 +60,105 @@ export const Targets = [
export const ServiceTypeList = [ export const ServiceTypeList = [
'Other', 'Other',
'Emby',
'Dash.', 'Dash.',
'Deluge', 'Deluge',
'Emby',
'Lidarr', 'Lidarr',
'Plex', 'Plex',
'qBittorrent',
'Radarr', 'Radarr',
'Readarr', 'Readarr',
'Sonarr', 'Sonarr',
'qBittorrent',
'Transmission', 'Transmission',
]; ];
export type ServiceType = export type ServiceType =
| 'Other' | 'Other'
| 'Emby'
| 'Dash.' | 'Dash.'
| 'Deluge' | 'Deluge'
| 'Emby'
| 'Lidarr' | 'Lidarr'
| 'Plex' | 'Plex'
| 'qBittorrent'
| 'Radarr' | 'Radarr'
| 'Readarr' | 'Readarr'
| 'Sonarr' | 'Sonarr'
| 'qBittorrent'
| 'Transmission'; | 'Transmission';
export const MatchingImages: { image: string; type: ServiceType }[] = [ export function tryMatchPort(name: string, form?: any) {
{ image: 'lscr.io/linuxserver/radarr', type: 'Radarr' }, // Match name with portmap key
{ image: 'lscr.io/linuxserver/sonarr', type: 'Sonarr' }, const port = portmap.find((p) => p.name === name.toLowerCase());
if (form && port) {
form.setFieldValue('url', `http://localhost:${port.value}`);
}
return port;
}
export const portmap = [
{ name: 'qbittorrent', value: '8080' },
{ name: 'sonarr', value: '8989' },
{ name: 'radarr', value: '7878' },
{ name: 'lidarr', value: '8686' },
{ name: 'readarr', value: '8787' },
{ name: 'deluge', value: '8112' },
{ name: 'transmission', value: '9091' },
{ name: 'dash.', value: '3001' },
];
export const MatchingImages: {
image: string;
type: ServiceType;
}[] = [
//Official images
{ image: 'mauricenino/dashdot', type: 'Dash.' },
{ image: 'emby/embyserver', type: 'Emby' },
{ image: 'plexinc/pms-docker', type: 'Plex' },
//Lidarr images
{ image: 'hotio/lidarr', type: 'Lidarr' },
{ image: 'ghcr.io/hotio/lidarr', type: 'Lidarr' },
{ image: 'cr.hotio.dev/hotio/lidarr', type: 'Lidarr' },
// Plex
{ image: 'hotio/plex', type: 'Plex' },
{ image: 'ghcr.io/hotio/plex', type: 'Plex' },
{ image: 'cr.hotio.dev/hotio/plex', type: 'Plex' },
// qbittorrent
{ image: 'hotio/qbittorrent', type: 'qBittorrent' },
{ image: 'ghcr.io/hotio/qbittorrent', type: 'qBittorrent' },
{ image: 'cr.hotio.dev/hotio/qbittorrent', type: 'qBittorrent' },
// Radarr
{ image: 'hotio/radarr', type: 'Radarr' },
{ image: 'ghcr.io/hotio/radarr', type: 'Radarr' },
{ image: 'cr.hotio.dev/hotio/radarr', type: 'Radarr' },
// Readarr
{ image: 'hotio/readarr', type: 'Readarr' },
{ image: 'ghcr.io/hotio/readarr', type: 'Readarr' },
{ image: 'cr.hotio.dev/hotio/readarr', type: 'Readarr' },
// Sonarr
{ image: 'hotio/sonarr', type: 'Sonarr' },
{ image: 'ghcr.io/hotio/sonarr', type: 'Sonarr' },
{ image: 'cr.hotio.dev/hotio/sonarr', type: 'Sonarr' },
//LinuxServer images
{ image: 'lscr.io/linuxserver/deluge', type: 'Deluge' },
{ image: 'lscr.io/linuxserver/emby', type: 'Emby' },
{ image: 'lscr.io/linuxserver/lidarr', type: 'Lidarr' },
{ image: 'lscr.io/linuxserver/plex', type: 'Plex' },
{ image: 'lscr.io/linuxserver/qbittorrent', type: 'qBittorrent' }, { image: 'lscr.io/linuxserver/qbittorrent', type: 'qBittorrent' },
{ image: 'lscr.io/linuxserver/radarr', type: 'Radarr' },
{ image: 'lscr.io/linuxserver/readarr', type: 'Readarr' },
{ image: 'lscr.io/linuxserver/sonarr', type: 'Sonarr' },
{ image: 'lscr.io/linuxserver/transmission', type: 'Transmission' },
// LinuxServer but on Docker Hub
{ image: 'linuxserver/deluge', type: 'Deluge' },
{ image: 'linuxserver/emby', type: 'Emby' },
{ image: 'linuxserver/lidarr', type: 'Lidarr' },
{ image: 'linuxserver/plex', type: 'Plex' },
{ image: 'linuxserver/qbittorrent', type: 'qBittorrent' },
{ image: 'linuxserver/radarr', type: 'Radarr' },
{ image: 'linuxserver/readarr', type: 'Readarr' },
{ image: 'linuxserver/sonarr', type: 'Sonarr' },
{ image: 'linuxserver/transmission', type: 'Transmission' },
//High usage
{ image: 'markusmcnugen/qbittorrentvpn', type: 'qBittorrent' },
{ image: 'haugene/transmission-openvpn', type: 'Transmission' },
]; ];
export interface serviceItem { export interface serviceItem {

11240
yarn.lock

File diff suppressed because it is too large Load Diff