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 @@ -
- {{template "header" .}} -
+ {{template "header" .}}

Account

diff --git a/web/html/backups.html b/web/html/backups.html index 260766d..e98660f 100644 --- a/web/html/backups.html +++ b/web/html/backups.html @@ -9,9 +9,7 @@ -
- {{template "header" .}} -
+ {{template "header" .}}

Instances / {{.config.Name}} / Backups

diff --git a/web/html/config.html b/web/html/config.html index c776cf5..b627317 100644 --- a/web/html/config.html +++ b/web/html/config.html @@ -19,9 +19,7 @@ -
- {{template "header" .}} -
+ {{template "header" .}}

Instances / {{.config.Name}} / Config

diff --git a/web/html/index.html b/web/html/index.html index 541b55a..052b6c2 100644 --- a/web/html/index.html +++ b/web/html/index.html @@ -65,9 +65,7 @@ -
- {{template "header" .}} -
+ {{template "header" .}}

Instances

diff --git a/web/html/login.html b/web/html/login.html index e5045e6..05796f6 100644 --- a/web/html/login.html +++ b/web/html/login.html @@ -7,9 +7,7 @@ -
- {{template "header" .}} -
+ {{template "header" .}}

{{.global.Organization}} Login

diff --git a/web/html/settings.html b/web/html/settings.html index 3c431b0..ecbebdf 100644 --- a/web/html/settings.html +++ b/web/html/settings.html @@ -26,9 +26,7 @@ -
- {{template "header" .}} -
+ {{template "header" .}}

Settings

@@ -42,6 +40,8 @@

App will periodically check for updates and synchronize only if needed. Medium resource usage.

App will react to changes and synchronize when changes are made. Low resource usage.

+ +

App will never automatically sync. Reload the page to sync the latest cluster state.

App Sync Frequency diff --git a/web/scripts/clientsync.js b/web/scripts/clientsync.js index 5e10409..2b6c347 100644 --- a/web/scripts/clientsync.js +++ b/web/scripts/clientsync.js @@ -2,8 +2,10 @@ import { getSyncSettings, requestAPI } from "./utils.js"; export async function setupClientSync (callback) { const { scheme, rate } = getSyncSettings(); - - if (scheme === "always") { + if (scheme === "never") { + return + } + else if (scheme === "always") { window.setInterval(callback, rate * 1000); } else if (scheme === "hash") { diff --git a/web/scripts/settings.js b/web/scripts/settings.js index 3ddfc5c..08756d2 100644 --- a/web/scripts/settings.js +++ b/web/scripts/settings.js @@ -4,6 +4,7 @@ window.addEventListener("DOMContentLoaded", init); function init () { setAppearance(); + const { scheme, rate } = getSyncSettings(); if (scheme) { document.querySelector(`#sync-${scheme}`).checked = true; diff --git a/web/templates/base.go.tmpl b/web/templates/base.go.tmpl index 7d360f1..3d2be7f 100644 --- a/web/templates/base.go.tmpl +++ b/web/templates/base.go.tmpl @@ -1,3 +1,4 @@ +{{/* common across all pages*/}} {{define "head"}} @@ -14,18 +15,21 @@ {{end}} +{{/*
common across all pages*/}} {{define "header"}} -

{{.global.Organization}}

- - - +
+

{{.global.Organization}}

+ + + +
{{end}} \ No newline at end of file diff --git a/web/templates/instance-card.go.tmpl b/web/templates/instance-card.go.tmpl index 0554233..dcf1a84 100644 --- a/web/templates/instance-card.go.tmpl +++ b/web/templates/instance-card.go.tmpl @@ -43,7 +43,7 @@ .hide-large {display: none !important;} .hide-medium {display:none !important} } - @media screen and (width <=601px) { + @media screen and (width <=601px) and (width >=440px){ .hide-large {display: none !important;} .hide-medium {display:none !important} .hide-small {display:none !important} diff --git a/web/templates/resource-chart.go.tmpl b/web/templates/resource-chart.go.tmpl index c444cb5..0b96147 100644 --- a/web/templates/resource-chart.go.tmpl +++ b/web/templates/resource-chart.go.tmpl @@ -37,7 +37,7 @@
diff --git a/web/templates/select.go.tmpl b/web/templates/select.go.tmpl index aa9d046..32ed5b7 100644 --- a/web/templates/select.go.tmpl +++ b/web/templates/select.go.tmpl @@ -1,11 +1,27 @@ +{{/* + Select: generic data driven -{{range .Options}} + {{range .Options}} + {{template "option" .}} + {{end}} + +{{end}} + +{{/* + Options: generic data driven {{else}} {{end}} -{{end}} - {{end}} \ No newline at end of file