add dashboard
This commit is contained in:
@@ -65,10 +65,26 @@ function defaults() {
|
||||
targets: Array.isArray(legacy?.targets) ? legacy.targets : targetsFrom(legacy?.target ?? ''),
|
||||
excludeDirs: legacy?.excludeDirs ?? DEFAULT_EXCLUDE_DIRS,
|
||||
excludeFiles: legacy?.excludeFiles ?? DEFAULT_EXCLUDE_FILES,
|
||||
// "Backup fällig": changed since the last backup and that is older than this
|
||||
remindDays: 7,
|
||||
auto: { ...AUTO_DEFAULT },
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// Automatic backup (lib/scheduler.js): interval off | start | hourly | daily | weekly,
|
||||
// time "HH:MM" (daily/weekly), weekday 0=So … 6=Sa (weekly), target 'all' or a target id.
|
||||
const AUTO_DEFAULT = { interval: 'off', time: '20:00', weekday: 5, target: 'all' }
|
||||
function cleanAuto(a, old) {
|
||||
const o = { ...AUTO_DEFAULT, ...(old ?? {}) }
|
||||
if (!a || typeof a !== 'object') return o
|
||||
if (['off', 'start', 'hourly', 'daily', 'weekly'].includes(a.interval)) o.interval = a.interval
|
||||
if (typeof a.time === 'string' && /^([01]\d|2[0-3]):[0-5]\d$/.test(a.time)) o.time = a.time
|
||||
if (Number.isInteger(+a.weekday) && +a.weekday >= 0 && +a.weekday <= 6) o.weekday = +a.weekday
|
||||
if (typeof a.target === 'string' && a.target) o.target = a.target
|
||||
return o
|
||||
}
|
||||
|
||||
let current = null
|
||||
|
||||
function load() {
|
||||
@@ -77,6 +93,7 @@ function load() {
|
||||
const backup = { ...d.backup, ...(saved?.backup ?? {}) }
|
||||
if (!Array.isArray(saved?.backup?.targets) && typeof saved?.backup?.target === 'string') backup.targets = targetsFrom(saved.backup.target)
|
||||
delete backup.target
|
||||
backup.auto = cleanAuto(saved?.backup?.auto)
|
||||
// older settings had one "projectsRoot"
|
||||
let roots = Array.isArray(saved?.roots)
|
||||
? saved.roots.filter((r) => r && typeof r.path === 'string' && r.path).map((r) => ({ id: String(r.id || newId()), name: String(r.name || rootName(r.path)), path: r.path }))
|
||||
@@ -225,8 +242,12 @@ function save(input) {
|
||||
targets,
|
||||
excludeDirs: cleanList(input.excludeDirs, s.backup.excludeDirs),
|
||||
excludeFiles: cleanList(input.excludeFiles, s.backup.excludeFiles),
|
||||
remindDays: Number.isFinite(+input.remindDays) && +input.remindDays >= 1 ? Math.min(365, Math.round(+input.remindDays)) : (s.backup.remindDays ?? 7),
|
||||
auto: cleanAuto(input.auto, s.backup.auto),
|
||||
},
|
||||
})
|
||||
// an automatic backup to a target that was removed falls back to all targets
|
||||
if (next.backup.auto.target !== 'all' && !targets.some((t) => t.id === next.backup.auto.target)) next.backup.auto.target = 'all'
|
||||
persist(next)
|
||||
// keep backup-projekte.bat in sync where it exists (it backs up the first folder to the first target)
|
||||
const legacy = legacyBackupFile(roots[0].path)
|
||||
|
||||
Reference in New Issue
Block a user