290 lines
13 KiB
HTML
290 lines
13 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="fr"><head>
|
|
<meta charset="UTF-8"><title>Blade Razer · Control Center</title>
|
|
<style>
|
|
body{font-family:-apple-system,BlinkMacSystemFont,sans-serif;background:#0a0e27;color:#e4e8f7;margin:0;padding:24px;max-width:1400px;margin:0 auto;padding:24px;line-height:1.5}
|
|
h1{color:#6ba3ff;border-bottom:2px solid #1e3a8a;padding-bottom:8px;margin-top:0}
|
|
h2{color:#c084fc;margin-top:24px}
|
|
.card{background:#141933;border:1px solid #263161;border-radius:8px;padding:16px;margin:12px 0}
|
|
.flex{display:flex;gap:16px;flex-wrap:wrap}.flex>div{flex:1;min-width:180px;text-align:center}
|
|
.num{font-size:28px;font-weight:bold;color:#6ba3ff}
|
|
.lbl{color:#9ca8d3;font-size:12px;text-transform:uppercase}
|
|
.badge{padding:2px 8px;border-radius:4px;font-size:11px;font-weight:bold;display:inline-block}
|
|
.ok{background:#10b981;color:#fff}.warn{background:#f59e0b;color:#111}.ko{background:#ef4444;color:#fff}.info{background:#3b82f6;color:#fff}
|
|
.dot{width:12px;height:12px;border-radius:50%;display:inline-block;margin-right:6px}
|
|
.dot.online{background:#10b981;animation:pulse 2s infinite}
|
|
.dot.offline{background:#ef4444}
|
|
@keyframes pulse{0%,100%{opacity:1}50%{opacity:0.5}}
|
|
table{width:100%;border-collapse:collapse}th,td{padding:8px;border-bottom:1px solid #263161;text-align:left;font-size:13px;vertical-align:top}
|
|
th{background:#1e2549;color:#9ca8d3;font-size:11px;text-transform:uppercase}
|
|
button{background:#1e3a8a;color:#fff;border:0;padding:8px 14px;border-radius:4px;cursor:pointer;font-size:12px;margin-right:4px}
|
|
button:hover{background:#2950a7}button.primary{background:#10b981}button.primary:hover{background:#059669}button.danger{background:#ef4444}
|
|
code{background:#0f1529;padding:2px 6px;border-radius:3px;color:#fbbf24;font-family:Monaco,monospace;font-size:12px}
|
|
pre{background:#000;color:#0f0;padding:12px;border-radius:4px;font-family:Monaco,monospace;font-size:11px;overflow-x:auto;max-height:350px;overflow-y:auto}
|
|
a{color:#6ba3ff}
|
|
.task-row.pending{border-left:3px solid #f59e0b}
|
|
.task-row.dispatched{border-left:3px solid #3b82f6}
|
|
.task-row.done{border-left:3px solid #10b981}
|
|
</style></head>
|
|
<body>
|
|
|
|
<h1>🎮 Blade Razer · Control Center</h1>
|
|
<p>Monitoring + control du Blade (Windows workstation). Heartbeat, task queue, wake status, commande à envoyer.</p>
|
|
|
|
<h2>📊 État live</h2>
|
|
<div class="card">
|
|
<div class="flex">
|
|
<div>
|
|
<div><span class="dot" id="dot">⚫</span><span class="num" id="status-txt">—</span></div>
|
|
<div class="lbl">Status Blade</div>
|
|
</div>
|
|
<div>
|
|
<div class="num" id="last-hb">—</div>
|
|
<div class="lbl">Dernier heartbeat</div>
|
|
</div>
|
|
<div>
|
|
<div class="num" id="pending">—</div>
|
|
<div class="lbl">Tasks pending</div>
|
|
</div>
|
|
<div>
|
|
<div class="num" id="dispatched">—</div>
|
|
<div class="lbl">Dispatched</div>
|
|
</div>
|
|
<div>
|
|
<div class="num" id="done">—</div>
|
|
<div class="lbl">Done</div>
|
|
</div>
|
|
</div>
|
|
<p style="margin-top:12px;color:#9ca8d3" id="blade-meta">—</p>
|
|
</div>
|
|
|
|
<h2>🔄 Actions</h2>
|
|
<div class="card">
|
|
<button class="primary" onclick="refresh()">🔄 Refresh status</button>
|
|
<button onclick="sendTask('Get-Date', 'Test ping')">▶️ Send test task (Get-Date)</button>
|
|
<button onclick="sendTask('Get-Process | Sort-Object CPU -Descending | Select -First 10', 'Top CPU')">📊 Top CPU</button>
|
|
<button onclick="flushDone()">🧹 Flush tasks done > 7j</button>
|
|
<button onclick="toggleAuto()"><span id="auto-lbl">▶️ Auto-refresh 10s</span></button>
|
|
</div>
|
|
|
|
<h2>📋 Task queue</h2>
|
|
<div class="card" id="tasks-container">Chargement…</div>
|
|
|
|
<h2>📜 Blade watchdog log (dernières 20 lignes)</h2>
|
|
<div class="card">
|
|
<pre id="watchdog-log">Chargement…</pre>
|
|
</div>
|
|
|
|
<h2>❓ Si Blade est OFFLINE — Que faire ?</h2>
|
|
<div class="card">
|
|
<p><strong>Cas 1 : Blade éteint physiquement</strong></p>
|
|
<ol>
|
|
<li>Aller sur le Razer Blade</li>
|
|
<li>Power button pression courte (réveil) ou longue (démarrage complet)</li>
|
|
<li>Sentinel agent démarre auto au login Windows</li>
|
|
<li>Heartbeat revient dans 60s max</li>
|
|
</ol>
|
|
|
|
<p><strong>Cas 2 : Blade allumé mais agent cassé</strong></p>
|
|
<ol>
|
|
<li>Admin PowerShell sur le Blade :</li>
|
|
<li><code>cd C:\ProgramData\WEVAL && .\sentinel-agent.ps1</code></li>
|
|
<li>Si erreur, relancer avec <code>Set-ExecutionPolicy Bypass -Scope Process</code></li>
|
|
</ol>
|
|
|
|
<p><strong>Cas 3 : Blade online mais tasks s'accumulent (cas actuel)</strong></p>
|
|
<ol>
|
|
<li>L'agent ne consume pas la queue → vérifier sur Blade que le script poll est bien en boucle</li>
|
|
<li>Tail du log agent : <code>Get-Content C:\ProgramData\WEVAL\agent.log -Tail 20</code></li>
|
|
<li>Restart agent : <code>Stop-Process -Name powershell -Force; .\sentinel-agent.ps1</code></li>
|
|
</ol>
|
|
</div>
|
|
|
|
<h2>🔗 Liens</h2>
|
|
<div class="card">
|
|
<ul>
|
|
<li><a href="/api/blade-status.php?k=BLADE2026" target="_blank">API blade-status</a></li>
|
|
<li><a href="/api/blade-task-queue.php?k=BLADE2026" target="_blank">API blade-task-queue</a></li>
|
|
<li><a href="/api/blade-poll.php?k=BLADE2026&action=poll" target="_blank">API blade-poll (simule agent)</a></li>
|
|
<li><a href="/tasks-live.html">Tasks & Logs Live (autres services)</a></li>
|
|
<li><a href="/wevia-master.html">WEVIA Master (chat)</a></li>
|
|
</ul>
|
|
</div>
|
|
|
|
<script>
|
|
let autoTimer = null;
|
|
let autoActive = false;
|
|
|
|
async function refresh() {
|
|
try {
|
|
const r = await fetch('/api/blade-status.php?k=BLADE2026');
|
|
const d = await r.json();
|
|
const b = d.blade || {};
|
|
const hb = b.heartbeat || {};
|
|
const s = b.stats || {};
|
|
|
|
const online = b.online === true;
|
|
document.getElementById('dot').innerHTML = online ? '<span class="dot online"></span>' : '<span class="dot offline"></span>';
|
|
document.getElementById('status-txt').textContent = online ? 'ONLINE' : 'OFFLINE';
|
|
document.getElementById('status-txt').style.color = online ? '#10b981' : '#ef4444';
|
|
|
|
if (hb.ts) {
|
|
const d2 = new Date(hb.ts);
|
|
const ago = Math.round((Date.now() - d2.getTime()) / 1000);
|
|
document.getElementById('last-hb').textContent = ago < 60 ? ago + 's' : ago < 3600 ? Math.round(ago/60) + 'min' : Math.round(ago/3600) + 'h';
|
|
}
|
|
document.getElementById('pending').textContent = s.pending || 0;
|
|
document.getElementById('dispatched').textContent = s.dispatched || 0;
|
|
document.getElementById('done').textContent = s.done || 0;
|
|
|
|
document.getElementById('blade-meta').innerHTML =
|
|
`Hostname: <strong>${hb.hostname || '?'}</strong> · IP: <strong>${hb.ip || '?'}</strong> · Agent: <strong>${hb.agent_version || '?'}</strong> · ts: <strong>${hb.ts || '—'}</strong>`;
|
|
|
|
// Load tasks
|
|
loadTasks();
|
|
} catch(e) {
|
|
document.getElementById('status-txt').textContent = 'ERROR';
|
|
document.getElementById('status-txt').style.color = '#ef4444';
|
|
}
|
|
}
|
|
|
|
async function loadTasks() {
|
|
try {
|
|
const r = await fetch('/api/blade-task-queue.php?k=BLADE2026');
|
|
const d = await r.json();
|
|
const tasks = d.tasks || [];
|
|
const tc = document.getElementById('tasks-container');
|
|
if (!tasks.length) {
|
|
tc.innerHTML = '<p style="color:#9ca8d3">Aucune tâche.</p>';
|
|
return;
|
|
}
|
|
tc.innerHTML = '<table><tr><th>Status</th><th>Name</th><th>Type</th><th>Created</th><th>Command (extrait)</th></tr>' +
|
|
tasks.slice(0, 30).map(t => `<tr class="task-row ${t.status}">
|
|
<td><span class="badge ${t.status === 'pending' ? 'warn' : t.status === 'done' ? 'ok' : 'info'}">${t.status}</span></td>
|
|
<td>${escapeHtml(t.name || '?')}</td>
|
|
<td>${escapeHtml(t.type || 'ps')}</td>
|
|
<td style="color:#9ca8d3;font-size:11px">${(t.created || '').slice(0, 16).replace('T', ' ')}</td>
|
|
<td><code>${escapeHtml((t.command || t.cmd || '').slice(0, 80))}...</code></td>
|
|
</tr>`).join('') + '</table>';
|
|
} catch(e) {
|
|
document.getElementById('tasks-container').innerHTML = 'Error loading tasks: ' + e.message;
|
|
}
|
|
|
|
// Load watchdog log
|
|
fetch('/api/tasks-live-api.php?action=tail&file=blade-watchdog.log&n=20').then(r => r.json()).then(d => {
|
|
document.getElementById('watchdog-log').textContent = d.content || '(log vide)';
|
|
}).catch(e => {
|
|
document.getElementById('watchdog-log').textContent = 'Log non accessible: ' + e.message;
|
|
});
|
|
}
|
|
|
|
async function sendTask(cmd, name) {
|
|
if (!confirm(`Envoyer la commande au Blade ?\n\n${cmd}`)) return;
|
|
try {
|
|
const fd = new FormData();
|
|
fd.append('k', 'BLADE2026');
|
|
fd.append('name', name);
|
|
fd.append('cmd', cmd);
|
|
fd.append('type', 'powershell');
|
|
const r = await fetch('/api/blade-task-queue.php?k=BLADE2026&action=add', {method:'POST', body: fd});
|
|
const d = await r.json();
|
|
alert('Task submitted: ' + JSON.stringify(d).slice(0, 200));
|
|
refresh();
|
|
} catch(e) {
|
|
alert('Error: ' + e.message);
|
|
}
|
|
}
|
|
|
|
async function flushDone() {
|
|
if (!confirm('Flush les tâches "done" de plus de 7 jours ?')) return;
|
|
try {
|
|
const r = await fetch('/api/blade-task-queue.php?k=BLADE2026&action=flush&older_days=7');
|
|
const d = await r.json();
|
|
alert('Flush result: ' + JSON.stringify(d));
|
|
refresh();
|
|
} catch(e) {
|
|
alert('Error: ' + e.message);
|
|
}
|
|
}
|
|
|
|
function toggleAuto() {
|
|
autoActive = !autoActive;
|
|
document.getElementById('auto-lbl').textContent = autoActive ? '⏸️ Auto 10s ON' : '▶️ Auto-refresh 10s';
|
|
if (autoActive) autoTimer = setInterval(refresh, 10000);
|
|
else clearInterval(autoTimer);
|
|
}
|
|
|
|
function escapeHtml(s) {
|
|
return (s || '').toString().replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>');
|
|
}
|
|
|
|
refresh();
|
|
</script>
|
|
|
|
<!-- === OPUS UNIVERSAL DRILL-DOWN v1 19avr — append-only, doctrine #14 === -->
|
|
<script>
|
|
(function(){
|
|
if (window.__opusUniversalDrill) return; window.__opusUniversalDrill = true;
|
|
var d = document;
|
|
var m = d.createElement('div');
|
|
m.id = 'opus-udrill';
|
|
m.style.cssText = 'position:fixed;inset:0;background:rgba(0,0,0,0.82);backdrop-filter:blur(6px);display:none;align-items:center;justify-content:center;z-index:99995;padding:20px;cursor:pointer';
|
|
var inner = d.createElement('div');
|
|
inner.id = 'opus-udrill-in';
|
|
inner.style.cssText = 'max-width:900px;width:100%;max-height:90vh;overflow:auto;background:#0b0d15;border:1px solid rgba(99,102,241,0.35);border-radius:14px;padding:28px;cursor:default;box-shadow:0 20px 60px rgba(0,0,0,0.6);color:#e2e8f0;font:14px/1.55 Inter,system-ui,sans-serif';
|
|
inner.addEventListener('click', function(e){ e.stopPropagation(); });
|
|
m.appendChild(inner);
|
|
m.addEventListener('click', function(){ m.style.display='none'; });
|
|
d.addEventListener('keydown', function(e){ if(e.key==='Escape') m.style.display='none'; });
|
|
(d.body || d.documentElement).appendChild(m);
|
|
|
|
function openCard(card) {
|
|
// Clone card content + show close btn + increase font-size
|
|
var html = '<div style="display:flex;justify-content:flex-end;margin-bottom:14px"><button id="opus-udrill-close" style="padding:6px 14px;background:#171b2a;border:1px solid rgba(99,102,241,0.25);color:#e2e8f0;border-radius:8px;cursor:pointer;font-size:12px">✕ Fermer (Esc)</button></div>';
|
|
html += '<div style="transform-origin:top left;font-size:1.05em">' + card.outerHTML + '</div>';
|
|
inner.innerHTML = html;
|
|
d.getElementById('opus-udrill-close').onclick = function(){ m.style.display='none'; };
|
|
m.style.display = 'flex';
|
|
}
|
|
|
|
function wire(root) {
|
|
var sels = '.card,[class*="card"],.kpi,[class*="kpi"],.stat,[class*="stat"],.tile,[class*="tile"],.metric,[class*="metric"],.widget,[class*="widget"]';
|
|
var cards = root.querySelectorAll(sels);
|
|
for (var i = 0; i < cards.length; i++) {
|
|
var c = cards[i];
|
|
if (c.__opusWired) continue;
|
|
if (c.closest('button, a, input, select, textarea, #opus-udrill')) continue;
|
|
var r = c.getBoundingClientRect();
|
|
if (r.width < 60 || r.height < 40) continue;
|
|
c.__opusWired = true;
|
|
c.style.cursor = 'pointer';
|
|
c.setAttribute('role','button');
|
|
c.setAttribute('tabindex','0');
|
|
c.addEventListener('click', function(ev){
|
|
// If a more-specific drill is already active (e.g. pp-card custom), let it handle
|
|
if (ev.target.closest('[data-pp-id]') && window.__opusDrillInit) return;
|
|
if (ev.target.closest('a,button,input,select')) return;
|
|
ev.preventDefault(); ev.stopPropagation();
|
|
openCard(this);
|
|
});
|
|
c.addEventListener('keydown', function(ev){ if(ev.key==='Enter'||ev.key===' '){ev.preventDefault();openCard(this);} });
|
|
}
|
|
}
|
|
|
|
// Initial + mutation observer
|
|
var initRun = function(){ wire(d.body || d.documentElement); };
|
|
if (d.readyState === 'loading') d.addEventListener('DOMContentLoaded', initRun);
|
|
else initRun();
|
|
var mo = new MutationObserver(function(muts){
|
|
var newCard = false;
|
|
for (var i=0;i<muts.length;i++) if (muts[i].addedNodes.length) { newCard = true; break; }
|
|
if (newCard) initRun();
|
|
});
|
|
mo.observe(d.body || d.documentElement, {childList:true, subtree:true});
|
|
})();
|
|
</script>
|
|
<!-- === OPUS UNIVERSAL DRILL-DOWN END === -->
|
|
|
|
<script src="/api/archi-meta-badge.js" defer></script>
|
|
</body></html>
|