rsync window cards: expand to show orch scripts and sync shares, drop toggle
This commit is contained in:
@@ -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),
|
||||
|
||||
@@ -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 = '<div class="vv-ry-win-stat">No run history</div>';
|
||||
if (ls && ls.ts) {
|
||||
@@ -597,16 +591,43 @@ function _windowsRow(data) {
|
||||
<div class="vv-ry-win-dur">${_rel(ls.ts)}${ls.duration ? ' · ' + _dur(ls.duration) : ''}</div>`;
|
||||
}
|
||||
|
||||
const panelHtml = toggleKey ? `
|
||||
<div class="vv-ry-win-panel" style="display:none;margin-top:9px;padding-top:8px;border-top:1px solid #1e1e1e;">
|
||||
<label class="vv-ry-toggle" title="${toggleKey}" onclick="event.stopPropagation()">
|
||||
<div class="vv-ry-toggle-track ${enabled ? 'on' : ''}" id="${trackId}"
|
||||
onclick="event.stopPropagation();vvRyToggle(this,'${toggleKey}')"></div>
|
||||
<span class="vv-ry-toggle-lbl" style="font-size:10px;color:#444;">${toggleKey}</span>
|
||||
</label>
|
||||
</div>` : '';
|
||||
let panelHtml = '';
|
||||
if (scripts.length || shares.length) {
|
||||
let inner = '';
|
||||
|
||||
return `<div class="vv-ry-win ${cls}" data-win-key="${key}" onclick="vvRyWinExpand(this)" style="cursor:pointer;">
|
||||
if (scripts.length) {
|
||||
inner += `<div style="font-size:9px;font-weight:700;color:#2a2a2a;text-transform:uppercase;letter-spacing:.07em;margin-bottom:4px;">Scripts</div>`;
|
||||
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 += `<div style="font-size:10px;color:#555;padding:1px 0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;">
|
||||
${folder ? `<span style="color:#2a2a2a;">${folder}/</span>` : ''}<span>${name}</span>
|
||||
</div>`;
|
||||
}
|
||||
}
|
||||
|
||||
if (shares.length) {
|
||||
if (scripts.length) inner += `<div style="border-top:1px solid #161616;margin:6px 0;"></div>`;
|
||||
inner += `<div style="font-size:9px;font-weight:700;color:#2a2a2a;text-transform:uppercase;letter-spacing:.07em;margin-bottom:4px;">Sync shares</div>`;
|
||||
for (const sh of shares) {
|
||||
const [rawPath, profile] = sh.split('|');
|
||||
const path = rawPath.trim();
|
||||
const basename = path.split('/').pop();
|
||||
inner += `<div style="font-size:10px;color:#555;padding:1px 0;display:flex;align-items:center;gap:5px;min-width:0;">
|
||||
<span style="overflow:hidden;text-overflow:ellipsis;white-space:nowrap;flex:1;" title="${path}">${basename}</span>
|
||||
${profile ? `<span style="font-size:9px;color:#2a3a2a;flex-shrink:0;font-family:monospace;">${profile.trim()}</span>` : ''}
|
||||
</div>`;
|
||||
}
|
||||
}
|
||||
|
||||
panelHtml = `<div class="vv-ry-win-panel" style="display:none;margin-top:9px;padding-top:8px;border-top:1px solid #1e1e1e;">${inner}</div>`;
|
||||
}
|
||||
|
||||
const expandable = !!(scripts.length || shares.length);
|
||||
|
||||
return `<div class="vv-ry-win ${cls}" data-win-key="${key}"
|
||||
${expandable ? 'onclick="vvRyWinExpand(this)" style="cursor:pointer;"' : ''}>
|
||||
<div style="display:flex;justify-content:space-between;align-items:flex-start;gap:4px;">
|
||||
<div style="min-width:0;">
|
||||
<div class="vv-ry-win-lbl">${meta.cadence}</div>
|
||||
@@ -614,7 +635,7 @@ function _windowsRow(data) {
|
||||
<span class="vv-ry-pill ${enabled ? 'on' : 'off'}">${enabled ? 'enabled' : 'disabled'}</span>
|
||||
${statusHtml}
|
||||
</div>
|
||||
<span class="vv-ry-win-chev" style="font-size:9px;color:#2a2a2a;flex-shrink:0;padding-top:2px;">▸</span>
|
||||
${expandable ? `<span class="vv-ry-win-chev" style="font-size:9px;color:#2a2a2a;flex-shrink:0;padding-top:2px;">▸</span>` : ''}
|
||||
</div>
|
||||
${panelHtml}
|
||||
</div>`;
|
||||
|
||||
Reference in New Issue
Block a user