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);
|
||||
});
|
||||
|
||||
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;
|
||||
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);
|
||||
if (publication is null)
|
||||
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)));
|
||||
|
@ -66,8 +66,8 @@ async function GetPublication(internalId){
|
||||
return json;
|
||||
}
|
||||
|
||||
async function GetChapters(internalId, connectorName, language){
|
||||
var uri = apiUri + `/Publications/GetChapters?internalId=${internalId}&connectorName=${connectorName}&language=${language}`;
|
||||
async function GetChapters(internalId, connectorName, onlyNew, language){
|
||||
var uri = apiUri + `/Publications/GetChapters?internalId=${internalId}&connectorName=${connectorName}&onlyNew=${onlyNew}&language=${language}`;
|
||||
let json = await GetData(uri);
|
||||
return json;
|
||||
}
|
||||
|
@ -154,7 +154,7 @@ function OpenDownloadChapterTaskPopup(){
|
||||
selectedChapters.value = "";
|
||||
chapterOutput.replaceChildren();
|
||||
createDownloadChaptersTask.style.display = "block";
|
||||
GetChapters(toEditId, connectorSelect.value, "en").then((json) => {
|
||||
GetChapters(toEditId, connectorSelect.value, true, "en").then((json) => {
|
||||
var i = 0;
|
||||
json.forEach(chapter => {
|
||||
var chapterDom = document.createElement("div");
|
||||
|
Loading…
Reference in New Issue
Block a user