Added memory limits and system info for memory

This commit is contained in:
2026-02-14 11:44:06 +01:00
parent e0e15867e9
commit 67ba0fe759
12 changed files with 295 additions and 20 deletions
+32
View File
@@ -16,6 +16,7 @@ import (
"gitea.dooplex.hu/admin/felhom-controller/internal/config"
"gitea.dooplex.hu/admin/felhom-controller/internal/stacks"
"gitea.dooplex.hu/admin/felhom-controller/internal/system"
"golang.org/x/crypto/bcrypt"
)
@@ -129,6 +130,34 @@ func (s *Server) loadTemplates() {
"appPageURL": func(slug string) string {
return s.cfg.AppPageURL(slug)
},
"usageColor": func(percent float64) string {
if percent >= 85 {
return "red"
}
if percent >= 70 {
return "yellow"
}
return "green"
},
"fmtMB": func(mb uint64) string {
if mb >= 1024 {
gb := float64(mb) / 1024.0
if gb >= 10 {
return fmt.Sprintf("%.0f GB", gb)
}
return fmt.Sprintf("%.1f GB", gb)
}
return fmt.Sprintf("%d MB", mb)
},
"fmtGB": func(gb float64) string {
if gb >= 100 {
return fmt.Sprintf("%.0f GB", gb)
}
if gb >= 10 {
return fmt.Sprintf("%.1f GB", gb)
}
return fmt.Sprintf("%.2f GB", gb)
},
}
s.tmpl = template.Must(template.New("").Funcs(funcMap).Parse(allTemplates))
@@ -315,11 +344,14 @@ func (s *Server) dashboardHandler(w http.ResponseWriter, _ *http.Request) {
}
}
sysInfo := system.GetInfo(s.cfg.Paths.HDDPath)
data := s.baseData("dashboard", "Vezérlőpult")
data["Stacks"] = stackList
data["RunningCount"] = running
data["StoppedCount"] = stopped
data["TotalCount"] = len(stackList)
data["SystemInfo"] = sysInfo
s.render(w, "dashboard", data)
}