diff --git a/app/common/utils.go b/app/common/utils.go index 7b5a775..6f260c6 100644 --- a/app/common/utils.go +++ b/app/common/utils.go @@ -244,7 +244,7 @@ func ExtractVMPath(c *gin.Context) (VMPath, error) { return vm_path, nil } -func FormatNumber(val int64, base int64) (float64, string) { +func FormatNumber(val int64, base int64) (string, string) { valf := float64(val) basef := float64(base) steps := 0 @@ -255,13 +255,19 @@ func FormatNumber(val int64, base int64) (float64, string) { switch base { case 1000: + s := fmt.Sprintf("%.4f", valf) + s = strings.TrimRight(s, "0") + s = strings.TrimRight(s, ".") prefixes := []string{"", "K", "M", "G", "T"} - return valf, prefixes[steps] + return s, prefixes[steps] case 1024: + s := fmt.Sprintf("%.4f", valf) + s = strings.TrimRight(s, "0") + s = strings.TrimRight(s, ".") prefixes := []string{"", "Ki", "Mi", "Gi", "Ti"} - return valf, prefixes[steps] + return s, prefixes[steps] default: - return 0, "" + return "0", "" } } diff --git a/app/routes/account.go b/app/routes/account.go index f024c23..9f3e986 100644 --- a/app/routes/account.go +++ b/app/routes/account.go @@ -77,7 +77,7 @@ type ResourceChart struct { Name string Used int64 Max int64 - Avail float64 + Avail string Prefix string Unit string ColorHex string @@ -149,13 +149,14 @@ func HandleGETAccount(c *gin.Context) { } for _, r := range t.Total { + avail := fmt.Sprintf("%d", r.Avail) l.Resources = append(l.Resources, ResourceChart{ Type: t.Type, Display: t.Display, Name: r.Name, Used: r.Used, Max: r.Max, - Avail: float64(r.Avail), // usually an int + Avail: avail, // usually an int Unit: "", ColorHex: InterpolateColorHSV(Green, Red, float64(r.Used)/float64(r.Max)).ToHTML(), }) diff --git a/web/css/nav.css b/web/css/nav.css index 4de6013..155beb3 100644 --- a/web/css/nav.css +++ b/web/css/nav.css @@ -80,7 +80,7 @@ label[for="navtoggle"], #navtoggle { display: none; } -@media screen and (width >= 600px){ +@media screen and (width >= 601px){ header { grid-template-columns: auto 1fr; } @@ -106,7 +106,7 @@ label[for="navtoggle"], #navtoggle { } } -@media screen and (width <= 600px){ +@media screen and (width <= 601px){ header { grid-template-columns: 1fr auto; } diff --git a/web/html/account.html b/web/html/account.html index d15c14c..5b26aa0 100644 --- a/web/html/account.html +++ b/web/html/account.html @@ -34,9 +34,7 @@
-