Info icon for problem values
This commit is contained in:
parent
239d48fc91
commit
dd4bc27bc7
20
problem.go
20
problem.go
@ -7,6 +7,9 @@ import (
|
|||||||
// Standard
|
// Standard
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"sort"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -16,6 +19,7 @@ type Problem struct {// {{{
|
|||||||
End sql.NullTime
|
End sql.NullTime
|
||||||
Acknowledged bool
|
Acknowledged bool
|
||||||
Datapoints map[string]any
|
Datapoints map[string]any
|
||||||
|
DatapointValues map[string]any `json:"datapoints"`
|
||||||
TriggerID int `json:"trigger_id"`
|
TriggerID int `json:"trigger_id"`
|
||||||
TriggerName string `json:"trigger_name"`
|
TriggerName string `json:"trigger_name"`
|
||||||
AreaName string `json:"area_name"`
|
AreaName string `json:"area_name"`
|
||||||
@ -33,6 +37,7 @@ func ProblemsRetrieve() (problems []Problem, err error) {// {{{
|
|||||||
p.start,
|
p.start,
|
||||||
p.end,
|
p.end,
|
||||||
p.acknowledged,
|
p.acknowledged,
|
||||||
|
p.datapoints,
|
||||||
t.id AS trigger_id,
|
t.id AS trigger_id,
|
||||||
t.name AS trigger_name,
|
t.name AS trigger_name,
|
||||||
a.name AS area_name,
|
a.name AS area_name,
|
||||||
@ -53,6 +58,7 @@ func ProblemsRetrieve() (problems []Problem, err error) {// {{{
|
|||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
false,
|
false,
|
||||||
|
'{}',
|
||||||
-1 AS trigger_id,
|
-1 AS trigger_id,
|
||||||
CONCAT(
|
CONCAT(
|
||||||
'NODATA: ',
|
'NODATA: ',
|
||||||
@ -137,3 +143,17 @@ func ProblemAcknowledge(id int, state bool) (err error) {// {{{
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
} // }}}
|
} // }}}
|
||||||
|
|
||||||
|
func (p Problem) FormattedValues() string {
|
||||||
|
out := []string{}
|
||||||
|
for key, val := range p.DatapointValues {
|
||||||
|
timeVal, ok := val.(time.Time)
|
||||||
|
if ok {
|
||||||
|
logger.Info("FOO", "timeVal", timeVal)
|
||||||
|
}
|
||||||
|
out = append(out, fmt.Sprintf("%s: %v", key, val))
|
||||||
|
}
|
||||||
|
sort.Strings(out)
|
||||||
|
|
||||||
|
return strings.Join(out, "\n")
|
||||||
|
}
|
||||||
|
@ -30,6 +30,10 @@
|
|||||||
#acknowledged-list .acknowledge img {
|
#acknowledged-list .acknowledge img {
|
||||||
height: 16px;
|
height: 16px;
|
||||||
}
|
}
|
||||||
|
#problems-list .info,
|
||||||
|
#acknowledged-list .info {
|
||||||
|
margin-right: 8px;
|
||||||
|
}
|
||||||
#acknowledged-list.hidden {
|
#acknowledged-list.hidden {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
@ -41,7 +45,7 @@
|
|||||||
}
|
}
|
||||||
#areas .area .section {
|
#areas .area .section {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(2, min-content);
|
grid-template-columns: repeat(3, min-content);
|
||||||
grid-gap: 8px 12px;
|
grid-gap: 8px 12px;
|
||||||
}
|
}
|
||||||
#areas .area .section .name {
|
#areas .area .section .name {
|
||||||
|
@ -30,6 +30,10 @@
|
|||||||
#acknowledged-list .acknowledge img {
|
#acknowledged-list .acknowledge img {
|
||||||
height: 16px;
|
height: 16px;
|
||||||
}
|
}
|
||||||
|
#problems-list .info,
|
||||||
|
#acknowledged-list .info {
|
||||||
|
margin-right: 8px;
|
||||||
|
}
|
||||||
#acknowledged-list.hidden {
|
#acknowledged-list.hidden {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
@ -41,7 +45,7 @@
|
|||||||
}
|
}
|
||||||
#areas .area .section {
|
#areas .area .section {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(2, min-content);
|
grid-template-columns: repeat(3, min-content);
|
||||||
grid-gap: 8px 12px;
|
grid-gap: 8px 12px;
|
||||||
}
|
}
|
||||||
#areas .area .section .name {
|
#areas .area .section .name {
|
||||||
|
@ -32,6 +32,10 @@
|
|||||||
height: 16px;
|
height: 16px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.info {
|
||||||
|
margin-right: 8px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#acknowledged-list.hidden{
|
#acknowledged-list.hidden{
|
||||||
@ -47,7 +51,7 @@
|
|||||||
.area {
|
.area {
|
||||||
.section {
|
.section {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(2, min-content);
|
grid-template-columns: repeat(3, min-content);
|
||||||
grid-gap: 8px 12px;
|
grid-gap: 8px 12px;
|
||||||
|
|
||||||
.name {
|
.name {
|
||||||
|
@ -34,13 +34,26 @@
|
|||||||
<div class="area">{{ .AreaName }}</div>
|
<div class="area">{{ .AreaName }}</div>
|
||||||
<div class="section">{{ .SectionName }}</div>
|
<div class="section">{{ .SectionName }}</div>
|
||||||
<div class="start"></div>
|
<div class="start"></div>
|
||||||
<div class="acknowledge"><img src="/images/{{ $version }}/{{ $theme }}/acknowledge.svg"></div>
|
<div class="acknowledge">
|
||||||
|
<img class="info" src="/images/{{ $version }}/{{ $theme }}/info-outline.svg">
|
||||||
|
<img src="/images/{{ $version }}/{{ $theme }}/acknowledge.svg">
|
||||||
|
</div>
|
||||||
{{ else }}
|
{{ else }}
|
||||||
<div class="trigger"><a href="/trigger/edit/{{ .TriggerID }}">{{ .TriggerName }}</a></div>
|
<div class="trigger"><a href="/trigger/edit/{{ .TriggerID }}">{{ .TriggerName }}</a></div>
|
||||||
<div class="area">{{ .AreaName }}</div>
|
<div class="area">{{ .AreaName }}</div>
|
||||||
<div class="section">{{ .SectionName }}</div>
|
<div class="section">{{ .SectionName }}</div>
|
||||||
<div class="start">{{ format_time .Start }}</div>
|
<div class="start">{{ format_time .Start }}</div>
|
||||||
<div class="acknowledge"><a href="/problem/acknowledge/{{ .ID }}"><img src="/images/{{ $version }}/{{ $theme }}/acknowledge-filled.svg"></a></div>
|
<div class="acknowledge">
|
||||||
|
{{ if .FormattedValues }}
|
||||||
|
<img class="info" src="/images/{{ $version }}/{{ $theme }}/info-filled.svg" title="{{ .FormattedValues }}">
|
||||||
|
{{ else }}
|
||||||
|
<img class="info" src="/images/{{ $version }}/{{ $theme }}/info-outline.svg">
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
<a href="/problem/acknowledge/{{ .ID }}">
|
||||||
|
<img src="/images/{{ $version }}/{{ $theme }}/acknowledge-filled.svg">
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</div>
|
</div>
|
||||||
@ -63,7 +76,9 @@
|
|||||||
<div class="area">{{ .AreaName }}</div>
|
<div class="area">{{ .AreaName }}</div>
|
||||||
<div class="section">{{ .SectionName }}</div>
|
<div class="section">{{ .SectionName }}</div>
|
||||||
<div class="start">{{ format_time .Start }}</div>
|
<div class="start">{{ format_time .Start }}</div>
|
||||||
<div class="acknowledge"><a href="/problem/unacknowledge/{{ .ID }}"><img src="/images/{{ $version }}/{{ $theme }}/acknowledge-outline.svg"></a></div>
|
<div class="acknowledge">
|
||||||
|
<a href="/problem/unacknowledge/{{ .ID }}"><img src="/images/{{ $version }}/{{ $theme }}/acknowledge-outline.svg"></a>
|
||||||
|
</div>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -79,6 +94,7 @@
|
|||||||
<div class="name">{{ $sectionName }}</div>
|
<div class="name">{{ $sectionName }}</div>
|
||||||
|
|
||||||
{{ range $problems }}
|
{{ range $problems }}
|
||||||
|
|
||||||
<div class="trigger">{{ .TriggerName }}</div>
|
<div class="trigger">{{ .TriggerName }}</div>
|
||||||
|
|
||||||
{{ if eq (.Start | html) "0001-01-01 00:00:00 +0000 UTC" }}
|
{{ if eq (.Start | html) "0001-01-01 00:00:00 +0000 UTC" }}
|
||||||
@ -86,6 +102,13 @@
|
|||||||
{{ else }}
|
{{ else }}
|
||||||
<div class="since">{{ format_time .Start }}</div>
|
<div class="since">{{ format_time .Start }}</div>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
|
{{ if .FormattedValues }}
|
||||||
|
<div><img src="/images/{{ $version }}/{{ $theme }}/info-filled.svg" title="{{ .FormattedValues }}"></div>
|
||||||
|
{{ else }}
|
||||||
|
<div><img src="/images/{{ $version }}/{{ $theme }}/info-outline.svg"></div>
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</div>
|
</div>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
Loading…
Reference in New Issue
Block a user