mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2025-07-23 12:51:40 +02:00
Add templates and custom urls for monitoring views
This commit is contained in:
@@ -9,6 +9,9 @@
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.1/dist/css/bootstrap.min.css" integrity="sha384-F3w7mX95PdgyTmZZMECAngseQB83DfGTowi0iMjiWaeVhAn4FJkqJByhZMI3AhiU" crossorigin="anonymous">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.4.1/font/bootstrap-icons.css">
|
||||
<link rel='stylesheet' href='/global.css'>
|
||||
<link rel='stylesheet' href='/uPlot.min.css'>
|
||||
|
||||
{{block "stylesheets" .}}{{end}}
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
@@ -20,5 +23,6 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{block "javascript" .}}{{end}}
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
10
templates/home.html
Normal file
10
templates/home.html
Normal file
@@ -0,0 +1,10 @@
|
||||
{{define "content"}}
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<ul>
|
||||
<li><a href="/monitoring/jobs/">jobs</a></li>
|
||||
<li><a href="/monitoring/users/">users</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
@@ -1,4 +1,3 @@
|
||||
{{template "base.html" .}}
|
||||
{{define "content"}}
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
|
29
templates/monitoring/job.html
Normal file
29
templates/monitoring/job.html
Normal file
@@ -0,0 +1,29 @@
|
||||
{{define "content"}}
|
||||
<div id="svelte-app"></div>
|
||||
{{end}}
|
||||
|
||||
{{define "stylesheets"}}
|
||||
<link rel='stylesheet' href='/build/job.css'>
|
||||
{{end}}
|
||||
{{define "javascript"}}
|
||||
<script>
|
||||
const jobInfos = {
|
||||
id: "{{ .Infos.id }}",
|
||||
jobId: "{{ .Infos.jobId }}",
|
||||
clusterId: "{{ .Infos.clusterId }}"
|
||||
};
|
||||
const clusterCockpitConfigPromise = Promise.resolve({
|
||||
plot_general_colorscheme: {{ .Config.plot_general_colorscheme }},
|
||||
plot_general_lineWidth: {{ .Config.plot_general_lineWidth }},
|
||||
plot_general_colorBackground: {{ .Config.plot_general_colorBackground }},
|
||||
plot_view_showRoofline: {{ .Config.plot_view_showRoofline }},
|
||||
plot_view_showPolarplot: {{ .Config.plot_view_showPolarplot }},
|
||||
plot_view_showStatTable: {{ .Config.plot_view_showStatTable }},
|
||||
plot_view_plotsPerRow: {{ .Config.plot_view_plotsPerRow }},
|
||||
job_view_selectedMetrics: {{ .Config.job_view_selectedMetrics }},
|
||||
job_view_nodestats_selectedMetrics: {{ .Config.job_view_nodestats_selectedMetrics }},
|
||||
job_view_polarPlotMetrics: {{ .Config.plot_view_polarPlotMetrics }},
|
||||
});
|
||||
</script>
|
||||
<script src='/build/job.js'></script>
|
||||
{{end}}
|
20
templates/monitoring/jobs.html
Normal file
20
templates/monitoring/jobs.html
Normal file
@@ -0,0 +1,20 @@
|
||||
{{define "content"}}
|
||||
<div id="svelte-app"></div>
|
||||
{{end}}
|
||||
|
||||
{{define "stylesheets"}}
|
||||
<link rel='stylesheet' href='/build/jobs.css'>
|
||||
{{end}}
|
||||
{{define "javascript"}}
|
||||
<script>
|
||||
const filterPresets = null;
|
||||
const clusterCockpitConfigPromise = Promise.resolve({
|
||||
plot_general_colorscheme: {{ .Config.plot_general_colorscheme }},
|
||||
plot_general_lineWidth: {{ .Config.plot_general_lineWidth }},
|
||||
plot_general_colorBackground: {{ .Config.plot_general_colorBackground }},
|
||||
plot_list_selectedMetrics: {{ .Config.plot_list_selectedMetrics }},
|
||||
plot_list_jobsPerPage: {{ .Config.plot_list_jobsPerPage }}
|
||||
});
|
||||
</script>
|
||||
<script src='/build/jobs.js'></script>
|
||||
{{end}}
|
22
templates/monitoring/user.html
Normal file
22
templates/monitoring/user.html
Normal file
@@ -0,0 +1,22 @@
|
||||
{{define "content"}}
|
||||
<div id="svelte-app"></div>
|
||||
{{end}}
|
||||
|
||||
{{define "stylesheets"}}
|
||||
<link rel='stylesheet' href='/build/user.css'>
|
||||
{{end}}
|
||||
{{define "javascript"}}
|
||||
<script>
|
||||
const userInfos = {
|
||||
userId: "{{ .Infos.userId }}"
|
||||
};
|
||||
const clusterCockpitConfigPromise = Promise.resolve({
|
||||
plot_general_colorscheme: {{ .Config.plot_general_colorscheme }},
|
||||
plot_general_lineWidth: {{ .Config.plot_general_lineWidth }},
|
||||
plot_general_colorBackground: {{ .Config.plot_general_colorBackground }},
|
||||
plot_list_selectedMetrics: {{ .Config.plot_list_selectedMetrics }},
|
||||
plot_list_jobsPerPage: {{ .Config.plot_list_jobsPerPage }}
|
||||
});
|
||||
</script>
|
||||
<script src='/build/user.js'></script>
|
||||
{{end}}
|
14
templates/monitoring/users.html
Normal file
14
templates/monitoring/users.html
Normal file
@@ -0,0 +1,14 @@
|
||||
{{define "content"}}
|
||||
<div id="svelte-app"></div>
|
||||
{{end}}
|
||||
|
||||
{{define "stylesheets"}}
|
||||
<link rel='stylesheet' href='/build/users.css'>
|
||||
{{end}}
|
||||
{{define "javascript"}}
|
||||
<script>
|
||||
const filterPresets = null;
|
||||
const clusterCockpitConfigPromise = Promise.resolve({});
|
||||
</script>
|
||||
<script src='/build/users.js'></script>
|
||||
{{end}}
|
@@ -6,11 +6,13 @@ import (
|
||||
"net/http"
|
||||
)
|
||||
|
||||
var templates *template.Template
|
||||
var templates map[string]*template.Template
|
||||
|
||||
type Page struct {
|
||||
Title string
|
||||
Login *LoginPage
|
||||
Title string
|
||||
Login *LoginPage
|
||||
Infos map[string]interface{}
|
||||
Config map[string]interface{}
|
||||
}
|
||||
|
||||
type LoginPage struct {
|
||||
@@ -19,11 +21,20 @@ type LoginPage struct {
|
||||
}
|
||||
|
||||
func init() {
|
||||
templates = template.Must(template.ParseGlob("./templates/*.html"))
|
||||
base := template.Must(template.ParseFiles("./templates/base.html"))
|
||||
templates = map[string]*template.Template{
|
||||
"home": template.Must(template.Must(base.Clone()).ParseFiles("./templates/home.html")),
|
||||
"404": template.Must(template.Must(base.Clone()).ParseFiles("./templates/404.html")),
|
||||
"login": template.Must(template.Must(base.Clone()).ParseFiles("./templates/login.html")),
|
||||
"monitoring/jobs/": template.Must(template.Must(base.Clone()).ParseFiles("./templates/monitoring/jobs.html")),
|
||||
"monitoring/job/": template.Must(template.Must(base.Clone()).ParseFiles("./templates/monitoring/job.html")),
|
||||
"monitoring/users/": template.Must(template.Must(base.Clone()).ParseFiles("./templates/monitoring/users.html")),
|
||||
"monitoring/user/": template.Must(template.Must(base.Clone()).ParseFiles("./templates/monitoring/user.html")),
|
||||
}
|
||||
}
|
||||
|
||||
func Render(rw http.ResponseWriter, r *http.Request, name string, page *Page) {
|
||||
if err := templates.ExecuteTemplate(rw, name, page); err != nil {
|
||||
if err := templates[name].Execute(rw, page); err != nil {
|
||||
log.Printf("template error: %s\n", err.Error())
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user