Wire all dashboard buttons: auth downloads, get_log feedback, action tests.

This commit is contained in:
drjones
2026-05-28 19:56:11 -07:00
parent 9e26c4babb
commit fda72041f0
8 changed files with 143 additions and 8 deletions

View File

@@ -4,6 +4,7 @@ import (
"encoding/json"
"net/http"
"strconv"
"time"
"crypto-miner-server/internal/alerts"
"crypto-miner-server/internal/db"
@@ -67,12 +68,20 @@ func (f *FleetHandler) GetAgentLog(w http.ResponseWriter, r *http.Request) {
http.Error(w, "websocket hub unavailable", http.StatusServiceUnavailable)
return
}
content := f.ws.GetAgentLog(id)
if r.URL.Query().Get("refresh") == "1" {
_ = f.ws.SendAgentCommand(id, "get_log", map[string]interface{}{"tail_lines": 300})
for i := 0; i < 12; i++ {
time.Sleep(150 * time.Millisecond)
if c := f.ws.GetAgentLog(id); c != "" {
content = c
break
}
}
}
writeJSON(w, map[string]interface{}{
"agent_id": id,
"content": f.ws.GetAgentLog(id),
"content": content,
})
}