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(){
|
2023-06-20 23:15:56 +02:00
|
|
|
|
var uri = apiUri + "/Connectors";
|
2023-05-23 13:52:35 +02:00
|
|
|
|
let json = await GetData(uri);
|
|
|
|
|
return json;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-31 12:56:09 +02:00
|
|
|
|
async function GetPublicationFromConnector(connector, title){
|
|
|
|
|
var uri = `${apiUri}/Manga/FromConnector?connector=${connector}&title=${title}`;
|
2023-05-23 13:52:35 +02:00
|
|
|
|
let json = await GetData(uri);
|
|
|
|
|
return json;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-31 12:56:09 +02:00
|
|
|
|
async function GetChapters(connector, internalId){
|
|
|
|
|
var uri = `${apiUri}/Manga/Chapters?connector=${connector}&internalId=${internalId}`;
|
2023-06-08 19:24:46 +02:00
|
|
|
|
let json = await GetData(uri);
|
|
|
|
|
return json;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-31 12:56:09 +02:00
|
|
|
|
async function GetAllJobs(){
|
|
|
|
|
var uri = `${apiUri}/Jobs`;
|
|
|
|
|
let json = await GetData(uri);
|
|
|
|
|
return json;
|
2023-06-08 19:24:46 +02:00
|
|
|
|
}
|
|
|
|
|
|
2023-08-31 12:56:09 +02:00
|
|
|
|
async function GetRunningJobs(){
|
|
|
|
|
var uri = `${apiUri}/Jobs/Running`;
|
2023-05-23 13:52:35 +02:00
|
|
|
|
let json = await GetData(uri);
|
|
|
|
|
return json;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-31 12:56:09 +02:00
|
|
|
|
async function GetWaitingJobs(){
|
|
|
|
|
var uri = `${apiUri}/Jobs/Waiting`;
|
2023-05-23 13:52:35 +02:00
|
|
|
|
let json = await GetData(uri);
|
|
|
|
|
return json;
|
|
|
|
|
}
|
2023-05-23 13:15:29 +02:00
|
|
|
|
|
2023-08-31 12:56:09 +02:00
|
|
|
|
async function GetProgress(jobId){
|
|
|
|
|
var uri = `${apiUri}/Jobs/Progress?jobId=${jobId}`;
|
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(){
|
2023-08-31 12:56:09 +02:00
|
|
|
|
var uri = `${apiUri}/Settings`;
|
2023-05-23 13:52:35 +02:00
|
|
|
|
let json = await GetData(uri);
|
|
|
|
|
return json;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-31 12:56:09 +02:00
|
|
|
|
async function GetAvailableNotificationConnectors(){
|
|
|
|
|
var uri = `${apiUri}/NotificationConnectors/Types`;
|
|
|
|
|
let json = await GetData(uri);
|
|
|
|
|
return json;
|
2023-05-24 21:48:54 +02:00
|
|
|
|
}
|
|
|
|
|
|
2023-08-31 12:56:09 +02:00
|
|
|
|
async function GetNotificationConnectors(){
|
|
|
|
|
var uri = `${apiUri}/NotificationConnectors`;
|
|
|
|
|
let json = await GetData(uri);
|
|
|
|
|
return json;
|
2023-06-08 19:24:46 +02:00
|
|
|
|
}
|
|
|
|
|
|
2023-08-31 12:56:09 +02:00
|
|
|
|
async function GetAvailableLibraryConnectors(){
|
|
|
|
|
var uri = `${apiUri}/LibraryConnectors/Types`;
|
|
|
|
|
let json = await GetData(uri);
|
|
|
|
|
return json;
|
2023-05-23 13:52:35 +02:00
|
|
|
|
}
|
|
|
|
|
|
2023-08-31 12:56:09 +02:00
|
|
|
|
async function GetLibraryConnectors(){
|
|
|
|
|
var uri = `${apiUri}/LibraryConnectors`;
|
|
|
|
|
let json = await GetData(uri);
|
|
|
|
|
return json;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function CreateMonitorJob(connector, internalId, interval){
|
|
|
|
|
var uri = `${apiUri}/Jobs/MonitorManga?connector=${connector}&internalId=${internalId}&interval=${interval}`;
|
2023-05-23 13:52:35 +02:00
|
|
|
|
PostData(uri);
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-31 12:56:09 +02:00
|
|
|
|
function CreateDownloadNewChaptersJob(connector, internalId){
|
|
|
|
|
var uri = `${apiUri}/Jobs/DownloadNewChapters?connector=${connector}&internalId=${internalId}`;
|
2023-05-23 13:52:35 +02:00
|
|
|
|
PostData(uri);
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-15 18:38:47 +02:00
|
|
|
|
function UpdateDownloadLocation(downloadLocation){
|
2023-08-31 12:56:09 +02:00
|
|
|
|
var uri = `${apiUri}/Settings/UpdateDownloadLocation?downloadLocation=${downloadLocation}`;
|
|
|
|
|
PostData(uri);
|
2023-06-15 18:38:47 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function UpdateKomga(komgaUrl, komgaAuth){
|
2023-08-31 12:56:09 +02:00
|
|
|
|
var uri = `/LibraryManagers/Update?libraryManager=Komga&komgaUrl=${komgaUrl}&komgaAuth=${komgaAuth}`;
|
2023-06-15 18:38:47 +02:00
|
|
|
|
PostData(uri);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function UpdateKavita(kavitaUrl, kavitaUser, kavitaPass){
|
2023-08-31 12:56:09 +02:00
|
|
|
|
var uri = `/LibraryManagers/Update?libraryManager=Kavita&kavitaUrl=${kavitaUrl}&kavitaUser=${kavitaUser}&kavitaPass={kavitaPass}`;
|
2023-06-15 18:38:47 +02:00
|
|
|
|
PostData(uri);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function UpdateGotify(gotifyUrl, gotifyAppToken){
|
2023-08-31 12:56:09 +02:00
|
|
|
|
var uri = `${apiUri}/NotificationConnectors/Update?notificationConnector=Gotify&gotifyUrl=${gotifyUrl}&gotifyAppToken=${gotifyAppToken}`;
|
2023-05-23 13:52:35 +02:00
|
|
|
|
PostData(uri);
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-15 18:57:21 +02:00
|
|
|
|
function UpdateLunaSea(lunaseaWebhook){
|
2023-08-31 12:56:09 +02:00
|
|
|
|
var uri = `${apiUri}/NotificationConnectors/Update?notificationConnector=LunaSea&lunaseaWebhook=${lunaseaWebhook}`;
|
2023-06-15 18:57:21 +02:00
|
|
|
|
PostData(uri);
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-31 12:56:09 +02:00
|
|
|
|
function RemoveJob(jobId){
|
|
|
|
|
var uri = `${apiUri}/Jobs?jobId=${jobId}`;
|
2023-05-23 13:52:35 +02:00
|
|
|
|
DeleteData(uri);
|
2023-05-23 12:51:21 +02:00
|
|
|
|
}
|