add dashboard

This commit is contained in:
2026-11-12 14:03:53 +01:00
parent 53f1896d05
commit 68bb7ff810
14 changed files with 2037 additions and 280 deletions

View File

@@ -27,6 +27,7 @@ const state = {
target: null, // target id of the job
scope: null, // null = everything, else the project's display name
autoCopy: false, // copy right after the check (per-project "Sichern")
auto: false, // started by the automatic backup schedule
error: null,
check: null, // summary of the last check
progress: null, // { files, filesTotal, bytes, bytesTotal, current }
@@ -90,10 +91,11 @@ function baseArgs(cfg) {
'/XD', ...cfg.excludeDirs, '/XF', ...cfg.excludeFiles]
}
// robocopy runs of a job: one per projects folder, or one for a single project
function itemsFor(t, scope) {
// robocopy runs of a job: one per projects folder (the shown ones, or `rootList`),
// or one for a single project
function itemsFor(t, scope, rootList = roots) {
if (scope) return [{ root: scope.root, source: path.join(scope.root, scope.folder), target: path.join(destOf(t, scope.root), scope.folder) }]
return roots.map((root) => ({ root, source: root, target: destOf(t, root) }))
return rootList.map((root) => ({ root, source: root, target: destOf(t, root) }))
}
const stamp = () => new Date().toISOString().slice(0, 16).replace('T', '_').replace(':', '-')
@@ -173,12 +175,14 @@ function failedFromLog(log, source, target) {
// scope: null = all shown projects folders, or { root, folder } of one project.
// autoCopy: continue with the copy right away (nothing is deleted, so no question needed).
// targetId: which backup target (default: the first one).
function check(scope = null, autoCopy = false, targetId = null) {
// opts.roots: other projects folders than the shown ones (automatic backup: all of them);
// opts.auto: started by the schedule (lib/scheduler.js), shown as such in the UI.
function check(scope = null, autoCopy = false, targetId = null, opts = {}) {
if (busy()) return false
const cfg = config(targetId)
const items = itemsFor(cfg.t, scope)
const items = itemsFor(cfg.t, scope, opts.roots?.length ? opts.roots : roots)
job = { scope, items }
Object.assign(state, { phase: 'checking', target: cfg.t.id, scope: scope ? keyOf(scope.root, scope.folder) : null, autoCopy, error: null, check: null, progress: null })
Object.assign(state, { phase: 'checking', target: cfg.t.id, scope: scope ? keyOf(scope.root, scope.folder) : null, autoCopy, auto: !!opts.auto, error: null, check: null, progress: null })
run(async () => {
const share = path.dirname(cfg.t.path)
if (!fs.existsSync(cfg.t.path) && !fs.existsSync(share)) throw new Error(`Backup-Ziel „${cfg.t.name}“ nicht erreichbar: ${cfg.t.path} – Laufwerk/NAS angeschlossen und eingeschaltet?`)