diff --git a/Website/modules/Job.tsx b/Website/modules/Job.tsx index c62736b..e75f84e 100644 --- a/Website/modules/Job.tsx +++ b/Website/modules/Job.tsx @@ -1,6 +1,7 @@ import {deleteData, getData, patchData, postData, putData} from '../App'; import IJob, {JobState, JobType} from "./interfaces/Jobs/IJob"; import IModifyJobRecord from "./interfaces/records/IModifyJobRecord"; +import IDownloadAvailableJobsRecord from "./interfaces/records/IDownloadAvailableJobsRecord"; export default class Job { @@ -117,16 +118,16 @@ export default class Job }); } - static async CreateDownloadAvailableChaptersJob(apiUri: string, mangaId: string, recurrenceMs: number): Promise { + static async CreateDownloadAvailableChaptersJob(apiUri: string, mangaId: string, data: IDownloadAvailableJobsRecord): Promise { if(mangaId === undefined || mangaId === null || mangaId.length < 1) { console.error(`mangaId was not provided`); return Promise.reject(); } - if(recurrenceMs === undefined || recurrenceMs === null || recurrenceMs < 0) { + if(data === undefined || data === null) { console.error(`recurrenceMs was not provided`); return Promise.reject(); } - return putData(`${apiUri}/v2/Job/DownloadAvailableChaptersJob/${mangaId}`, recurrenceMs) + return putData(`${apiUri}/v2/Job/DownloadAvailableChaptersJob/${mangaId}`, data) .then((json) => { //console.info(`Got Job ${jobId}`); const ret = json as string[]; diff --git a/Website/modules/Search.tsx b/Website/modules/Search.tsx index 82d3baf..eebe6a2 100644 --- a/Website/modules/Search.tsx +++ b/Website/modules/Search.tsx @@ -7,6 +7,8 @@ import '../styles/search.css'; import '../styles/ExtendedInfo.css' import SearchFunctions from "./SearchFunctions"; import Job from "./Job"; +import ILocalLibrary from "./interfaces/ILocalLibrary"; +import LocalLibrary from "./interfaces/LocalLibrary"; export default function Search({apiUri, jobInterval, onJobsChanged, closeSearch} : {apiUri: string, jobInterval: Date, onJobsChanged: (internalId: string) => void, closeSearch(): void}) { const [mangaConnectors, setConnectors] = useState(); @@ -86,6 +88,27 @@ export default function Search({apiUri, jobInterval, onJobsChanged, closeSearch} } const changeSelectedLanguage : ChangeEventHandler = (event) => setSelectedLanguage(event.target.value); + let [selectedLibrary, setSelectedLibrary] = useState(null); + let [libraries, setLibraries] = useState(null); + useEffect(() => { + LocalLibrary.GetLibraries(apiUri).then(setLibraries); + }, []); + useEffect(() => { + if(libraries === null || libraries.length < 1) + setSelectedLibrary(null); + else + setSelectedLibrary(libraries[0]); + }, [libraries]); + + const selectedLibraryChanged : ChangeEventHandler = (event) => { + event.preventDefault(); + if(libraries === null) + return; + const selectedLibrary = libraries.find((lib:ILocalLibrary) => lib.localLibraryId == event.target.value); + if(selectedLibrary === undefined) + return; + setSelectedLibrary(selectedLibrary); + } return (