mirror of
https://github.com/prometheus/alertmanager
synced 2025-01-09 23:39:36 +00:00
Simplify code and remove infinite redirect
This commit is contained in:
parent
8a82068b2b
commit
e1e64f4415
21
src/Main.elm
21
src/Main.elm
@ -29,7 +29,7 @@ init location =
|
||||
route =
|
||||
Parsing.urlParser location
|
||||
in
|
||||
( Model [] (Silence 0 "" "" "" "" "" []) [] (Alert "") route, routeCmd route )
|
||||
update (urlUpdate location) (Model [] (Silence 0 "" "" "" "" "" []) [] (Alert "") route)
|
||||
|
||||
|
||||
update : Msg -> Model -> ( Model, Cmd Msg )
|
||||
@ -54,21 +54,8 @@ update msg model =
|
||||
FetchSilence id ->
|
||||
( { model | route = SilenceRoute id }, Api.getSilence id )
|
||||
|
||||
RedirectAlerts ->
|
||||
( { model | route = AlertsRoute }, Navigation.newUrl "/#/alerts" )
|
||||
|
||||
|
||||
routeCmd : Route -> Cmd Msg
|
||||
routeCmd route =
|
||||
case route of
|
||||
SilencesRoute ->
|
||||
Api.getSilences
|
||||
|
||||
SilenceRoute id ->
|
||||
Api.getSilence id
|
||||
|
||||
_ ->
|
||||
Cmd.none
|
||||
RedirectSilences ->
|
||||
( { model | route = AlertsRoute }, Navigation.newUrl "/#/silences" )
|
||||
|
||||
|
||||
urlUpdate : Navigation.Location -> Msg
|
||||
@ -86,7 +73,7 @@ urlUpdate location =
|
||||
|
||||
_ ->
|
||||
-- TODO: 404 page
|
||||
RedirectAlerts
|
||||
RedirectSilences
|
||||
|
||||
|
||||
|
||||
|
@ -53,7 +53,7 @@ type Msg
|
||||
| SilencesFetch (Result Http.Error (List Silence))
|
||||
| FetchSilences
|
||||
| FetchSilence String
|
||||
| RedirectAlerts
|
||||
| RedirectSilences
|
||||
|
||||
|
||||
type Route
|
||||
|
Loading…
Reference in New Issue
Block a user