Make apiUri changeable from frontend

This commit is contained in:
2024-10-20 20:12:27 +02:00
parent d2533ee98f
commit d97eff9796
14 changed files with 339 additions and 108 deletions

View File

@ -0,0 +1,18 @@
export default interface IBackendSettings {
"downloadLocation": string;
"workingDirectory": string;
"apiPortNumber": number;
"userAgent": string;
"bufferLibraryUpdates": boolean;
"bufferNotifications": boolean;
"version": number;
"aprilFoolsMode": boolean;
"requestLimits": {
"MangaInfo": number;
"MangaDexFeed": number;
"MangaDexImage": number;
"MangaImage": number;
"MangaCover": number;
"Default": number
}
}

View File

@ -1,3 +1,33 @@
import {Cookies} from "react-cookie";
export default interface IFrontendSettings {
jobInterval: Date;
apiUri: string;
}
export function FrontendSettingsWith(settings: IFrontendSettings | undefined, jobInterval: Date | undefined, apiUri: string | undefined): IFrontendSettings {
const cookies = new Cookies();
let transform : IFrontendSettings;
if(settings === undefined) {
transform = {
apiUri: apiUri === undefined
? cookies.get('apiUri') === undefined
? `${window.location.protocol}//${window.location.host}/api`
: cookies.get('apiUri')
: apiUri,
jobInterval: jobInterval === undefined
? cookies.get('jobInterval') === undefined
? new Date(0,0,0,3)
: cookies.get('jobInterval')
: jobInterval
}
}else {
transform = {
apiUri: apiUri === undefined ? settings.apiUri : apiUri,
jobInterval: jobInterval === undefined ? settings.jobInterval : jobInterval,
}
}
console.debug(settings);
console.debug(transform);
return transform;
}

View File

@ -0,0 +1,13 @@
export default interface ILibraryConnector {
libraryType: number;
baseUrl: string;
auth: string;
}
export function GetLibraryConnectorNameFromNumber(n: number): string {
switch(n){
case 0: return "Komga";
case 1: return "Kavita";
}
return "";
}

View File

@ -0,0 +1,8 @@
export default interface INotificationConnector {
"notificationConnectorType": number; //see NotificationConnectorType
"endpoint": string | undefined;//only on Ntfy, Gotify
"appToken": string | undefined;//only on Gotify
"auth": string | undefined;//only on Ntfy
"topic": string | undefined;//only on Ntfy
"id": string | undefined;//only on LunaSea
}