2
0

Website: Added connector NotificationManager LunaSea

Added Update Method for TrangaSettings for LunaSea
#21
This commit is contained in:
glax 2023-06-15 18:57:21 +02:00
parent c6c8f5cdf6
commit 02a382a99a
5 changed files with 32 additions and 3 deletions

View File

@ -244,7 +244,7 @@ app.MapGet("/Settings/Get", () => taskManager.settings);
app.MapPost("/Settings/Update", app.MapPost("/Settings/Update",
(string? downloadLocation, string? komgaUrl, string? komgaAuth, string? kavitaUrl, string? kavitaUsername, (string? downloadLocation, string? komgaUrl, string? komgaAuth, string? kavitaUrl, string? kavitaUsername,
string? kavitaPassword, string? gotifyUrl, string? gotifyAppToken) => string? kavitaPassword, string? gotifyUrl, string? gotifyAppToken, string? lunaseaWebhook) =>
{ {
if (downloadLocation is not null && downloadLocation.Length > 0) if (downloadLocation is not null && downloadLocation.Length > 0)
taskManager.settings.UpdateSettings(TrangaSettings.UpdateField.DownloadLocation, logger, downloadLocation); taskManager.settings.UpdateSettings(TrangaSettings.UpdateField.DownloadLocation, logger, downloadLocation);
@ -256,6 +256,8 @@ app.MapPost("/Settings/Update",
kavitaPassword); kavitaPassword);
if (gotifyUrl is not null && gotifyAppToken is not null && gotifyUrl.Length > 5 && gotifyAppToken.Length > 0) if (gotifyUrl is not null && gotifyAppToken is not null && gotifyUrl.Length > 5 && gotifyAppToken.Length > 0)
taskManager.settings.UpdateSettings(TrangaSettings.UpdateField.Gotify, logger, gotifyUrl, gotifyAppToken); taskManager.settings.UpdateSettings(TrangaSettings.UpdateField.Gotify, logger, gotifyUrl, gotifyAppToken);
if(lunaseaWebhook is not null && lunaseaWebhook.Length > 5)
taskManager.settings.UpdateSettings(TrangaSettings.UpdateField.LunaSea, logger, lunaseaWebhook);
}); });
app.Run(); app.Run();

View File

@ -70,8 +70,14 @@ public class TrangaSettings
notificationManagers.RemoveWhere(nm => nm.GetType() == typeof(Gotify)); notificationManagers.RemoveWhere(nm => nm.GetType() == typeof(Gotify));
notificationManagers.Add(new Gotify(values[0], values[1], logger)); notificationManagers.Add(new Gotify(values[0], values[1], logger));
break; break;
case UpdateField.LunaSea:
if(values.Length != 1)
return;
notificationManagers.RemoveWhere(nm => nm.GetType() == typeof(LunaSea));
notificationManagers.Add(new LunaSea(values[0], logger));
break;
} }
} }
public enum UpdateField { DownloadLocation, Komga, Kavita, Gotify} public enum UpdateField { DownloadLocation, Komga, Kavita, Gotify, LunaSea}
} }

View File

@ -150,6 +150,12 @@ function UpdateGotify(gotifyUrl, gotifyAppToken){
PostData(uri); PostData(uri);
} }
function UpdateLunaSea(lunaseaWebhook){
var uri = apiUri + "/Settings/Update?"
uri += `&lunaseaWebhook=${lunaseaWebhook}`;
PostData(uri);
}
function DeleteTask(taskType, connectorName, publicationId){ function DeleteTask(taskType, connectorName, publicationId){
var uri = apiUri + `/Tasks/Delete?taskType=${taskType}&connectorName=${connectorName}&publicationId=${publicationId}`; var uri = apiUri + `/Tasks/Delete?taskType=${taskType}&connectorName=${connectorName}&publicationId=${publicationId}`;
DeleteData(uri); DeleteData(uri);

View File

@ -139,6 +139,11 @@
<label for="gotifyUrl"></label><input placeholder="URL" id="gotifyUrl" type="text"> <label for="gotifyUrl"></label><input placeholder="URL" id="gotifyUrl" type="text">
<label for="gotifyAppToken"></label><input placeholder="App-Token" id="gotifyAppToken" type="text"> <label for="gotifyAppToken"></label><input placeholder="App-Token" id="gotifyAppToken" type="text">
</div> </div>
<div>
<span class="title">LunaSea</span>
<div>Configured: <span id="lunaseaConfigured">✅❌</span></div>
<label for="lunaseaWebhook"></label><input placeholder="Webhook-Url" id="lunaseaWebhook" type="text">
</div>
<div> <div>
<label for="libraryUpdateTime" style="margin-right: 5px;">Update Time</label><input id="libraryUpdateTime" type="time" value="00:01:00" step="10"> <label for="libraryUpdateTime" style="margin-right: 5px;">Update Time</label><input id="libraryUpdateTime" type="time" value="00:01:00" step="10">
<input type="submit" value="Update" onclick="UpdateLibrarySettings()"> <input type="submit" value="Update" onclick="UpdateLibrarySettings()">

View File

@ -35,10 +35,12 @@ const settingKavitaUser = document.querySelector("#kavitaUsername");
const settingKavitaPass = document.querySelector("#kavitaPassword"); const settingKavitaPass = document.querySelector("#kavitaPassword");
const settingGotifyUrl = document.querySelector("#gotifyUrl"); const settingGotifyUrl = document.querySelector("#gotifyUrl");
const settingGotifyAppToken = document.querySelector("#gotifyAppToken"); const settingGotifyAppToken = document.querySelector("#gotifyAppToken");
const settingLunaseaWebhook = document.querySelector("#lunaseaWebhook");
const libraryUpdateTime = document.querySelector("#libraryUpdateTime"); const libraryUpdateTime = document.querySelector("#libraryUpdateTime");
const settingKomgaConfigured = document.querySelector("#komgaConfigured"); const settingKomgaConfigured = document.querySelector("#komgaConfigured");
const settingKavitaConfigured = document.querySelector("#kavitaConfigured"); const settingKavitaConfigured = document.querySelector("#kavitaConfigured");
const settingGotifyConfigured = document.querySelector("#gotifyConfigured"); const settingGotifyConfigured = document.querySelector("#gotifyConfigured");
const settingLunaseaConfigured = document.querySelector("#lunaseaConfigured");
const settingApiUri = document.querySelector("#settingApiUri"); const settingApiUri = document.querySelector("#settingApiUri");
const tagTasksRunning = document.querySelector("#tasksRunningTag"); const tagTasksRunning = document.querySelector("#tasksRunningTag");
const tagTasksQueued = document.querySelector("#tasksQueuedTag"); const tagTasksQueued = document.querySelector("#tasksQueuedTag");
@ -295,6 +297,8 @@ function GetSettingsClick(){
settingGotifyUrl.value = ""; settingGotifyUrl.value = "";
settingGotifyAppToken.value = ""; settingGotifyAppToken.value = "";
settingGotifyConfigured.innerText = "❌"; settingGotifyConfigured.innerText = "❌";
settingLunaseaWebhook.value = "";
settingLunaseaConfigured.innerText = "❌";
settingApiUri.placeholder = apiUri; settingApiUri.placeholder = apiUri;
@ -317,7 +321,9 @@ function GetSettingsClick(){
json.notificationManagers.forEach(nm => { json.notificationManagers.forEach(nm => {
if(nm.notificationManagerType == 0){ if(nm.notificationManagerType == 0){
settingGotifyConfigured.innerText = "✅"; settingGotifyConfigured.innerText = "✅";
} } else if(nm.notificationManagerType == 1){
settingLunaseaConfigured.innerText = "✅";
}
}); });
}); });
@ -342,6 +348,10 @@ function UpdateLibrarySettings(){
UpdateGotify(settingGotifyUrl.value, settingGotifyAppToken.value); UpdateGotify(settingGotifyUrl.value, settingGotifyAppToken.value);
} }
if(settingLunaseaWebhook.value != ""){
UpdateLunaSea(settingLunaseaWebhook.value);
}
CreateUpdateLibraryTask(libraryUpdateTime.value); CreateUpdateLibraryTask(libraryUpdateTime.value);
setTimeout(() => GetSettingsClick(), 200); setTimeout(() => GetSettingsClick(), 200);
} }