From df3c806ab7a107da38a1edc1a6033bc1742b0f5e Mon Sep 17 00:00:00 2001 From: Lou Knauer Date: Tue, 15 Feb 2022 10:03:09 +0100 Subject: [PATCH] Header in svelte --- frontend | 2 +- routes.go | 21 ++---- server.go | 29 +++----- templates/base.tmpl | 102 +++-------------------------- templates/home.tmpl | 2 +- templates/login.tmpl | 2 + templates/monitoring/analysis.tmpl | 1 + templates/monitoring/job.tmpl | 1 + templates/monitoring/jobs.tmpl | 1 + templates/monitoring/list.tmpl | 1 + templates/monitoring/node.tmpl | 1 + templates/monitoring/systems.tmpl | 1 + templates/monitoring/taglist.tmpl | 6 ++ templates/monitoring/user.tmpl | 1 + templates/templates.go | 26 ++++++-- 15 files changed, 63 insertions(+), 134 deletions(-) diff --git a/frontend b/frontend index 42f56f0..cb04475 160000 --- a/frontend +++ b/frontend @@ -1 +1 @@ -Subproject commit 42f56f0a0a162bec0871949cade791590bea6a89 +Subproject commit cb0447516b5102b7869eb6068df3de08b7736caf diff --git a/routes.go b/routes.go index 4ba89fe..d4e4985 100644 --- a/routes.go +++ b/routes.go @@ -86,27 +86,20 @@ func setupRoutes(router *mux.Router, routes []Route) { return } - infos := map[string]interface{}{ - "admin": true, - } - - if user := auth.GetUser(r.Context()); user != nil { - infos["loginId"] = user.Username - infos["admin"] = user.HasRole(auth.RoleAdmin) - } else { - infos["loginId"] = false - infos["admin"] = false - } - - infos = route.Setup(infos, r) + infos := route.Setup(map[string]interface{}{}, r) if id, ok := infos["id"]; ok { route.Title = strings.Replace(route.Title, "", id.(string), 1) } - infos["clusters"] = config.Clusters + username, isAdmin := "", true + if user := auth.GetUser(r.Context()); user != nil { + username = user.Username + isAdmin = user.HasRole(auth.RoleAdmin) + } page := templates.Page{ Title: route.Title, + User: templates.User{Username: username, IsAdmin: isAdmin}, Config: conf, Infos: infos, } diff --git a/server.go b/server.go index ed9cf39..8b97fd9 100644 --- a/server.go +++ b/server.go @@ -95,15 +95,9 @@ var programConfig ProgramConfig = ProgramConfig{ JobArchive: "./var/job-archive", AsyncArchiving: true, DisableArchive: false, - LdapConfig: &auth.LdapConfig{ - Url: "ldap://localhost", - UserBase: "ou=hpc,dc=rrze,dc=uni-erlangen,dc=de", - SearchDN: "cn=admin,dc=rrze,dc=uni-erlangen,dc=de", - UserBind: "uid={username},ou=hpc,dc=rrze,dc=uni-erlangen,dc=de", - UserFilter: "(&(objectclass=posixAccount)(uid=*))", - }, - HttpsCertFile: "", - HttpsKeyFile: "", + LdapConfig: nil, + HttpsCertFile: "", + HttpsKeyFile: "", UiDefaults: map[string]interface{}{ "analysis_view_histogramMetrics": []string{"flops_any", "mem_bw", "mem_used"}, "analysis_view_scatterPlotMetrics": [][]string{{"flops_any", "mem_bw"}, {"flops_any", "cpu_load"}, {"cpu_load", "mem_bw"}}, @@ -407,22 +401,19 @@ func main() { return } - infos := map[string]interface{}{ - "clusters": config.Clusters, - } - + username, isAdmin := "", true if user := auth.GetUser(r.Context()); user != nil { - infos["loginId"] = user.Username - infos["admin"] = user.HasRole(auth.RoleAdmin) - } else { - infos["loginId"] = false - infos["admin"] = false + username = user.Username + isAdmin = user.HasRole(auth.RoleAdmin) } templates.Render(rw, r, "home.tmpl", &templates.Page{ Title: "ClusterCockpit", + User: templates.User{Username: username, IsAdmin: isAdmin}, Config: conf, - Infos: infos, + Infos: map[string]interface{}{ + "clusters": config.Clusters, + }, }) }) diff --git a/templates/base.tmpl b/templates/base.tmpl index 884fa3d..82a13ed 100644 --- a/templates/base.tmpl +++ b/templates/base.tmpl @@ -13,101 +13,16 @@ {{block "stylesheets" .}} {{end}} + -
- -
+
@@ -127,6 +42,7 @@ {{end}} {{block "javascript" .}} + {{end}} diff --git a/templates/home.tmpl b/templates/home.tmpl index e99bfea..7dd526e 100644 --- a/templates/home.tmpl +++ b/templates/home.tmpl @@ -1,6 +1,6 @@ {{define "content"}}
-
+

Clusters

diff --git a/templates/login.tmpl b/templates/login.tmpl index 8ba1145..b78ec74 100644 --- a/templates/login.tmpl +++ b/templates/login.tmpl @@ -38,5 +38,7 @@ + + {{end}} diff --git a/templates/monitoring/analysis.tmpl b/templates/monitoring/analysis.tmpl index af34f8e..ffd619e 100644 --- a/templates/monitoring/analysis.tmpl +++ b/templates/monitoring/analysis.tmpl @@ -7,6 +7,7 @@ {{end}} {{define "javascript"}} diff --git a/templates/monitoring/list.tmpl b/templates/monitoring/list.tmpl index 0c1994e..6c577f8 100644 --- a/templates/monitoring/list.tmpl +++ b/templates/monitoring/list.tmpl @@ -7,6 +7,7 @@ {{end}} {{define "javascript"}} diff --git a/templates/monitoring/systems.tmpl b/templates/monitoring/systems.tmpl index 27bbf64..1f762d2 100644 --- a/templates/monitoring/systems.tmpl +++ b/templates/monitoring/systems.tmpl @@ -7,6 +7,7 @@ {{end}} {{define "javascript"}} diff --git a/templates/monitoring/taglist.tmpl b/templates/monitoring/taglist.tmpl index 6e487dd..b677fe4 100644 --- a/templates/monitoring/taglist.tmpl +++ b/templates/monitoring/taglist.tmpl @@ -1,3 +1,9 @@ +{{define "javascript"}} + + +{{end}} {{define "content"}}
diff --git a/templates/monitoring/user.tmpl b/templates/monitoring/user.tmpl index 693ae61..430dc23 100644 --- a/templates/monitoring/user.tmpl +++ b/templates/monitoring/user.tmpl @@ -7,6 +7,7 @@ {{end}} {{define "javascript"}}