1
0
mirror of https://github.com/jhillyerd/inbucket.git synced 2026-05-14 17:43:49 +00:00

ui: Refactor update and setRoute with updateWith

This commit is contained in:
James Hillyerd
2018-11-22 22:02:01 -08:00
parent 0c9cf81c94
commit e71377f966
5 changed files with 69 additions and 87 deletions

View File

@@ -17,7 +17,7 @@ type alias Model =
{ greeting : String }
init : ( Model, Cmd Msg )
init : ( Model, Cmd Msg, Session.Msg )
init =
let
cmdGreeting =
@@ -26,7 +26,7 @@ init =
, expect = Http.expectString GreetingLoaded
}
in
( Model "", cmdGreeting )
( Model "", cmdGreeting, Session.none )

View File

@@ -77,10 +77,11 @@ type alias Model =
}
init : String -> Maybe MessageID -> ( Model, Cmd Msg )
init : String -> Maybe MessageID -> ( Model, Cmd Msg, Session.Msg )
init mailboxName selection =
( Model mailboxName (LoadingList selection) SafeHtmlBody "" (Time.millisToPosix 0)
, load mailboxName
, Session.none
)

View File

@@ -27,9 +27,9 @@ type MonitorMessage
| Message MessageHeader
init : ( Model, Cmd Msg )
init : ( Model, Cmd Msg, Session.Msg )
init =
( Model False [], Ports.monitorCommand True )
( Model False [], Ports.monitorCommand True, Session.none )

View File

@@ -1,4 +1,4 @@
module Page.Status exposing (Model, Msg, init, load, subscriptions, update, view)
module Page.Status exposing (Model, Msg, init, subscriptions, update, view)
import Data.Metrics as Metrics exposing (Metrics)
import Data.Session as Session exposing (Session)
@@ -46,25 +46,28 @@ type alias Metric =
}
init : Model
init : ( Model, Cmd Msg, Session.Msg )
init =
{ metrics = Nothing
, xCounter = 60
, sysMem = Metric "System Memory" 0 Filesize.format graphZero initDataSet 10
, heapSize = Metric "Heap Size" 0 Filesize.format graphZero initDataSet 10
, heapUsed = Metric "Heap Used" 0 Filesize.format graphZero initDataSet 10
, heapObjects = Metric "Heap # Objects" 0 fmtInt graphZero initDataSet 10
, goRoutines = Metric "Goroutines" 0 fmtInt graphZero initDataSet 10
, webSockets = Metric "Open WebSockets" 0 fmtInt graphZero initDataSet 10
, smtpConnOpen = Metric "Open Connections" 0 fmtInt graphZero initDataSet 10
, smtpConnTotal = Metric "Total Connections" 0 fmtInt graphChange initDataSet 60
, smtpReceivedTotal = Metric "Messages Received" 0 fmtInt graphChange initDataSet 60
, smtpErrorsTotal = Metric "Messages Errors" 0 fmtInt graphChange initDataSet 60
, smtpWarnsTotal = Metric "Messages Warns" 0 fmtInt graphChange initDataSet 60
, retentionDeletesTotal = Metric "Retention Deletes" 0 fmtInt graphChange initDataSet 60
, retainedCount = Metric "Stored Messages" 0 fmtInt graphZero initDataSet 60
, retainedSize = Metric "Store Size" 0 Filesize.format graphZero initDataSet 60
}
( { metrics = Nothing
, xCounter = 60
, sysMem = Metric "System Memory" 0 Filesize.format graphZero initDataSet 10
, heapSize = Metric "Heap Size" 0 Filesize.format graphZero initDataSet 10
, heapUsed = Metric "Heap Used" 0 Filesize.format graphZero initDataSet 10
, heapObjects = Metric "Heap # Objects" 0 fmtInt graphZero initDataSet 10
, goRoutines = Metric "Goroutines" 0 fmtInt graphZero initDataSet 10
, webSockets = Metric "Open WebSockets" 0 fmtInt graphZero initDataSet 10
, smtpConnOpen = Metric "Open Connections" 0 fmtInt graphZero initDataSet 10
, smtpConnTotal = Metric "Total Connections" 0 fmtInt graphChange initDataSet 60
, smtpReceivedTotal = Metric "Messages Received" 0 fmtInt graphChange initDataSet 60
, smtpErrorsTotal = Metric "Messages Errors" 0 fmtInt graphChange initDataSet 60
, smtpWarnsTotal = Metric "Messages Warns" 0 fmtInt graphChange initDataSet 60
, retentionDeletesTotal = Metric "Retention Deletes" 0 fmtInt graphChange initDataSet 60
, retainedCount = Metric "Stored Messages" 0 fmtInt graphZero initDataSet 60
, retainedSize = Metric "Store Size" 0 Filesize.format graphZero initDataSet 60
}
, getMetrics
, Session.none
)
initDataSet : Spark.DataSet
@@ -73,11 +76,6 @@ initDataSet =
|> List.map (\x -> ( toFloat x, 0 ))
load : Cmd Msg
load =
getMetrics
-- SUBSCRIPTIONS --