diff --git a/Website/App.tsx b/Website/App.tsx index 25a5e96..86d65ea 100644 --- a/Website/App.tsx +++ b/Website/App.tsx @@ -16,18 +16,16 @@ export default function App(){ const [updateInterval, setUpdateInterval] = React.useState(undefined); const checkConnectedInterval = 1000; - const apiUri = frontendSettings.apiUri; - useEffect(() => { setCookie('apiUri', frontendSettings.apiUri); setCookie('jobInterval', frontendSettings.jobInterval); - updateConnected(apiUri, connected, setConnected); + updateConnected(frontendSettings.apiUri, connected, setConnected); }, [frontendSettings]); useEffect(() => { if(updateInterval === undefined){ setUpdateInterval(setInterval(() => { - updateConnected(apiUri, connected, setConnected); + updateConnected(frontendSettings.apiUri, connected, setConnected); }, checkConnectedInterval)); }else{ clearInterval(updateInterval); @@ -36,23 +34,23 @@ export default function App(){ }, [connected]); return(
-
+
{connected ? <> {showSearch ? <> - setShowSearch(false)} /> + setShowSearch(false)} />
: <>} - setShowSearch(true)} connectedToBackend={connected} checkConnectedInterval={checkConnectedInterval} /> + setShowSearch(true)} connectedToBackend={connected} checkConnectedInterval={checkConnectedInterval} /> : <>

No connection to the Backend.

Check the Settings ApiUri.

} -
+
) } diff --git a/Website/modules/Settings.tsx b/Website/modules/Settings.tsx index 65c959c..5ac4565 100644 --- a/Website/modules/Settings.tsx +++ b/Website/modules/Settings.tsx @@ -15,6 +15,12 @@ export default function Settings({backendConnected, apiUri, frontendSettings, se NotificationConnectorFunctions.GetNotificationConnectors(apiUri).then(setNotificationConnectors); }, []); + const dateToStr = (x: Date) => { + const ret = (x.getHours() < 10 ? "0" + x.getHours() : x.getHours()) + + ":" + + (x.getMinutes() < 10 ? "0" + x.getMinutes() : x.getMinutes()); + return ret; + } return (
@@ -30,20 +36,11 @@ export default function Settings({backendConnected, apiUri, frontendSettings, se
- { - let newSettings = frontendSettings; - newSettings.apiUri = e.currentTarget.value; - setFrontendSettings(newSettings); - }} id="ApiUri" /> + setFrontendSettings({...frontendSettings, apiUri:e.currentTarget.value})} id="ApiUri" />
- { - let newSettings = frontendSettings; - newSettings.jobInterval = e.currentTarget.valueAsDate ?? frontendSettings.jobInterval; - setFrontendSettings(newSettings); - console.log(frontendSettings); - }}/> + setFrontendSettings({...frontendSettings, jobInterval: new Date(e.currentTarget.valueAsNumber-60*60*1000) ?? frontendSettings.jobInterval})}/>
{notificationConnectors.map(c => )} diff --git a/Website/modules/interfaces/INotificationConnector.tsx b/Website/modules/interfaces/INotificationConnector.tsx index 02620c7..80966e0 100644 --- a/Website/modules/interfaces/INotificationConnector.tsx +++ b/Website/modules/interfaces/INotificationConnector.tsx @@ -2,6 +2,9 @@ import {ReactElement, ReactEventHandler, useState} from "react"; import "../../styles/notificationConnector.css"; import Loader from "../Loader"; import NotificationConnectorFunctions from "../NotificationConnectorFunctions"; +import {LunaseaItem} from "./records/ILunaseaRecord"; +import {GotifyItem} from "./records/IGotifyRecord"; +import {NtfyItem} from "./records/INtfyRecord"; export default interface INotificationConnector { name: string; @@ -12,7 +15,32 @@ export default interface INotificationConnector { } export function NotificationConnectorItem({apiUri, notificationConnector} : {apiUri: string, notificationConnector: INotificationConnector | null}) : ReactElement { - const AddHeader : ReactEventHandler = (e) => { + if(notificationConnector != null) + return + + const [selectedConnectorElement, setSelectedConnectorElement] = useState(); + + return <> +

New Notification Connector

+ + {selectedConnectorElement} + ; +} + +function DefaultItem({apiUri, notificationConnector}:{apiUri: string, notificationConnector: INotificationConnector | null}) : ReactElement { + const AddHeader : ReactEventHandler = () => { let header : Record = {}; let x = info; x.headers = [header, ...x.headers]; @@ -20,7 +48,6 @@ export function NotificationConnectorItem({apiUri, notificationConnector} : {api setHeaderElements([...headerElements, ]) } const [headerElements, setHeaderElements] = useState([]); - const [loading, setLoading] = useState(false); const [info, setInfo] = useState({ name: "", url: "", @@ -28,30 +55,22 @@ export function NotificationConnectorItem({apiUri, notificationConnector} : {api httpMethod: "", body: "" }); - - return (
-

{notificationConnector ? notificationConnector.name : "New Notification Connector"}

+ const [loading, setLoading] = useState(false); + return
+ setInfo({...info, name: e.currentTarget.value})} />
- setInfo({...info, httpMethod: e.currentTarget.value})} > - { - let x = info; - x.url = e.currentTarget.value; - setInfo(x); - }} /> + setInfo({...info, url: e.currentTarget.value})} />
-