add torrent client

This commit is contained in:
Manuel Ruwe
2022-12-31 16:07:05 +01:00
parent 78bc883667
commit 4e097caf98
14 changed files with 264 additions and 29 deletions

15
src/tools/calculateEta.ts Normal file
View File

@@ -0,0 +1,15 @@
export const calculateETA = (givenSeconds: number) => {
// If its superior than one day return > 1 day
if (givenSeconds > 86400) {
return '> 1 day';
}
// Transform the givenSeconds into a readable format. e.g. 1h 2m 3s
const hours = Math.floor(givenSeconds / 3600);
const minutes = Math.floor((givenSeconds % 3600) / 60);
const seconds = Math.floor(givenSeconds % 60);
// Only show hours if it's greater than 0.
const hoursString = hours > 0 ? `${hours}h ` : '';
const minutesString = minutes > 0 ? `${minutes}m ` : '';
const secondsString = seconds > 0 ? `${seconds}s` : '';
return `${hoursString}${minutesString}${secondsString}`;
};

View File

@@ -1,3 +1,4 @@
import Consola from 'consola';
import { BackendConfigType } from '../../types/config';
import { configExists } from './configExists';
import { getFallbackConfig } from './getFallbackConfig';
@@ -11,8 +12,9 @@ export const getConfig = (name: string): BackendConfigType => {
// to the new format.
const config = readConfig(name);
if (config.schemaVersion === undefined) {
console.log('Migrating config file...', config);
Consola.log('Migrating config file...', config);
return migrateConfig(config, name);
}
return config;
};

View File

@@ -14,8 +14,8 @@ export const getFrontendConfig = (name: string): ConfigType => {
properties:
app.integration?.properties.map((property) => ({
...property,
value: property.type === 'private' ? undefined : property.value,
isDefined: property.value != null,
value: property.type === 'private' ? null : property.value,
isDefined: property.value !== null,
})) ?? [],
},
})),

View File

@@ -23,7 +23,7 @@ export const dashboardNamespaces = [
'modules/dlspeed',
'modules/usenet',
'modules/search',
'modules/torrents-status',
'modules/torrents',
'modules/weather',
'modules/ping',
'modules/docker',