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