Include link to user dashboard when provided
This commit is contained in:
parent
1d794896ac
commit
f7a2436665
|
@ -13,6 +13,8 @@
|
|||
<a href="/graph">Graph & Console</a>
|
||||
<a href="/">Status</a>
|
||||
<a href="/databases">Databases</a>
|
||||
{{ define "user_dashboard_link" }}{{ end }}
|
||||
{{ template "user_dashboard_link" .}}
|
||||
|
||||
<!-- Help should preferentially be the right-most element. -->
|
||||
<a href="https://github.com/prometheus/prometheus/wiki" target="_blank">Help</a>
|
||||
|
|
33
web/web.go
33
web/web.go
|
@ -75,12 +75,15 @@ func (w WebService) ServeForever() error {
|
|||
return http.ListenAndServe(*listenAddress, exp.DefaultCoarseMux)
|
||||
}
|
||||
|
||||
func getTemplate(name string) (t *template.Template, err error) {
|
||||
if *useLocalAssets {
|
||||
return template.ParseFiles("web/templates/_base.html", fmt.Sprintf("web/templates/%s.html", name))
|
||||
}
|
||||
func getLocalTemplate(name string) (*template.Template, error) {
|
||||
return template.ParseFiles(
|
||||
"web/templates/_base.html",
|
||||
fmt.Sprintf("web/templates/%s.html", name),
|
||||
)
|
||||
}
|
||||
|
||||
t = template.New("_base")
|
||||
func getEmbeddedTemplate(name string) (*template.Template, error) {
|
||||
t := template.New("_base")
|
||||
|
||||
file, err := blob.GetFile(blob.TemplateFiles, "_base.html")
|
||||
if err != nil {
|
||||
|
@ -96,6 +99,26 @@ func getTemplate(name string) (t *template.Template, err error) {
|
|||
}
|
||||
t.Parse(string(file))
|
||||
|
||||
return t, nil
|
||||
}
|
||||
|
||||
|
||||
func getTemplate(name string) (t *template.Template, err error) {
|
||||
if *useLocalAssets {
|
||||
t, err = getLocalTemplate(name)
|
||||
} else {
|
||||
t, err = getEmbeddedTemplate(name)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if *userAssetsPath != "" {
|
||||
// replace "user_dashboard_link" template
|
||||
t.Parse(`{{define "user_dashboard_link"}}<a href="/user">User Dashboard{{end}}`)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue