Bump version to 1.0.11
Machine status probe on page load: - POST /api/machines/refresh probes all machines in parallel (max 20 concurrent, 1.5s timeout) - Updates DB status and broadcasts via SSE to all connected browser tabs - Server-side throttle: ignores refresh requests within 10s - Machines.tsx and Dashboard.tsx fire probe on mount - Visual "Checking machine status..." indicator in Machines table - MachineHandler now accepts *Engine for ProbeAllMachines access
This commit is contained in:
@@ -10,15 +10,17 @@ import (
|
||||
|
||||
"github.com/go-chi/chi/v5"
|
||||
"github.com/syncserver/internal/models"
|
||||
"github.com/syncserver/internal/syncengine"
|
||||
"github.com/syncserver/internal/wol"
|
||||
)
|
||||
|
||||
type MachineHandler struct {
|
||||
db *sql.DB
|
||||
db *sql.DB
|
||||
engine *syncengine.Engine
|
||||
}
|
||||
|
||||
func NewMachineHandler(db *sql.DB) *MachineHandler {
|
||||
return &MachineHandler{db: db}
|
||||
func NewMachineHandler(db *sql.DB, engine *syncengine.Engine) *MachineHandler {
|
||||
return &MachineHandler{db: db, engine: engine}
|
||||
}
|
||||
|
||||
var macRegex = regexp.MustCompile(`^([0-9A-Fa-f]{2}[:-]){5}[0-9A-Fa-f]{2}$`)
|
||||
@@ -209,6 +211,16 @@ func (h *MachineHandler) TestWoL(w http.ResponseWriter, r *http.Request) {
|
||||
writeJSON(w, map[string]interface{}{"ok": true, "sent": 3})
|
||||
}
|
||||
|
||||
func (h *MachineHandler) Refresh(w http.ResponseWriter, r *http.Request) {
|
||||
if h.engine == nil {
|
||||
writeError(w, http.StatusInternalServerError, "engine not available")
|
||||
return
|
||||
}
|
||||
go h.engine.ProbeAllMachines()
|
||||
w.WriteHeader(http.StatusAccepted)
|
||||
writeJSON(w, map[string]string{"status": "probing"})
|
||||
}
|
||||
|
||||
func (h *MachineHandler) Delete(w http.ResponseWriter, r *http.Request) {
|
||||
id, err := strconv.ParseInt(chi.URLParam(r, "id"), 10, 64)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user