Put the AI master switch on Settings, so the switch that hides the AI tab is reachable without it
Turning AI off takes the AI tools and their conf gear off the Tools card with it, which left the raw master.conf editor as the only way back on.
This commit is contained in:
@@ -23,7 +23,7 @@
|
|||||||
// Values are escaped on render and on write-back.
|
// Values are escaped on render and on write-back.
|
||||||
//
|
//
|
||||||
// RENDERS
|
// RENDERS
|
||||||
// Storage mode selector, global toggles, general conf fields
|
// Storage mode selector, global toggles, AI master switch, general conf fields
|
||||||
//
|
//
|
||||||
// DEPENDS ON
|
// DEPENDS ON
|
||||||
// api/confform.php conf read/write → include/confform.php
|
// api/confform.php conf read/write → include/confform.php
|
||||||
@@ -42,6 +42,13 @@ $_enableLogging = ($_vars['ENABLE_LOGGING'] ?? 'false') === 'true';
|
|||||||
$_discordKey = $_myId . '_DISCORD_WEBHOOK';
|
$_discordKey = $_myId . '_DISCORD_WEBHOOK';
|
||||||
$_discordHook = $_vars[$_discordKey] ?? '';
|
$_discordHook = $_vars[$_discordKey] ?? '';
|
||||||
|
|
||||||
|
// AI. The card is drawn only on the host that can actually run it — elsewhere AI_ENABLED is a
|
||||||
|
// switch with nothing behind it, since the model and the index are HOST1's. vv_ai_ui_on() is
|
||||||
|
// not the test here: it folds the switch into the host check, and this card is how the switch
|
||||||
|
// gets turned back on. Fail-closed on anything but "true", matching the gate it feeds.
|
||||||
|
$_aiHost = vv_is_ai_host();
|
||||||
|
$_aiEnabled = strtolower(trim($_vars['AI_ENABLED'] ?? 'false')) === 'true';
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<style>
|
<style>
|
||||||
.vv-set-card { background:#161616;border:1px solid #2a2a2a;border-radius:6px;padding:14px 16px;margin-bottom:14px; }
|
.vv-set-card { background:#161616;border:1px solid #2a2a2a;border-radius:6px;padding:14px 16px;margin-bottom:14px; }
|
||||||
@@ -167,6 +174,35 @@ $_discordHook = $_vars[$_discordKey] ?? '';
|
|||||||
<span id="vv-ntf-fb" style="font-size:11px;"></span>
|
<span id="vv-ntf-fb" style="font-size:11px;"></span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<?php if ($_aiHost): ?>
|
||||||
|
<!-- AI card -->
|
||||||
|
<div class="vv-set-card">
|
||||||
|
<div class="vv-set-hdr">AI</div>
|
||||||
|
|
||||||
|
<label class="vv-set-tog-wrap" style="margin-bottom:12px;">
|
||||||
|
<div class="vv-set-tog-track<?= $_aiEnabled ? ' on' : '' ?>" id="vv-set-ai-tog"
|
||||||
|
onclick="vvSetAiToggle(this)"></div>
|
||||||
|
<div>
|
||||||
|
<div class="vv-set-tog-lbl">AI features</div>
|
||||||
|
<div class="vv-set-tog-sub">Master switch — the AI tab, the Scheduler assistant, and the AI tools on the Tools card</div>
|
||||||
|
</div>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<div class="vv-set-info">
|
||||||
|
Varaverk works exactly as well with this off. Every feature that can lean on AI has a
|
||||||
|
complete non-AI path, so turning it off removes the AI surfaces from the WebGUI and
|
||||||
|
nothing else — no script changes behaviour, no schedule changes.
|
||||||
|
<br>
|
||||||
|
Off is total: with it off the AI tab is not in the tab bar, the Scheduler's assistant dock
|
||||||
|
is not drawn, the AI tools are not listed, and
|
||||||
|
<code style="font-size:10px;color:#4a7a4a;background:#080808;padding:1px 4px;border-radius:2px;">api/ai.php</code>
|
||||||
|
refuses every request. This card is the way back on.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<span id="vv-set-ai-fb" style="font-size:11px;color:#444;"></span>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
<!-- Unraid API Key card -->
|
<!-- Unraid API Key card -->
|
||||||
<div class="vv-set-card">
|
<div class="vv-set-card">
|
||||||
<div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:12px;">
|
<div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:12px;">
|
||||||
@@ -356,6 +392,43 @@ function vvNtfSaveWebhook() {
|
|||||||
.catch(() => { btn.disabled = false; btn.textContent = 'Save'; fb.style.color='#ef5350'; fb.textContent='Request failed'; });
|
.catch(() => { btn.disabled = false; btn.textContent = 'Save'; fb.style.color='#ef5350'; fb.textContent='Request failed'; });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ── AI ────────────────────────────────────────────────────────────────────────
|
||||||
|
// Reloads on success, unlike the notification toggles, because this one changes the page around
|
||||||
|
// it: the tab bar and the assistant dock are decided server-side at render, so without a reload
|
||||||
|
// the switch would read "off" with the AI tab still sitting next to it. The switch is moved
|
||||||
|
// first and reverted if the write fails, matching the toggles above.
|
||||||
|
function vvSetAiToggle(track) {
|
||||||
|
const on = !track.classList.contains('on');
|
||||||
|
const fb = document.getElementById('vv-set-ai-fb');
|
||||||
|
track.classList.toggle('on', on);
|
||||||
|
fb.style.color = '#444';
|
||||||
|
fb.textContent = 'Saving…';
|
||||||
|
|
||||||
|
const fd = new URLSearchParams();
|
||||||
|
fd.append('id', 'settings');
|
||||||
|
fd.append('changes', JSON.stringify([
|
||||||
|
{ file: 'master.conf', key: 'AI_ENABLED', value: on ? 'true' : 'false', type: 'scalar' }
|
||||||
|
]));
|
||||||
|
fetch('/plugins/varaverk/api/confform.php', { method: 'POST', body: fd })
|
||||||
|
.then(r => r.json())
|
||||||
|
.then(d => {
|
||||||
|
if (!d.ok) {
|
||||||
|
track.classList.toggle('on', !on);
|
||||||
|
fb.style.color = '#ef5350';
|
||||||
|
fb.textContent = d.error || 'Failed';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
fb.style.color = '#4caf50';
|
||||||
|
fb.textContent = (on ? 'Enabled' : 'Disabled') + ' — reloading…';
|
||||||
|
setTimeout(() => location.reload(), 700);
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
track.classList.toggle('on', !on);
|
||||||
|
fb.style.color = '#ef5350';
|
||||||
|
fb.textContent = 'Request failed';
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// ── Unraid API Keys ───────────────────────────────────────────────────────────
|
// ── Unraid API Keys ───────────────────────────────────────────────────────────
|
||||||
function vvApiCheck() {
|
function vvApiCheck() {
|
||||||
const btn = document.getElementById('vv-api-check-btn');
|
const btn = document.getElementById('vv-api-check-btn');
|
||||||
|
|||||||
Reference in New Issue
Block a user