From c3383ca246061cc8764b91b1190bb0c80a8715da Mon Sep 17 00:00:00 2001 From: Opus-Yacine Date: Fri, 17 Apr 2026 14:17:16 +0200 Subject: [PATCH] =?UTF-8?q?BLADE=20control=20center:=20blade-control.html?= =?UTF-8?q?=20UI=20live=20status+tasks+watchdog+actions=20=C2=B7=202=20nou?= =?UTF-8?q?veaux=20endpoints=20blade-task-queue=20(add=20+=20flush=20avec?= =?UTF-8?q?=20archive=20doctrine=2059=20no-delete)=20=C2=B7=20Blade=20onli?= =?UTF-8?q?ne=20avec=20heartbeat=20+=2036=20tasks=20pending=20identifies?= =?UTF-8?q?=20=C2=B7=20pages=20liens=20vers=20tasks-live?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/blade-task-queue.php | 51 +++++++++ blade-control.html | 223 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 274 insertions(+) create mode 100644 blade-control.html diff --git a/api/blade-task-queue.php b/api/blade-task-queue.php index 5025b78d5..adfa5ccb8 100644 --- a/api/blade-task-queue.php +++ b/api/blade-task-queue.php @@ -35,6 +35,57 @@ switch ($action) { } break; + + case "flush": + $older_days = max(1, intval($_GET["older_days"] ?? $_POST["older_days"] ?? 7)); + $cutoff = time() - ($older_days * 86400); + $archived = 0; $kept = 0; + $archive_dir = $queue_dir . "archived_" . date("Y-m-d") . "/"; + @mkdir($archive_dir, 0777, true); + foreach (glob($queue_dir . "*.json") as $ff) { + $t = @json_decode(@file_get_contents($ff), true); + if (!$t) continue; + if (($t["status"] ?? "") === "done" || ($t["status"] ?? "") === "completed") { + $t_time = strtotime($t["completed_at"] ?? $t["created_at"] ?? ""); + if ($t_time > 0 && $t_time < $cutoff) { + // MOVE to archive, not delete (doctrine 59 NO-DELETE) + @rename($ff, $archive_dir . basename($ff)); + $archived++; + } else { $kept++; } + } + } + echo json_encode([ + "ok" => true, + "action" => "flush", + "older_days" => $older_days, + "archived" => $archived, + "kept" => $kept, + "archive_dir" => $archive_dir, + "note" => "done tasks moved to archive (not deleted, doctrine 59)" + ]); + break; + + case "add": + $id = "task_" . date("YmdHis") . "_" . substr(md5(rand()), 0, 6); + $task = [ + "id" => $id, + "name" => $_POST["name"] ?? $_GET["name"] ?? "Unnamed", + "type" => $_POST["type"] ?? $_GET["type"] ?? "powershell", + "command" => $_POST["cmd"] ?? $_POST["command"] ?? $_GET["cmd"] ?? "", + "cmd" => $_POST["cmd"] ?? $_POST["command"] ?? $_GET["cmd"] ?? "", + "priority" => $_POST["priority"] ?? "normal", + "status" => "pending", + "created" => date("c"), + "created_by" => "blade-control-ui" + ]; + if (!$task["command"]) { + echo json_encode(["error" => "cmd required"]); + break; + } + file_put_contents($queue_dir . $id . ".json", json_encode($task, JSON_PRETTY_PRINT)); + echo json_encode(["ok" => true, "task_id" => $id, "task" => $task]); + break; + case "create": $id = "task_" . date("YmdHis") . "_" . substr(md5(rand()), 0, 6); $task = [ diff --git a/blade-control.html b/blade-control.html new file mode 100644 index 000000000..2e6263842 --- /dev/null +++ b/blade-control.html @@ -0,0 +1,223 @@ + + +Blade Razer · Control Center + + + +

🎮 Blade Razer · Control Center

+

Monitoring + control du Blade (Windows workstation). Heartbeat, task queue, wake status, commande à envoyer.

+ +

📊 État live

+
+
+
+
+
Status Blade
+
+
+
+
Dernier heartbeat
+
+
+
+
Tasks pending
+
+
+
+
Dispatched
+
+
+
+
Done
+
+
+

+
+ +

🔄 Actions

+
+ + + + + +
+ +

📋 Task queue

+
Chargement…
+ +

📜 Blade watchdog log (dernières 20 lignes)

+
+
Chargement…
+
+ +

❓ Si Blade est OFFLINE — Que faire ?

+
+

Cas 1 : Blade éteint physiquement

+
    +
  1. Aller sur le Razer Blade
  2. +
  3. Power button pression courte (réveil) ou longue (démarrage complet)
  4. +
  5. Sentinel agent démarre auto au login Windows
  6. +
  7. Heartbeat revient dans 60s max
  8. +
+ +

Cas 2 : Blade allumé mais agent cassé

+
    +
  1. Admin PowerShell sur le Blade :
  2. +
  3. cd C:\ProgramData\WEVAL && .\sentinel-agent.ps1
  4. +
  5. Si erreur, relancer avec Set-ExecutionPolicy Bypass -Scope Process
  6. +
+ +

Cas 3 : Blade online mais tasks s'accumulent (cas actuel)

+
    +
  1. L'agent ne consume pas la queue → vérifier sur Blade que le script poll est bien en boucle
  2. +
  3. Tail du log agent : Get-Content C:\ProgramData\WEVAL\agent.log -Tail 20
  4. +
  5. Restart agent : Stop-Process -Name powershell -Force; .\sentinel-agent.ps1
  6. +
+
+ +

🔗 Liens

+
+ +
+ + +