diff options
| author | Aleksandr Nogikh <nogikh@google.com> | 2025-07-03 15:09:21 +0200 |
|---|---|---|
| committer | Aleksandr Nogikh <nogikh@google.com> | 2025-07-08 13:37:33 +0000 |
| commit | a7f206f0e4b264de8fb8b059d10c96beb8c6a3a4 (patch) | |
| tree | 7052f94d5f29cf29fb5f5b6affe056deed1505e0 /syz-cluster/dashboard | |
| parent | 4f67c4aece4f5794be20c6bc99c177e44b1320e8 (diff) | |
syz-cluster: make the displayed title configurable
Diffstat (limited to 'syz-cluster/dashboard')
| -rw-r--r-- | syz-cluster/dashboard/deployment.yaml | 7 | ||||
| -rw-r--r-- | syz-cluster/dashboard/handler.go | 21 | ||||
| -rw-r--r-- | syz-cluster/dashboard/templates/base.html | 6 |
3 files changed, 29 insertions, 5 deletions
diff --git a/syz-cluster/dashboard/deployment.yaml b/syz-cluster/dashboard/deployment.yaml index 4dd683d6f..94407a9fe 100644 --- a/syz-cluster/dashboard/deployment.yaml +++ b/syz-cluster/dashboard/deployment.yaml @@ -22,6 +22,9 @@ spec: envFrom: - configMapRef: name: global-config-env + volumeMounts: + - name: config-volume + mountPath: /config ports: - containerPort: 8081 resources: @@ -31,3 +34,7 @@ spec: limits: cpu: 4 memory: 8G + volumes: + - name: config-volume + configMap: + name: global-config diff --git a/syz-cluster/dashboard/handler.go b/syz-cluster/dashboard/handler.go index 9b8503df3..ddcc51a47 100644 --- a/syz-cluster/dashboard/handler.go +++ b/syz-cluster/dashboard/handler.go @@ -21,6 +21,7 @@ import ( ) type dashboardHandler struct { + title string seriesRepo *db.SeriesRepository sessionRepo *db.SessionRepository sessionTestRepo *db.SessionTestRepository @@ -41,7 +42,12 @@ func newHandler(env *app.AppEnvironment) (*dashboardHandler, error) { return nil, err } } + cfg, err := app.Config() + if err != nil { + return nil, err + } return &dashboardHandler{ + title: cfg.Name, templates: perFile, blobStorage: env.BlobStorage, seriesRepo: db.NewSeriesRepository(env.Spanner), @@ -133,7 +139,7 @@ func (h *dashboardHandler) seriesList(w http.ResponseWriter, r *http.Request) er data.NextPageURL = urlutil.SetParam(baseURL, "offset", fmt.Sprintf("%d", data.Filter.Offset+len(data.List))) } - return h.templates["index.html"].ExecuteTemplate(w, "base.html", data) + return h.renderTemplate(w, "index.html", data) } func (h *dashboardHandler) getOffset(r *http.Request) (int, error) { @@ -202,7 +208,7 @@ func (h *dashboardHandler) seriesInfo(w http.ResponseWriter, r *http.Request) er } data.Sessions = append(data.Sessions, sessionData) } - return h.templates["series.html"].ExecuteTemplate(w, "base.html", data) + return h.renderTemplate(w, "series.html", data) } func groupFindings(findings []*db.Finding) map[string][]*db.Finding { @@ -213,6 +219,17 @@ func groupFindings(findings []*db.Finding) map[string][]*db.Finding { return ret } +func (h *dashboardHandler) renderTemplate(w http.ResponseWriter, name string, data any) error { + type page struct { + Title string + Data any + } + return h.templates[name].ExecuteTemplate(w, "base.html", page{ + Title: h.title, + Data: data, + }) +} + // nolint:dupl func (h *dashboardHandler) sessionLog(w http.ResponseWriter, r *http.Request) error { session, err := h.sessionRepo.GetByID(r.Context(), r.PathValue("id")) diff --git a/syz-cluster/dashboard/templates/base.html b/syz-cluster/dashboard/templates/base.html index df5cca54f..c154de1db 100644 --- a/syz-cluster/dashboard/templates/base.html +++ b/syz-cluster/dashboard/templates/base.html @@ -6,11 +6,11 @@ <link rel="stylesheet" href="/static/bootstrap.min.css"> <script src="/static/jquery-3.7.1.min.js"></script> <script src="/static/bootstrap.bundle.min.js"></script> - <title>syz-cluster</title> + <title>{{.Title}}</title> </head> <body> <nav class="navbar navbar-light bg-light justify-content-start"> - <a class="navbar-brand px-3" href="#">Syz-Cluster</a> + <a class="navbar-brand px-3" href="#">{{.Title}}</a> <div class=""> <ul class="navbar-nav"> <li class="nav-item active"> @@ -19,6 +19,6 @@ </ul> </div> </nav> - {{block "content" .}}{{end}} + {{block "content" .Data}}{{end}} </body> </html> |
