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
+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;