Settings to enable and disable MangaConnectors

This commit is contained in:
glax 2025-03-27 19:50:41 +01:00
parent f38290b2ed
commit e3ad70c0a9
2 changed files with 18 additions and 1 deletions

View File

@ -21,7 +21,9 @@ export default function Search({apiUri, jobInterval, closeSearch} : {apiUri: str
const pattern = /https:\/\/([a-z0-9.]+\.[a-z0-9]{2,})(?:\/.*)?/i
useEffect(() => {
MangaConnectorFunctions.GetAllConnectors(apiUri).then(setConnectors).then(() => setLoading(false));
MangaConnectorFunctions.GetAllConnectors(apiUri).then((connectors)=> {
return connectors.filter(c => c.enabled);
}).then(setConnectors).then(() => setLoading(false));
}, []);
useEffect(() => {

View File

@ -11,6 +11,8 @@ import BackendSettings from "./BackendSettingsFunctions";
import Toggle from "react-toggle";
import Loader from "./Loader";
import {RequestType} from "./interfaces/IRequestLimits";
import IMangaConnector from "./interfaces/IMangaConnector";
import {MangaConnectorFunctions} from "./MangaConnectorFunctions";
export default function Settings({ backendConnected, apiUri, frontendSettings, setFrontendSettings } : {
backendConnected: boolean,
@ -22,6 +24,7 @@ export default function Settings({ backendConnected, apiUri, frontendSettings, s
const [loadingBackend, setLoadingBackend] = useState(false);
const [backendSettings, setBackendSettings] = useState<IBackendSettings|null>(null);
const [notificationConnectors, setNotificationConnectors] = useState<INotificationConnector[]>([]);
const [mangaConnectors,setMangaConnectors] = useState<IMangaConnector[]>([]);
const [localLibraries, setLocalLibraries] = useState<ILocalLibrary[]>([]);
useEffect(() => {
@ -30,6 +33,7 @@ export default function Settings({ backendConnected, apiUri, frontendSettings, s
NotificationConnectorFunctions.GetNotificationConnectors(apiUri).then(setNotificationConnectors);
LocalLibraryFunctions.GetLibraries(apiUri).then(setLocalLibraries);
BackendSettings.GetSettings(apiUri).then(setBackendSettings);
MangaConnectorFunctions.GetAllConnectors(apiUri).then(setMangaConnectors);
}, [backendConnected, showSettings]);
const dateToStr = (x: Date) => {
@ -154,6 +158,17 @@ export default function Settings({ backendConnected, apiUri, frontendSettings, s
<input id="MangaCover" type="number" defaultValue={backendSettings ? backendSettings.requestLimits.MangaCover : 0} disabled={backendSettings ? false : !loadingBackend}
onChange={(e) => ChangeRequestLimit(RequestType.MangaCover, e.currentTarget.valueAsNumber)} />
</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>
<h3>Notification Connectors:</h3>
{notificationConnectors.map(c => <NotificationConnectorItem apiUri={apiUri} notificationConnector={c} key={c.name} />)}