Start of error reporting
This commit is contained in:
parent
e728a302ee
commit
b0ffce05f0
@ -9,6 +9,8 @@ import (
|
||||
"smon/notification"
|
||||
|
||||
// Standard
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"time"
|
||||
)
|
||||
|
||||
@ -19,7 +21,8 @@ type NotificationSend struct {
|
||||
UUID string
|
||||
Sent time.Time `db:"send"`
|
||||
OK bool
|
||||
Error []byte
|
||||
Error sql.NullString
|
||||
ErrorIndented string
|
||||
Acknowledged bool
|
||||
TriggerName string `db:"trigger_name"`
|
||||
}
|
||||
@ -51,7 +54,7 @@ func notificationsSent() (nss []NotificationSend, err error) {
|
||||
ns.uuid,
|
||||
ns.send,
|
||||
ns.ok,
|
||||
ns.error,
|
||||
ns.error::varchar,
|
||||
ns.acknowledged
|
||||
|
||||
FROM
|
||||
@ -76,6 +79,15 @@ func notificationsSent() (nss []NotificationSend, err error) {
|
||||
err = werr.Wrap(err)
|
||||
return
|
||||
}
|
||||
|
||||
// Error contains json (can be NULL),
|
||||
// and can at least be presented indented.
|
||||
foo := make(map[string]any)
|
||||
json.Unmarshal([]byte(ns.Error.String), &foo)
|
||||
var j []byte
|
||||
j, err = json.MarshalIndent(foo, "", " ")
|
||||
ns.ErrorIndented = string(j)
|
||||
|
||||
nss = append(nss, ns)
|
||||
}
|
||||
return
|
||||
|
@ -1,6 +1,6 @@
|
||||
#notifications {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, min-content);
|
||||
grid-template-columns: repeat(5, min-content);
|
||||
grid-gap: 4px 16px;
|
||||
margin-top: 32px;
|
||||
margin-bottom: 32px;
|
||||
|
@ -46,7 +46,7 @@
|
||||
}
|
||||
#areas .area .section .name {
|
||||
color: #000;
|
||||
grid-column: -1;
|
||||
grid-column: 1 / -1;
|
||||
font-weight: bold !important;
|
||||
line-height: 24px;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
#notifications {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, min-content);
|
||||
grid-template-columns: repeat(5, min-content);
|
||||
grid-gap: 4px 16px;
|
||||
margin-top: 32px;
|
||||
margin-bottom: 32px;
|
||||
|
@ -46,7 +46,7 @@
|
||||
}
|
||||
#areas .area .section .name {
|
||||
color: #f7edd7;
|
||||
grid-column: -1;
|
||||
grid-column: 1 / -1;
|
||||
font-weight: bold !important;
|
||||
line-height: 24px;
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
#notifications {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, min-content);
|
||||
grid-template-columns: repeat(5, min-content);
|
||||
grid-gap: 4px 16px;
|
||||
margin-top: 32px;
|
||||
margin-bottom: 32px;
|
||||
|
@ -52,7 +52,7 @@
|
||||
|
||||
.name {
|
||||
color: @text2;
|
||||
grid-column: 1 / -1;
|
||||
grid-column: ~"1 / -1";
|
||||
font-weight: bold !important;
|
||||
line-height: 24px;
|
||||
}
|
||||
|
@ -10,11 +10,13 @@
|
||||
<div class="header">OK</div>
|
||||
<div class="header">Trigger name</div>
|
||||
<div class="header">Service</div>
|
||||
<div class="header">Error</div>
|
||||
{{ range .Data.Notifications }}
|
||||
<div>{{ format_time .Sent }}</div>
|
||||
<div>{{ if .OK }}✔{{ else }}✗{{ end }}</div>
|
||||
<div>{{ .TriggerName }}</div>
|
||||
<div>{{ .Prio }}:{{ .Service }}</div>
|
||||
<div><pre>{{ if .Error.Valid }}{{ .ErrorIndented }}{{ end }}</pre></div>
|
||||
{{ end }}
|
||||
</div>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user