All API-calls #1
This commit is contained in:
parent
290819de09
commit
da4a5bed09
@ -1,35 +1,95 @@
|
|||||||
const apiUri = "http://localhost:5177";
|
const apiUri = "http://localhost:5177";
|
||||||
|
|
||||||
function GetAvailableControllers(){
|
async function GetData(uri){
|
||||||
var uri = apiUri + "/GetAvailableControllers";
|
let request = await fetch(uri, {
|
||||||
const response = await fetch(uri, {
|
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers: {
|
headers: {
|
||||||
'Accept': 'application/json'
|
'Accept': 'application/json'
|
||||||
}
|
}
|
||||||
}).catch(error => console.error('Unable to get items.', error));
|
});
|
||||||
return await response.json();
|
let json = await request.json();
|
||||||
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function PostData(uri){
|
||||||
|
fetch(uri, {
|
||||||
|
method: 'POST'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function GetTasks(){
|
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(){
|
||||||
|
var uri = apiUri + "/Tranga/Tasks/GetTaskTypes";
|
||||||
|
let json = await GetData(uri);
|
||||||
|
return json;
|
||||||
|
}
|
||||||
|
async function GetRunningTasks(){
|
||||||
|
var uri = apiUri + "/Tranga/GetRunningTasks";
|
||||||
|
let json = await GetData(uri);
|
||||||
|
return json;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function GetTasks(){
|
||||||
var uri = apiUri + "/Tasks/GetList";
|
var uri = apiUri + "/Tasks/GetList";
|
||||||
const response = await fetch(uri, {
|
let json = await GetData(uri);
|
||||||
method: 'GET',
|
return json;
|
||||||
headers: {
|
|
||||||
'Accept': 'application/json'
|
|
||||||
}
|
|
||||||
}).catch(error => console.error('Unable to get items.', error));
|
|
||||||
return await response.json();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function GetSettings(){
|
async function GetSettings(){
|
||||||
var uri = apiUri + "/Settings/Get";
|
var uri = apiUri + "/Settings/Get";
|
||||||
const response = await fetch(uri, {
|
let json = await GetData(uri);
|
||||||
method: 'GET',
|
return json;
|
||||||
headers: {
|
}
|
||||||
'Accept': 'application/json'
|
|
||||||
}
|
function CreateTask(taskType, reoccurrence, connectorName, publicationId, language){
|
||||||
}).catch(error => console.error('Unable to get items.', error));
|
var uri = apiUri + `/Tasks/Create?taskType=${taskType}&connectorName=${connectorName}&publicationId=${publicationId}&reoccurenceTime=${reoccurrence}&language=${language}`;
|
||||||
return await response.json();
|
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){
|
||||||
|
var uri = apiUri + `/Settings/Update?downloadLocation=${downloadLocation}&komgaUrl=${komgaAuth}&komgaAuth=${komgaAuth}`;
|
||||||
|
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);
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user