From 9b440c0da330ab290a4cfeffdf273eae0d4a4f40 Mon Sep 17 00:00:00 2001 From: "Thomas \"ajnart\" Camlong" Date: Thu, 19 May 2022 02:04:48 +0200 Subject: [PATCH 01/33] =?UTF-8?q?=F0=9F=9A=A7=20Add=20basic=20BASE=5FURL?= =?UTF-8?q?=20and=20PORT=20env=20utilisation=20#76?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- next.config.js | 3 +++ package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/next.config.js b/next.config.js index 9cc409a07..a5d9163bd 100644 --- a/next.config.js +++ b/next.config.js @@ -1,3 +1,5 @@ +const { env } = require('process'); + const withBundleAnalyzer = require('@next/bundle-analyzer')({ enabled: process.env.ANALYZE === 'true', }); @@ -10,4 +12,5 @@ module.exports = withBundleAnalyzer({ experimental: { outputStandalone: true, }, + basePath: env.BASE_URL, }); diff --git a/package.json b/package.json index 8b110f68e..df92b3155 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "dev": "next dev", "build": "next build", "analyze": "ANALYZE=true next build", - "start": "next start --port 7575", + "start": "next start", "typecheck": "tsc --noEmit", "export": "next build && next export", "lint": "next lint", From 667322d14e878384936b014bf6504a8d7724677d Mon Sep 17 00:00:00 2001 From: "Thomas \"ajnart\" Camlong" Date: Thu, 19 May 2022 22:29:35 +0200 Subject: [PATCH 02/33] Use ID instead of only names --- src/components/AppShelf/AddAppShelfItem.tsx | 8 ++++++-- src/components/AppShelf/AppShelf.tsx | 4 ++-- src/components/AppShelf/AppShelfMenu.tsx | 3 ++- src/tools/types.ts | 2 +- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/components/AppShelf/AddAppShelfItem.tsx b/src/components/AppShelf/AddAppShelfItem.tsx index ccc6569f2..50cabc968 100644 --- a/src/components/AppShelf/AddAppShelfItem.tsx +++ b/src/components/AppShelf/AddAppShelfItem.tsx @@ -15,6 +15,7 @@ import { Title, } from '@mantine/core'; import { useForm } from '@mantine/form'; +import { time } from 'console'; import { motion } from 'framer-motion'; import { useState } from 'react'; import { Apps } from 'tabler-icons-react'; @@ -126,6 +127,7 @@ export function AddAppShelfItemForm(props: { setOpened: (b: boolean) => void } & const form = useForm({ initialValues: { + id: props.id ?? Date.now(), type: props.type ?? 'Other', name: props.name ?? '', icon: props.icon ?? '', @@ -166,11 +168,13 @@ export function AddAppShelfItemForm(props: { setOpened: (b: boolean) => void } &
{ // If service already exists, update it. - if (config.services && config.services.find((s) => s.name === form.values.name)) { + if (config.services && config.services.find((s) => s.id === form.values.id)) { + console.log('found service with the same id (modify)'); setConfig({ ...config, + // replace the found item by matching ID services: config.services.map((s) => { - if (s.name === form.values.name) { + if (s.id === form.values.id) { return { ...form.values, }; diff --git a/src/components/AppShelf/AppShelf.tsx b/src/components/AppShelf/AppShelf.tsx index 10cbee4ec..4d3fa553c 100644 --- a/src/components/AppShelf/AppShelf.tsx +++ b/src/components/AppShelf/AppShelf.tsx @@ -22,8 +22,8 @@ const AppShelf = (props: any) => { return ( {config.services.map((service) => ( - - + + ))} diff --git a/src/components/AppShelf/AppShelfMenu.tsx b/src/components/AppShelf/AppShelfMenu.tsx index 257d61629..0a491796d 100644 --- a/src/components/AppShelf/AppShelfMenu.tsx +++ b/src/components/AppShelf/AppShelfMenu.tsx @@ -22,6 +22,7 @@ export default function AppShelfMenu(props: any) { { setConfig({ ...config, - services: config.services.filter((s) => s.name !== service.name), + services: config.services.filter((s) => s.id !== service.id), }); showNotification({ autoClose: 5000, diff --git a/src/tools/types.ts b/src/tools/types.ts index 6465fc295..f22a3bb19 100644 --- a/src/tools/types.ts +++ b/src/tools/types.ts @@ -29,7 +29,7 @@ export type ServiceType = | 'Emby'; export interface serviceItem { - [x: string]: any; + id: number; name: string; type: string; url: string; From f36e7b8abb982a42cb6de3d75c1eb523af19f873 Mon Sep 17 00:00:00 2001 From: ajnart Date: Fri, 20 May 2022 23:03:42 +0200 Subject: [PATCH 03/33] :sparkles: Made service name clickable Co-authored-by: Bjorn L. --- src/components/AppShelf/AppShelf.tsx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/components/AppShelf/AppShelf.tsx b/src/components/AppShelf/AppShelf.tsx index 4d3fa553c..9d689e157 100644 --- a/src/components/AppShelf/AppShelf.tsx +++ b/src/components/AppShelf/AppShelf.tsx @@ -1,6 +1,6 @@ import React, { useState } from 'react'; import { motion } from 'framer-motion'; -import { Text, AspectRatio, Card, Image, Center, Grid, createStyles } from '@mantine/core'; +import { Text, AspectRatio, Card, Image, Center, Grid, createStyles, Anchor } from '@mantine/core'; import { useConfig } from '../../tools/state'; import { serviceItem } from '../../tools/types'; import AppShelfMenu from './AppShelfMenu'; @@ -51,9 +51,15 @@ export function AppShelfItem(props: any) { > - - {service.name} - + + + {service.name} + + Date: Sat, 21 May 2022 00:52:39 +0200 Subject: [PATCH 04/33] :wheelchair: Change 404 message --- src/pages/404.tsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/pages/404.tsx b/src/pages/404.tsx index 8dd04f06e..a98ece27d 100644 --- a/src/pages/404.tsx +++ b/src/pages/404.tsx @@ -78,10 +78,9 @@ export default function NothingFoundBackground() {
- Nothing to see here + Config not found - Page you are trying to open does not exist. You may have mistyped the address, or the - page has been moved to another URL. If you think this is an error contact support. + The config you are trying to access does not exist. Please check the URL and try again. From 25ccdffeb9fe2b582fe61401ba755d276b4a9b19 Mon Sep 17 00:00:00 2001 From: ajnart Date: Sat, 21 May 2022 00:52:55 +0200 Subject: [PATCH 05/33] :sparkles: Make logo clickable --- src/components/layout/Logo.tsx | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/components/layout/Logo.tsx b/src/components/layout/Logo.tsx index 805d5469d..c1232a051 100644 --- a/src/components/layout/Logo.tsx +++ b/src/components/layout/Logo.tsx @@ -1,4 +1,5 @@ import { Group, Image, Text } from '@mantine/core'; +import { NextLink } from '@mantine/next'; import * as React from 'react'; export function Logo({ style }: any) { @@ -11,14 +12,22 @@ export function Logo({ style }: any) { position: 'relative', }} /> - - Homarr - + + Homarr + + ); } From adb341c0fae8cfa9a3124c3ebcf2a6fde904fbdf Mon Sep 17 00:00:00 2001 From: ajnart Date: Sat, 21 May 2022 00:54:36 +0200 Subject: [PATCH 06/33] :sparkles: Add default icon, fix URL parsing Fixes #121 and Fixes #132 --- src/components/AppShelf/AddAppShelfItem.tsx | 29 +++++++++------------ 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/src/components/AppShelf/AddAppShelfItem.tsx b/src/components/AppShelf/AddAppShelfItem.tsx index 50cabc968..6cce33389 100644 --- a/src/components/AppShelf/AddAppShelfItem.tsx +++ b/src/components/AppShelf/AddAppShelfItem.tsx @@ -15,7 +15,6 @@ import { Title, } from '@mantine/core'; import { useForm } from '@mantine/form'; -import { time } from 'console'; import { motion } from 'framer-motion'; import { useState } from 'react'; import { Apps } from 'tabler-icons-react'; @@ -107,15 +106,11 @@ function MatchIcon(name: string, form: any) { `https://cdn.jsdelivr.net/gh/walkxhub/dashboard-icons/png/${name .replace(/\s+/g, '-') .toLowerCase()}.png` - ) - .then((res) => { - if (res.status === 200) { - form.setFieldValue('icon', res.url); - } - }) - .catch(() => { - // Do nothing - }); + ).then((res) => { + if (res.ok) { + form.setFieldValue('icon', res.url); + } + }); return false; } @@ -130,7 +125,7 @@ export function AddAppShelfItemForm(props: { setOpened: (b: boolean) => void } & id: props.id ?? Date.now(), type: props.type ?? 'Other', name: props.name ?? '', - icon: props.icon ?? '', + icon: props.icon ?? '/favicon.svg', url: props.url ?? '', apiKey: props.apiKey ?? (undefined as unknown as string), }, @@ -138,15 +133,18 @@ export function AddAppShelfItemForm(props: { setOpened: (b: boolean) => void } & apiKey: () => null, // Validate icon with a regex icon: (value: string) => { - if (!value.match(/^https?:\/\/.+\.(png|jpg|jpeg|gif)$/)) { + // Regex to match everything that ends with and icon extension + if (!value.match(/\.(png|jpg|jpeg|gif|svg)$/)) { return 'Please enter a valid icon URL'; } return null; }, // Validate url with a regex http/https url: (value: string) => { - if (!value.match(/^https?:\/\/.+\/$/)) { - return 'Please enter a valid URL (that ends with a /)'; + try { + const _isValid = new URL(value); + } catch (e) { + return 'Please enter a valid URL'; } return null; }, @@ -169,7 +167,6 @@ export function AddAppShelfItemForm(props: { setOpened: (b: boolean) => void } & onSubmit={form.onSubmit(() => { // If service already exists, update it. if (config.services && config.services.find((s) => s.id === form.values.id)) { - console.log('found service with the same id (modify)'); setConfig({ ...config, // replace the found item by matching ID @@ -217,7 +214,7 @@ export function AddAppShelfItemForm(props: { setOpened: (b: boolean) => void } &