chore: prep 0.1.2 release, tidy repo
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
// UI controller for unattended-upgrades settings.
|
||||
// Fetches current config, mirrors it into the form, and saves changes.
|
||||
import { getUpdateConfig, saveUpdateConfig } from "./api.js";
|
||||
import { logUi } from "./diaglog.js";
|
||||
|
||||
const TIME_RE = /^(\d{1,2}):(\d{2})$/;
|
||||
const MAX_BANDWIDTH_KBPS = 1_000_000; // 1 GB/s cap to prevent typos
|
||||
@@ -115,15 +116,14 @@ export function initUpdateSettings({
|
||||
|
||||
function showMessage(text, isError = false) {
|
||||
if (!msgEl) return;
|
||||
// Only surface inline text for errors; successes go to toast only.
|
||||
if (isError) {
|
||||
msgEl.textContent = text || "Something went wrong";
|
||||
msgEl.classList.add("error");
|
||||
toast?.(text || "Error", "error");
|
||||
} else {
|
||||
msgEl.textContent = "";
|
||||
msgEl.textContent = text || "";
|
||||
msgEl.classList.remove("error");
|
||||
}
|
||||
if (toast) toast(text || (isError ? "Error" : ""), isError ? "error" : "success");
|
||||
}
|
||||
|
||||
function currentConfigFromForm() {
|
||||
@@ -246,6 +246,7 @@ export function initUpdateSettings({
|
||||
showMessage("");
|
||||
|
||||
try {
|
||||
const prev = lastConfig ? { ...lastConfig } : null;
|
||||
const payload = buildPayload();
|
||||
|
||||
if (overrideEnable !== null) payload.enable = !!overrideEnable;
|
||||
@@ -257,6 +258,7 @@ export function initUpdateSettings({
|
||||
|
||||
showMessage("Update settings saved.");
|
||||
toast?.("Updates saved", "success");
|
||||
logUi("Update settings saved", "info", { from: prev, to: payload });
|
||||
|
||||
onAfterSave?.();
|
||||
|
||||
@@ -273,6 +275,16 @@ export function initUpdateSettings({
|
||||
|
||||
}
|
||||
showMessage(e?.error || e?.message || "Save failed", true);
|
||||
logUi("Update settings save failed", "error", {
|
||||
payload: (() => {
|
||||
try {
|
||||
return buildPayload();
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
})(),
|
||||
reason: e?.error || e?.message,
|
||||
});
|
||||
|
||||
} finally {
|
||||
saving = false;
|
||||
|
||||
Reference in New Issue
Block a user