From 4c418add810dc943f1a4d917b3f42487364bd50b Mon Sep 17 00:00:00 2001 From: db-2001 Date: Sun, 11 Feb 2024 16:59:05 -0500 Subject: [PATCH] Updates to match API --- .gitignore | 7 ++- Website/apiConnector.js | 22 ++++--- Website/index.html | 47 ++++++++------ Website/interaction.js | 131 +++++++++++++++++----------------------- 4 files changed, 105 insertions(+), 102 deletions(-) diff --git a/.gitignore b/.gitignore index a471f98..a77fa96 100644 --- a/.gitignore +++ b/.gitignore @@ -18,4 +18,9 @@ riderModule.iml /dataSources.local.xml /.idea cover.jpg -cover.png \ No newline at end of file +cover.png +.vs/slnx.sqlite +.vs/tranga-website/config/applicationhost.config +.vs/tranga-website/FileContentIndex/91a465d3-1190-42e0-95eb-fa3694744e58.vsidx +.vs/tranga-website/v17/.wsuo +.vs/VSWorkspaceState.json diff --git a/Website/apiConnector.js b/Website/apiConnector.js index 955ecf0..ef71666 100644 --- a/Website/apiConnector.js +++ b/Website/apiConnector.js @@ -39,10 +39,11 @@ async function GetData(uri){ return json; } -function PostData(uri){ - fetch(uri, { +async function PostData(uri){ + let request = await fetch(uri, { method: 'POST' }); + console.log(request); } function DeleteData(uri){ @@ -143,6 +144,12 @@ async function GetLibraryConnectors(){ return json; } +async function GetRateLimits() { + var uri = `${apiUri}/Settings/customRequestLimit` + let json = await GetData(uri); + return json; +} + function CreateMonitorJob(connector, internalId, language){ var uri = `${apiUri}/Jobs/MonitorManga?connector=${connector}&internalId=${internalId}&interval=03:00:00&translatedLanguage=${language}`; PostData(uri); @@ -171,6 +178,7 @@ function RefreshLibraryMetadata() { async function DownloadLogs() { var uri = `${apiUri}/LogFile`; let response = await GetData(uri); + console.log(response); } //Komga @@ -213,7 +221,7 @@ function UpdateGotify(gotifyUrl, gotifyAppToken){ } function ResetGotify(){ - var uri = `${apiUri}/NotificationConnectors/Reset?libraryConnector=Gotify`; + var uri = `${apiUri}/NotificationConnectors/Reset?notificationConnector=Gotify`; PostData(uri); } @@ -229,7 +237,7 @@ function UpdateLunaSea(lunaseaWebhook){ } function ResetLunaSea(){ - var uri = `${apiUri}/NotificationConnectors/Reset?libraryConnector=LunaSea`; + var uri = `${apiUri}/NotificationConnectors/Reset?notificationConnector=LunaSea`; PostData(uri); } @@ -245,7 +253,7 @@ function UpdateNtfy(ntfyEndpoint, ntfyAuth){ } function ResetNtfy(){ - var uri = `${apiUri}/NotificationConnectors/Reset?libraryConnector=Ntfy`; + var uri = `${apiUri}/NotificationConnectors/Reset?notificationConnector=Ntfy`; PostData(uri); } @@ -259,8 +267,8 @@ function UpdateUserAgent(userAgent){ PostData(uri); } -function UpdateRateLimit(connector, byteValue, rateLimit) { - var uri = `${apiUri}/Settings/customRequestLimit?requestType=${byteValue}&requestsPerMinute=${rateLimit}&connector=${connector}`; +function UpdateRateLimit(byteValue, rateLimit) { + var uri = `${apiUri}/Settings/customRequestLimit?requestType=${byteValue}&requestsPerMinute=${rateLimit}`; PostData(uri); } diff --git a/Website/index.html b/Website/index.html index 3d8acc3..1bb8c4c 100644 --- a/Website/index.html +++ b/Website/index.html @@ -101,6 +101,13 @@ Download Logs +
+ Rate Limits + + + + +
Appearance + + +
-
+ + + +
diff --git a/Website/interaction.js b/Website/interaction.js index e378440..889ade9 100644 --- a/Website/interaction.js +++ b/Website/interaction.js @@ -33,14 +33,16 @@ const mangaViewerTags = document.querySelector("#publicationViewerTags"); const mangaViewerAuthor = document.querySelector("#publicationViewerAuthor"); const mangaViewCover = document.querySelector("#pubviewcover"); -//Rate Limits -const manganatoRateLimit = document.querySelector('#manganatoRL'); -const mangaseeRateLimit = document.querySelector('#mangaseeRL'); -const mangadexRateLimit = document.querySelector('#mDexRL'); -const mangakatanaRateLimit = document.querySelector('#mKatanaRL'); -const mangaworldRateLimit = document.querySelector('#mWorldRL'); -const batoRateLimit = document.querySelector('#batoRL'); -const mangalifeRateLimit = document.querySelector('#mLifeRL'); +//General Rate Limits +const defaultRL = document.querySelector("#defaultRL"); +const coverRL = document.querySelector("#coverRL"); +const imageRL = document.querySelector("#imageRL"); +const infoRL = document.querySelector("#infoRL"); + +//MangaDex Rate Limits +const mDexAuthorRL = document.querySelector("#mDexAuthorRL"); +const mDexFeedRL = document.querySelector("#mDexFeedRL"); +const mDexImageRL = document.querySelector("#mDexImageRL"); //Komga const settingKomgaUrl = document.querySelector("#komgaUrl"); @@ -151,6 +153,15 @@ function Setup(){ //console.log(json); settingApiUri.placeholder = apiUri; }); + GetRateLimits().then((json) => { + defaultRL.placeholder = json.Default + ' Requests/Minute'; + coverRL.placeholder = json.MangaCover + ' Requests/Minute'; + imageRL.placeholder = json.MangaImage + ' Requests/Minute'; + infoRL.placeholder = json.MangaInfo + ' Requests/Minute'; + mDexAuthorRL.placeholder = json.MangaDexAuthor + ' Requests/Minute'; + mDexFeedRL.placeholder = json.MangaDexFeed + ' Requests/Minute'; + mDexImageRL.placeholder = json.MangaDexImage + ' Requests/Minute'; + }); //If the cssStyle key isn't in the local storage of the browser, then set the css style to the default and load the page //Otherwise get the style key from storage and set it. @@ -515,59 +526,14 @@ settingNtfyAuth.addEventListener("keypress", (event) => { if(event.key === "Ente settingUserAgent.addEventListener("keypress", (event) => { if(event.key === "Enter") UpdateSettings(); }); settingApiUri.addEventListener("keypress", (event) => { if(event.key === "Enter") UpdateSettings(); }); -manganatoRateLimit.addEventListener("keypress", (event) => { if(event.key === "Enter") NewRateLimit(event);}); -mangaseeRateLimit.addEventListener("keypress", (event) => { if(event.key === "Enter") NewRateLimit(event);}); -mangadexRateLimit.addEventListener("keypress", (event) => { if(event.key === "Enter") NewRateLimit(event);}); -mangakatanaRateLimit.addEventListener("keypress", (event) => { if(event.key === "Enter") NewRateLimit(event);}); -mangaworldRateLimit.addEventListener("keypress", (event) => { if(event.key === "Enter") NewRateLimit(event);}); -batoRateLimit.addEventListener("keypress", (event) => { if(event.key === "Enter") NewRateLimit(event);}); -mangalifeRateLimit.addEventListener("keypress", (event) => { if(event.key === "Enter") NewRateLimit(event);}); +defaultRL.addEventListener("keypress", (event) => { if(event.key === "Enter") UpdateSettings();}); +coverRL.addEventListener("keypress", (event) => { if(event.key === "Enter") UpdateSettings();}); +imageRL.addEventListener("keypress", (event) => { if(event.key === "Enter") UpdateSettings();}); +infoRL.addEventListener("keypress", (event) => { if(event.key === "Enter") UpdateSettings();}); +mDexAuthorRL.addEventListener("keypress", (event) => { if(event.key === "Enter") UpdateSettings();}); +mDexFeedRL.addEventListener("keypress", (event) => { if(event.key === "Enter") UpdateSettings();}); +mDexImageRL.addEventListener("keypress", (event) => { if(event.key === "Enter") UpdateSettings();}); -function NewRateLimit(event) { - if (event.target.value.length > 0 && event.target.value != 0) { - console.log(event.target.id); - switch (event.target.id) { - case "manganatoRL": - connector = 'Manganato'; - byteValue = 1; - UpdateRateLimit(connector, byteValue, event.target.value); - break; - case "mangaseeRL": - connector = 'Mangasee'; - byteValue = 1; - UpdateRateLimit(connector, byteValue, event.target.value); - break; - case "mDexRL": - connector = 'MangaDex' - byteValue = 250; - UpdateRateLimit(connector, byteValue, event.target.value); - break; - case "mKatanaRL": - connector = 'MangaKatana'; - byteValue = 1; - UpdateRateLimit(connector, byteValue, event.target.value); - break; - case "mWorldRL": - connector = 'Mangaworld'; - byteValue = 1; - UpdateRateLimit(connector, byteValue, event.target.value); - break; - case "batoRL": - connector = 'Bato'; - byteValue = 1; - UpdateRateLimit(connector, byteValue, event.target.value); - break; - case "mLifeRL": - connector = 'Manga4Life'; - byteValue = 1; - UpdateRateLimit(connector, byteValue, event.target.value); - break; - default: - console.log("Unknown connector:"); - console.log(event.target.id); - } - } -} function OpenSettings(){ settingGotifyConfigured.setAttribute("configuration", "Not Configured"); @@ -588,6 +554,13 @@ function OpenSettings(){ settingNtfyEndpoint.value = ""; settingUserAgent.value = ""; settingApiUri.value = ""; + defaultRL.value = ""; + coverRL.value = ""; + imageRL.value = ""; + infoRL.value = ""; + mDexAuthorRL.value = ""; + mDexFeedRL.value = ""; + mDexImageRL.value = ""; GetSettings().then((json) => { //console.log(json); @@ -595,6 +568,15 @@ function OpenSettings(){ settingUserAgent.value = json.userAgent; //console.log(json.styleSheet); }); + GetRateLimits().then((json) => { + defaultRL.placeholder = json.Default + ' Requests/Minute'; + coverRL.placeholder = json.MangaCover + ' Requests/Minute'; + imageRL.placeholder = json.MangaImage + ' Requests/Minute'; + infoRL.placeholder = json.MangaInfo + ' Requests/Minute'; + mDexAuthorRL.placeholder = json.MangaDexAuthor + ' Requests/Minute'; + mDexFeedRL.placeholder = json.MangaDexFeed + ' Requests/Minute'; + mDexImageRL.placeholder = json.MangaDexImage + ' Requests/Minute'; + }); GetLibraryConnectors().then((json) => { //console.log(json); json.forEach(connector => { @@ -619,7 +601,6 @@ function OpenSettings(){ }); }); GetNotificationConnectors().then((json) => { - console.log(json); json.forEach(connector => { switch(notificationConnectorTypes[connector.notificationConnectorType]){ case "Gotify": @@ -719,32 +700,32 @@ function UpdateSettings(){ UpdateUserAgent(settingUserAgent.value); } - if (manganatoRateLimit.value.length > 0) { - UpdateRateLimit('Manganato', 1, manganatoRateLimit.value); + if (defaultRL.value != "") { + UpdateRateLimit(0, defaultRL.value); } - if (mangaseeRateLimit.value.length > 0) { - UpdateRateLimit('Mangasee', 1, mangaseeRateLimit.value); + if (coverRL.value != "") { + UpdateRateLimit(3, coverRL.value); } - if (mangadexRateLimit.value.length > 0) { - UpdateRateLimit('MangaDex', 250, mangadexRateLimit.value); + if (imageRL.value != "") { + UpdateRateLimit(2, imageRL.value); } - if (mangakatanaRateLimit.value.length > 0) { - UpdateRateLimit('MangaKatana', 1, mangakatanaRateLimit.value); + if (infoRL.value != "") { + UpdateRateLimit(6, infoRL.value); } - if (mangaworldRateLimit.value.length > 0) { - UpdateRateLimit('Mangaworld', 1, mangaworldRateLimit.value); + if (mDexAuthorRL.value != "") { + UpdateRateLimit(5, mDexAuthorRL.value); } - if (batoRateLimit.value.length > 0) { - UpdateRateLimit('Bato', 1, batoRateLimit.value); + if (mDexFeedRL.value != "") { + UpdateRateLimit(1, mDexFeedRL.value); } - if (mangalifeRateLimit.value.length > 0) { - UpdateRateLimit('Manga4Life', 1, mangalifeRateLimit.value); + if (mDexImageRL.value != "") { + UpdateRateLimit(5, mDexImageRL.value); } setTimeout(() => {