Scheduler UI polish + per-script verbose logging + coffee report as orchestrator
- Cron and Advanced button vertically aligned in their respective rows - Verbose checkbox next to Log button — saves immediately, persists to schedule.json - --log flag injected into cron lines, manual Run, and Dry Run when verbose enabled - Coffee report rewritten as lean orchestrator over COFFEE_REPORT_SCRIPTS array - COFFEE_REPORT_SCRIPTS added to master.conf (7 Sunday monitor scripts) - Scheduler Advanced tab auto-discovers children via existing array detection
This commit is contained in:
@@ -12,6 +12,7 @@ $tree = vv_job_tree();
|
||||
|
||||
<!-- ── Left: script cards ── -->
|
||||
<div id="vv-sched-left">
|
||||
<div id="vv-sched-cards">
|
||||
|
||||
<?php foreach ($tree as $orch): $oid = htmlspecialchars($orch['id']); ?>
|
||||
<div class="vv-card vv-wide vv-sched-card" data-id="<?= $oid ?>">
|
||||
@@ -23,15 +24,9 @@ $tree = vv_job_tree();
|
||||
onchange="vvSaveJob(this)">
|
||||
<span class="vv-slider"></span>
|
||||
</label>
|
||||
<div class="vv-name-cron">
|
||||
<span class="vv-job-label"><?= htmlspecialchars($orch['label']) ?></span>
|
||||
<input type="text" class="vv-cron" value="<?= htmlspecialchars($orch['cron']) ?>"
|
||||
placeholder="cron expression">
|
||||
</div>
|
||||
<span class="vv-job-status"></span>
|
||||
<?php if (!empty($orch['children'])): ?>
|
||||
<button class="vv-advanced-toggle" onclick="vvToggleAdvanced(this)">Advanced ▸</button>
|
||||
<?php endif; ?>
|
||||
<span class="vv-job-label"><?= htmlspecialchars($orch['label']) ?></span>
|
||||
<input type="text" class="vv-cron" value="<?= htmlspecialchars($orch['cron']) ?>"
|
||||
placeholder="cron expression">
|
||||
</div>
|
||||
<?php if (!empty($orch['desc'])): ?>
|
||||
<div class="vv-job-desc" title="<?= htmlspecialchars($orch['desc']) ?>"><?= htmlspecialchars($orch['desc']) ?></div>
|
||||
@@ -40,7 +35,16 @@ $tree = vv_job_tree();
|
||||
<button class="vv-btn-sm vv-run-btn" onclick="vvRunJob(this)">▶ Run</button>
|
||||
<button class="vv-btn-sm vv-dry-btn" onclick="vvDryRun(this)">▶ Dry Run</button>
|
||||
<button class="vv-btn-sm" onclick="vvSelectLog(this)">Log</button>
|
||||
<label class="vv-log-label" title="Enable verbose --log output">
|
||||
<input type="checkbox" class="vv-log-enabled"
|
||||
<?= $orch['log_enabled'] ? 'checked' : '' ?>
|
||||
onchange="vvSaveJob(this)">
|
||||
<span>Verbose</span>
|
||||
</label>
|
||||
<span class="vv-job-dot"></span>
|
||||
<?php if (!empty($orch['children'])): ?>
|
||||
<button class="vv-advanced-toggle" style="margin-left:auto;width:110px" onclick="vvToggleAdvanced(this)">Advanced ▸</button>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<?php if (!empty($orch['children'])): ?>
|
||||
@@ -54,12 +58,9 @@ $tree = vv_job_tree();
|
||||
onchange="vvSaveJob(this)">
|
||||
<span class="vv-slider"></span>
|
||||
</label>
|
||||
<div class="vv-name-cron">
|
||||
<span class="vv-job-label"><?= htmlspecialchars($child['label']) ?></span>
|
||||
<input type="text" class="vv-cron" value="<?= htmlspecialchars($child['cron']) ?>"
|
||||
placeholder="cron expression">
|
||||
</div>
|
||||
<span class="vv-job-status"></span>
|
||||
<span class="vv-job-label"><?= htmlspecialchars($child['label']) ?></span>
|
||||
<input type="text" class="vv-cron" value="<?= htmlspecialchars($child['cron']) ?>"
|
||||
placeholder="cron expression">
|
||||
</div>
|
||||
<?php if (!empty($child['desc'])): ?>
|
||||
<div class="vv-job-desc" title="<?= htmlspecialchars($child['desc']) ?>"><?= htmlspecialchars($child['desc']) ?></div>
|
||||
@@ -68,6 +69,12 @@ $tree = vv_job_tree();
|
||||
<button class="vv-btn-sm vv-run-btn" onclick="vvRunJob(this)">▶ Run</button>
|
||||
<button class="vv-btn-sm vv-dry-btn" onclick="vvDryRun(this)">▶ Dry Run</button>
|
||||
<button class="vv-btn-sm" onclick="vvSelectLog(this)">Log</button>
|
||||
<label class="vv-log-label" title="Enable verbose --log output">
|
||||
<input type="checkbox" class="vv-log-enabled"
|
||||
<?= $child['log_enabled'] ? 'checked' : '' ?>
|
||||
onchange="vvSaveJob(this)">
|
||||
<span>Verbose</span>
|
||||
</label>
|
||||
<span class="vv-job-dot"></span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -78,8 +85,10 @@ $tree = vv_job_tree();
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
|
||||
</div><!-- /#vv-sched-cards -->
|
||||
|
||||
<!-- Single global save -->
|
||||
<div class="vv-card-footer" style="margin-top:4px;">
|
||||
<div class="vv-sched-footer">
|
||||
<button class="vv-save-btn" onclick="vvSaveAll(this)">Save Schedule</button>
|
||||
<span id="vv-save-all-status" class="vv-save-status"></span>
|
||||
</div>
|
||||
@@ -88,7 +97,7 @@ $tree = vv_job_tree();
|
||||
|
||||
<!-- ── Right: persistent log panel ── -->
|
||||
<div id="vv-sched-right">
|
||||
<div class="vv-card">
|
||||
<div class="vv-card vv-log-card">
|
||||
<div class="vv-log-toolbar" style="margin-bottom:8px;">
|
||||
<div style="display:flex;align-items:center;gap:8px;">
|
||||
<span id="vv-log-title" style="font-size:13px;font-weight:bold;color:#ccc;">No script selected</span>
|
||||
@@ -101,6 +110,29 @@ $tree = vv_job_tree();
|
||||
</div>
|
||||
<pre id="vv-log-pre" class="vv-log-pre vv-log-right-pre">Click Log, Run, or Dry Run on a script to view output here.</pre>
|
||||
</div>
|
||||
<?php
|
||||
$totalJobs = 0; $scheduledJobs = 0;
|
||||
foreach ($tree as $orch) {
|
||||
$totalJobs++;
|
||||
if (!empty($orch['cron']) && $orch['enabled']) $scheduledJobs++;
|
||||
foreach (($orch['children'] ?? []) as $child) {
|
||||
$totalJobs++;
|
||||
if (!empty($child['cron']) && $child['enabled']) $scheduledJobs++;
|
||||
}
|
||||
}
|
||||
$runningScripts = [];
|
||||
exec('pgrep -af bash 2>/dev/null', $psLines);
|
||||
foreach ($psLines as $line) {
|
||||
if (preg_match('#' . preg_quote(SCRIPTS_DIR, '#') . '/([^\s]+\.sh)#', $line, $rm)) {
|
||||
$runningScripts[] = basename($rm[1], '.sh');
|
||||
}
|
||||
}
|
||||
$runningScripts = array_unique($runningScripts);
|
||||
?>
|
||||
<div class="vv-sched-footer vv-sched-info">
|
||||
<span><?= $scheduledJobs ?> of <?= $totalJobs ?> job<?= $totalJobs !== 1 ? 's' : '' ?> scheduled</span>
|
||||
<span><?= !empty($runningScripts) ? 'Currently Running: ' . htmlspecialchars(implode(', ', $runningScripts)) : 'Currently Running scripts: none' ?></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div><!-- /#vv-sched-layout -->
|
||||
@@ -122,6 +154,40 @@ function vvPost(url, data) {
|
||||
}).then(r => r.json());
|
||||
}
|
||||
|
||||
function vvFitRight() {
|
||||
const right = document.getElementById('vv-sched-right');
|
||||
if (!right.classList.contains('vv-panel-visible')) return;
|
||||
const left = document.getElementById('vv-sched-left');
|
||||
|
||||
const lf = left.querySelector('.vv-sched-footer');
|
||||
const rf = right.querySelector('.vv-sched-info');
|
||||
const toolbar = right.querySelector('.vv-log-toolbar');
|
||||
const pre = document.getElementById('vv-log-pre');
|
||||
|
||||
// Read viewport rects BEFORE any mutations
|
||||
const leftRect = left.getBoundingClientRect();
|
||||
const rightRect = right.getBoundingClientRect();
|
||||
|
||||
// Match footer heights
|
||||
rf.style.height = lf.offsetHeight + 'px';
|
||||
|
||||
// Pin right panel bottom to left panel bottom using viewport coords
|
||||
right.style.height = Math.round(leftRect.bottom - rightRect.top) + 'px';
|
||||
|
||||
// Pre fills from toolbar bottom to footer border, leaving 12px card padding below
|
||||
// -12 footer margin, -12 card padding-bottom, -8 toolbar margin-bottom
|
||||
const preH = Math.max(80, lf.getBoundingClientRect().top - 32 - toolbar.getBoundingClientRect().bottom);
|
||||
pre.style.maxHeight = 'none';
|
||||
pre.style.height = preH + 'px';
|
||||
|
||||
console.log('[vvFitRight]', {
|
||||
leftBottom: Math.round(leftRect.bottom), rightTop: Math.round(rightRect.top),
|
||||
rightBottomAfter: Math.round(right.getBoundingClientRect().bottom),
|
||||
rfH: lf.offsetHeight, preH, preActual: pre.offsetHeight,
|
||||
});
|
||||
}
|
||||
window.addEventListener('resize', vvFitRight);
|
||||
|
||||
// Open the right panel for a given job id
|
||||
function vvOpenRight(id) {
|
||||
// Deselect old
|
||||
@@ -137,6 +203,7 @@ function vvOpenRight(id) {
|
||||
const name = id.replace(/\.sh$/, '').split('/').pop();
|
||||
document.getElementById('vv-log-title').textContent = name;
|
||||
document.getElementById('vv-sched-right').classList.add('vv-panel-visible');
|
||||
requestAnimationFrame(vvFitRight);
|
||||
|
||||
vvFetchRight();
|
||||
if (!vvPollTimer) vvPollTimer = setInterval(vvFetchRight, 2000);
|
||||
@@ -220,13 +287,12 @@ function vvDryRun(btn) {
|
||||
}
|
||||
|
||||
function vvSaveJob(el) {
|
||||
const job = el.closest('[data-id]');
|
||||
const id = job.dataset.id;
|
||||
const enabled = job.querySelector('.vv-enabled').checked ? '1' : '0';
|
||||
const cron = job.querySelector('.vv-cron').value.trim();
|
||||
const status = job.querySelector('.vv-job-status');
|
||||
vvPost('/plugins/varaverk/api/scheduler.php', {id, enabled, cron})
|
||||
.then(d => { if (status) vvFlashStatus(status, d.ok ? '✓' : '✗ ' + (d.error ?? ''), d.ok); });
|
||||
const job = el.closest('[data-id]');
|
||||
const id = job.dataset.id;
|
||||
const enabled = job.querySelector('.vv-enabled').checked ? '1' : '0';
|
||||
const cron = job.querySelector('.vv-cron').value.trim();
|
||||
const log_enabled = job.querySelector('.vv-log-enabled')?.checked ? '1' : '0';
|
||||
vvPost('/plugins/varaverk/api/scheduler.php', {id, enabled, cron, log_enabled});
|
||||
}
|
||||
|
||||
function vvSaveAll() {
|
||||
@@ -236,10 +302,11 @@ function vvSaveAll() {
|
||||
if (!pending) { vvFlashStatus(status, '✗ No jobs found', false); return; }
|
||||
status.textContent = 'Saving…';
|
||||
jobs.forEach(job => {
|
||||
const id = job.dataset.id;
|
||||
const enabled = job.querySelector('.vv-enabled').checked ? '1' : '0';
|
||||
const cron = job.querySelector('.vv-cron').value.trim();
|
||||
vvPost('/plugins/varaverk/api/scheduler.php', {id, enabled, cron})
|
||||
const id = job.dataset.id;
|
||||
const enabled = job.querySelector('.vv-enabled').checked ? '1' : '0';
|
||||
const cron = job.querySelector('.vv-cron').value.trim();
|
||||
const log_enabled = job.querySelector('.vv-log-enabled')?.checked ? '1' : '0';
|
||||
vvPost('/plugins/varaverk/api/scheduler.php', {id, enabled, cron, log_enabled})
|
||||
.then(d => {
|
||||
if (!d.ok) allOk = false;
|
||||
if (--pending === 0) vvFlashStatus(status, allOk ? '✓ Saved' : '✗ Some failed', allOk);
|
||||
|
||||
Reference in New Issue
Block a user