Add resumable downloads, download paths, queue controls and history

This commit is contained in:
SirBlob committed 2026-11-01 13:36:29 -05:00
1 parent 434f6441da
commit 6027cfabb9
43 files changed
+2138 -291

No files matched your search

+14
View File
@@ -1,5 +1,6 @@
import { api } from "./api.js";
import { element } from "./dom.js";
import { notificationsEnabled, setNotificationsEnabled } from "./notify.js";
const themeStorageKey = "ddc-theme";
@@ -10,10 +11,13 @@ const fields = {
cancelButton: document.getElementById("settings-cancel"),
error: document.getElementById("settings-error"),
concurrent: document.getElementById("setting-concurrent"),
connections: document.getElementById("setting-connections"),
notifications: document.getElementById("setting-notifications"),
minFree: document.getElementById("setting-min-free"),
ports: document.getElementById("setting-ports"),
autoExtract: document.getElementById("setting-auto-extract"),
cleanup: document.getElementById("setting-cleanup"),
downloadPaths: document.getElementById("setting-download-paths"),
theme: document.getElementById("setting-theme"),
downloadDir: document.getElementById("info-download-dir"),
roots: document.getElementById("info-roots"),
@@ -42,10 +46,13 @@ export async function openSettings() {
function fillForm(data) {
const settings = data.settings;
fields.concurrent.value = settings.maxConcurrentDownloads;
fields.connections.value = settings.connectionsPerDownload;
fields.notifications.checked = notificationsEnabled();
fields.minFree.value = settings.minFreeGB;
fields.ports.value = settings.allowedPorts.length > 0 ? settings.allowedPorts.join(", ") : "*";
fields.autoExtract.checked = settings.autoExtract;
fields.cleanup.checked = settings.cleanupAfterMove;
fields.downloadPaths.value = (settings.downloadPaths || []).join("\n");
fields.theme.value = readTheme();
fields.downloadDir.textContent = data.downloadDir;
fields.roots.replaceChildren(...data.libraryRoots.map((root) => element("div", "mono", root)));
@@ -57,11 +64,14 @@ async function saveSettings(event, onSaved) {
try {
const payload = {
maxConcurrentDownloads: Number(fields.concurrent.value),
connectionsPerDownload: Number(fields.connections.value),
minFreeGB: Number(fields.minFree.value),
allowedPorts: parsePorts(fields.ports.value),
autoExtract: fields.autoExtract.checked,
cleanupAfterMove: fields.cleanup.checked,
downloadPaths: parseDownloadPaths(fields.downloadPaths.value),
};
await setNotificationsEnabled(fields.notifications.checked);
const data = await api.saveSettings(payload);
storeTheme(fields.theme.value);
fields.dialog.close();
@@ -80,6 +90,10 @@ function parsePorts(text) {
return ports;
}
function parseDownloadPaths(text) {
return text.split("\n").map((line) => line.trim()).filter(Boolean);
}
function readTheme() {
try {
return localStorage.getItem(themeStorageKey) || "system";