diff --git a/Plugin/unraid/api/rsync.php b/Plugin/unraid/api/rsync.php index bcfc10a..2ddf2d6 100644 --- a/Plugin/unraid/api/rsync.php +++ b/Plugin/unraid/api/rsync.php @@ -30,6 +30,26 @@ if (file_exists($bwLog)) { } } +// Per-window orch arrays (scripts + sync shares) +$masterRaw = vv_read_conf_raw('master.conf'); +$myId = strtoupper(vv_detect_host()); +$hostRaw = vv_read_conf_raw(vv_detect_host() . '.conf'); + +$winArrayDefs = [ + 'critical' => ['CRITICAL_MAINTENANCE_SCRIPTS', "{$myId}_CRITICAL_SYNC_SHARES"], + 'intermediate' => ['INTERMEDIATE_MAINTENANCE_SCRIPTS', "{$myId}_INTERMEDIATE_SYNC_SHARES"], + 'daily' => ['DAILY_MAINTENANCE_SCRIPTS', "{$myId}_DAILY_SYNC_SHARES"], + 'weekly' => ['WEEKLY_MAINTENANCE_SCRIPTS', "{$myId}_WEEKLY_SYNC_SHARES"], + 'fallback' => [null, null], +]; +$winArrays = []; +foreach ($winArrayDefs as $win => [$sv, $shv]) { + $winArrays[$win] = [ + 'scripts' => $sv ? vv_parse_bash_array($masterRaw, $sv) : [], + 'shares' => $shv ? vv_parse_bash_array($hostRaw, $shv) : [], + ]; +} + echo json_encode([ 'enabled' => $base['enabled'], 'windows' => $base['windows'], @@ -37,6 +57,7 @@ echo json_encode([ 'last_sync' => $base['last_sync'], 'bw_history' => $history, 'bw_warn_gb' => $warnGb, + 'win_arrays' => $winArrays, 'settings' => [ 'bw_limit' => (int)($vars['BW_LIMIT'] ?? 0), 'retry_count' => (int)($vars['RETRY_COUNT'] ?? 3), diff --git a/Plugin/unraid/pages/rsync.php b/Plugin/unraid/pages/rsync.php index 3fb8348..aaedf86 100644 --- a/Plugin/unraid/pages/rsync.php +++ b/Plugin/unraid/pages/rsync.php @@ -571,24 +571,18 @@ function _lastSyncCard(data) { } // ── Window cards row ────────────────────────────────────────────────────────── -const WIN_TOGGLE_KEYS = { - critical: 'CRITICAL_RSYNC_ENABLED', - intermediate: 'INTERMEDIATE_RSYNC_ENABLED', - daily: 'DAILY_RSYNC_ENABLED', - weekly: 'WEEKLY_RSYNC_ENABLED', - fallback: 'FALLBACK_RSYNC_ENABLED', -}; - function _windowsRow(data) { - const windows = data.windows || {}; - const lastSync = data.last_sync || {}; + const windows = data.windows || {}; + const lastSync = data.last_sync || {}; + const winArr = data.win_arrays || {}; const cards = Object.entries(WIN_META).map(([key, meta]) => { - const enabled = windows[key] !== false; - const ls = lastSync[key]; - const cls = enabled ? 'enabled' : 'disabled'; - const toggleKey = WIN_TOGGLE_KEYS[key] || ''; - const trackId = 'vv-ry-tog-win-' + key; + const enabled = windows[key] !== false; + const ls = lastSync[key]; + const cls = enabled ? 'enabled' : 'disabled'; + const cfg = winArr[key] || {}; + const scripts = cfg.scripts || []; + const shares = cfg.shares || []; let statusHtml = '
No run history
'; if (ls && ls.ts) { @@ -597,16 +591,43 @@ function _windowsRow(data) {
${_rel(ls.ts)}${ls.duration ? ' · ' + _dur(ls.duration) : ''}
`; } - const panelHtml = toggleKey ? ` - ` : ''; + let panelHtml = ''; + if (scripts.length || shares.length) { + let inner = ''; - return `
+ if (scripts.length) { + inner += `
Scripts
`; + for (const s of scripts) { + const parts = s.split('/'); + const folder = parts.length > 1 ? parts.slice(0, -1).join('/') : ''; + const name = parts[parts.length - 1].replace(/\.sh$/, ''); + inner += `
+ ${folder ? `${folder}/` : ''}${name} +
`; + } + } + + if (shares.length) { + if (scripts.length) inner += `
`; + inner += `
Sync shares
`; + for (const sh of shares) { + const [rawPath, profile] = sh.split('|'); + const path = rawPath.trim(); + const basename = path.split('/').pop(); + inner += `
+ ${basename} + ${profile ? `${profile.trim()}` : ''} +
`; + } + } + + panelHtml = ``; + } + + const expandable = !!(scripts.length || shares.length); + + return `
${meta.cadence}
@@ -614,7 +635,7 @@ function _windowsRow(data) { ${enabled ? 'enabled' : 'disabled'} ${statusHtml}
- + ${expandable ? `` : ''}
${panelHtml}
`;