forked from prometheus/alertmanager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Updates.elm
124 lines (100 loc) · 4.61 KB
/
Updates.elm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
module Updates exposing (update)
import Browser.Navigation as Navigation
import Task
import Types exposing (Model, Msg(..), Route(..))
import Views.AlertList.Types exposing (AlertListMsg(..))
import Views.AlertList.Updates
import Views.Settings.Updates
import Views.SilenceForm.Types exposing (SilenceFormMsg(..))
import Views.SilenceForm.Updates
import Views.SilenceList.Types exposing (SilenceListMsg(..))
import Views.SilenceList.Updates
import Views.SilenceView.Types as SilenceViewTypes
import Views.SilenceView.Updates
import Views.Status.Types exposing (StatusMsg(..))
import Views.Status.Updates
update : Msg -> Model -> ( Model, Cmd Msg )
update msg ({ basePath, apiUrl } as model) =
case msg of
NavigateToAlerts filter ->
let
( alertList, cmd ) =
Views.AlertList.Updates.update FetchAlerts model.alertList filter apiUrl basePath
in
( { model | alertList = alertList, route = AlertsRoute filter, filter = filter }, cmd )
NavigateToSilenceList filter ->
let
( silenceList, cmd ) =
Views.SilenceList.Updates.update FetchSilences model.silenceList filter basePath apiUrl
in
( { model | silenceList = silenceList, route = SilenceListRoute filter, filter = filter }
, Cmd.map MsgForSilenceList cmd
)
NavigateToStatus ->
( { model | route = StatusRoute }, Task.perform identity (Task.succeed <| MsgForStatus <| InitStatusView apiUrl) )
NavigateToSilenceView silenceId ->
let
( silenceView, cmd ) =
Views.SilenceView.Updates.update (SilenceViewTypes.InitSilenceView silenceId) model.silenceView apiUrl
in
( { model | route = SilenceViewRoute silenceId, silenceView = silenceView }
, Cmd.map MsgForSilenceView cmd
)
NavigateToSilenceFormNew params ->
( { model | route = SilenceFormNewRoute params }
, Task.perform (NewSilenceFromMatchersAndComment model.defaultCreator >> MsgForSilenceForm) (Task.succeed params)
)
NavigateToSilenceFormEdit uuid ->
( { model | route = SilenceFormEditRoute uuid }, Task.perform identity (Task.succeed <| (FetchSilence uuid |> MsgForSilenceForm)) )
NavigateToNotFound ->
( { model | route = NotFoundRoute }, Cmd.none )
NavigateToInternalUrl url ->
( model, Navigation.pushUrl model.key url )
NavigateToExternalUrl url ->
( model, Navigation.load url )
RedirectAlerts ->
( model, Navigation.pushUrl model.key (basePath ++ "#/alerts") )
NavigateToSettings ->
( { model | route = SettingsRoute }, Cmd.none )
MsgForStatus subMsg ->
Views.Status.Updates.update subMsg model
MsgForAlertList subMsg ->
let
( alertList, cmd ) =
Views.AlertList.Updates.update subMsg model.alertList model.filter apiUrl basePath
in
( { model | alertList = alertList }, cmd )
MsgForSilenceList subMsg ->
let
( silenceList, cmd ) =
Views.SilenceList.Updates.update subMsg model.silenceList model.filter basePath apiUrl
in
( { model | silenceList = silenceList }, Cmd.map MsgForSilenceList cmd )
MsgForSettings subMsg ->
let
( settingsView, cmd ) =
Views.Settings.Updates.update subMsg model.settings
in
( { model | settings = settingsView }, cmd )
MsgForSilenceView subMsg ->
let
( silenceView, cmd ) =
Views.SilenceView.Updates.update subMsg model.silenceView apiUrl
in
( { model | silenceView = silenceView }, Cmd.map MsgForSilenceView cmd )
MsgForSilenceForm subMsg ->
let
( silenceForm, cmd ) =
Views.SilenceForm.Updates.update subMsg model.silenceForm basePath apiUrl
in
( { model | silenceForm = silenceForm }, cmd )
BootstrapCSSLoaded css ->
( { model | bootstrapCSS = css }, Cmd.none )
FontAwesomeCSSLoaded css ->
( { model | fontAwesomeCSS = css }, Cmd.none )
ElmDatepickerCSSLoaded css ->
( { model | elmDatepickerCSS = css }, Cmd.none )
SetDefaultCreator name ->
( { model | defaultCreator = name }, Cmd.none )
SetGroupExpandAll expanded ->
( { model | expandAll = expanded }, Cmd.none )