feat: one-page panel - shell with Машины, Терминал and Настройки, pages as fragments, forms sent in place

This commit is contained in:
redtea committed 2026-10-15 20:05:20 +03:00
1 parent 7b9daa524e
commit 113c63fd1b
17 files changed
+678 -432

No files matched your search

+10 -9
View File
@@ -112,11 +112,12 @@ func (s *Server) handleLogout(w http.ResponseWriter, r *http.Request) {
// --- dashboard ---
func (s *Server) handleDashboard(w http.ResponseWriter, r *http.Request) {
agents, err := s.db.ListAgents()
if err != nil {
http.Error(w, "internal error", http.StatusInternalServerError)
return
}
s.renderPage(w, r, "dashboard", s.dashboardData(r))
}
// dashboardData is the machines list as the user may see it.
func (s *Server) dashboardData(r *http.Request) map[string]any {
agents, _ := s.db.ListAgents()
type row struct {
Agent
Online bool
@@ -131,12 +132,12 @@ func (s *Server) handleDashboard(w http.ResponseWriter, r *http.Request) {
on := s.online(&a)
rows = append(rows, row{Agent: a, Online: on, Seen: seenText(on, a.LastSeen)})
}
s.render(w, "dashboard.html", map[string]any{
return map[string]any{
"Admin": me,
"IsAdmin": me.IsAdmin(),
"Agents": rows,
"CSRF": csrfToken(r),
})
}
}
// seenText is the "activity" cell: a connected agent is active now, whatever
@@ -239,7 +240,7 @@ func (s *Server) handleAgentEdit(w http.ResponseWriter, r *http.Request) {
data["UsersErr"] = err.Error()
}
}
s.render(w, "edit.html", data)
s.renderPage(w, r, "edit", data)
}
// POST /agents/{id}/transport - how the agent is to reach the server: auto,
@@ -434,7 +435,7 @@ func (s *Server) handleSettings(w http.ResponseWriter, r *http.Request) {
code := s.db.InstallCode()
ufwInstalled, ufwActive, ufwRunnable := s.ufw.status()
ufwRules, _ := s.db.ListUfwRules()
s.render(w, "settings.html", map[string]any{
s.renderPage(w, r, "settings", map[string]any{
"Admin": s.currentAdmin(r),
"Host": host,
"Direct": direct,