mirror of
https://github.com/C9Glax/tranga-website.git
synced 2025-06-15 16:27:54 +02:00
Make apiUri changeable from frontend
This commit is contained in:
18
Website/modules/interfaces/IBackendSettings.tsx
Normal file
18
Website/modules/interfaces/IBackendSettings.tsx
Normal 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
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
13
Website/modules/interfaces/ILibraryConnector.tsx
Normal file
13
Website/modules/interfaces/ILibraryConnector.tsx
Normal 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 "";
|
||||
}
|
8
Website/modules/interfaces/INotificationConnector.tsx
Normal file
8
Website/modules/interfaces/INotificationConnector.tsx
Normal 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
|
||||
}
|
Reference in New Issue
Block a user