Skip to content

Commit

Permalink
add preamble
Browse files Browse the repository at this point in the history
  • Loading branch information
rbren committed May 7, 2019
1 parent 3aea1f5 commit d3c7e32
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
14 changes: 11 additions & 3 deletions pkg/dashboard/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ import (
const (
// MainTemplateName is the main template
MainTemplateName = "main.gohtml"
// DashboardTemplateName contains the content of the dashboard
DashboardTemplateName = "dashboard.gohtml"
// HeaderTemplateName contains the navbar
HeaderTemplateName = "header.gohtml"
// PreambleTemplateName contains an empty preamble that can be overridden
PreambleTemplateName = "preamble.gohtml"
// DashboardTemplateName contains the content of the dashboard
DashboardTemplateName = "dashboard.gohtml"
// FooterTemplateName contains the footer
FooterTemplateName = "footer.gohtml"
)
Expand Down Expand Up @@ -78,7 +80,13 @@ func GetBaseTemplate(name string) (*template.Template, error) {
})

templateBox := GetTemplateBox()
templateFileNames := []string{DashboardTemplateName, HeaderTemplateName, FooterTemplateName, MainTemplateName}
templateFileNames := []string{
DashboardTemplateName,
HeaderTemplateName,
PreambleTemplateName,
FooterTemplateName,
MainTemplateName,
}
for _, fname := range templateFileNames {
templateFile, err := templateBox.Find(fname)
if err != nil {
Expand Down
6 changes: 2 additions & 4 deletions pkg/dashboard/templates/dashboard.gohtml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{{define "dashboard"}}
<div class="dashboard-content">
<div class="card cluster">
<h3>Cluster Overview</h3>
<div class="cluster-overview">
Expand Down Expand Up @@ -113,7 +112,6 @@
</table>
</div>
{{ end }} {{/* end range .AuditData.NamespacedResults */}}
</div>
<script src="/static/js/charts.js">
</script>
<script src="/static/js/charts.js">
</script>
{{end}}
5 changes: 4 additions & 1 deletion pkg/dashboard/templates/main.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@

<body>
{{ template "header" . }}
{{ template "dashboard" . }}
<div class="dashboard-content">
{{ template "preamble" . }}
{{ template "dashboard" . }}
</div>
{{ template "footer" . }}
</body>
</html>
2 changes: 2 additions & 0 deletions pkg/dashboard/templates/preamble.gohtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{{ define "preamble" }}
{{ end }}

0 comments on commit d3c7e32

Please sign in to comment.