mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-10 07:25:48 +01:00
🚨 Fix nestjs warnings, remove old eslint plugins
This commit is contained in:
@@ -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`,
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user