mirror of
https://github.com/CaramelFur/Picsur.git
synced 2026-05-07 14:17:22 +02:00
add system preferences to frontend
This commit is contained in:
@@ -14,7 +14,8 @@ import {
|
||||
|
||||
export class UpdateSysPreferenceRequest {
|
||||
@IsNotEmpty()
|
||||
value: string;
|
||||
@IsSysPrefValue()
|
||||
value: SysPrefValueType;
|
||||
}
|
||||
|
||||
export class SysPreferenceResponse {
|
||||
|
||||
@@ -10,7 +10,6 @@ import tuple from '../types/tuple';
|
||||
const SysPreferencesTuple = tuple(
|
||||
'jwt_secret',
|
||||
'jwt_expires_in',
|
||||
'upload_require_auth',
|
||||
'test_string',
|
||||
'test_number',
|
||||
'test_boolean',
|
||||
@@ -19,6 +18,16 @@ const SysPreferencesTuple = tuple(
|
||||
export const SysPreferences: string[] = SysPreferencesTuple;
|
||||
export type SysPreferences = typeof SysPreferencesTuple[number];
|
||||
|
||||
export const SysPreferenceFriendlyNames: {
|
||||
[key in SysPreferences]: string;
|
||||
} = {
|
||||
jwt_secret: 'JWT Secret',
|
||||
jwt_expires_in: 'JWT Expiry Time',
|
||||
test_string: 'Test String',
|
||||
test_number: 'Test Number',
|
||||
test_boolean: 'Test Boolean',
|
||||
};
|
||||
|
||||
// Syspref Values
|
||||
|
||||
export type SysPrefValueType = string | number | boolean;
|
||||
@@ -30,7 +39,6 @@ export const SysPreferenceValueTypes: {
|
||||
} = {
|
||||
jwt_secret: 'string',
|
||||
jwt_expires_in: 'string',
|
||||
upload_require_auth: 'boolean',
|
||||
test_string: 'string',
|
||||
test_number: 'number',
|
||||
test_boolean: 'boolean',
|
||||
|
||||
@@ -17,9 +17,11 @@ export type AsyncFailable<T> = Promise<Failable<T>>;
|
||||
// TODO: prevent promise from being allowed in these 2 functions
|
||||
|
||||
export function HasFailed<T>(failable: Failable<T>): failable is Failure {
|
||||
if (failable instanceof Promise) throw new Error('Invalid use of HasFailed');
|
||||
return failable instanceof Failure;
|
||||
}
|
||||
|
||||
export function HasSuccess<T>(failable: Failable<T>): failable is T {
|
||||
if (failable instanceof Promise) throw new Error('Invalid use of HasSuccess');
|
||||
return !(failable instanceof Failure);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user