v2.1 - Small improvement

This commit is contained in:
pporcheret
2026-10-28 15:38:38 +01:00
parent 5f82b1bdf2
commit a6169bcfdb
22 changed files with 1138 additions and 4 deletions
+17
View File
@@ -0,0 +1,17 @@
/* Alfred Configuration & Surveillance V2: additive styles only */
.admin-v2-stt-panel {margin-top:18px}
.admin-v2-form-grid {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:0 20px}
.admin-v2-form-grid .field {min-width:0}
.admin-v2-help {line-height:1.6;color:#a7c0d0;font-size:.82rem;background:#ffffff08;border:1px solid #ffffff18;padding:13px 15px;border-radius:11px;margin:1px 0 0}
.admin-v2-help code,.admin-v2-monitor code,.admin-v2-maintenance code{font-size:.84em;color:#bde0fc}
.admin-v2-monitor {margin:17px 0}
.admin-v2-summary {display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:10px;border-bottom:1px solid #ffffff16;padding:10px 0}
.admin-v2-summary strong {font-size:.85rem;color:#eaf4fd;overflow-wrap:anywhere}
.admin-v2-monitor p.microtext {line-height:1.6;margin:9px 0 18px}
.admin-v2-monitor .info-note{margin-top:12px}
.admin-v2-timer-list{max-height:200px;overflow:auto;margin-top:8px}
.admin-v2-timer-row{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:10px 0;border-bottom:1px solid #ffffff13;font-size:.82rem}
.admin-v2-timer-row span{color:#adc5d7;text-align:right}
.admin-v2-maintenance{margin-bottom:17px}
.admin-v2-maintenance p{line-height:1.65}
@media(max-width:720px){.admin-v2-form-grid{grid-template-columns:1fr}.admin-v2-summary{align-items:flex-start}}
+49
View File
@@ -0,0 +1,49 @@
/* Alfred V2 monitoring extension: no credentials, no write calls. */
(() => {
'use strict';
const byId = id => document.getElementById(id);
const text = (id, value) => { const el = byId(id); if (el) el.textContent = String(value ?? '—'); };
const pill = (id, state) => {
const el = byId(id); if (!el) return;
const states = {ok:'Disponible', warning:'Attention', down:'Indisponible', unknown:'Non vérifié'};
el.dataset.state = state || 'unknown';
el.textContent = states[state] || 'Non vérifié';
};
const duration = seconds => {
const n = Math.max(0, Math.floor(Number(seconds) || 0));
if (n >= 3600) return `${Math.floor(n/3600)} h ${String(Math.floor((n%3600)/60)).padStart(2,'0')} min`;
return `${Math.floor(n/60)} min ${String(n%60).padStart(2,'0')} s`;
};
window.alfredAdminV2Health = data => {
if (document.body.dataset.page !== 'surveillance') return;
const stt = data.stt || {}, whisper = stt.whisper || {}, timers = data.timers || {};
text('v2SttActive', stt.active_engine === 'wyoming' ? 'Whisper distant' : 'Vosk local');
text('v2SttDetail', stt.detail || 'État indisponible');
pill('v2SttState', stt.state);
text('v2WhisperAddress', stt.host && stt.port ? `${stt.host}:${stt.port}` : 'Non configuré');
text('v2WhisperDetail', whisper.detail || 'Service non vérifié');
pill('v2WhisperState', whisper.state);
text('v2TimerCount', `${(timers.items || []).length} actif(s)`);
pill('v2TimerState', timers.state);
const list = byId('v2TimerList');
if (list) {
list.replaceChildren();
const items = timers.items || [];
if (!items.length) {
const p=document.createElement('p');p.className='muted microtext';
p.textContent=timers.detail || 'Aucun minuteur actif'; list.appendChild(p);
}
items.forEach(item => {
const row=document.createElement('div'); row.className='admin-v2-timer-row';
const name=document.createElement('strong'); name.textContent=item.label || 'Minuteur';
const val=document.createElement('span');
val.textContent=item.state === 'paused' ? 'En pause' :
(item.remaining == null ? duration(item.elapsed || 0) + ' écoulées' : duration(item.remaining) + ' restantes');
row.append(name,val); list.appendChild(row);
});
}
const allowed = Boolean(data.maintenance?.web_restart_enabled);
text('v2RestartLabel', allowed ? 'Autorisé' : 'Désactivé');
pill('v2RestartState', allowed ? 'ok' : 'warning');
};
})();
+5 -1
View File
@@ -78,7 +78,7 @@
serviceStatus($('wakeStatus'), {state:!wake.running?'down':wake.paused?'warning':'ok'});
safeText('wakeLabel', `Vosk · ${wake.word || 'alfred'}`);
safeText('wakeDetail', wake.error || (wake.paused ? 'Détection en pause' : 'Détection active'));
const labels = {alfred:'Alfred / Flask', hermes_cli:'Hermes Agent (CLI)', hermes_dashboard:'Hermes WebUI', comfyui:'ComfyUI', ollama:'Ollama', home_assistant:'Home Assistant', wyoming_piper:'Wyoming Piper'};
const labels = {alfred:'Alfred / Flask', hermes_cli:'Hermes Agent (CLI)', hermes_dashboard:'Hermes WebUI', comfyui:'ComfyUI', ollama:'Ollama', home_assistant:'Home Assistant', wyoming_piper:'Wyoming Piper', wyoming_whisper:'Whisper (STT)', alfred_timers:'Minuteurs Alfred'};
const list = $('serviceList'); list.replaceChildren();
for (const [key,service] of Object.entries(data.services || {})) {
const row = document.createElement('div'); row.className='service-row';
@@ -108,7 +108,11 @@
const p=document.createElement('p');p.textContent=mcp.detail;
card.append(title,status,p);mcps.append(card);
}
if (typeof window.alfredAdminV2Health === 'function') {
window.alfredAdminV2Health(data);
}
}
// ALFRED_ADMIN_SURVEILLANCE_V2: monitoring hook
let inFlight = false;
async function refreshHealth() {
if (inFlight || document.hidden) return;