diff --git a/app/routes/account.go b/app/routes/account.go index 9f3e986..8144325 100644 --- a/app/routes/account.go +++ b/app/routes/account.go @@ -12,8 +12,8 @@ import ( ) type Account struct { - Username string - Pools map[string]paas.Pool + paas.User + Pools map[string]paas.Pool } // numerical constraint @@ -98,6 +98,13 @@ var Green = color.RGB{ func HandleGETAccount(c *gin.Context) { auth, err := common.GetAuth(c) if err == nil { + + account, err := GetUser(auth) + if err != nil { + common.HandleNonFatalError(c, err) + return + } + pools, err := GetUserPools(auth) if err != nil { common.HandleNonFatalError(c, err) @@ -167,19 +174,33 @@ func HandleGETAccount(c *gin.Context) { } } + account.Pools = pools + c.HTML(http.StatusOK, "html/account.html", gin.H{ - "global": common.Global, - "page": "account", - "account": map[string]any{ - "Username": auth.Username, - "Pools": pools, - }, + "global": common.Global, + "page": "account", + "account": account, }) } else { c.Redirect(http.StatusFound, "/login") // if user is not authed, redirect user to login page } } +func GetUser(auth common.Auth) (Account, error) { + account := Account{} + ctx := common.GetRequestContextFromCookies(auth) + body := map[string]any{} + res, code, err := common.RequestGetAPI(fmt.Sprintf("/access/users/%s", auth.Username), ctx, &body) + if err != nil { + return account, err + } + if code != 200 { + return account, fmt.Errorf("request to /access/pools resulted in %+v", res) + } + err = mapstructure.Decode(body, &account) + return account, err +} + func GetUserPools(auth common.Auth) (map[string]paas.Pool, error) { pools := map[string]paas.Pool{} diff --git a/web/css/form.css b/web/css/form.css index 447b545..95a5e1b 100644 --- a/web/css/form.css +++ b/web/css/form.css @@ -41,6 +41,7 @@ legend { fieldset { border: 0; + padding: 0; } fieldset > *:last-child { diff --git a/web/css/nav.css b/web/css/nav.css index 155beb3..7ffe358 100644 --- a/web/css/nav.css +++ b/web/css/nav.css @@ -53,7 +53,6 @@ header { } header h1 { - font-size: 18px; margin: 0; background-color: var(--nav-header-bg-color); color: var(--nav-header-text-color); @@ -61,8 +60,8 @@ header h1 { } nav { + font-size: var(--small-font-size); overflow: hidden; - font-size: larger; width: fit-content; } diff --git a/web/css/style.css b/web/css/style.css index 1f5b860..0420bf2 100644 --- a/web/css/style.css +++ b/web/css/style.css @@ -3,6 +3,9 @@ --positive-color: #0f0; --highlight-color: yellow; --lightbg-text-color: black; + --large-font-size: 32px; + --medium-font-size: 24px; + --small-font-size: 16px; } @media screen and (prefers-color-scheme: dark) { @@ -41,9 +44,22 @@ } } -* { +*, h1, h2, h3, p { box-sizing: border-box; font-family: monospace; + +} + +h1, p { + font-size: var(--small-font-size); +} + +h2 { + font-size: var(--large-font-size); +} + +h3 { + font-size: var(--medium-font-size); } html { diff --git a/web/html/account.html b/web/html/account.html index 5b26aa0..0674a8e 100644 --- a/web/html/account.html +++ b/web/html/account.html @@ -39,13 +39,9 @@

Account

Account Details

-

Username: {{.account.Username}}

-
-
-
-

Password

- -
+

Username: {{.account.Username.UserID}}@{{.account.Username.Realm}}

+

Email: {{.account.Mail}}

+

Password:

{{range $poolname, $pool := .account.Pools}} {{template "pool-resources" $pool}} diff --git a/web/html/index.html b/web/html/index.html index 052b6c2..f3cbd02 100644 --- a/web/html/index.html +++ b/web/html/index.html @@ -72,7 +72,7 @@
diff --git a/web/scripts/clientsync.js b/web/scripts/clientsync.js index 2b6c347..43994d7 100644 --- a/web/scripts/clientsync.js +++ b/web/scripts/clientsync.js @@ -3,7 +3,7 @@ import { getSyncSettings, requestAPI } from "./utils.js"; export async function setupClientSync (callback) { const { scheme, rate } = getSyncSettings(); if (scheme === "never") { - return + return; } else if (scheme === "always") { window.setInterval(callback, rate * 1000);