mirror of
https://github.com/C9Glax/tranga-website.git
synced 2025-05-10 00:52:09 +02:00
Remove Lunasea https://github.com/C9Glax/tranga/issues/389
This commit is contained in:
parent
10f48af9fa
commit
5626a9d0fd
@ -1,32 +0,0 @@
|
||||
import {ReactElement, useState} from "react";
|
||||
import NotificationConnector from "../api/NotificationConnector";
|
||||
import Loader from "../Loader";
|
||||
import ILunaseaRecord from "../types/records/ILunaseaRecord";
|
||||
|
||||
export function LunaseaItem ({apiUri} : {apiUri: string}) : ReactElement{
|
||||
const [record, setRecord] = useState<ILunaseaRecord>({
|
||||
id: ""
|
||||
});
|
||||
const [loading, setLoading] = useState(false);
|
||||
return <div className="NotificationConnectorItem">
|
||||
<input className="NotificationConnectorItem-Name" value="LunaSea" disabled={true} />
|
||||
<div className="NotificationConnectorItem-Url">
|
||||
<input type="text" className="NotificationConnectorItem-RequestUrl" placeholder="device/:device_id or user/:user_id" onChange={(e) => setRecord({...record, id: e.currentTarget.value})} />
|
||||
</div>
|
||||
<>
|
||||
<button className="NotificationConnectorItem-Save" onClick={(e) => {
|
||||
if(record === null || Validate(record) === false)
|
||||
return;
|
||||
setLoading(true);
|
||||
NotificationConnector.CreateLunasea(apiUri, record)
|
||||
.finally(() => setLoading(false));
|
||||
}}>Add</button>
|
||||
<Loader loading={loading} style={{width:"40px",height:"40px",margin:"25vh calc(sin(70)*(50% - 40px))"}}/>
|
||||
</>
|
||||
</div>;
|
||||
}
|
||||
|
||||
const regex = new RegExp("(?:device|user)\/[0-9a-zA-Z\-]+");
|
||||
function Validate(record: ILunaseaRecord) : boolean {
|
||||
return regex.test(record.id);
|
||||
}
|
@ -5,7 +5,6 @@ import NotificationConnector from "../api/NotificationConnector";
|
||||
import INotificationConnector from "../types/INotificationConnector";
|
||||
import {GotifyItem} from "./Gotify";
|
||||
import {NtfyItem} from "./Ntfy";
|
||||
import {LunaseaItem} from "./Lunasea";
|
||||
import {PushoverItem} from "./Pushover";
|
||||
|
||||
export default function NotificationConnectorItem({apiUri, notificationConnector} : {apiUri: string, notificationConnector: INotificationConnector | null}) : ReactElement {
|
||||
@ -22,14 +21,12 @@ export default function NotificationConnectorItem({apiUri, notificationConnector
|
||||
case "default": setSelectedConnectorElement(<DefaultItem apiUri={apiUri} notificationConnector={null} />); break;
|
||||
case "gotify": setSelectedConnectorElement(<GotifyItem apiUri={apiUri} />); break;
|
||||
case "ntfy": setSelectedConnectorElement(<NtfyItem apiUri={apiUri} />); break;
|
||||
case "lunasea": setSelectedConnectorElement(<LunaseaItem apiUri={apiUri} />); break;
|
||||
case "pushover": setSelectedConnectorElement(<PushoverItem apiUri={apiUri} />); break;
|
||||
}
|
||||
}}>
|
||||
<option value="default">Generic REST</option>
|
||||
<option value="gotify">Gotify</option>
|
||||
<option value="ntfy">Ntfy</option>
|
||||
<option value="lunasea">Lunasea</option>
|
||||
<option value="pushover">Pushover</option>
|
||||
</select>
|
||||
{selectedConnectorElement}
|
||||
|
@ -1,7 +1,6 @@
|
||||
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";
|
||||
|
||||
@ -82,21 +81,6 @@ export default class NotificationConnector {
|
||||
});
|
||||
}
|
||||
|
||||
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`);
|
||||
|
Loading…
x
Reference in New Issue
Block a user