2
0

Compare commits

...

2 Commits

Author SHA1 Message Date
e2afc09c4a API: GetSettings 2023-05-21 16:46:34 +02:00
e9db7cfacc API: List Settings 2023-05-21 16:41:02 +02:00

View File

@ -135,7 +135,8 @@ app.MapGet("/TaskEnqueue", (TrangaTask.Task task, string? connectorName, string?
});
app.MapGet("/TaskDequeue", (TrangaTask.Task task, string? connectorName, string? publicationInternalId) =>
{TrangaTask[] allTasks = taskManager.GetAllTasks();
{
TrangaTask[] allTasks = taskManager.GetAllTasks();
TrangaTask? taskToDequeue = allTasks.FirstOrDefault(tTask =>
tTask.task == task && tTask.connectorName == connectorName &&
tTask.publication?.internalId == publicationInternalId);
@ -145,4 +146,36 @@ app.MapGet("/TaskDequeue", (TrangaTask.Task task, string? connectorName, string?
return JsonSerializer.Serialize("Success");
});
app.Run();
app.MapGet("/Settings", () =>
{
return JsonSerializer.Serialize(new Settings(taskManager.settings));
});
app.Run();
struct Settings
{
public Komga? komga { get; set; }
public string downloadLocation { get; set; }
public string settingsFilePath { get; set; }
public Settings(TaskManager.SettingsData data)
{
this.settingsFilePath = data.settingsFilePath;
this.downloadLocation = data.downloadLocation;
this.komga = data.komga;
}
public Settings(string downloadLocation, string settingsFilePath, Komga komga)
{
this.downloadLocation = downloadLocation;
this.settingsFilePath = settingsFilePath;
this.komga = komga;
}
public void Update(string? newDownloadLocation = null, string? newSettingsFilePath = null, Komga? newKomga= null)
{
this.downloadLocation = newDownloadLocation ?? this.downloadLocation;
this.settingsFilePath = newSettingsFilePath ?? this.settingsFilePath;
this.komga = newKomga ?? this.komga;
}
}