fix(webui): populate per-location backup dropdowns (Type/Path/Engine/SSH auth)

The location editor's Type, Path Mode, Engine and SSH Auth selects rendered
with no options. The config generator only scans flat per-category files and
never descends into configs/backup/locations/<n>/, so configData carries no
options for CFG_BACKUP_LOC_<n>_* keys — and the hardcoded fallbacks had been
removed in favour of generator-emitted ones.

Resolve these four dropdowns by suffix in ConfigOptions.getSelectOptions with
their static option lists (labels mirror location.config), so every location
works regardless of index — including locations added after install. The
global CFG_BACKUP_ENGINE/STRATEGY selects still come from the generator.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Signed-off-by: librelad <librelad@digitalangels.vip>
This commit is contained in:
librelad 2026-05-22 23:32:56 +01:00
parent c987aefb72
commit 2af21c94fa

View File

@ -232,11 +232,42 @@ class ConfigOptions {
return generated; return generated;
} }
// Backup-related dropdowns (TYPE / ENGINE / PATH_MODE / SSH_AUTH / // Per-location backup dropdowns (CFG_BACKUP_LOC_<n>_*). Their options are
// STRATEGY) now come from the bash generator's [value:Label|...] parser // static and identical for every location, but the config generator only
// and land in window.configData.config[key].options — see the // scans flat per-category files — it never descends into the nested
// "Generator-emitted options" check above. The corresponding hardcoded // configs/backup/locations/<n>/ dir — so configData carries no options for
// blocks that used to live here are gone on purpose. // these keys. Resolve them here by suffix so every location index works,
// including ones added after install. (The global CFG_BACKUP_ENGINE/
// STRATEGY still come from the generator via the check above.)
const locDropdown = key.match(/^CFG_BACKUP_LOC_[0-9]+_(TYPE|PATH_MODE|ENGINE|SSH_AUTH)$/);
if (locDropdown) {
const BACKUP_LOC_OPTIONS = {
TYPE: [
{ value: 'local', label: 'Local / mounted path' },
{ value: 'sftp', label: 'SFTP' },
{ value: 'rest', label: 'REST' },
{ value: 's3', label: 'S3' },
{ value: 'b2', label: 'Backblaze B2' },
{ value: 'gs', label: 'Google Cloud Storage' },
{ value: 'azure', label: 'Azure' },
{ value: 'rclone', label: 'rclone' }
],
PATH_MODE: [
{ value: 'auto', label: 'Automatic (/docker/backups/<id>)' },
{ value: 'custom', label: 'Custom path' }
],
ENGINE: [
{ value: 'restic', label: 'restic' },
{ value: 'borg', label: 'BorgBackup' },
{ value: 'kopia', label: 'Kopia' }
],
SSH_AUTH: [
{ value: 'key', label: 'SSH key (~/.ssh/id_rsa)' },
{ value: 'password', label: 'Password (via sshpass)' }
]
};
return BACKUP_LOC_OPTIONS[locDropdown[1]];
}
const result = optionMaps[key] || []; const result = optionMaps[key] || [];
//console.log('Final result for', key, ':', result); //console.log('Final result for', key, ':', result);