Browse Source

En cours de développement

master
mls-361 9 months ago
parent
commit
f3663fb28c
  1. 28
      internal/gui/dashboard.go

28
internal/gui/dashboard.go

@ -7,6 +7,7 @@
package gui
import (
"fmt"
"strconv"
"forge.chapril.org/armen/jw"
@ -41,13 +42,13 @@ func (d *dashboard) empty() g.Node {
)
}
func (d *dashboard) value(name string, value int) g.Node {
func (d *dashboard) value(name string, value int, url string) g.Node {
return Div(
Class("value"),
A(
Class("label"),
g.Text(name),
Href("/"),
Href(url),
),
Span(
Class(name),
@ -57,19 +58,22 @@ func (d *dashboard) value(name string, value int) g.Node {
}
func (d *dashboard) metrics(ms *jw.Metrics) g.Node {
const jobURL = "/gui/job/list?status=%s"
const wfURL = "/gui/workflow/list?status=%s"
return Div(
Class("metrics"),
Div(
Class("panel"),
Div(
d.title("Jobs"),
d.value(string(jw.StatusTodo), ms.Jobs.Todo),
d.value(string(jw.StatusPending), ms.Jobs.Pending),
d.value(string(jw.StatusRunning), ms.Jobs.Running),
d.value(string(jw.StatusSucceeded), ms.Jobs.Succeeded),
d.value(string(jw.StatusFailed), ms.Jobs.Failed),
d.value(string(jw.StatusTodo), ms.Jobs.Todo, fmt.Sprintf(jobURL, jw.StatusTodo)),
d.value(string(jw.StatusPending), ms.Jobs.Pending, fmt.Sprintf(jobURL, jw.StatusPending)),
d.value(string(jw.StatusRunning), ms.Jobs.Running, fmt.Sprintf(jobURL, jw.StatusRunning)),
d.value(string(jw.StatusSucceeded), ms.Jobs.Succeeded, fmt.Sprintf(jobURL, jw.StatusSucceeded)),
d.value(string(jw.StatusFailed), ms.Jobs.Failed, fmt.Sprintf(jobURL, jw.StatusFailed)),
Hr(),
d.value("total", ms.Jobs.Total),
d.value("total", ms.Jobs.Total, "/gui/job/list"),
),
),
Div(
@ -78,11 +82,11 @@ func (d *dashboard) metrics(ms *jw.Metrics) g.Node {
d.title("Workflows"),
d.empty(),
d.empty(),
d.value(string(jw.StatusRunning), ms.Workflows.Running),
d.value(string(jw.StatusSucceeded), ms.Workflows.Succeeded),
d.value(string(jw.StatusFailed), ms.Workflows.Failed),
d.value(string(jw.StatusRunning), ms.Workflows.Running, fmt.Sprintf(wfURL, jw.StatusRunning)),
d.value(string(jw.StatusSucceeded), ms.Workflows.Succeeded, fmt.Sprintf(wfURL, jw.StatusSucceeded)),
d.value(string(jw.StatusFailed), ms.Workflows.Failed, fmt.Sprintf(wfURL, jw.StatusFailed)),
Hr(),
d.value("total", ms.Workflows.Total),
d.value("total", ms.Workflows.Total, "/gui/workflow/list"),
),
),
)

Loading…
Cancel
Save