mirror of
https://github.com/C9Glax/tranga-website.git
synced 2025-06-15 16:27:54 +02:00
Multiple Base-Paths support
This commit is contained in:
14
Website/modules/interfaces/ILocalLibrary.tsx
Normal file
14
Website/modules/interfaces/ILocalLibrary.tsx
Normal file
@ -0,0 +1,14 @@
|
||||
import {ReactElement} from "react";
|
||||
|
||||
export default interface ILocalLibrary {
|
||||
localLibraryId: string;
|
||||
basePath: string;
|
||||
libraryName: string;
|
||||
}
|
||||
|
||||
export function LocalLibrary(library: ILocalLibrary) : ReactElement {
|
||||
return (<div key={library.localLibraryId}>
|
||||
<p className={"LocalLibrary-Name"}>{library.libraryName}</p>
|
||||
<p className={"LocalLibrary-Path"}>{library.basePath}</p>
|
||||
</div>);
|
||||
}
|
51
Website/modules/interfaces/LocalLibrary.tsx
Normal file
51
Website/modules/interfaces/LocalLibrary.tsx
Normal file
@ -0,0 +1,51 @@
|
||||
import ILocalLibrary from "./ILocalLibrary";
|
||||
import {deleteData, getData, patchData, putData} from "../../App";
|
||||
import INewLibraryRecord from "./records/INewLibraryRecord";
|
||||
|
||||
export default class LocalLibrary
|
||||
{
|
||||
static async GetLibraries(apiUri: string): Promise<ILocalLibrary[]> {
|
||||
return getData(`${apiUri}/v2/LocalLibraries`)
|
||||
.then((json) => {
|
||||
const ret = json as ILocalLibrary[];
|
||||
console.debug(ret);
|
||||
return (ret);
|
||||
});
|
||||
}
|
||||
|
||||
static async GetLibrary(apiUri: string, libraryId: string): Promise<ILocalLibrary> {
|
||||
return getData(`${apiUri}/v2/LocalLibraries/${libraryId}`)
|
||||
.then((json) => {
|
||||
const ret = json as ILocalLibrary;
|
||||
//console.debug(ret);
|
||||
return (ret);
|
||||
});
|
||||
}
|
||||
|
||||
static async CreateLibrary(apiUri: string, data: INewLibraryRecord): Promise<ILocalLibrary> {
|
||||
return putData(`${apiUri}/v2/LocalLibraries`, data)
|
||||
.then((json) => {
|
||||
const ret = json as ILocalLibrary;
|
||||
//console.debug(ret);
|
||||
return (ret);
|
||||
});
|
||||
}
|
||||
|
||||
static async DeleteLibrary(apiUri: string, libraryId: string): Promise<void> {
|
||||
return deleteData(`${apiUri}/v2/LocalLibraries/${libraryId}`);
|
||||
}
|
||||
|
||||
static async ChangeLibraryPath(apiUri: string, libraryId: string, newPath: string): Promise<void> {
|
||||
return patchData(`${apiUri}/v2/LocalLibraries/${libraryId}/ChangeBasePath`, newPath)
|
||||
.then(()=> {
|
||||
return Promise.resolve()
|
||||
});
|
||||
}
|
||||
|
||||
static async ChangeLibraryName(apiUri: string, libraryId: string, newName: string): Promise<void> {
|
||||
return patchData(`${apiUri}/v2/LocalLibraries/${libraryId}/ChangeName`, newName)
|
||||
.then(()=> {
|
||||
return Promise.resolve()
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
export default interface IDownloadAvailableJobsRecord {
|
||||
recurrenceTimeMs: number;
|
||||
localLibraryId: string;
|
||||
}
|
4
Website/modules/interfaces/records/INewLibraryRecord.ts
Normal file
4
Website/modules/interfaces/records/INewLibraryRecord.ts
Normal file
@ -0,0 +1,4 @@
|
||||
export default interface INewLibraryRecord {
|
||||
path: string;
|
||||
name: string;
|
||||
}
|
Reference in New Issue
Block a user