implement full load of videos and startdata

modify api where necessary
This commit is contained in:
2021-02-23 16:01:29 +00:00
parent 2967aee16d
commit f2b5fb6587
69 changed files with 14016 additions and 21001 deletions

View File

@ -40,20 +40,7 @@ function getAPIDomain(): string {
interface ApiBaseRequest {
action: string | number,
[_: string]: string | number | boolean
}
/**
* helper function to build a formdata for requesting post data correctly
* @param args api request object
*/
function buildFormData(args: ApiBaseRequest): FormData {
const req = new FormData();
for (const i in args) {
req.append(i, (args[i].toString()));
}
return req;
[_: string]: string | number | boolean | object
}
/**
@ -64,7 +51,7 @@ function buildFormData(args: ApiBaseRequest): FormData {
* @param errorcallback a optional callback if an error occured
*/
export function callAPI<T>(apinode: APINode, fd: ApiBaseRequest, callback: (_: T) => void, errorcallback: (_: string) => void = (_: string): void => {}): void {
fetch(getAPIDomain() + apinode, {method: 'POST', body: buildFormData(fd)})
fetch(getAPIDomain() + apinode, {method: 'POST', body: JSON.stringify(fd)})
.then((response) => response.json()
.then((result) => {
callback(result);
@ -78,7 +65,7 @@ export function callAPI<T>(apinode: APINode, fd: ApiBaseRequest, callback: (_: T
* @param callback the callback with PLAIN text reply from backend
*/
export function callAPIPlain(apinode: APINode, fd: ApiBaseRequest, callback: (_: string) => void): void {
fetch(getAPIDomain() + apinode, {method: 'POST', body: buildFormData(fd)})
fetch(getAPIDomain() + apinode, {method: 'POST', body: JSON.stringify(fd)})
.then((response) => response.text()
.then((result) => {
callback(result);
@ -90,8 +77,8 @@ export function callAPIPlain(apinode: APINode, fd: ApiBaseRequest, callback: (_:
* API nodes definitions
*/
export enum APINode {
Settings = 'settings.php',
Tags = 'tags.php',
Actor = 'actor.php',
Video = 'video.php'
Settings = 'settings',
Tags = 'tags',
Actor = 'actor',
Video = 'video'
}

View File

@ -6,31 +6,47 @@ import lighttheme from '../AppLightTheme.module.css';
* it contains general infos about app - like theme
*/
class StaticInfos {
#darktheme = true;
private darktheme: boolean = true;
private videopath: string = ""
/**
* check if the current theme is the dark theme
* @returns {boolean} is dark theme?
*/
isDarkTheme() {
return this.#darktheme;
isDarkTheme(): boolean {
return this.darktheme;
};
/**
* setter to enable or disable the dark or light theme
* @param enable enable the dark theme?
*/
enableDarkTheme(enable = true) {
this.#darktheme = enable;
enableDarkTheme(enable = true): void {
this.darktheme = enable;
}
/**
* get the currently selected theme stylesheet
* @returns {*} the style object of the current active theme
*/
getThemeStyle() {
getThemeStyle(): { [_: string]: string } {
return this.isDarkTheme() ? darktheme : lighttheme;
}
/**
* set the current videopath
* @param vidpath videopath with beginning and ending slash
*/
setVideoPath(vidpath: string): void {
this.videopath = vidpath;
}
/**
* return the current videopath
*/
getVideoPath(): string {
return this.videopath;
}
}
const GlobalInfos = new StaticInfos();