feat: suppression agent, RAM en Go, métriques par défaut (cpu/mem/disk/smart)

- API DELETE /api/agents/{id} — supprime agent + métriques + config + icône
- Bouton poubelle sur chaque tuile + dialog de confirmation
- RAM : affichage "utilisé/total" en Go (ex: 6.2Go/8.0Go) au lieu du %
- Config agent par défaut : cpu, memory, disk, smart activés (UDP)
- DefaultAgentConfig() dans models pour les nouveaux agents

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Gilles Soulier
2026-05-22 19:54:10 +02:00
co-authored by Claude Sonnet 4.6
parent e9524858f5
commit 775d54f07c
10 changed files with 117 additions and 4 deletions
+17
View File
@@ -3,6 +3,7 @@ package handlers
import (
"encoding/json"
"net/http"
"strings"
"github.com/user/nanometrics/server/db"
)
@@ -18,3 +19,19 @@ func AgentsHandler(database *db.DB) http.HandlerFunc {
json.NewEncoder(w).Encode(agents)
}
}
func DeleteAgentHandler(database *db.DB) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
parts := strings.Split(strings.Trim(r.URL.Path, "/"), "/")
if len(parts) < 3 {
http.Error(w, "invalid path", 400)
return
}
agentID := parts[2]
if err := database.DeleteAgent(agentID); err != nil {
http.Error(w, err.Error(), 500)
return
}
w.WriteHeader(http.StatusNoContent)
}
}