Updates to match API

This commit is contained in:
db-2001 2024-02-11 16:59:05 -05:00
parent 1ee17360e5
commit 4c418add81
4 changed files with 105 additions and 102 deletions

7
.gitignore vendored
View File

@ -18,4 +18,9 @@ riderModule.iml
/dataSources.local.xml
/.idea
cover.jpg
cover.png
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

View File

@ -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);
}

View File

@ -101,6 +101,13 @@
<border-bar-button class="section" onclick="DownloadLogs()">Download Logs</border-bar-button>
</row>
</div>
<div class="section-item dyn-height">
<span class="title">Rate Limits</span>
<row><label for="DefaultRL">Default:</label><input id="defaultRL" type="text" ></row>
<row><label for="CoverRL">Manga Covers:</label><input id="coverRL" type="text"></row>
<row><label for="ImageRL">Manga Images:</label><input id="imageRL" type="text"></row>
<row><label for="InfoRL">Manga Info:</label><input id="infoRL" type="text"></row>
</div>
<div class="section-item dyn-height">
<span class="title">Appearance</span>
<row><label for="cssStyle">Library Style:</label><select id="cssStyle">
@ -114,34 +121,36 @@
<div class="popup-section">
MANGA SOURCES
<div class="section-content">
<div class="section-item dyn-height">
<!-- <div class="section-item dyn-height">
<span class="title"><img src="connector-icons/manganato.png"><a href="https://manganato.com">MangaNato</a></span>
<row><label for="manganatoRL">Rate Limit: </label><input placeholder="60 Requests/Minute" id="manganatoRL" type="text"></row>
</div>
<div class="section-item dyn-height">
</div> -->
<!-- <div class="section-item dyn-height">
<span class="title"><img src="connector-icons/mangasee.png"><a href="https://mangasee123.com">MangaSee</a></span>
<row><label for="mangaseeRL">Rate Limit: </label><input placeholder="60 Requests/Minute" id="mangaseeRL" type="text"></row>
</div>
</div> -->
<div class="section-item dyn-height">
<span class="title"><img src="connector-icons/mangadex-logo.svg"><a href="https://mangadex.org">MangaDex</a></span>
<row><label for="mDexRL">Rate Limit: </label><input placeholder="60 Requests/Minute" id="mDexRL" type="text"></row>
<row><label for="mDexAuthorRL">Author Rate Limit:</label><input id="mDexAuthorRL" type="text"></row>
<row><label for="mDexFeedRL">Feed Rate Limit:</label><input id="mDexFeedRL" type="text"></row>
<row><label for="mDexImageRL">Image Rate Limit:</label><input id="mDexImageRL" type="text"></row>
</div>
<div class="section-item dyn-height">
<!-- <div class="section-item dyn-height">
<span class="title"><img src="connector-icons/mangakatana.png"><a href="https://mangakatana.com">MangaKatana</a></span>
<row><label for="mKatanaRL">Rate Limit: </label><input placeholder="60 Requests/Minute" id="mKatanaRL" type="text"></row>
</div>
<div class="section-item dyn-height">
</div> -->
<!-- <div class="section-item dyn-height">
<span class="title"><img src="connector-icons/mangaworld.png"><a href="https://www.mangaworld.ac">MangaWorld</a></span>
<row><label for="mWorldRL">Rate Limit: </label><input placeholder="60 Requests/Minute" id="mWorldRL" type="text"></row>
</div>
<div class="section-item dyn-height">
</div> -->
<!-- <div class="section-item dyn-height">
<span class="title"><img src="connector-icons/bato.ico"><a href="https://bato.to">Bato</a></span>
<row><label for="batoRL">Rate Limit: </label><input placeholder="60 Requests/Minute" id="batoRL" type="text"></row>
</div>
<div class="section-item dyn-height">
</div> -->
<!-- <div class="section-item dyn-height">
<span class="title"><img src="connector-icons/mangalife.png"><a href="https://www.manga4life.com">MangaLife</a></span>
<row><label for="mLifeRL">Rate Limit: </label><input placeholder="60 Requests/Minute" id="mLifeRL" type="text"></row>
</div>
</div> -->
</div>
</div>

View File

@ -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(() => {