diff --git a/Website/App.tsx b/Website/App.tsx index e6051ac..6ef37ad 100644 --- a/Website/App.tsx +++ b/Website/App.tsx @@ -4,7 +4,6 @@ import Search from "./modules/Search"; import Header from "./modules/Header"; import MonitorJobsList from "./modules/MonitorJobsList"; import './styles/index.css' -import {Job} from "./modules/Job"; import IFrontendSettings, {FrontendSettingsWith} from "./modules/interfaces/IFrontendSettings"; import {useCookies} from "react-cookie"; @@ -14,6 +13,7 @@ export default function App(){ const [showSearch, setShowSearch] = React.useState(false); const [frontendSettings, setFrontendSettings] = useState(FrontendSettingsWith(undefined, undefined, undefined)); const [updateInterval, setUpdateInterval] = React.useState(); + const [updateMonitorList, setUpdateMonitorList] = React.useState(new Date()); const apiUri = frontendSettings.apiUri; @@ -35,9 +35,7 @@ export default function App(){ setCookie('jobInterval', settings.jobInterval); } - function CreateJob(internalId: string, jobType: string){ - Job.CreateJobDateInterval(apiUri, internalId, jobType, frontendSettings.jobInterval); - } + const UpdateList = () => {setUpdateMonitorList(new Date())} return(
@@ -45,11 +43,11 @@ export default function App(){ ? <> {showSearch ? <> - setShowSearch(false)} /> + setShowSearch(false)} />
: <>} - setShowSearch(true)} onJobsChanged={() => console.debug("jobsChanged")} connectedToBackend={connected} /> + setShowSearch(true)} onJobsChanged={UpdateList} connectedToBackend={connected} /> :

No connection to backend

}
diff --git a/Website/modules/MonitorJobsList.tsx b/Website/modules/MonitorJobsList.tsx index e4a4aef..fb949a9 100644 --- a/Website/modules/MonitorJobsList.tsx +++ b/Website/modules/MonitorJobsList.tsx @@ -8,7 +8,7 @@ import '../styles/MangaCoverCard.css' import Icon from '@mdi/react'; import { mdiTrashCanOutline, mdiPlayBoxOutline } from '@mdi/js'; -export default function MonitorJobsList({onStartSearch, onJobsChanged, connectedToBackend, apiUri} : {onStartSearch() : void, onJobsChanged: EventHandler, connectedToBackend: boolean, apiUri: string}) { +export default function MonitorJobsList({onStartSearch, onJobsChanged, connectedToBackend, apiUri, updateList} : {onStartSearch() : void, onJobsChanged: EventHandler, connectedToBackend: boolean, apiUri: string, updateList: Date}) { const [MonitoringJobs, setMonitoringJobs] = useState([]); const [AllManga, setAllManga] = useState([]); const [joblistUpdateInterval, setJoblistUpdateInterval] = React.useState(); @@ -40,7 +40,13 @@ export default function MonitorJobsList({onStartSearch, onJobsChanged, connected } }, [connectedToBackend]); + useEffect(() => { + UpdateMonitoringJobsList(); + }, [updateList]); + function UpdateMonitoringJobsList(){ + if(!connectedToBackend) + return; //console.debug("Updating MonitoringJobsList"); Job.GetMonitoringJobs(apiUri) .then((jobs) => { diff --git a/Website/modules/Search.tsx b/Website/modules/Search.tsx index 2d76572..f0d1c0a 100644 --- a/Website/modules/Search.tsx +++ b/Website/modules/Search.tsx @@ -6,14 +6,13 @@ import IManga, {SearchResult} from "./interfaces/IManga"; import '../styles/search.css'; import '../styles/MangaSearchResult.css' -export default function Search({apiUri, createJob, closeSearch} : {apiUri: string, createJob: (internalId: string, type: string) => void, closeSearch(): void}) { +export default function Search({apiUri, jobInterval, onJobsChanged, closeSearch} : {apiUri: string, jobInterval: Date, onJobsChanged: (internalId: string) => void, closeSearch(): void}) { const [mangaConnectors, setConnectors] = useState(); const [selectedConnector, setSelectedConnector] = useState(); const [selectedLanguage, setSelectedLanguage] = useState(); const [searchBoxValue, setSearchBoxValue] = useState(""); const [searchResults, setSearchResults] = useState(); - const pattern = /https:\/\/([a-z0-9.]+\.[a-z0-9]{2,})(?:\/.*)?/i useEffect(() => { @@ -106,7 +105,7 @@ export default function Search({apiUri, createJob, closeSearch} : {apiUri: strin
{searchResults === undefined ?

- : searchResults.map(result => SearchResult(apiUri, result, createJob))} + : searchResults.map(result => SearchResult(apiUri, result, jobInterval, onJobsChanged))}
) } \ No newline at end of file diff --git a/Website/modules/interfaces/IManga.tsx b/Website/modules/interfaces/IManga.tsx index 6b46467..11389ef 100644 --- a/Website/modules/interfaces/IManga.tsx +++ b/Website/modules/interfaces/IManga.tsx @@ -54,7 +54,7 @@ export function CoverCard(apiUri: string, manga: IManga) : ReactElement { ); } -export function SearchResult(apiUri: string, manga: IManga, createJob: (internalId: string, type: string) => void) : ReactElement { +export function SearchResult(apiUri: string, manga: IManga, interval: Date, onJobsChanged: (internalId: string) => void) : ReactElement { return(
Manga Cover @@ -67,7 +67,7 @@ export function SearchResult(apiUri: string, manga: IManga, createJob: (internal
);