monitoring page: storage labels follow the reader's language (W26, rehearsal 2026-10-20); unreleased
gates / gates (push) Successful in 1m11s
gates / gates (push) Successful in 1m11s
This commit is contained in:
@@ -38,9 +38,11 @@ func (s *Server) ServeHostMetricsAPI(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
// The agent enumerates storages via `pvesm` in a non-deterministic order, so #host-storage-bars
|
||||
// reordered on every poll (item 2). Stabilise the order Go-side and attach friendly Hungarian
|
||||
// labels + a one-line purpose per entry — display-only; we NEVER rename the PVE storage ids.
|
||||
enrichHostStorageTargets(resp.StorageTargets)
|
||||
// reordered on every poll (item 2). Stabilise the order Go-side and attach friendly labels + a
|
||||
// one-line purpose per entry in the reader's language (W26, rehearsal 2026-10-20: they were
|
||||
// Hungarian on the English dashboard) — display-only; we NEVER rename the PVE storage ids.
|
||||
lang := s.langFor(r)
|
||||
enrichHostStorageTargets(resp.StorageTargets, func(key string) string { return s.msgLang(lang, key) })
|
||||
writeDiskJSON(w, http.StatusOK, true, "", resp)
|
||||
}
|
||||
|
||||
@@ -48,7 +50,8 @@ func (s *Server) ServeHostMetricsAPI(w http.ResponseWriter, r *http.Request) {
|
||||
// order (user-data → system+apps → backup → other; alphabetical by id within a tier) and fills in
|
||||
// a friendly label + purpose per entry. Mirrors the disk-overview's sortDisksForView contract:
|
||||
// a Go-side ordering beats relying on the agent's enumeration order or template JS.
|
||||
func enrichHostStorageTargets(targets []agentapi.StorageTarget) {
|
||||
// msg turns a message key into the reader's text.
|
||||
func enrichHostStorageTargets(targets []agentapi.StorageTarget, msg func(key string) string) {
|
||||
sort.SliceStable(targets, func(i, j int) bool {
|
||||
if ri, rj := storageTypeRank(targets[i].Type), storageTypeRank(targets[j].Type); ri != rj {
|
||||
return ri < rj
|
||||
@@ -56,7 +59,7 @@ func enrichHostStorageTargets(targets []agentapi.StorageTarget) {
|
||||
return targets[i].Name < targets[j].Name
|
||||
})
|
||||
for i := range targets {
|
||||
label, purpose := storageLabelAndPurpose(targets[i])
|
||||
label, purpose := storageLabelAndPurpose(targets[i], msg)
|
||||
targets[i].Label = label
|
||||
targets[i].Purpose = purpose
|
||||
}
|
||||
@@ -79,24 +82,24 @@ func storageTypeRank(typ string) int {
|
||||
}
|
||||
}
|
||||
|
||||
// storageLabelAndPurpose maps a storage target to a friendly Hungarian label + one-line purpose.
|
||||
// Falls back to the raw id for unrecognised types. The raw id stays in Name (rendered muted).
|
||||
func storageLabelAndPurpose(t agentapi.StorageTarget) (string, string) {
|
||||
// storageLabelAndPurpose maps a storage target to a friendly label + one-line purpose (message keys
|
||||
// host_storage.*). Falls back to the raw id for unrecognised types. The raw id stays in Name (rendered muted).
|
||||
func storageLabelAndPurpose(t agentapi.StorageTarget, msg func(key string) string) (string, string) {
|
||||
switch t.Type {
|
||||
case "usb":
|
||||
return "Külső adattároló (USB)", "Az alkalmazások adatai (fájlok, médiatár) ezen a meghajtón vannak."
|
||||
return msg("host_storage.usb.label"), msg("host_storage.userdata.purpose")
|
||||
case "local-dir":
|
||||
return "Külső adattároló", "Az alkalmazások adatai (fájlok, médiatár) ezen a meghajtón vannak."
|
||||
return msg("host_storage.local_dir.label"), msg("host_storage.userdata.purpose")
|
||||
case "lvmthin", "lvm":
|
||||
return "Belső SSD – rendszer és alkalmazások", "Az operációs rendszer és a telepített alkalmazások tárhelye."
|
||||
return msg("host_storage.system.label"), msg("host_storage.system.purpose")
|
||||
case "local":
|
||||
return "Belső lemez – sablonok és helyi mentések", "Rendszersablonok és helyi biztonsági mentések."
|
||||
return msg("host_storage.local.label"), msg("host_storage.local.purpose")
|
||||
case "pbs":
|
||||
return "Távoli biztonsági mentés", "Titkosított, telephelyen kívüli biztonsági mentések."
|
||||
return msg("host_storage.pbs.label"), msg("host_storage.pbs.purpose")
|
||||
case "nfs":
|
||||
return "Hálózati mentés (NFS)", "Hálózati tárolón őrzött biztonsági mentések."
|
||||
return msg("host_storage.nfs.label"), msg("host_storage.network.purpose")
|
||||
case "cifs":
|
||||
return "Hálózati mentés (SMB)", "Hálózati tárolón őrzött biztonsági mentések."
|
||||
return msg("host_storage.cifs.label"), msg("host_storage.network.purpose")
|
||||
default:
|
||||
return t.Name, ""
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user