mirror of
https://github.com/C9Glax/tranga-website.git
synced 2025-05-09 08:32:10 +02:00
Compare commits
No commits in common. "d358611133131b36970b4e887d3b69b184241556" and "f38290b2eddb844ce6864afa44390653afbc15a4" have entirely different histories.
d358611133
...
f38290b2ed
@ -58,12 +58,4 @@ export default class BackendSettings {
|
|||||||
static async UpdateAprilFoolsToggle(apiUri: string, value: boolean) {
|
static async UpdateAprilFoolsToggle(apiUri: string, value: boolean) {
|
||||||
return patchData(`${apiUri}/v2/Settings/AprilFoolsMode`, value);
|
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -3,7 +3,6 @@ import {deleteData, getData, putData} from "../App";
|
|||||||
import IGotifyRecord from "./interfaces/records/IGotifyRecord";
|
import IGotifyRecord from "./interfaces/records/IGotifyRecord";
|
||||||
import INtfyRecord from "./interfaces/records/INtfyRecord";
|
import INtfyRecord from "./interfaces/records/INtfyRecord";
|
||||||
import ILunaseaRecord from "./interfaces/records/ILunaseaRecord";
|
import ILunaseaRecord from "./interfaces/records/ILunaseaRecord";
|
||||||
import IPushoverRecord from "./interfaces/records/IPushoverRecord";
|
|
||||||
|
|
||||||
export default class NotificationConnectorFunctions {
|
export default class NotificationConnectorFunctions {
|
||||||
|
|
||||||
@ -84,7 +83,7 @@ export default class NotificationConnectorFunctions {
|
|||||||
|
|
||||||
static async CreateLunasea(apiUri: string, lunasea: ILunaseaRecord) : Promise<string> {
|
static async CreateLunasea(apiUri: string, lunasea: ILunaseaRecord) : Promise<string> {
|
||||||
if(lunasea === undefined || lunasea === null) {
|
if(lunasea === undefined || lunasea === null) {
|
||||||
console.error(`lunasea was not provided`);
|
console.error(`ntfy was not provided`);
|
||||||
return Promise.reject();
|
return Promise.reject();
|
||||||
}
|
}
|
||||||
//console.info("Getting Notification Connectors");
|
//console.info("Getting Notification Connectors");
|
||||||
@ -96,19 +95,4 @@ export default class NotificationConnectorFunctions {
|
|||||||
return (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);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -21,9 +21,7 @@ export default function Search({apiUri, jobInterval, closeSearch} : {apiUri: str
|
|||||||
const pattern = /https:\/\/([a-z0-9.]+\.[a-z0-9]{2,})(?:\/.*)?/i
|
const pattern = /https:\/\/([a-z0-9.]+\.[a-z0-9]{2,})(?:\/.*)?/i
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
MangaConnectorFunctions.GetAllConnectors(apiUri).then((connectors)=> {
|
MangaConnectorFunctions.GetAllConnectors(apiUri).then(setConnectors).then(() => setLoading(false));
|
||||||
return connectors.filter(c => c.enabled);
|
|
||||||
}).then(setConnectors).then(() => setLoading(false));
|
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -11,8 +11,6 @@ import BackendSettings from "./BackendSettingsFunctions";
|
|||||||
import Toggle from "react-toggle";
|
import Toggle from "react-toggle";
|
||||||
import Loader from "./Loader";
|
import Loader from "./Loader";
|
||||||
import {RequestType} from "./interfaces/IRequestLimits";
|
import {RequestType} from "./interfaces/IRequestLimits";
|
||||||
import IMangaConnector from "./interfaces/IMangaConnector";
|
|
||||||
import {MangaConnectorFunctions} from "./MangaConnectorFunctions";
|
|
||||||
|
|
||||||
export default function Settings({ backendConnected, apiUri, frontendSettings, setFrontendSettings } : {
|
export default function Settings({ backendConnected, apiUri, frontendSettings, setFrontendSettings } : {
|
||||||
backendConnected: boolean,
|
backendConnected: boolean,
|
||||||
@ -24,9 +22,7 @@ export default function Settings({ backendConnected, apiUri, frontendSettings, s
|
|||||||
const [loadingBackend, setLoadingBackend] = useState(false);
|
const [loadingBackend, setLoadingBackend] = useState(false);
|
||||||
const [backendSettings, setBackendSettings] = useState<IBackendSettings|null>(null);
|
const [backendSettings, setBackendSettings] = useState<IBackendSettings|null>(null);
|
||||||
const [notificationConnectors, setNotificationConnectors] = useState<INotificationConnector[]>([]);
|
const [notificationConnectors, setNotificationConnectors] = useState<INotificationConnector[]>([]);
|
||||||
const [mangaConnectors,setMangaConnectors] = useState<IMangaConnector[]>([]);
|
|
||||||
const [localLibraries, setLocalLibraries] = useState<ILocalLibrary[]>([]);
|
const [localLibraries, setLocalLibraries] = useState<ILocalLibrary[]>([]);
|
||||||
const [chapterNamingScheme, setChapterNamingScheme] = useState<string>("");
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if(!backendConnected)
|
if(!backendConnected)
|
||||||
@ -34,7 +30,6 @@ export default function Settings({ backendConnected, apiUri, frontendSettings, s
|
|||||||
NotificationConnectorFunctions.GetNotificationConnectors(apiUri).then(setNotificationConnectors);
|
NotificationConnectorFunctions.GetNotificationConnectors(apiUri).then(setNotificationConnectors);
|
||||||
LocalLibraryFunctions.GetLibraries(apiUri).then(setLocalLibraries);
|
LocalLibraryFunctions.GetLibraries(apiUri).then(setLocalLibraries);
|
||||||
BackendSettings.GetSettings(apiUri).then(setBackendSettings);
|
BackendSettings.GetSettings(apiUri).then(setBackendSettings);
|
||||||
MangaConnectorFunctions.GetAllConnectors(apiUri).then(setMangaConnectors);
|
|
||||||
}, [backendConnected, showSettings]);
|
}, [backendConnected, showSettings]);
|
||||||
|
|
||||||
const dateToStr = (x: Date) => {
|
const dateToStr = (x: Date) => {
|
||||||
@ -75,14 +70,6 @@ export default function Settings({ backendConnected, apiUri, frontendSettings, s
|
|||||||
<h3>Default Job-Interval</h3>
|
<h3>Default Job-Interval</h3>
|
||||||
<input type="time" min="00:30" max="23:59" defaultValue={dateToStr(new Date(frontendSettings.jobInterval))} onChange={(e) => setFrontendSettings({...frontendSettings, jobInterval: new Date(e.currentTarget.valueAsNumber-60*60*1000) ?? frontendSettings.jobInterval})}/>
|
<input type="time" min="00:30" max="23:59" defaultValue={dateToStr(new Date(frontendSettings.jobInterval))} onChange={(e) => setFrontendSettings({...frontendSettings, jobInterval: new Date(e.currentTarget.valueAsNumber-60*60*1000) ?? frontendSettings.jobInterval})}/>
|
||||||
</div>
|
</div>
|
||||||
<div className={"settings-chapterNamingScheme"}>
|
|
||||||
<h3>Chapter Naming-Scheme</h3>
|
|
||||||
<input type={"text"} placeholder={backendSettings?.chapterNamingScheme} onChange={(e) => setChapterNamingScheme(e.target.value)} />
|
|
||||||
<button type={"button"} onClick={() => {
|
|
||||||
setLoadingBackend(true);
|
|
||||||
BackendSettings.UpdateChapterNamingScheme(apiUri, chapterNamingScheme).finally(() => setLoadingBackend(false));
|
|
||||||
}}>Submit</button>
|
|
||||||
</div>
|
|
||||||
<div className="settings-bwimages">
|
<div className="settings-bwimages">
|
||||||
<h3>B/W Images</h3>
|
<h3>B/W Images</h3>
|
||||||
<Toggle defaultChecked={backendSettings ? backendSettings.bwImages : false} disabled={backendSettings ? false : !loadingBackend}
|
<Toggle defaultChecked={backendSettings ? backendSettings.bwImages : false} disabled={backendSettings ? false : !loadingBackend}
|
||||||
@ -167,17 +154,6 @@ export default function Settings({ backendConnected, apiUri, frontendSettings, s
|
|||||||
<input id="MangaCover" type="number" defaultValue={backendSettings ? backendSettings.requestLimits.MangaCover : 0} disabled={backendSettings ? false : !loadingBackend}
|
<input id="MangaCover" type="number" defaultValue={backendSettings ? backendSettings.requestLimits.MangaCover : 0} disabled={backendSettings ? false : !loadingBackend}
|
||||||
onChange={(e) => ChangeRequestLimit(RequestType.MangaCover, e.currentTarget.valueAsNumber)} />
|
onChange={(e) => ChangeRequestLimit(RequestType.MangaCover, e.currentTarget.valueAsNumber)} />
|
||||||
</div>
|
</div>
|
||||||
<div className={"settings-mangaConnectors"}>
|
|
||||||
{mangaConnectors.map(mc => {
|
|
||||||
return (
|
|
||||||
<div key={mc.name}>
|
|
||||||
<span>{mc.name}</span>
|
|
||||||
<Toggle defaultChecked={mc.enabled} onChange={(e) => {
|
|
||||||
MangaConnectorFunctions.SetConnectorEnabled(apiUri, mc.name, e.currentTarget.checked);
|
|
||||||
}} />
|
|
||||||
</div>);
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
<div>
|
<div>
|
||||||
<h3>Notification Connectors:</h3>
|
<h3>Notification Connectors:</h3>
|
||||||
{notificationConnectors.map(c => <NotificationConnectorItem apiUri={apiUri} notificationConnector={c} key={c.name} />)}
|
{notificationConnectors.map(c => <NotificationConnectorItem apiUri={apiUri} notificationConnector={c} key={c.name} />)}
|
||||||
|
@ -14,5 +14,4 @@ export default interface IBackendSettings {
|
|||||||
compression: number;
|
compression: number;
|
||||||
bwImages: boolean;
|
bwImages: boolean;
|
||||||
startNewJobTimeoutMs: number;
|
startNewJobTimeoutMs: number;
|
||||||
chapterNamingScheme: string;
|
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@ import NotificationConnectorFunctions from "../NotificationConnectorFunctions";
|
|||||||
import {LunaseaItem} from "./records/ILunaseaRecord";
|
import {LunaseaItem} from "./records/ILunaseaRecord";
|
||||||
import {GotifyItem} from "./records/IGotifyRecord";
|
import {GotifyItem} from "./records/IGotifyRecord";
|
||||||
import {NtfyItem} from "./records/INtfyRecord";
|
import {NtfyItem} from "./records/INtfyRecord";
|
||||||
import {PushoverItem} from "./records/IPushoverRecord";
|
|
||||||
|
|
||||||
export default interface INotificationConnector {
|
export default interface INotificationConnector {
|
||||||
name: string;
|
name: string;
|
||||||
@ -30,14 +29,12 @@ export function NotificationConnectorItem({apiUri, notificationConnector} : {api
|
|||||||
case "gotify": setSelectedConnectorElement(<GotifyItem apiUri={apiUri} />); break;
|
case "gotify": setSelectedConnectorElement(<GotifyItem apiUri={apiUri} />); break;
|
||||||
case "ntfy": setSelectedConnectorElement(<NtfyItem apiUri={apiUri} />); break;
|
case "ntfy": setSelectedConnectorElement(<NtfyItem apiUri={apiUri} />); break;
|
||||||
case "lunasea": setSelectedConnectorElement(<LunaseaItem 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="default">Generic REST</option>
|
||||||
<option value="gotify">Gotify</option>
|
<option value="gotify">Gotify</option>
|
||||||
<option value="ntfy">Ntfy</option>
|
<option value="ntfy">Ntfy</option>
|
||||||
<option value="lunasea">Lunasea</option>
|
<option value="lunasea">Lunasea</option>
|
||||||
<option value="pushover">Pushover</option>
|
|
||||||
</select>
|
</select>
|
||||||
{selectedConnectorElement}
|
{selectedConnectorElement}
|
||||||
</div>;
|
</div>;
|
||||||
|
@ -1,43 +0,0 @@
|
|||||||
import {ReactElement, useState} from "react";
|
|
||||||
import NotificationConnectorFunctions from "../../NotificationConnectorFunctions";
|
|
||||||
import Loader from "../../Loader";
|
|
||||||
import "../../../styles/notificationConnector.css";
|
|
||||||
import {isValidUri} from "../../../App";
|
|
||||||
|
|
||||||
export default interface IPushoverRecord {
|
|
||||||
apptoken: string;
|
|
||||||
user: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
function Validate(record: IPushoverRecord) : boolean {
|
|
||||||
if(record.apptoken.length < 1)
|
|
||||||
return false;
|
|
||||||
if(record.user.length < 1)
|
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function PushoverItem ({apiUri} : {apiUri: string}) : ReactElement{
|
|
||||||
const [info, setInfo] = useState<IPushoverRecord>({
|
|
||||||
apptoken: "",
|
|
||||||
user: ""
|
|
||||||
});
|
|
||||||
const [loading, setLoading] = useState(false);
|
|
||||||
return <div className="NotificationConnectorItem">
|
|
||||||
<input className="NotificationConnectorItem-Name" value="Pushover" disabled={true} />
|
|
||||||
<div className="NotificationConnectorItem-Ident">
|
|
||||||
<input type="text" className="NotificationConnectorItem-Apptoken" placeholder="Apptoken" onChange={(e) => setInfo({...info, apptoken: e.currentTarget.value})} />
|
|
||||||
<input type="text" className="NotificationConnectorItem-User" placeholder="User" onChange={(e) => setInfo({...info, user: e.currentTarget.value})} />
|
|
||||||
</div>
|
|
||||||
<>
|
|
||||||
<button className="NotificationConnectorItem-Save" onClick={(e) => {
|
|
||||||
if(info === null || Validate(info) === false)
|
|
||||||
return;
|
|
||||||
setLoading(true);
|
|
||||||
NotificationConnectorFunctions.CreatePushover(apiUri, info)
|
|
||||||
.finally(() => setLoading(false));
|
|
||||||
}}>Add</button>
|
|
||||||
<Loader loading={loading} style={{width:"40px",height:"40px",margin:"25vh calc(sin(70)*(50% - 40px))"}}/>
|
|
||||||
</>
|
|
||||||
</div>;
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user