Skip to content

Commit

Permalink
Make sure historic errors are shown in notifications bell
Browse files Browse the repository at this point in the history
  • Loading branch information
NHAS committed Apr 30, 2024
1 parent f820e62 commit 5bc2057
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
2 changes: 2 additions & 0 deletions internal/data/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ type EventError struct {
ErrorID string
FailedEventData []byte
Error string
Time time.Time
}

func RaiseError(idHex string, raisedError error, value []byte) (err error) {
Expand All @@ -222,6 +223,7 @@ func RaiseError(idHex string, raisedError error, value []byte) (err error) {
NodeID: idHex,
FailedEventData: value,
Error: raisedError.Error(),
Time: time.Now(),
}

ee.ErrorID, err = generateRandomBytes(16)
Expand Down
23 changes: 22 additions & 1 deletion ui/notifications.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,28 @@ var (
func getNotifications() []Notification {

notificationsMapLck.RLock()

// Make sure we have any historic errors on display as a notification
errs, err := data.GetAllErrors()
if err == nil {
for _, e := range errs {
if _, ok := notificationsMap[e.ErrorID]; !ok {
notificationsMap[e.ErrorID] = Notification{
ID: e.ErrorID,
Heading: "Node Error",
Message: []string{"Node " + e.NodeID, e.Error},
Url: "/cluster/events/",
Time: e.Time,
OpenNewTab: false,
Color: "#db0b3c",
}

}
}
}

notfs := maps.Values(notificationsMap)

notificationsMapLck.RUnlock()

sort.Slice(notfs, func(i, j int) bool {
Expand Down Expand Up @@ -165,7 +186,7 @@ func receiveErrorNotifications(notifications chan<- Notification) func(key strin
Heading: "Node Error",
Message: []string{"Node " + current.NodeID, current.Error},
Url: "/cluster/events/",
Time: time.Now(),
Time: current.Time,
OpenNewTab: false,
Color: "#db0b3c",
}
Expand Down
2 changes: 2 additions & 0 deletions ui/templates/cluster/events.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ <h1 class="m-0 text-gray-900">Events</h1>
</div>
</div>
<div class="col-sm">


<div class="card shadow mb-4">
<div class="card-header py-3">
<h1 class="m-0 text-gray-900">Errors</h1>
Expand Down

0 comments on commit 5bc2057

Please sign in to comment.