mirror of
https://github.com/prometheus/alertmanager
synced 2025-01-09 23:39:36 +00:00
Parse silenced and silence id
Show buttons for each
This commit is contained in:
parent
e823a66d53
commit
cb9e95bacb
17
src/Api.elm
17
src/Api.elm
@ -73,15 +73,30 @@ blockDecoder =
|
||||
|
||||
alertDecoder : Json.Decoder Alert
|
||||
alertDecoder =
|
||||
Json.map6 Alert
|
||||
Json.map7 Alert
|
||||
(field "annotations" (Json.keyValuePairs Json.string))
|
||||
(field "labels" (Json.keyValuePairs Json.string))
|
||||
(field "inhibited" Json.bool)
|
||||
(Json.maybe (field "silenced" Json.int))
|
||||
(decodeSilenced)
|
||||
(field "startsAt" stringToDate)
|
||||
(field "generatorURL" Json.string)
|
||||
|
||||
|
||||
decodeSilenced : Decoder Bool
|
||||
decodeSilenced =
|
||||
Json.maybe (Json.at [ "silenced" ] Json.int)
|
||||
|> andThen
|
||||
(\val ->
|
||||
case val of
|
||||
Just _ ->
|
||||
Json.succeed True
|
||||
|
||||
Nothing ->
|
||||
Json.succeed False
|
||||
)
|
||||
|
||||
|
||||
stringToDate : Decoder Date.Date
|
||||
stringToDate =
|
||||
Json.string
|
||||
|
@ -43,9 +43,8 @@ type alias Alert =
|
||||
{ annotations : List ( String, String )
|
||||
, labels : List ( String, String )
|
||||
, inhibited : Bool
|
||||
, silenced :
|
||||
Maybe Int
|
||||
-- TODO: See how to rename this on parsing from API to silenceId
|
||||
, silenceId : Maybe Int
|
||||
, silenced : Bool
|
||||
, startsAt : Date
|
||||
, generatorUrl : String
|
||||
}
|
||||
|
@ -85,19 +85,36 @@ blockView : Block -> Html msg
|
||||
blockView block =
|
||||
-- Block level
|
||||
div [] <|
|
||||
p [] [ text "one block, this'll probably be changed to accept a Block type instead of just the list of alerts" ]
|
||||
p [] [ text "one block" ]
|
||||
:: (List.map alertView block.alerts)
|
||||
|
||||
|
||||
alertView : Alert -> Html msg
|
||||
alertView alert =
|
||||
div [] [ text <| Utils.Date.dateFormat alert.startsAt ]
|
||||
let
|
||||
id =
|
||||
case alert.silenceId of
|
||||
Just id ->
|
||||
id
|
||||
|
||||
Nothing ->
|
||||
0
|
||||
|
||||
b =
|
||||
if alert.silenced then
|
||||
button "Silenced" ("#/silences/" ++ toString id)
|
||||
else
|
||||
button "Active" "#/alerts"
|
||||
in
|
||||
div []
|
||||
[ p [] [ text <| Utils.Date.dateFormat alert.startsAt ]
|
||||
, b
|
||||
]
|
||||
|
||||
|
||||
|
||||
-- Make this into a type?
|
||||
-- labelView : (( String, String ), List Alert) -> Html msg
|
||||
-- labelView (( key, value ), alerts) =
|
||||
button : String -> String -> Html msg
|
||||
button txt link =
|
||||
a [ class "f6 link dim br-pill ba ph3 pv2 mb2 dib dark-blue", href link ] [ text txt ]
|
||||
|
||||
|
||||
labelHeader : ( String, String ) -> Html msg
|
||||
|
Loading…
Reference in New Issue
Block a user