Add receiver name to the alerts page (#3289)

Signed-off-by: Julien Pivotto <roidelapluie@o11y.eu>
This commit is contained in:
Julien Pivotto 2023-03-09 17:32:13 +01:00 committed by GitHub
parent e35e13d7a1
commit 14a265b710
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 11 deletions

File diff suppressed because one or more lines are too long

View File

@ -2,6 +2,7 @@ module Views.AlertList.Views exposing (view)
import Data.AlertGroup exposing (AlertGroup) import Data.AlertGroup exposing (AlertGroup)
import Data.GettableAlert exposing (GettableAlert) import Data.GettableAlert exposing (GettableAlert)
import Data.Receiver exposing (Receiver)
import Dict import Dict
import Html exposing (..) import Html exposing (..)
import Html.Attributes exposing (..) import Html.Attributes exposing (..)
@ -91,25 +92,25 @@ defaultAlertGroups activeId activeGroups expandAll groups =
[] -> [] ->
Utils.Views.error "No alert groups found" Utils.Views.error "No alert groups found"
[ { labels, alerts } ] -> [ { labels, receiver, alerts } ] ->
let let
labels_ = labels_ =
Dict.toList labels Dict.toList labels
in in
alertGroup activeId (Set.singleton 0) labels_ alerts 0 expandAll alertGroup activeId (Set.singleton 0) receiver labels_ alerts 0 expandAll
_ -> _ ->
div [ class "pl-5" ] div [ class "pl-5" ]
(List.indexedMap (List.indexedMap
(\index group -> (\index group ->
alertGroup activeId activeGroups (Dict.toList group.labels) group.alerts index expandAll alertGroup activeId activeGroups group.receiver (Dict.toList group.labels) group.alerts index expandAll
) )
groups groups
) )
alertGroup : Maybe String -> Set Int -> Labels -> List GettableAlert -> Int -> Bool -> Html Msg alertGroup : Maybe String -> Set Int -> Receiver -> Labels -> List GettableAlert -> Int -> Bool -> Html Msg
alertGroup activeId activeGroups labels alerts groupId expandAll = alertGroup activeId activeGroups receiver labels alerts groupId expandAll =
let let
groupActive = groupActive =
expandAll || Set.member groupId activeGroups expandAll || Set.member groupId activeGroups
@ -142,7 +143,7 @@ alertGroup activeId activeGroups labels alerts groupId expandAll =
labels labels
expandButton = expandButton =
expandAlertGroup groupActive groupId expandAlertGroup groupActive groupId receiver
|> Html.map (\msg -> MsgForAlertList (ActiveGroups msg)) |> Html.map (\msg -> MsgForAlertList (ActiveGroups msg))
alertCount = alertCount =
@ -168,8 +169,8 @@ alertGroup activeId activeGroups labels alerts groupId expandAll =
] ]
expandAlertGroup : Bool -> Int -> Html Int expandAlertGroup : Bool -> Int -> Receiver -> Html Int
expandAlertGroup expanded groupId = expandAlertGroup expanded groupId receiver =
let let
icon = icon =
if expanded then if expanded then
@ -183,4 +184,10 @@ expandAlertGroup expanded groupId =
, class "btn btn-outline-info border-0 mr-1 mb-1" , class "btn btn-outline-info border-0 mr-1 mb-1"
, style "margin-left" "-3rem" , style "margin-left" "-3rem"
] ]
[ i [ class ("fa " ++ icon) ] [] ] [ i
[ class ("fa " ++ icon)
, class "mr-2"
]
[]
, text receiver.name
]