feat: improve UI for timespan inputs on admin page (#726)

* Define Timestamp type

* Implement Timestamp utils

* Implement Timespan input

* Use timestamp input on config page

* Add timespan type to config services

* Refactor maxExpiration to use timespan type across services and components

* Update sessionDuration to use timespan type in config and adjust token expiration logic

* Update localized strings
This commit is contained in:
Aaron
2025-01-02 17:35:50 +01:00
committed by GitHub
parent df1ffaa2bc
commit 36afbf91b7
14 changed files with 158 additions and 20 deletions

View File

@@ -7,6 +7,7 @@ import {
import { Config } from "@prisma/client";
import { EventEmitter } from "events";
import { PrismaService } from "src/prisma/prisma.service";
import { stringToTimespan } from "src/utils/date.util";
/**
* ConfigService extends EventEmitter to allow listening for config updates,
@@ -35,6 +36,8 @@ export class ConfigService extends EventEmitter {
if (configVariable.type == "boolean") return value == "true";
if (configVariable.type == "string" || configVariable.type == "text")
return value;
if (configVariable.type == "timespan")
return stringToTimespan(value);
}
async getByCategory(category: string) {
@@ -94,7 +97,8 @@ export class ConfigService extends EventEmitter {
} else if (
typeof value != configVariable.type &&
typeof value == "string" &&
configVariable.type != "text"
configVariable.type != "text" &&
configVariable.type != "timespan"
) {
throw new BadRequestException(
`Config variable must be of type ${configVariable.type}`,
@@ -132,6 +136,7 @@ export class ConfigService extends EventEmitter {
condition: (value: number) => value >= 0 && value <= 9,
message: "Zip compression level must be between 0 and 9",
},
// TODO add validation for timespan type
];
const validation = validations.find((validation) => validation.key == key);