mirror of
https://github.com/prometheus/alertmanager
synced 2025-01-03 20:42:07 +00:00
Re-use silenceView
This commit is contained in:
parent
99bb581e7e
commit
47fed35d26
@ -12,33 +12,39 @@ import ISO8601
|
||||
|
||||
import Types exposing (Silence, Matcher, Msg(..))
|
||||
import Utils.Views exposing (..)
|
||||
import Utils.Date
|
||||
|
||||
|
||||
silenceView : Silence -> Html Msg
|
||||
silenceView silence =
|
||||
let
|
||||
dictMatchers =
|
||||
List.map (\x -> ( x.name, x.value )) silence.matchers
|
||||
-- TODO: Check with fabxc if the alert being in the first position can
|
||||
-- be relied upon.
|
||||
alertName =
|
||||
case List.head silence.matchers of
|
||||
Just m ->
|
||||
m.value
|
||||
|
||||
Nothing ->
|
||||
""
|
||||
|
||||
editUrl =
|
||||
String.join "/" [ "#/silences", toString silence.id, "edit" ]
|
||||
in
|
||||
div []
|
||||
[ dl [ class "mt2 f6 lh-copy" ]
|
||||
[ objectData (toString silence.id)
|
||||
, objectData silence.createdBy
|
||||
, objectData silence.comment
|
||||
div [ class "f6 mb3" ]
|
||||
[ a
|
||||
[ class "db link blue mb3"
|
||||
, href ("#/silences/" ++ (toString silence.id))
|
||||
]
|
||||
, ul [ class "list" ]
|
||||
(List.map labelButton dictMatchers)
|
||||
, a
|
||||
[ class "f6 link br2 ba ph3 pv2 mr2 dib blue"
|
||||
, href ("#/silences/" ++ (toString silence.id) ++ "/edit")
|
||||
[ b [ class "db f4 mb1" ]
|
||||
[ text alertName ]
|
||||
]
|
||||
[ text "Update" ]
|
||||
, a
|
||||
[ class "f6 link br2 ba ph3 pv2 mr2 dib dark-red"
|
||||
, href ("#")
|
||||
, onClick (DestroySilence silence)
|
||||
, div [ class "mb1" ]
|
||||
[ buttonLink "fa-pencil" editUrl "blue" (Noop [])
|
||||
, buttonLink "fa-trash-o" "#/silences" "dark-red" (DestroySilence silence)
|
||||
, p [ class "dib mr2" ] [ text <| "Until " ++ Utils.Date.dateFormat silence.endsAt ]
|
||||
]
|
||||
[ text "Destroy" ]
|
||||
, div [ class "mb2 w-80-l w-100-m" ] (List.map matcherButton <| List.filter (\m -> m.name /= "alertname") silence.matchers)
|
||||
]
|
||||
|
||||
|
||||
|
@ -4,7 +4,7 @@ module Utils.Views exposing (..)
|
||||
|
||||
import Html exposing (..)
|
||||
import Html.Attributes exposing (..)
|
||||
import Html.Events exposing (onCheck, onInput)
|
||||
import Html.Events exposing (onCheck, onInput, onClick)
|
||||
|
||||
|
||||
-- Internal Imports
|
||||
@ -43,3 +43,10 @@ textField labelText content msg =
|
||||
[ label [ class "f6 b db mb2" ] [ text labelText ]
|
||||
, textarea [ class "db border-box hover-black w-100 ba b--black-20 pa2 br1 mb2", value content, onInput msg ] []
|
||||
]
|
||||
|
||||
|
||||
buttonLink : String -> String -> String -> msg -> Html msg
|
||||
buttonLink icon link color msg =
|
||||
a [ class <| "f6 link br1 ba mr1 ph3 pv2 mb2 dib " ++ color, href link, onClick msg ]
|
||||
[ i [ class <| "fa fa-3 " ++ icon ] []
|
||||
]
|
||||
|
@ -89,13 +89,6 @@ alertView alert =
|
||||
]
|
||||
|
||||
|
||||
buttonLink : String -> String -> String -> msg -> Html msg
|
||||
buttonLink icon link color msg =
|
||||
a [ class <| "f6 link br1 ba mr1 ph3 pv2 mb2 dib " ++ color, href link, onClick msg ]
|
||||
[ i [ class <| "fa fa-3 " ++ icon ] []
|
||||
]
|
||||
|
||||
|
||||
alertHeader : ( String, String ) -> Html msg
|
||||
alertHeader ( key, value ) =
|
||||
if key == "alertname" then
|
||||
@ -124,33 +117,7 @@ genericListView fn list =
|
||||
|
||||
silenceListView : Silence -> Html Msg
|
||||
silenceListView silence =
|
||||
let
|
||||
-- TODO: Check with fabxc if the alert being in the first position can
|
||||
-- be relied upon.
|
||||
alertName =
|
||||
case List.head silence.matchers of
|
||||
Just m ->
|
||||
m.value
|
||||
|
||||
Nothing ->
|
||||
""
|
||||
|
||||
editUrl =
|
||||
String.join "/" [ "#/silences", toString silence.id, "edit" ]
|
||||
in
|
||||
li
|
||||
[ class "pa3 pa4-ns bb b--black-10" ]
|
||||
[ a
|
||||
[ class "db link blue mb3"
|
||||
, href ("#/silences/" ++ (toString silence.id))
|
||||
]
|
||||
[ b [ class "db f4 mb1" ]
|
||||
[ text alertName ]
|
||||
]
|
||||
, div [ class "mb1 f6" ]
|
||||
[ buttonLink "fa-pencil" editUrl "blue" (Noop [])
|
||||
, buttonLink "fa-trash-o" "#/silences" "dark-red" (DestroySilence silence)
|
||||
, p [ class "dib mr2" ] [ text <| "Until " ++ Utils.Date.dateFormat silence.endsAt ]
|
||||
]
|
||||
, div [ class "mb2 w-80-l w-100-m" ] (List.map Silences.Views.matcherButton <| List.filter (\m -> m.name /= "alertname") silence.matchers)
|
||||
]
|
||||
li
|
||||
[ class "pa3 pa4-ns bb b--black-10" ]
|
||||
[ Silences.Views.silenceView silence
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user