Files
cloud-ip-validator/internal/dashboard/routes.go
T
ayurishchevandClaude Sonnet 5 ec44d54ac1 Add bulk recheck and auto-refresh to the IPs dashboard page
"Перепроверить выбранные" joins the existing "Удалить выбранные" / "Очистить
всё" bulk actions, using the checked-row selection the same way delete
already does — no control-api changes needed, since forcing a recheck of a
batch of addresses (new, finished, or already-queued, skipping anything
mid-check) is exactly what POST /api/v1/admin/ips (db.SubmitIPs) already
does, and the dashboard's own SubmitIPs client method already backs both
the top add/recheck form and the single-row recheck button.

The page also now auto-refreshes every 5s (handleIPsFragment + GET
/ips/fragment), mirroring the overview page's existing hx-trigger="every
Ns" polling and reusing the same config-driven interval
(Cfg.OverviewPollIntervalS) rather than adding a duplicate knob. Since the
table now polls itself, each row's selection checkbox gets a stable id
plus hx-preserve so a checked box survives the refresh (its own DOM node
is kept) while the rest of the row still updates live.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-18 18:47:11 +03:00

52 lines
2.1 KiB
Go

package dashboard
import "net/http"
func (s *Server) routes(mux *http.ServeMux) {
mux.HandleFunc("GET /{$}", s.handleIndex)
mux.HandleFunc("GET /overview", s.handleOverview)
mux.HandleFunc("GET /overview/fragment", s.handleOverviewFragment)
mux.HandleFunc("GET /ips", s.handleIPsPage)
mux.HandleFunc("GET /ips/fragment", s.handleIPsFragment)
mux.HandleFunc("GET /ips/{ip}", s.handleIPDetail)
mux.HandleFunc("POST /ips", s.handleIPsSubmit)
mux.HandleFunc("POST /ips/{ip}/recheck", s.handleIPRecheck)
mux.HandleFunc("POST /ips/{ip}/cancel", s.handleIPCancel)
mux.HandleFunc("DELETE /ips/{ip}", s.handleIPDelete)
mux.HandleFunc("POST /ips/delete", s.handleIPsDeleteSelected)
mux.HandleFunc("POST /ips/recheck", s.handleIPsRecheckSelected)
mux.HandleFunc("POST /ips/clear", s.handleIPsClear)
mux.HandleFunc("GET /validators", s.handleValidatorsPage)
mux.HandleFunc("POST /validators", s.handleValidatorCreate)
mux.HandleFunc("PUT /validators/{id}", s.handleValidatorUpdate)
mux.HandleFunc("DELETE /validators/{id}", s.handleValidatorDelete)
mux.HandleFunc("GET /sites", s.handleSitesPage)
mux.HandleFunc("POST /sites", s.handleSiteCreate)
mux.HandleFunc("PUT /sites/{index}", s.handleSitePut)
mux.HandleFunc("DELETE /sites/{index}", s.handleSiteDelete)
mux.HandleFunc("GET /targets", s.handleTargetsPage)
mux.HandleFunc("POST /targets", s.handleTargetCreate)
mux.HandleFunc("PUT /targets/{group}", s.handleTargetUpdate)
mux.HandleFunc("DELETE /targets/{group}", s.handleTargetDelete)
mux.HandleFunc("GET /check-types", s.handleCheckTypesPage)
mux.HandleFunc("POST /check-types", s.handleCheckTypeCreate)
mux.HandleFunc("PUT /check-types/{name}", s.handleCheckTypeUpdate)
mux.HandleFunc("DELETE /check-types/{name}", s.handleCheckTypeDelete)
mux.HandleFunc("GET /settings", s.handleSettingsPage)
mux.HandleFunc("PUT /settings", s.handleSettingsPut)
mux.HandleFunc("PUT /settings/inbound-checks", s.handleInboundChecksPut)
mux.Handle("GET /static/", http.StripPrefix("/static/", http.FileServerFS(staticSubFS())))
}
func (s *Server) handleIndex(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, "/overview", http.StatusFound)
}