From 761241191794ba8e7f30b9fb495019af9c1c0bee Mon Sep 17 00:00:00 2001 From: glax Date: Sat, 3 Jun 2023 16:25:04 +0200 Subject: [PATCH] #33 Update Website --- Website/apiConnector.js | 2 +- Website/index.html | 12 ++++++++++-- Website/interaction.js | 43 +++++++++++++++++++++++++++-------------- Website/style.css | 2 +- 4 files changed, 41 insertions(+), 18 deletions(-) diff --git a/Website/apiConnector.js b/Website/apiConnector.js index 816f19f..f7640a6 100644 --- a/Website/apiConnector.js +++ b/Website/apiConnector.js @@ -84,7 +84,7 @@ async function GetSettings(){ } async function GetKomgaTask(){ - var uri = apiUri + "/Tasks/Get?taskType=UpdateKomgaLibrary"; + var uri = apiUri + "/Tasks/Get?taskType=UpdateLibraries"; let json = await GetData(uri); return json; } diff --git a/Website/index.html b/Website/index.html index 9cec0d0..95eb751 100644 --- a/Website/index.html +++ b/Website/index.html @@ -94,9 +94,17 @@ - - + + Kavita +
Configured: ✅❌
+ + +
+
+ + +
diff --git a/Website/interaction.js b/Website/interaction.js index 9e3648d..8662f01 100644 --- a/Website/interaction.js +++ b/Website/interaction.js @@ -26,8 +26,11 @@ const settingDownloadLocation = document.querySelector("#downloadLocation"); const settingKomgaUrl = document.querySelector("#komgaUrl"); const settingKomgaUser = document.querySelector("#komgaUsername"); const settingKomgaPass = document.querySelector("#komgaPassword"); -const settingKomgaTime = document.querySelector("#komgaUpdateTime"); +const settingKavitaUrl = document.querySelector("#kavitaUrl"); +const settingKavitaApi = document.querySelector("#kavitaApiKey"); +const libraryUpdateTime = document.querySelector("#libraryUpdateTime"); const settingKomgaConfigured = document.querySelector("#komgaConfigured"); +const settingKavitaConfigured = document.querySelector("#kavitaConfigured"); const settingApiUri = document.querySelector("#settingApiUri"); const tagTasksRunning = document.querySelector("#tasksRunningTag"); const tagTasksQueued = document.querySelector("#tasksQueuedTag"); @@ -239,38 +242,50 @@ function GetSettingsClick(){ settingKomgaUrl.value = ""; settingKomgaUser.value = ""; settingKomgaPass.value = ""; + settingKavitaUrl.value = ""; + settingKavitaApi.value = ""; + settingKomgaConfigured.innerText = "❌"; + settingKavitaConfigured.innerText = "❌"; settingApiUri.placeholder = apiUri; GetSettings().then(json => { settingDownloadLocation.innerText = json.downloadLocation; - if(json.komga != null) { - settingKomgaUrl.placeholder = json.komga.baseUrl; - settingKomgaUser.placeholder = "Configured"; - settingKomgaPass.placeholder = "***"; - } + json.libraryManagers.forEach(lm => { + if(lm.libraryType == 0){ + settingKomgaUrl.placeholder = lm.baseUrl; + settingKomgaUser.placeholder = "Configured"; + settingKomgaPass.placeholder = "***"; + settingKomgaConfigured.innerText = "✅"; + } else if(libraryType == 1){ + settingKavitaUrl.placeholder = lm.baseUrl; + settingKavitaApi.placeholder = "***"; + settingKavitaConfigured.innerText = "✅"; + } + }); }); GetKomgaTask().then(json => { - settingKomgaTime.value = json[0].reoccurrence; if(json.length > 0) - settingKomgaConfigured.innerText = "✅"; - else - settingKomgaConfigured.innerText = "❌"; + libraryUpdateTime.value = json[0].reoccurrence; }); } -function UpdateKomgaSettings(){ +function UpdateLibrarySettings(){ if(settingKomgaUser.value != "" && settingKomgaPass != ""){ var auth = utf8_to_b64(`${settingKomgaUser.value}:${settingKomgaPass.value}`); console.log(auth); if(settingKomgaUrl.value != "") - UpdateSettings("", settingKomgaUrl.value, auth); + UpdateSettings("", settingKomgaUrl.value, auth, "", ""); else - UpdateSettings("", settingKomgaUrl.placeholder, auth); + UpdateSettings("", settingKomgaUrl.placeholder, auth, "", ""); } - CreateTask("UpdateKomgaLibrary", settingKomgaTime.value, "","",""); + + if(settingKavitaUrl.value != "" && settingKavitaApi != ""){ + UpdateSettings("", "", "", settingKavitaUrl.value, settingKavitaApi.value); + } + CreateTask("UpdateLibraries", libraryUpdateTime.value, "","",""); setTimeout(() => GetSettingsClick(), 100); } diff --git a/Website/style.css b/Website/style.css index 4a4c25d..43d6792 100644 --- a/Website/style.css +++ b/Website/style.css @@ -155,7 +155,7 @@ settings { z-index: 10; position: absolute; left: 25%; - top: 25%; + top: 100px; border-radius: 5px; padding: 10px 0; }