2023-05-25 10:42:19 +02:00
|
|
|
|
let apiUri = `http://${window.location.host.split(':')[0]}:6531`
|
|
|
|
|
|
|
|
|
|
if(getCookie("apiUri") != ""){
|
|
|
|
|
apiUri = getCookie("apiUri");
|
|
|
|
|
}
|
|
|
|
|
function getCookie(cname) {
|
|
|
|
|
let name = cname + "=";
|
|
|
|
|
let decodedCookie = decodeURIComponent(document.cookie);
|
|
|
|
|
let ca = decodedCookie.split(';');
|
|
|
|
|
for(let i = 0; i < ca.length; i++) {
|
|
|
|
|
let c = ca[i];
|
|
|
|
|
while (c.charAt(0) == ' ') {
|
|
|
|
|
c = c.substring(1);
|
|
|
|
|
}
|
|
|
|
|
if (c.indexOf(name) == 0) {
|
|
|
|
|
return c.substring(name.length, c.length);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return "";
|
|
|
|
|
}
|
2023-05-23 12:51:21 +02:00
|
|
|
|
|
2023-05-23 13:52:35 +02:00
|
|
|
|
async function GetData(uri){
|
|
|
|
|
let request = await fetch(uri, {
|
2023-05-23 13:15:29 +02:00
|
|
|
|
method: 'GET',
|
|
|
|
|
headers: {
|
|
|
|
|
'Accept': 'application/json'
|
|
|
|
|
}
|
2023-05-23 13:52:35 +02:00
|
|
|
|
});
|
|
|
|
|
let json = await request.json();
|
|
|
|
|
return json;
|
2023-05-23 13:15:29 +02:00
|
|
|
|
}
|
|
|
|
|
|
2023-05-23 13:52:35 +02:00
|
|
|
|
function PostData(uri){
|
|
|
|
|
fetch(uri, {
|
|
|
|
|
method: 'POST'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function DeleteData(uri){
|
|
|
|
|
fetch(uri, {
|
|
|
|
|
method: 'DELETE'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function GetAvailableControllers(){
|
|
|
|
|
var uri = apiUri + "/Tranga/GetAvailableControllers";
|
|
|
|
|
let json = await GetData(uri);
|
|
|
|
|
return json;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function GetPublication(connectorName, title){
|
|
|
|
|
var uri = apiUri + `/Tranga/GetPublicationsFromConnector?connectorName=${connectorName}&title=${title}`;
|
|
|
|
|
let json = await GetData(uri);
|
|
|
|
|
return json;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function GetKnownPublications(){
|
|
|
|
|
var uri = apiUri + "/Tranga/GetKnownPublications";
|
|
|
|
|
let json = await GetData(uri);
|
|
|
|
|
return json;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function GetTaskTypes(){
|
2023-05-23 14:44:45 +02:00
|
|
|
|
var uri = apiUri + "/Tasks/GetTaskTypes";
|
2023-05-23 13:52:35 +02:00
|
|
|
|
let json = await GetData(uri);
|
|
|
|
|
return json;
|
|
|
|
|
}
|
|
|
|
|
async function GetRunningTasks(){
|
|
|
|
|
var uri = apiUri + "/Tranga/GetRunningTasks";
|
|
|
|
|
let json = await GetData(uri);
|
|
|
|
|
return json;
|
|
|
|
|
}
|
2023-05-23 13:15:29 +02:00
|
|
|
|
|
2023-05-24 21:48:54 +02:00
|
|
|
|
async function GetDownloadTasks(){
|
|
|
|
|
var uri = apiUri + "/Tasks/Get?taskType=DownloadNewChapters";
|
2023-05-23 13:52:35 +02:00
|
|
|
|
let json = await GetData(uri);
|
|
|
|
|
return json;
|
2023-05-23 13:15:29 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function GetSettings(){
|
|
|
|
|
var uri = apiUri + "/Settings/Get";
|
2023-05-23 13:52:35 +02:00
|
|
|
|
let json = await GetData(uri);
|
|
|
|
|
return json;
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-24 21:48:54 +02:00
|
|
|
|
async function GetKomgaTask(){
|
|
|
|
|
var uri = apiUri + "/Tasks/Get?taskType=UpdateKomgaLibrary";
|
|
|
|
|
let json = await GetData(uri);
|
|
|
|
|
return json;
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-23 13:52:35 +02:00
|
|
|
|
function CreateTask(taskType, reoccurrence, connectorName, publicationId, language){
|
2023-05-23 15:17:47 +02:00
|
|
|
|
var uri = apiUri + `/Tasks/Create?taskType=${taskType}&connectorName=${connectorName}&publicationId=${publicationId}&reoccurrenceTime=${reoccurrence}&language=${language}`;
|
2023-05-23 13:52:35 +02:00
|
|
|
|
PostData(uri);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function StartTask(taskType, connectorName, publicationId){
|
|
|
|
|
var uri = apiUri + `/Tasks/Start?taskType=${taskType}&connectorName=${connectorName}&publicationId=${publicationId}`;
|
|
|
|
|
PostData(uri);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function EnqueueTask(taskType, connectorName, publicationId){
|
|
|
|
|
var uri = apiUri + `/Queue/Enqueue?taskType=${taskType}&connectorName=${connectorName}&publicationId=${publicationId}`;
|
|
|
|
|
PostData(uri);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function UpdateSettings(downloadLocation, komgaUrl, komgaAuth){
|
2023-05-24 21:48:54 +02:00
|
|
|
|
var uri = apiUri + `/Settings/Update?downloadLocation=${downloadLocation}&komgaUrl=${komgaUrl}&komgaAuth=${komgaAuth}`;
|
2023-05-23 13:52:35 +02:00
|
|
|
|
PostData(uri);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function DeleteTask(taskType, connectorName, publicationId){
|
|
|
|
|
var uri = apiUri + `/Tasks/Delete?taskType=${taskType}&connectorName=${connectorName}&publicationId=${publicationId}`;
|
|
|
|
|
DeleteData(uri);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function DequeueTask(taskType, connectorName, publicationId){
|
|
|
|
|
var uri = apiUri + `/Queue/Dequeue?taskType=${taskType}&connectorName=${connectorName}&publicationId=${publicationId}`;
|
|
|
|
|
DeleteData(uri);
|
2023-05-23 12:51:21 +02:00
|
|
|
|
}
|