Varaverk: suggested cron hints left of every cron input

- vv_script_children() now calls vv_script_suggested_cron() per child,
  adding suggested_cron and suggested_label to each child entry
- Orch rows (non-event) and regular script child rows render a faint
  .vv-cron-hint span to the left of the cron input showing the suggested
  cron from the script's # Schedule: header
- Clicking the hint fills in the cron input (data-cron + onclick)
- Tooltip shows full "suggested_cron — label" string on hover
- .vv-cron-hint: color #444, brightens to #888 on hover
This commit is contained in:
Gmer4Lfe
2026-05-24 22:59:33 -04:00
parent d6cfcaef46
commit dfb462a18e
3 changed files with 32 additions and 9 deletions
@@ -57,6 +57,10 @@
cursor: default; }
.vv-cron { flex: 0 0 110px; width: 110px; background: #111; border: 1px solid #444; color: #ddd;
padding: 4px 6px; border-radius: 4px; font-family: monospace; font-size: 13px; }
.vv-cron-hint { font-size: 11px; font-family: monospace; color: #444; cursor: pointer;
white-space: nowrap; flex-shrink: 0; padding: 3px 5px; border-radius: 3px;
user-select: none; transition: color 0.15s; }
.vv-cron-hint:hover { color: #888; background: rgba(255,255,255,0.04); }
.vv-event-badge { flex: 0 0 auto; padding: 3px 8px; border-radius: 4px; font-size: 12px;
background: #1a3a1a; border: 1px solid #2e6b2e; color: #6fcf6f;
white-space: nowrap; font-weight: 500; }
@@ -400,6 +400,7 @@ function vv_script_children(string $orchPath, array $schedule): array {
$seen[$rel] = true;
$entry = $schedule[$rel] ?? ['enabled' => false, 'cron' => ''];
$conf = $confMap[$rel] ?? ['array' => null, 'enabled' => null, 'managed' => false];
$suggested = vv_script_suggested_cron("$scriptsDir/$rel");
$children[] = [
'id' => $rel,
'label' => basename($rel, '.sh'),
@@ -410,6 +411,8 @@ function vv_script_children(string $orchPath, array $schedule): array {
'log_enabled' => (bool)($entry['log_enabled'] ?? false),
'conf_managed' => $conf['managed'],
'conf_enabled' => $conf['enabled'], // null if not in any *_SCRIPTS array
'suggested_cron' => $suggested['cron'],
'suggested_label' => $suggested['label'],
];
};
@@ -36,6 +36,14 @@ foreach ($tree as $orch) {
<span class="vv-event-badge"><?= $orch['cron'] === '@array_start' ? '⚡ Array Start' : '⚡ Array Stop' ?></span>
<input type="hidden" class="vv-cron" value="<?= htmlspecialchars($orch['cron']) ?>">
<?php else: ?>
<?php if ($orch['suggested_cron']): ?>
<span class="vv-cron-hint"
data-cron="<?= htmlspecialchars($orch['suggested_cron']) ?>"
onclick="this.nextElementSibling.value=this.dataset.cron"
title="Suggested: <?= htmlspecialchars($orch['suggested_cron'] . ($orch['suggested_label'] ? ' — ' . $orch['suggested_label'] : '')) ?>">
<?= htmlspecialchars($orch['suggested_cron']) ?>
</span>
<?php endif; ?>
<input type="text" class="vv-cron" value="<?= htmlspecialchars($orch['cron']) ?>"
placeholder="cron expression">
<?php endif; ?>
@@ -106,6 +114,14 @@ foreach ($tree as $orch) {
<span class="vv-slider"></span>
</label>
<span class="vv-job-label"><?= htmlspecialchars($child['label']) ?></span>
<?php if (!empty($child['suggested_cron'])): ?>
<span class="vv-cron-hint"
data-cron="<?= htmlspecialchars($child['suggested_cron']) ?>"
onclick="this.nextElementSibling.value=this.dataset.cron"
title="Suggested: <?= htmlspecialchars($child['suggested_cron'] . (!empty($child['suggested_label']) ? ' — ' . $child['suggested_label'] : '')) ?>">
<?= htmlspecialchars($child['suggested_cron']) ?>
</span>
<?php endif; ?>
<input type="text" class="vv-cron" value="<?= htmlspecialchars($child['cron']) ?>"
placeholder="cron (orch off only)">
<span class="vv-save-check"></span>