Website: On Download Chapters only show chapters that have not yet been downloaded
API: Added new variables to /Publications/GetChapters: onlyNew and onlyExisting. API will return only new, only existing or all chapters depending on variables. #19
This commit is contained in:
parent
b571bfa43d
commit
8b58e7dd13
@ -75,7 +75,7 @@ app.MapGet("/Publications/GetFromConnector", (string connectorName, string title
|
|||||||
return taskManager.GetPublicationsFromConnector(connector, title);
|
return taskManager.GetPublicationsFromConnector(connector, title);
|
||||||
});
|
});
|
||||||
|
|
||||||
app.MapGet("/Publications/GetChapters", (string connectorName, string internalId, string? language) =>
|
app.MapGet("/Publications/GetChapters", (string connectorName, string internalId, bool onlyNew, bool onlyExisting, string? language) =>
|
||||||
{
|
{
|
||||||
Connector? connector = taskManager.GetAvailableConnectors().FirstOrDefault(con => con.Key == connectorName).Value;
|
Connector? connector = taskManager.GetAvailableConnectors().FirstOrDefault(con => con.Key == connectorName).Value;
|
||||||
if (connector is null)
|
if (connector is null)
|
||||||
@ -83,7 +83,13 @@ app.MapGet("/Publications/GetChapters", (string connectorName, string internalId
|
|||||||
Publication? publication = taskManager.GetAllPublications().FirstOrDefault(pub => pub.internalId == internalId);
|
Publication? publication = taskManager.GetAllPublications().FirstOrDefault(pub => pub.internalId == internalId);
|
||||||
if (publication is null)
|
if (publication is null)
|
||||||
return Array.Empty<Chapter>();
|
return Array.Empty<Chapter>();
|
||||||
return connector.GetChapters((Publication)publication, language??"en");
|
|
||||||
|
if(onlyNew)
|
||||||
|
return taskManager.GetNewChaptersList(connector, (Publication)publication, language??"en").ToArray();
|
||||||
|
else if (onlyExisting)
|
||||||
|
return taskManager.GetExistingChaptersList(connector, (Publication)publication, language ?? "en").ToArray();
|
||||||
|
else
|
||||||
|
return connector.GetChapters((Publication)publication, language??"en");
|
||||||
});
|
});
|
||||||
|
|
||||||
app.MapGet("/Tasks/GetTypes", () => Enum.GetNames(typeof(TrangaTask.Task)));
|
app.MapGet("/Tasks/GetTypes", () => Enum.GetNames(typeof(TrangaTask.Task)));
|
||||||
|
@ -66,8 +66,8 @@ async function GetPublication(internalId){
|
|||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function GetChapters(internalId, connectorName, language){
|
async function GetChapters(internalId, connectorName, onlyNew, language){
|
||||||
var uri = apiUri + `/Publications/GetChapters?internalId=${internalId}&connectorName=${connectorName}&language=${language}`;
|
var uri = apiUri + `/Publications/GetChapters?internalId=${internalId}&connectorName=${connectorName}&onlyNew=${onlyNew}&language=${language}`;
|
||||||
let json = await GetData(uri);
|
let json = await GetData(uri);
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
@ -154,7 +154,7 @@ function OpenDownloadChapterTaskPopup(){
|
|||||||
selectedChapters.value = "";
|
selectedChapters.value = "";
|
||||||
chapterOutput.replaceChildren();
|
chapterOutput.replaceChildren();
|
||||||
createDownloadChaptersTask.style.display = "block";
|
createDownloadChaptersTask.style.display = "block";
|
||||||
GetChapters(toEditId, connectorSelect.value, "en").then((json) => {
|
GetChapters(toEditId, connectorSelect.value, true, "en").then((json) => {
|
||||||
var i = 0;
|
var i = 0;
|
||||||
json.forEach(chapter => {
|
json.forEach(chapter => {
|
||||||
var chapterDom = document.createElement("div");
|
var chapterDom = document.createElement("div");
|
||||||
|
Loading…
Reference in New Issue
Block a user