🚨 Fix nestjs warnings, remove old eslint plugins

This commit is contained in:
Manuel
2023-03-17 22:40:14 +01:00
parent 4a856c6267
commit 464b9d4142
10 changed files with 181 additions and 1889 deletions

View File

@@ -17,8 +17,8 @@ import { useState } from 'react';
import { TFunction } from 'react-i18next';
import { v4 as uuidv4 } from 'uuid';
import { useConfigContext } from '../../config/provider';
import { tryMatchService } from '../../tools/addToHomarr';
import { openContextModalGeneric } from '../../tools/mantineModalManagerExtensions';
import { MatchingImages, ServiceType, tryMatchPort } from '../../tools/types';
import { AppType } from '../../types/app';
let t: TFunction<'modules/docker', undefined>;
@@ -206,3 +206,28 @@ export default function ContainerActionBar({ selected, reload }: ContainerAction
</Group>
);
}
function tryMatchType(imageName: string): ServiceType {
const match = MatchingImages.find(({ image }) => imageName.includes(image));
if (match) {
return match.type;
}
// TODO: Remove this legacy code
return 'Other';
}
const tryMatchService = (container: Dockerode.ContainerInfo | undefined) => {
if (container === undefined) return {};
const name = container.Names[0].substring(1);
const type = tryMatchType(container.Image);
const port = tryMatchPort(type.toLowerCase())?.value ?? container.Ports[0]?.PublicPort;
return {
name,
id: container.Id,
type: tryMatchType(container.Image),
url: `localhost${port ? `:${port}` : ''}`,
icon: `https://cdn.jsdelivr.net/gh/walkxcode/dashboard-icons/png/${name
.replace(/\s+/g, '-')
.toLowerCase()}.png`,
};
};

View File

@@ -9,8 +9,9 @@ import {
} from '@mantine/core';
import React from 'react';
import { serverSideTranslations } from 'next-i18next/serverSideTranslations';
import { GetServerSidePropsContext } from 'next';
import Link from 'next/link';
import { getServerSideTranslations } from '../tools/server/getServerSideTranslations';
const useStyles = createStyles((theme) => ({
root: {
@@ -94,12 +95,11 @@ export default function Custom404() {
</Container>
);
}
export async function getStaticProps({ locale }: { locale: string }) {
export async function getStaticProps({ req, res, locale }: GetServerSidePropsContext) {
const translations = await getServerSideTranslations(['common'], locale, undefined, undefined);
return {
props: {
...(await serverSideTranslations(locale, ['common'])),
// Will be passed to the page component as props
...translations,
},
};
}

View File

@@ -23,7 +23,7 @@ export async function getServerSideProps({
const configPath = path.join(process.cwd(), 'data/configs', `${configName}.json`);
const configExists = fs.existsSync(configPath);
const translations = await getServerSideTranslations(req, res, dashboardNamespaces, locale);
const translations = await getServerSideTranslations(dashboardNamespaces, locale, req, res);
if (!configExists) {
// Redirect to 404

View File

@@ -46,7 +46,7 @@ export async function getServerSideProps({
configName = 'default';
}
const translations = await getServerSideTranslations(req, res, dashboardNamespaces, locale);
const translations = await getServerSideTranslations(dashboardNamespaces, locale, req, res);
const config = getFrontendConfig(configName as string);
return {

View File

@@ -3,17 +3,22 @@ import { IncomingMessage, ServerResponse } from 'http';
import { serverSideTranslations } from 'next-i18next/serverSideTranslations';
export const getServerSideTranslations = async (
req: IncomingMessage,
res: ServerResponse,
namespaces: string[],
requestLocale?: string
requestLocale?: string,
req?: IncomingMessage,
res?: ServerResponse,
) => {
if (!req || !res) {
return await serverSideTranslations(
requestLocale ?? 'en',
namespaces
);
}
const configLocale = getCookie('config-locale', { req, res });
const translations = await serverSideTranslations(
return await serverSideTranslations(
(configLocale ?? requestLocale ?? 'en') as string,
namespaces
);
return translations;
};