feat: dashboard dynamique + RAM min/max dans popup

- Grid: nouvel agent ajouté en temps réel dès le 1er paquet WebSocket (plus besoin d'actualiser la page)
- Grid: ip/status mis à jour depuis chaque metrics_update (adresse DHCP fraîche)
- WS: diffuse agent_removed lors de la suppression d'un agent (sync multi-onglets)
- Popup détail: min/max RAM sur la période affichée (calculé depuis l'historique déjà chargé)
- CSS: classe .chart-minmax pour l'affichage min/max sous le graphe

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Gilles Soulier
2026-05-22 22:53:05 +02:00
parent a2060a1713
commit 22b429f247
6 changed files with 37 additions and 4 deletions
+3 -1
View File
@@ -6,6 +6,7 @@ import (
"strings"
"github.com/user/nanometrics/server/db"
"github.com/user/nanometrics/server/models"
)
func AgentsHandler(database *db.DB) http.HandlerFunc {
@@ -23,7 +24,7 @@ func AgentsHandler(database *db.DB) http.HandlerFunc {
}
}
func DeleteAgentHandler(database *db.DB) http.HandlerFunc {
func DeleteAgentHandler(database *db.DB, broadcast func(interface{})) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
parts := strings.Split(strings.Trim(r.URL.Path, "/"), "/")
if len(parts) < 3 {
@@ -35,6 +36,7 @@ func DeleteAgentHandler(database *db.DB) http.HandlerFunc {
http.Error(w, err.Error(), 500)
return
}
broadcast(models.WSMessage{Type: "agent_removed", AgentID: agentID})
w.WriteHeader(http.StatusNoContent)
}
}
+1 -1
View File
@@ -111,7 +111,7 @@ func main() {
case endsWith(r.URL.Path, "/icon") && r.Method == http.MethodGet:
handlers.IconGetHandler(database)(w, r)
case r.Method == http.MethodDelete:
handlers.DeleteAgentHandler(database)(w, r)
handlers.DeleteAgentHandler(database, hub.Broadcast)(w, r)
default:
http.NotFound(w, r)
}