mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2025-07-23 12:51:40 +02:00
Add more views
This commit is contained in:
@@ -1,10 +1,57 @@
|
||||
{{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>
|
||||
{{if .Infos.username}}
|
||||
<i class="bi bi-person-circle"></i> {{ .Infos.username }}
|
||||
{{if .Infos.admin}}
|
||||
<span class="badge bg-primary">Admin</span>
|
||||
{{end}}
|
||||
{{end}}
|
||||
</div>
|
||||
<div class="col" style="text-align: right;">
|
||||
<form method="post" action="/logout">
|
||||
<button type="submit" class="btn btn-primary">Logout</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
{{if .Infos.admin}}
|
||||
<div class="col-4">
|
||||
<ul>
|
||||
<li><a href="/monitoring/jobs/">All jobs</a></li>
|
||||
<li><a href="/monitoring/users/">All users</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
{{else}}
|
||||
<div class="col-4">
|
||||
<ul>
|
||||
<li><a href="/monitoring/jobs/">My jobs</a></li>
|
||||
<li><a href="/monitoring/user/{{.Infos.username}}">My user view</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
{{end}}
|
||||
<div class="col-8">
|
||||
<h2>Clusters</h2>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name/ID</th>
|
||||
<th>Jobs</th>
|
||||
<th>System View</th>
|
||||
<th>Analysis View</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{range .Infos.clusters}}
|
||||
<tr>
|
||||
<td>{{.ClusterID}}</td>
|
||||
<td><a href="/monitoring/jobs/?cluster={{.ClusterID}}">Jobs</a></td>
|
||||
<td><a href="/monitoring/systems/?cluster={{.ClusterID}}">System View</a></td>
|
||||
<td><a href="/monitoring/analysis/?cluster={{.ClusterID}}">Analysis View</a></td>
|
||||
</tr>
|
||||
{{end}}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
|
18
templates/monitoring/analysis.html
Normal file
18
templates/monitoring/analysis.html
Normal file
@@ -0,0 +1,18 @@
|
||||
{{define "content"}}
|
||||
<div id="svelte-app"></div>
|
||||
{{end}}
|
||||
|
||||
{{define "stylesheets"}}
|
||||
<link rel='stylesheet' href='/build/analysis.css'>
|
||||
{{end}}
|
||||
{{define "javascript"}}
|
||||
<script>
|
||||
const filterPresets = {{ .FilterPresets }};
|
||||
const clusterCockpitConfigPromise = Promise.resolve({
|
||||
plot_view_plotsPerRow: {{ .Config.plot_view_plotsPerRow }},
|
||||
analysis_view_histogramMetrics: {{ .Config.analysis_view_histogramMetrics }},
|
||||
analysis_view_scatterPlotMetrics: {{ .Config.analysis_view_scatterPlotMetrics }}
|
||||
});
|
||||
</script>
|
||||
<script src='/build/analysis.js'></script>
|
||||
{{end}}
|
@@ -7,7 +7,7 @@
|
||||
{{end}}
|
||||
{{define "javascript"}}
|
||||
<script>
|
||||
const filterPresets = null;
|
||||
const filterPresets = {{ .FilterPresets }};
|
||||
const clusterCockpitConfigPromise = Promise.resolve({
|
||||
plot_general_colorscheme: {{ .Config.plot_general_colorscheme }},
|
||||
plot_general_lineWidth: {{ .Config.plot_general_lineWidth }},
|
||||
|
21
templates/monitoring/node.html
Normal file
21
templates/monitoring/node.html
Normal file
@@ -0,0 +1,21 @@
|
||||
{{define "content"}}
|
||||
<div id="svelte-app"></div>
|
||||
{{end}}
|
||||
|
||||
{{define "stylesheets"}}
|
||||
<link rel='stylesheet' href='/build/node.css'>
|
||||
{{end}}
|
||||
{{define "javascript"}}
|
||||
<script>
|
||||
const nodeInfos = {
|
||||
nodeId: "{{ .Infos.nodeId }}",
|
||||
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 }},
|
||||
});
|
||||
</script>
|
||||
<script src='/build/node.js'></script>
|
||||
{{end}}
|
19
templates/monitoring/systems.html
Normal file
19
templates/monitoring/systems.html
Normal file
@@ -0,0 +1,19 @@
|
||||
{{define "content"}}
|
||||
<div id="svelte-app"></div>
|
||||
{{end}}
|
||||
|
||||
{{define "stylesheets"}}
|
||||
<link rel='stylesheet' href='/build/systems.css'>
|
||||
{{end}}
|
||||
{{define "javascript"}}
|
||||
<script>
|
||||
const filterPresets = {{ .FilterPresets }};
|
||||
const clusterCockpitConfigPromise = Promise.resolve({
|
||||
plot_view_plotsPerRow: {{ .Config.plot_view_plotsPerRow }},
|
||||
plot_general_colorscheme: {{ .Config.plot_general_colorscheme }},
|
||||
plot_general_lineWidth: {{ .Config.plot_general_lineWidth }},
|
||||
plot_general_colorBackground: {{ .Config.plot_general_colorBackground }},
|
||||
});
|
||||
</script>
|
||||
<script src='/build/systems.js'></script>
|
||||
{{end}}
|
@@ -9,10 +9,11 @@ import (
|
||||
var templates map[string]*template.Template
|
||||
|
||||
type Page struct {
|
||||
Title string
|
||||
Login *LoginPage
|
||||
Infos map[string]interface{}
|
||||
Config map[string]interface{}
|
||||
Title string
|
||||
Login *LoginPage
|
||||
FilterPresets map[string]interface{}
|
||||
Infos map[string]interface{}
|
||||
Config map[string]interface{}
|
||||
}
|
||||
|
||||
type LoginPage struct {
|
||||
@@ -23,18 +24,26 @@ type LoginPage struct {
|
||||
func init() {
|
||||
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")),
|
||||
"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")),
|
||||
"monitoring/analysis/": template.Must(template.Must(base.Clone()).ParseFiles("./templates/monitoring/analysis.html")),
|
||||
"monitoring/systems/": template.Must(template.Must(base.Clone()).ParseFiles("./templates/monitoring/systems.html")),
|
||||
"monitoring/node/": template.Must(template.Must(base.Clone()).ParseFiles("./templates/monitoring/node.html")),
|
||||
}
|
||||
}
|
||||
|
||||
func Render(rw http.ResponseWriter, r *http.Request, name string, page *Page) {
|
||||
if err := templates[name].Execute(rw, page); err != nil {
|
||||
t, ok := templates[name]
|
||||
if !ok {
|
||||
panic("templates must be predefinied!")
|
||||
}
|
||||
|
||||
if err := t.Execute(rw, page); err != nil {
|
||||
log.Printf("template error: %s\n", err.Error())
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user