Finished Settings-Cart
This commit is contained in:
parent
7aeb78e2f6
commit
a0636ac7a2
@ -52,8 +52,8 @@ async function GetRunningTasks(){
|
||||
return json;
|
||||
}
|
||||
|
||||
async function GetTasks(){
|
||||
var uri = apiUri + "/Tasks/GetList";
|
||||
async function GetDownloadTasks(){
|
||||
var uri = apiUri + "/Tasks/Get?taskType=DownloadNewChapters";
|
||||
let json = await GetData(uri);
|
||||
return json;
|
||||
}
|
||||
@ -64,6 +64,12 @@ async function GetSettings(){
|
||||
return json;
|
||||
}
|
||||
|
||||
async function GetKomgaTask(){
|
||||
var uri = apiUri + "/Tasks/Get?taskType=UpdateKomgaLibrary";
|
||||
let json = await GetData(uri);
|
||||
return json;
|
||||
}
|
||||
|
||||
function CreateTask(taskType, reoccurrence, connectorName, publicationId, language){
|
||||
var uri = apiUri + `/Tasks/Create?taskType=${taskType}&connectorName=${connectorName}&publicationId=${publicationId}&reoccurrenceTime=${reoccurrence}&language=${language}`;
|
||||
PostData(uri);
|
||||
@ -80,7 +86,7 @@ function EnqueueTask(taskType, connectorName, publicationId){
|
||||
}
|
||||
|
||||
function UpdateSettings(downloadLocation, komgaUrl, komgaAuth){
|
||||
var uri = apiUri + `/Settings/Update?downloadLocation=${downloadLocation}&komgaUrl=${komgaAuth}&komgaAuth=${komgaAuth}`;
|
||||
var uri = apiUri + `/Settings/Update?downloadLocation=${downloadLocation}&komgaUrl=${komgaUrl}&komgaAuth=${komgaAuth}`;
|
||||
PostData(uri);
|
||||
}
|
||||
|
||||
|
@ -80,13 +80,16 @@
|
||||
</viewport>
|
||||
|
||||
<settingstab id="settingstab">
|
||||
<p>Download Location: <span id="downloadLocation"></span></p>
|
||||
<span class="title">Download Location:</span>
|
||||
<span id="downloadLocation"></span>
|
||||
<komga-settings>
|
||||
<span class="title">Komga</span>
|
||||
<div>Configured: <span id="komgaConfigured">✅❌</span></div>
|
||||
<label for="komgaUrl"></label><input placeholder="URL" id="komgaUrl" type="text">
|
||||
<label for="komgaUsername"></label><input placeholder="Username" id="komgaUsername" type="text">
|
||||
<label for="komgaPassword"></label><input placeholder="Password" id="komgaPassword" type="password">
|
||||
<label for="komgaUpdateTime">Update Time</label><input id="komgaUpdateTime" type="time" value="00:01">
|
||||
<input type="submit" value="Update" onclick="UpdateSettingsClick()">;
|
||||
<div><label for="komgaUpdateTime" style="margin-right: 5px;">Update Time</label><input id="komgaUpdateTime" type="time" value="00:01"></div>
|
||||
<input type="submit" value="Update" onclick="UpdateSettingsClick()">
|
||||
</komga-settings>
|
||||
</settingstab>
|
||||
|
||||
|
@ -40,13 +40,14 @@ const publicationDelete = document.querySelector("publication-delete");
|
||||
const publicationAdd = document.querySelector("publication-add");
|
||||
const closetaskpopup = document.querySelector("#closePopupImg");
|
||||
const settingDownloadLocation = document.querySelector("#downloadLocation");
|
||||
const settingKomgaUrl = document.querySelector("#komgaURL");
|
||||
const settingKomgaUrl = document.querySelector("#komgaUrl");
|
||||
const settingKomgaUser = document.querySelector("#komgaUsername");
|
||||
const settingKomgaPass = document.querySelector("#komgaPassword");
|
||||
const settingKomgaTime = document.querySelector("#komgaUpdateTime");
|
||||
const settingKomgaConfigured = document.querySelector("#komgaConfigured");
|
||||
|
||||
|
||||
settingsCog.addEventListener("click", () => slide());
|
||||
settingsCog.addEventListener("click", () => OpenSettings());
|
||||
closetaskpopup.addEventListener("click", () => HideAddTaskPopup());
|
||||
document.querySelector("#blurBackgroundTaskPopup").addEventListener("click", () => HideAddTaskPopup());
|
||||
document.querySelector("#blurBackgroundPublicationPopup").addEventListener("click", () => HidePublicationPopup());
|
||||
@ -203,20 +204,47 @@ const fadeInTiming = {
|
||||
fill: "forwards"
|
||||
}
|
||||
|
||||
function GetSettingsClick(){
|
||||
function OpenSettings(){
|
||||
GetSettingsClick();
|
||||
slide();
|
||||
}
|
||||
|
||||
function GetSettingsClick(){
|
||||
settingKomgaUrl.value = "";
|
||||
settingKomgaUser.value = "";
|
||||
settingKomgaPass.value = "";
|
||||
|
||||
GetSettings().then(json => {
|
||||
console.log(json);
|
||||
settingDownloadLocation.innerText = json.downloadLocation;
|
||||
if(json.komga != null)
|
||||
settingKomgaUrl.placeholder = json.komga.baseUrl;
|
||||
});
|
||||
|
||||
GetKomgaTask().then(json => {
|
||||
if(json.length > 0)
|
||||
settingKomgaConfigured.innerText = "✅";
|
||||
else
|
||||
settingKomgaConfigured.innerText = "❌";
|
||||
});
|
||||
}
|
||||
|
||||
function UpdateSettingsClick(){
|
||||
var auth = atob(`${settingKomgaUser.value}:${settingKomgaPass.value}`)
|
||||
UpdateSettings(settingDownloadLocation.value, settingKomgaUrl.value, auth);
|
||||
var auth = utf8_to_b64(`${settingKomgaUser.value}:${settingKomgaPass.value}`);
|
||||
console.log(auth);
|
||||
UpdateSettings("", settingKomgaUrl.value, auth);
|
||||
CreateTask("UpdateKomgaLibrary", settingKomgaTime.value, "","","");
|
||||
setTimeout(() => GetSettingsClick(), 500);
|
||||
}
|
||||
|
||||
function utf8_to_b64( str ) {
|
||||
return window.btoa(unescape(encodeURIComponent( str )));
|
||||
}
|
||||
|
||||
//Resets the tasks shown
|
||||
ResetContent();
|
||||
//Get Tasks and show them
|
||||
GetTasks()
|
||||
GetDownloadTasks()
|
||||
.then(json => json.forEach(task => {
|
||||
var publication = CreatePublication(task.publication, task.connectorName);
|
||||
publication.addEventListener("click", (event) => ShowPublicationViewerWindow(task.publication.internalId, event, false));
|
||||
@ -227,7 +255,7 @@ GetTasks()
|
||||
setInterval(() => {
|
||||
//Tasks from API
|
||||
var cTasks = [];
|
||||
GetTasks()
|
||||
GetDownloadTasks()
|
||||
.then(json => json.forEach(task => cTasks.push(task)))
|
||||
.then(() => {
|
||||
//Only update view if tasks-amount has changed
|
||||
|
@ -123,6 +123,36 @@ settingstab{
|
||||
height: calc(100% - var(--topbar-height) - 40px);
|
||||
margin-bottom: 10px;
|
||||
border-radius: 5px 0 0 5px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex-wrap: nowrap;
|
||||
}
|
||||
|
||||
settingstab > * {
|
||||
margin: 0 20px;
|
||||
}
|
||||
|
||||
settingstab .title {
|
||||
font-size: 14pt;
|
||||
font-weight: bolder;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
komga-settings {
|
||||
margin-top: 20px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex-wrap: nowrap;
|
||||
}
|
||||
|
||||
komga-settings > * {
|
||||
margin: 2px 0;
|
||||
}
|
||||
|
||||
komga-settings input {
|
||||
padding: 3px;
|
||||
border-radius: 3px;
|
||||
border: 0;
|
||||
}
|
||||
|
||||
#addPublication {
|
||||
|
Loading…
Reference in New Issue
Block a user