controller v0.45.0: storage UX polish — deterministic order, init filter, register shortcut, system-storage clarity
B1 sort /api/disks (user-data→system→backup, alpha within); B2 init wizard excludes mounted drives; B3 Regisztrálás primary action for mounted-unregistered user-data drives (POST /api/storage/register); B4 per-card purpose descriptions + app-backing tags + tiering note (local & local-lvm both kept); B5 eject already names affected apps. Pairs with felhom-agent v0.24.0 eject role-gate. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"net/http"
|
||||
"sort"
|
||||
|
||||
"gitea.dooplex.hu/admin/felhom-controller/internal/agentapi"
|
||||
)
|
||||
@@ -73,9 +74,39 @@ func (s *Server) agentDisksListHandler(w http.ResponseWriter, r *http.Request) {
|
||||
writeDiskJSON(w, http.StatusBadGateway, false, err.Error(), nil)
|
||||
return
|
||||
}
|
||||
// Deterministic order: the agent's storage view iterates a Go map (unordered), so the list would
|
||||
// otherwise reorder on every reload (CLAUDE.md lesson #3). The customer's manageable drives go on
|
||||
// top, in a stable order: user-data first, then system, then backup, alpha by name within a tier.
|
||||
sortDisksForView(resp.Disks)
|
||||
writeDiskJSON(w, http.StatusOK, true, "", resp)
|
||||
}
|
||||
|
||||
// sortDisksForView orders the agent's disk list deterministically (user-data → system → backup →
|
||||
// unrecognized; alphabetical by storage name within each tier). A stable Go-side contract beats
|
||||
// relying on map iteration order or template JS alone.
|
||||
func sortDisksForView(disks []agentapi.DiskInfo) {
|
||||
sort.SliceStable(disks, func(i, j int) bool {
|
||||
if ri, rj := diskRoleRank(disks[i].Role), diskRoleRank(disks[j].Role); ri != rj {
|
||||
return ri < rj
|
||||
}
|
||||
return disks[i].Name < disks[j].Name
|
||||
})
|
||||
}
|
||||
|
||||
// diskRoleRank ranks a role for the overview ordering (lower sorts first).
|
||||
func diskRoleRank(role string) int {
|
||||
switch role {
|
||||
case "user-data":
|
||||
return 0
|
||||
case "system":
|
||||
return 1
|
||||
case "backup":
|
||||
return 2
|
||||
default:
|
||||
return 3
|
||||
}
|
||||
}
|
||||
|
||||
// agentDiskAssignHandler proxies POST /api/disks/assign → agent POST /disks/assign.
|
||||
func (s *Server) agentDiskAssignHandler(w http.ResponseWriter, r *http.Request) {
|
||||
var req struct {
|
||||
|
||||
Reference in New Issue
Block a user