mirror of
https://github.com/C9Glax/tranga-website.git
synced 2025-06-15 16:27:54 +02:00
@mui/joy
This commit is contained in:
70
Website/modules/api/BackendSettings.tsx
Normal file
70
Website/modules/api/BackendSettings.tsx
Normal file
@ -0,0 +1,70 @@
|
||||
import {deleteData, getData, patchData} from "../../App";
|
||||
import IRequestLimits from "../types/IRequestLimits";
|
||||
import IBackendSettings from "../types/IBackendSettings";
|
||||
import {RequestLimitType} from "../types/EnumRequestLimitType";
|
||||
|
||||
export default class BackendSettings {
|
||||
static async GetSettings(apiUri: string) : Promise<IBackendSettings> {
|
||||
return getData(`${apiUri}/v2/Settings`).then((s) => s as IBackendSettings);
|
||||
}
|
||||
|
||||
static async GetUserAgent(apiUri: string) : Promise<string> {
|
||||
return getData(`${apiUri}/v2/Settings/UserAgent`).then((text) => text as unknown as string);
|
||||
}
|
||||
|
||||
static async UpdateUserAgent(apiUri: string, userAgent: string) {
|
||||
return patchData(`${apiUri}/v2/Settings/UserAgent`, userAgent);
|
||||
}
|
||||
|
||||
static async ResetUserAgent(apiUri: string) {
|
||||
return deleteData(`${apiUri}/v2/Settings/UserAgent`);
|
||||
}
|
||||
|
||||
static async GetRequestLimits(apiUri: string) : Promise<IRequestLimits> {
|
||||
return getData(`${apiUri}/v2/Settings/RequestLimits`).then((limits) => limits as IRequestLimits);
|
||||
}
|
||||
|
||||
static async ResetRequestLimits(apiUri: string) {
|
||||
return deleteData(`${apiUri}/v2/Settings/RequestLimits`);
|
||||
}
|
||||
|
||||
static async UpdateRequestLimit(apiUri: string, requestType: RequestLimitType, value: number) {
|
||||
return patchData(`${apiUri}/v2/Settings/RequestLimits/${requestType}`, value);
|
||||
}
|
||||
|
||||
static async ResetRequestLimit(apiUri: string, requestType: RequestLimitType) {
|
||||
return deleteData(`${apiUri}/v2/Settings/RequestLimits/${requestType}`);
|
||||
}
|
||||
|
||||
static async GetImageCompressionValue(apiUri: string) : Promise<number> {
|
||||
return getData(`${apiUri}/v2/Settings/ImageCompression`).then((n) => n as unknown as number);
|
||||
}
|
||||
|
||||
static async UpdateImageCompressionValue(apiUri: string, value: number) {
|
||||
return patchData(`${apiUri}/v2/Settings/ImageCompression`, value);
|
||||
}
|
||||
|
||||
static async GetBWImageToggle(apiUri: string) : Promise<boolean> {
|
||||
return getData(`${apiUri}/v2/Settings/BWImages`).then((state) => state as unknown as boolean);
|
||||
}
|
||||
|
||||
static async UpdateBWImageToggle(apiUri: string, value: boolean) {
|
||||
return patchData(`${apiUri}/v2/Settings/BWImages`, value);
|
||||
}
|
||||
|
||||
static async GetAprilFoolsToggle(apiUri: string) : Promise<boolean> {
|
||||
return getData(`${apiUri}/v2/Settings/AprilFoolsMode`).then((state) => state as unknown as boolean);
|
||||
}
|
||||
|
||||
static async UpdateAprilFoolsToggle(apiUri: string, value: boolean) {
|
||||
return patchData(`${apiUri}/v2/Settings/AprilFoolsMode`, value);
|
||||
}
|
||||
|
||||
static async GetChapterNamingScheme(apiUri: string) : Promise<string> {
|
||||
return getData(`${apiUri}/v2/Settings/ChapterNamingScheme`).then((state) => state as unknown as string);
|
||||
}
|
||||
|
||||
static async UpdateChapterNamingScheme(apiUri: string, value: string) {
|
||||
return patchData(`${apiUri}/v2/Settings/ChapterNamingScheme`, value);
|
||||
}
|
||||
}
|
19
Website/modules/api/Chapter.tsx
Normal file
19
Website/modules/api/Chapter.tsx
Normal file
@ -0,0 +1,19 @@
|
||||
import {getData} from "../../App";
|
||||
import IChapter from "../types/IChapter";
|
||||
|
||||
export default class Chapter {
|
||||
|
||||
static async GetChapterFromId(apiUri: string, chapterId: string): Promise<IChapter> {
|
||||
if(chapterId === undefined || chapterId === null) {
|
||||
console.error(`chapterId was not provided`);
|
||||
return Promise.reject();
|
||||
}
|
||||
return getData(`${apiUri}/v2/Query/Chapter/${chapterId}`)
|
||||
.then((json) => {
|
||||
//console.info("Got all Manga");
|
||||
const ret = json as IChapter;
|
||||
//console.debug(ret);
|
||||
return (ret);
|
||||
});
|
||||
}
|
||||
}
|
14
Website/modules/api/FrontendSettings.tsx
Normal file
14
Website/modules/api/FrontendSettings.tsx
Normal file
@ -0,0 +1,14 @@
|
||||
import {Cookies} from "react-cookie";
|
||||
import IFrontendSettings from "../types/IFrontendSettings";
|
||||
|
||||
export function LoadFrontendSettings(): IFrontendSettings {
|
||||
const cookies = new Cookies();
|
||||
return {
|
||||
jobInterval: cookies.get('jobInterval') === undefined
|
||||
? new Date(Date.parse("1970-01-01T03:00:00.000Z"))
|
||||
: cookies.get('jobInterval'),
|
||||
apiUri: cookies.get('apiUri') === undefined
|
||||
? `${window.location.protocol}//${window.location.host}/api`
|
||||
: cookies.get('apiUri')
|
||||
}
|
||||
}
|
208
Website/modules/api/Job.tsx
Normal file
208
Website/modules/api/Job.tsx
Normal file
@ -0,0 +1,208 @@
|
||||
import {deleteData, getData, patchData, postData, putData} from '../../App';
|
||||
import IJob, {JobState, JobType} from "../types/Jobs/IJob";
|
||||
import IModifyJobRecord from "../types/records/IModifyJobRecord";
|
||||
import IDownloadAvailableJobsRecord from "../types/records/IDownloadAvailableJobsRecord";
|
||||
|
||||
export default class Job
|
||||
{
|
||||
static IntervalStringFromDate(date: Date) : string {
|
||||
let x = new Date(date);
|
||||
return `${x.getDay()}.${x.getHours()}:${x.getMinutes()}:${x.getSeconds()}`;
|
||||
}
|
||||
|
||||
static async GetAllJobs(apiUri: string): Promise<IJob[]> {
|
||||
//console.info("Getting all Jobs");
|
||||
return getData(`${apiUri}/v2/Job`)
|
||||
.then((json) => {
|
||||
//console.info("Got all Jobs");
|
||||
const ret = json as IJob[];
|
||||
//console.debug(ret);
|
||||
return (ret);
|
||||
});
|
||||
}
|
||||
|
||||
static async GetJobsWithIds(apiUri: string, jobIds: string[]): Promise<IJob[]> {
|
||||
return postData(`${apiUri}/v2/Job/WithIDs`, jobIds)
|
||||
.then((json) => {
|
||||
//console.info("Got all Jobs");
|
||||
const ret = json as IJob[];
|
||||
//console.debug(ret);
|
||||
return (ret);
|
||||
});
|
||||
}
|
||||
|
||||
static async GetJobsInState(apiUri: string, state: JobState): Promise<IJob[]> {
|
||||
if(state == null || state == undefined) {
|
||||
console.error(`state was not provided`);
|
||||
return Promise.reject();
|
||||
}
|
||||
return getData(`${apiUri}/v2/Job/State/${state}`)
|
||||
.then((json) => {
|
||||
//console.info("Got all Jobs");
|
||||
const ret = json as IJob[];
|
||||
//console.debug(ret);
|
||||
return (ret);
|
||||
});
|
||||
}
|
||||
|
||||
static async GetJobsWithType(apiUri: string, jobType: JobType): Promise<IJob[]> {
|
||||
if(jobType == null || jobType == undefined) {
|
||||
console.error(`jobType was not provided`);
|
||||
return Promise.reject();
|
||||
}
|
||||
return getData(`${apiUri}/v2/Job/Type/${jobType}`)
|
||||
.then((json) => {
|
||||
//console.info("Got all Jobs");
|
||||
const ret = json as IJob[];
|
||||
//console.debug(ret);
|
||||
return (ret);
|
||||
});
|
||||
}
|
||||
|
||||
static async GetJobsOfTypeAndWithState(apiUri: string, jobType: JobType, state: JobState): Promise<IJob[]> {
|
||||
if(jobType == null || jobType == undefined) {
|
||||
console.error(`jobType was not provided`);
|
||||
return Promise.reject();
|
||||
}
|
||||
if(state == null || state == undefined) {
|
||||
console.error(`state was not provided`);
|
||||
return Promise.reject();
|
||||
}
|
||||
return getData(`${apiUri}/v2/Job/TypeAndState/${jobType}/${state}`)
|
||||
.then((json) => {
|
||||
//console.info("Got all Jobs");
|
||||
const ret = json as IJob[];
|
||||
//console.debug(ret);
|
||||
return (ret);
|
||||
});
|
||||
}
|
||||
|
||||
static async GetJob(apiUri: string, jobId: string): Promise<IJob>{
|
||||
if(jobId === undefined || jobId === null || jobId.length < 1) {
|
||||
console.error(`JobId was not provided`);
|
||||
return Promise.reject();
|
||||
}
|
||||
//console.info(`Getting Job ${jobId}`);
|
||||
return getData(`${apiUri}/v2/Job/${jobId}`)
|
||||
.then((json) => {
|
||||
//console.info(`Got Job ${jobId}`);
|
||||
const ret = json as IJob;
|
||||
//console.debug(ret);
|
||||
return (ret);
|
||||
});
|
||||
}
|
||||
|
||||
static DeleteJob(apiUri: string, jobId: string) : Promise<void> {
|
||||
if(jobId === undefined || jobId === null || jobId.length < 1) {
|
||||
console.error(`JobId was not provided`);
|
||||
return Promise.reject();
|
||||
}
|
||||
return deleteData(`${apiUri}/v2/Job/${jobId}`);
|
||||
}
|
||||
|
||||
static async ModifyJob(apiUri: string, jobId: string, modifyData: IModifyJobRecord): Promise<IJob> {
|
||||
if(jobId === undefined || jobId === null || jobId.length < 1) {
|
||||
console.error(`JobId was not provided`);
|
||||
return Promise.reject();
|
||||
}
|
||||
if(modifyData === undefined || modifyData === null) {
|
||||
console.error(`modifyData was not provided`);
|
||||
return Promise.reject();
|
||||
}
|
||||
return patchData(`${apiUri}/v2/Job/${jobId}`, modifyData)
|
||||
.then((json) => {
|
||||
//console.info(`Got Job ${jobId}`);
|
||||
const ret = json as IJob;
|
||||
//console.debug(ret);
|
||||
return (ret);
|
||||
});
|
||||
}
|
||||
|
||||
static async CreateDownloadAvailableChaptersJob(apiUri: string, mangaId: string, data: IDownloadAvailableJobsRecord): Promise<string[]> {
|
||||
if(mangaId === undefined || mangaId === null || mangaId.length < 1) {
|
||||
console.error(`mangaId was not provided`);
|
||||
return Promise.reject();
|
||||
}
|
||||
if(data === undefined || data === null) {
|
||||
console.error(`recurrenceMs was not provided`);
|
||||
return Promise.reject();
|
||||
}
|
||||
return putData(`${apiUri}/v2/Job/DownloadAvailableChaptersJob/${mangaId}`, data)
|
||||
.then((json) => {
|
||||
//console.info(`Got Job ${jobId}`);
|
||||
const ret = json as string[];
|
||||
//console.debug(ret);
|
||||
return (ret);
|
||||
});
|
||||
}
|
||||
|
||||
static async CreateDownloadSingleChapterJob(apiUri: string, chapterId: string): Promise<string[]> {
|
||||
if(chapterId === undefined || chapterId === null || chapterId.length < 1) {
|
||||
console.error(`mangaId was not provided`);
|
||||
return Promise.reject();
|
||||
}
|
||||
return putData(`${apiUri}/v2/Job/DownloadSingleChapterJob/${chapterId}`, {})
|
||||
.then((json) => {
|
||||
//console.info(`Got Job ${jobId}`);
|
||||
const ret = json as string[];
|
||||
//console.debug(ret);
|
||||
return (ret);
|
||||
});
|
||||
}
|
||||
|
||||
static async CreateUpdateFilesJob(apiUri: string, mangaId: string): Promise<string[]> {
|
||||
if(mangaId === undefined || mangaId === null || mangaId.length < 1) {
|
||||
console.error(`mangaId was not provided`);
|
||||
return Promise.reject();
|
||||
}
|
||||
return putData(`${apiUri}/v2/Job/UpdateFilesJob/${mangaId}`, {})
|
||||
.then((json) => {
|
||||
//console.info(`Got Job ${jobId}`);
|
||||
const ret = json as string[];
|
||||
//console.debug(ret);
|
||||
return (ret);
|
||||
});
|
||||
}
|
||||
|
||||
static async CreateUpdateAllFilesJob(apiUri: string): Promise<string[]> {
|
||||
return putData(`${apiUri}/v2/Job/UpdateAllFilesJob`, {})
|
||||
.then((json) => {
|
||||
//console.info(`Got Job ${jobId}`);
|
||||
const ret = json as string[];
|
||||
//console.debug(ret);
|
||||
return (ret);
|
||||
});
|
||||
}
|
||||
|
||||
static async CreateUpdateMetadataJob(apiUri: string, mangaId: string): Promise<string[]> {
|
||||
if(mangaId === undefined || mangaId === null || mangaId.length < 1) {
|
||||
console.error(`mangaId was not provided`);
|
||||
return Promise.reject();
|
||||
}
|
||||
return putData(`${apiUri}/v2/Job/UpdateMetadataJob/${mangaId}`, {})
|
||||
.then((json) => {
|
||||
//console.info(`Got Job ${jobId}`);
|
||||
const ret = json as string[];
|
||||
//console.debug(ret);
|
||||
return (ret);
|
||||
});
|
||||
}
|
||||
|
||||
static async CreateUpdateAllMetadataJob(apiUri: string): Promise<string[]> {
|
||||
return putData(`${apiUri}/v2/Job/UpdateAllMetadataJob`, {})
|
||||
.then((json) => {
|
||||
//console.info(`Got Job ${jobId}`);
|
||||
const ret = json as string[];
|
||||
//console.debug(ret);
|
||||
return (ret);
|
||||
});
|
||||
}
|
||||
|
||||
static StartJob(apiUri: string, jobId: string) : Promise<object> {
|
||||
return postData(`${apiUri}/v2/Job/${jobId}/Start`, {});
|
||||
}
|
||||
|
||||
static StopJob(apiUri: string, jobId: string) : Promise<object> {
|
||||
return postData(`${apiUri}/v2/Job/${jobId}/Stop`, {});
|
||||
}
|
||||
}
|
57
Website/modules/api/LocalLibrary.tsx
Normal file
57
Website/modules/api/LocalLibrary.tsx
Normal file
@ -0,0 +1,57 @@
|
||||
import {deleteData, getData, patchData, putData} from "../../App";
|
||||
import INewLibraryRecord from "../types/records/INewLibraryRecord";
|
||||
import ILocalLibrary from "../types/ILocalLibrary";
|
||||
|
||||
export default class LocalLibrary
|
||||
{
|
||||
static async GetLibraries(apiUri: string): Promise<ILocalLibrary[]> {
|
||||
return getData(`${apiUri}/v2/LocalLibraries`)
|
||||
.then((json) => {
|
||||
const ret = json as ILocalLibrary[];
|
||||
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()
|
||||
});
|
||||
}
|
||||
|
||||
static async UpdateLibrary(apiUri: string, libraryId: string, record: INewLibraryRecord): Promise<void> {
|
||||
return patchData(`${apiUri}/v2/LocalLibraries/${libraryId}`, record)
|
||||
.then(()=> {
|
||||
return Promise.resolve()
|
||||
});
|
||||
}
|
||||
}
|
156
Website/modules/api/Manga.tsx
Normal file
156
Website/modules/api/Manga.tsx
Normal file
@ -0,0 +1,156 @@
|
||||
import {deleteData, getData, patchData, postData} from '../../App';
|
||||
import IManga from "../types/IManga";
|
||||
import IChapter from "../types/IChapter";
|
||||
|
||||
export default class Manga
|
||||
{
|
||||
static async GetAllManga(apiUri: string): Promise<IManga[]> {
|
||||
//console.info("Getting all Manga");
|
||||
return getData(`${apiUri}/v2/Manga`)
|
||||
.then((json) => {
|
||||
//console.info("Got all Manga");
|
||||
const ret = json as IManga[];
|
||||
//console.debug(ret);
|
||||
return (ret);
|
||||
});
|
||||
}
|
||||
|
||||
static async GetMangaWithIds(apiUri: string, mangaIds: string[]): Promise<IManga[]> {
|
||||
if(mangaIds === undefined || mangaIds === null || mangaIds.length < 1) {
|
||||
console.error(`mangaIds was not provided`);
|
||||
return Promise.reject();
|
||||
}
|
||||
//console.debug(`Getting Mangas ${internalIds.join(",")}`);
|
||||
return await postData(`${apiUri}/v2/Manga/WithIds`, mangaIds)
|
||||
.then((json) => {
|
||||
//console.debug(`Got Manga ${internalIds.join(",")}`);
|
||||
const ret = json as IManga[];
|
||||
//console.debug(ret);
|
||||
return (ret);
|
||||
});
|
||||
}
|
||||
|
||||
static async GetMangaById(apiUri: string, mangaId: string): Promise<IManga> {
|
||||
if(mangaId === undefined || mangaId === null || mangaId.length < 1) {
|
||||
console.error(`mangaId was not provided`);
|
||||
return Promise.reject();
|
||||
}
|
||||
//console.info(`Getting Manga ${internalId}`);
|
||||
return await getData(`${apiUri}/v2/Manga/${mangaId}`)
|
||||
.then((json) => {
|
||||
//console.info(`Got Manga ${internalId}`);
|
||||
const ret = json as IManga;
|
||||
//console.debug(ret);
|
||||
return (ret);
|
||||
});
|
||||
}
|
||||
|
||||
static async DeleteManga(apiUri: string, mangaId: string): Promise<void> {
|
||||
if(mangaId === undefined || mangaId === null || mangaId.length < 1) {
|
||||
console.error(`mangaId was not provided`);
|
||||
return Promise.reject();
|
||||
}
|
||||
return deleteData(`${apiUri}/v2/Manga/${mangaId}`);
|
||||
}
|
||||
|
||||
static GetMangaCoverImageUrl(apiUri: string, mangaId: string, ref: HTMLImageElement | undefined): string {
|
||||
//console.debug(`Getting Manga Cover-Url ${internalId}`);
|
||||
if(ref == null || ref == undefined)
|
||||
return `${apiUri}/v2/Manga/${mangaId}/Cover?width=64&height=64`;
|
||||
return `${apiUri}/v2/Manga/${mangaId}/Cover?width=${ref.clientWidth}&height=${ref.clientHeight}`;
|
||||
}
|
||||
|
||||
static async GetChapters(apiUri: string, mangaId: string): Promise<IChapter[]> {
|
||||
if(mangaId === undefined || mangaId === null || mangaId.length < 1) {
|
||||
console.error(`mangaId was not provided`);
|
||||
return Promise.reject();
|
||||
}
|
||||
return getData(`${apiUri}/v2/Manga/${mangaId}/Chapters`)
|
||||
.then((json) => {
|
||||
//console.info(`Got Manga ${internalId}`);
|
||||
const ret = json as IChapter[];
|
||||
//console.debug(ret);
|
||||
return (ret);
|
||||
});
|
||||
}
|
||||
|
||||
static async GetDownloadedChapters(apiUri: string, mangaId: string): Promise<IChapter[]> {
|
||||
if(mangaId === undefined || mangaId === null || mangaId.length < 1) {
|
||||
console.error(`mangaId was not provided`);
|
||||
return Promise.reject();
|
||||
}
|
||||
return getData(`${apiUri}/v2/Manga/${mangaId}/Chapters/Downloaded`)
|
||||
.then((json) => {
|
||||
//console.info(`Got Manga ${internalId}`);
|
||||
const ret = json as IChapter[];
|
||||
//console.debug(ret);
|
||||
return (ret);
|
||||
});
|
||||
}
|
||||
|
||||
static async GetNotDownloadedChapters(apiUri: string, mangaId: string): Promise<IChapter[]> {
|
||||
if(mangaId === undefined || mangaId === null || mangaId.length < 1) {
|
||||
console.error(`mangaId was not provided`);
|
||||
return Promise.reject();
|
||||
}
|
||||
return getData(`${apiUri}/v2/Manga/${mangaId}/Chapters/NotDownloaded`)
|
||||
.then((json) => {
|
||||
//console.info(`Got Manga ${internalId}`);
|
||||
const ret = json as IChapter[];
|
||||
//console.debug(ret);
|
||||
return (ret);
|
||||
});
|
||||
}
|
||||
|
||||
static async GetLatestChapterAvailable(apiUri: string, mangaId: string): Promise<IChapter> {
|
||||
if(mangaId === undefined || mangaId === null || mangaId.length < 1) {
|
||||
console.error(`mangaId was not provided`);
|
||||
return Promise.reject();
|
||||
}
|
||||
return getData(`${apiUri}/v2/Manga/${mangaId}/Chapter/LatestAvailable`)
|
||||
.then((json) => {
|
||||
//console.info(`Got Manga ${internalId}`);
|
||||
const ret = json as IChapter;
|
||||
//console.debug(ret);
|
||||
return (ret);
|
||||
});
|
||||
}
|
||||
|
||||
static async GetLatestChapterDownloaded(apiUri: string, mangaId: string): Promise<IChapter> {
|
||||
if(mangaId === undefined || mangaId === null || mangaId.length < 1) {
|
||||
console.error(`mangaId was not provided`);
|
||||
return Promise.reject();
|
||||
}
|
||||
return getData(`${apiUri}/v2/Manga/${mangaId}/Chapter/LatestDownloaded`)
|
||||
.then((json) => {
|
||||
//console.info(`Got Manga ${internalId}`);
|
||||
const ret = json as IChapter;
|
||||
//console.debug(ret);
|
||||
return (ret);
|
||||
});
|
||||
}
|
||||
|
||||
static async SetIgnoreThreshold(apiUri: string, mangaId: string, chapterThreshold: number): Promise<object> {
|
||||
if(mangaId === undefined || mangaId === null || mangaId.length < 1) {
|
||||
console.error(`mangaId was not provided`);
|
||||
return Promise.reject();
|
||||
}
|
||||
if(chapterThreshold === undefined || chapterThreshold === null) {
|
||||
console.error(`chapterThreshold was not provided`);
|
||||
return Promise.reject();
|
||||
}
|
||||
return patchData(`${apiUri}/v2/Manga/${mangaId}/IgnoreChaptersBefore`, chapterThreshold);
|
||||
}
|
||||
|
||||
static async MoveFolder(apiUri: string, mangaId: string, newPath: string): Promise<object> {
|
||||
if(mangaId === undefined || mangaId === null || mangaId.length < 1) {
|
||||
console.error(`mangaId was not provided`);
|
||||
return Promise.reject();
|
||||
}
|
||||
if(newPath === undefined || newPath === null || newPath.length < 1) {
|
||||
console.error(`newPath was not provided`);
|
||||
return Promise.reject();
|
||||
}
|
||||
return postData(`${apiUri}/v2/Manga/{MangaId}/MoveFolder`, {newPath});
|
||||
}
|
||||
}
|
44
Website/modules/api/MangaConnector.tsx
Normal file
44
Website/modules/api/MangaConnector.tsx
Normal file
@ -0,0 +1,44 @@
|
||||
import IMangaConnector from '../types/IMangaConnector';
|
||||
import {getData, patchData} from '../../App';
|
||||
|
||||
export class MangaConnector
|
||||
{
|
||||
static async GetAllConnectors(apiUri: string): Promise<IMangaConnector[]> {
|
||||
//console.info("Getting all MangaConnectors");
|
||||
return getData(`${apiUri}/v2/MangaConnector`)
|
||||
.then((json) => {
|
||||
//console.info("Got all MangaConnectors");
|
||||
return (json as IMangaConnector[]);
|
||||
});
|
||||
}
|
||||
|
||||
static async GetEnabledConnectors(apiUri: string): Promise<IMangaConnector[]> {
|
||||
//console.info("Getting all enabled MangaConnectors");
|
||||
return getData(`${apiUri}/v2/MangaConnector/enabled`)
|
||||
.then((json) => {
|
||||
//console.info("Got all enabled MangaConnectors");
|
||||
return (json as IMangaConnector[]);
|
||||
});
|
||||
}
|
||||
|
||||
static async GetDisabledConnectors(apiUri: string): Promise<IMangaConnector[]> {
|
||||
//console.info("Getting all disabled MangaConnectors");
|
||||
return getData(`${apiUri}/v2/MangaConnector/disabled`)
|
||||
.then((json) => {
|
||||
//console.info("Got all disabled MangaConnectors");
|
||||
return (json as IMangaConnector[]);
|
||||
});
|
||||
}
|
||||
|
||||
static async SetConnectorEnabled(apiUri: string, connectorName: string, enabled: boolean): Promise<object> {
|
||||
if(connectorName === undefined || connectorName === null || connectorName.length < 1) {
|
||||
console.error(`connectorName was not provided`);
|
||||
return Promise.reject();
|
||||
}
|
||||
if(enabled === undefined || enabled === null) {
|
||||
console.error(`enabled was not provided`);
|
||||
return Promise.reject();
|
||||
}
|
||||
return patchData(`${apiUri}/v2/MangaConnector/${connectorName}/SetEnabled/${enabled}`, {});
|
||||
}
|
||||
}
|
114
Website/modules/api/NotificationConnector.tsx
Normal file
114
Website/modules/api/NotificationConnector.tsx
Normal file
@ -0,0 +1,114 @@
|
||||
import {deleteData, getData, putData} from "../../App";
|
||||
import IGotifyRecord from "../types/records/IGotifyRecord";
|
||||
import INtfyRecord from "../types/records/INtfyRecord";
|
||||
import ILunaseaRecord from "../types/records/ILunaseaRecord";
|
||||
import IPushoverRecord from "../types/records/IPushoverRecord";
|
||||
import INotificationConnector from "../types/INotificationConnector";
|
||||
|
||||
export default class NotificationConnector {
|
||||
|
||||
static async GetNotificationConnectors(apiUri: string) : Promise<INotificationConnector[]> {
|
||||
//console.info("Getting Notification Connectors");
|
||||
return getData(`${apiUri}/v2/NotificationConnector`)
|
||||
.then((json) => {
|
||||
//console.info("Got Notification Connectors");
|
||||
const ret = json as INotificationConnector[];
|
||||
//console.debug(ret);
|
||||
return (ret);
|
||||
});
|
||||
}
|
||||
|
||||
static async CreateNotificationConnector(apiUri: string, newConnector: INotificationConnector): Promise<string> {
|
||||
return putData(`${apiUri}/v2/NotificationConnector`, newConnector)
|
||||
.then((json) => {
|
||||
//console.info("Got Notification Connectors");
|
||||
const ret = json as unknown as string;
|
||||
//console.debug(ret);
|
||||
return (ret);
|
||||
});
|
||||
}
|
||||
|
||||
static async GetNotificationConnectorWithId(apiUri: string, notificationConnectorId: string) : Promise<INotificationConnector> {
|
||||
if(notificationConnectorId === undefined || notificationConnectorId === null || notificationConnectorId.length < 1) {
|
||||
console.error(`notificationConnectorId was not provided`);
|
||||
return Promise.reject();
|
||||
}
|
||||
//console.info("Getting Notification Connectors");
|
||||
return getData(`${apiUri}/v2/NotificationConnector/${notificationConnectorId}`)
|
||||
.then((json) => {
|
||||
//console.info("Got Notification Connectors");
|
||||
const ret = json as INotificationConnector;
|
||||
//console.debug(ret);
|
||||
return (ret);
|
||||
});
|
||||
}
|
||||
|
||||
static async DeleteNotificationConnectorWithId(apiUri: string, notificationConnectorId: string) : Promise<void> {
|
||||
if(notificationConnectorId === undefined || notificationConnectorId === null || notificationConnectorId.length < 1) {
|
||||
console.error(`notificationConnectorId was not provided`);
|
||||
return Promise.reject();
|
||||
}
|
||||
//console.info("Getting Notification Connectors");
|
||||
return deleteData(`${apiUri}/v2/NotificationConnector/${notificationConnectorId}`);
|
||||
}
|
||||
|
||||
static async CreateGotify(apiUri: string, gotify: IGotifyRecord) : Promise<string> {
|
||||
if(gotify === undefined || gotify === null) {
|
||||
console.error(`gotify was not provided`);
|
||||
return Promise.reject();
|
||||
}
|
||||
//console.info("Getting Notification Connectors");
|
||||
return putData(`${apiUri}/v2/NotificationConnector/Gotify`, gotify)
|
||||
.then((json) => {
|
||||
//console.info("Got Notification Connectors");
|
||||
const ret = json as unknown as string;
|
||||
//console.debug(ret);
|
||||
return (ret);
|
||||
});
|
||||
}
|
||||
|
||||
static async CreateNtfy(apiUri: string, ntfy: INtfyRecord) : Promise<string> {
|
||||
if(ntfy === undefined || ntfy === null) {
|
||||
console.error(`ntfy was not provided`);
|
||||
return Promise.reject();
|
||||
}
|
||||
//console.info("Getting Notification Connectors");
|
||||
return putData(`${apiUri}/v2/NotificationConnector/Ntfy`, ntfy)
|
||||
.then((json) => {
|
||||
//console.info("Got Notification Connectors");
|
||||
const ret = json as unknown as string;
|
||||
//console.debug(ret);
|
||||
return (ret);
|
||||
});
|
||||
}
|
||||
|
||||
static async CreateLunasea(apiUri: string, lunasea: ILunaseaRecord) : Promise<string> {
|
||||
if(lunasea === undefined || lunasea === null) {
|
||||
console.error(`lunasea was not provided`);
|
||||
return Promise.reject();
|
||||
}
|
||||
//console.info("Getting Notification Connectors");
|
||||
return putData(`${apiUri}/v2/NotificationConnector/Lunasea`, lunasea)
|
||||
.then((json) => {
|
||||
//console.info("Got Notification Connectors");
|
||||
const ret = json as unknown as string;
|
||||
//console.debug(ret);
|
||||
return (ret);
|
||||
});
|
||||
}
|
||||
|
||||
static async CreatePushover(apiUri: string, pushover: IPushoverRecord) : Promise<string> {
|
||||
if(pushover === undefined || pushover === null) {
|
||||
console.error(`pushover was not provided`);
|
||||
return Promise.reject();
|
||||
}
|
||||
//console.info("Getting Notification Connectors");
|
||||
return putData(`${apiUri}/v2/NotificationConnector/Pushover`, pushover)
|
||||
.then((json) => {
|
||||
//console.info("Got Notification Connectors");
|
||||
const ret = json as unknown as string;
|
||||
//console.debug(ret);
|
||||
return (ret);
|
||||
});
|
||||
}
|
||||
}
|
46
Website/modules/api/Search.tsx
Normal file
46
Website/modules/api/Search.tsx
Normal file
@ -0,0 +1,46 @@
|
||||
import {postData} from "../../App";
|
||||
import IManga from "../types/IManga";
|
||||
|
||||
export default class SearchFunctions {
|
||||
|
||||
static async SearchName(apiUri: string, name: string) : Promise<IManga[]> {
|
||||
if(name === undefined || name === null || name.length < 1) {
|
||||
console.error(`name was not provided`);
|
||||
return Promise.reject();
|
||||
}
|
||||
return postData(`${apiUri}/v2/Search/Name`, name)
|
||||
.then((json) => {
|
||||
const ret = json as IManga[];
|
||||
return (ret);
|
||||
});
|
||||
}
|
||||
|
||||
static async SearchNameOnConnector(apiUri: string, connectorName: string, name: string) : Promise<IManga[]> {
|
||||
if(connectorName === undefined || connectorName === null || connectorName.length < 1) {
|
||||
console.error(`connectorName was not provided`);
|
||||
return Promise.reject();
|
||||
}
|
||||
if(name === undefined || name === null || name.length < 1) {
|
||||
console.error(`name was not provided`);
|
||||
return Promise.reject();
|
||||
}
|
||||
return postData(`${apiUri}/v2/Search/${connectorName}`, name)
|
||||
.then((json) => {
|
||||
const ret = json as IManga[];
|
||||
return (ret);
|
||||
});
|
||||
}
|
||||
|
||||
static async SearchUrl(apiUri: string, url: string) : Promise<IManga> {
|
||||
if(url === undefined || url === null || url.length < 1) {
|
||||
console.error(`name was not provided`);
|
||||
return Promise.reject();
|
||||
}
|
||||
return postData(`${apiUri}/v2/Search/Url`, url)
|
||||
.then((json) => {
|
||||
const ret = json as IManga;
|
||||
return (ret);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user