2016-08-15 17:04:36 +00:00
|
|
|
port module ResponsePaneHeader exposing (..)
|
|
|
|
|
|
|
|
import Html exposing (..)
|
|
|
|
import Html.Attributes exposing (..)
|
|
|
|
import Html.App as App
|
|
|
|
import TimeTag exposing (..)
|
|
|
|
import SizeTag exposing (..)
|
|
|
|
import StatusTag exposing (..)
|
|
|
|
|
|
|
|
|
|
|
|
-- APP
|
|
|
|
|
2016-09-18 22:58:50 +00:00
|
|
|
|
2016-08-15 17:04:36 +00:00
|
|
|
main : Program Model
|
|
|
|
main =
|
2016-09-18 22:58:50 +00:00
|
|
|
App.programWithFlags
|
|
|
|
{ init = init
|
|
|
|
, view = view
|
|
|
|
, update = update
|
|
|
|
, subscriptions = subscriptions
|
|
|
|
}
|
|
|
|
|
2016-08-15 17:04:36 +00:00
|
|
|
|
|
|
|
|
|
|
|
-- MODEL
|
|
|
|
|
2016-09-18 22:58:50 +00:00
|
|
|
|
2016-08-15 17:04:36 +00:00
|
|
|
type alias Model =
|
|
|
|
{ statusCode : Int
|
|
|
|
, statusMessage : String
|
|
|
|
, statusDescription : String
|
|
|
|
, elapsedTime : Int
|
|
|
|
, bytesRead : Int
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-09-18 22:58:50 +00:00
|
|
|
init : Model -> ( Model, Cmd Msg )
|
2016-08-15 17:04:36 +00:00
|
|
|
init flags =
|
2016-09-18 22:58:50 +00:00
|
|
|
flags ! []
|
|
|
|
|
2016-08-15 17:04:36 +00:00
|
|
|
|
|
|
|
|
|
|
|
-- UPDATE
|
|
|
|
|
|
|
|
|
2016-09-18 22:58:50 +00:00
|
|
|
type Msg
|
|
|
|
= NewModel Model
|
2016-08-15 17:04:36 +00:00
|
|
|
|
2016-09-18 22:58:50 +00:00
|
|
|
|
|
|
|
update : Msg -> Model -> ( Model, Cmd Msg )
|
2016-08-15 17:04:36 +00:00
|
|
|
update msg model =
|
|
|
|
case msg of
|
|
|
|
NewModel newModel ->
|
|
|
|
newModel ! []
|
|
|
|
|
|
|
|
|
2016-09-18 22:58:50 +00:00
|
|
|
|
2016-08-15 17:04:36 +00:00
|
|
|
-- SUBSCRIPTIONS
|
|
|
|
|
2016-09-18 22:58:50 +00:00
|
|
|
|
2016-08-15 17:04:36 +00:00
|
|
|
port replaceModel : (Model -> msg) -> Sub msg
|
|
|
|
|
2016-09-18 22:58:50 +00:00
|
|
|
|
2016-08-15 17:04:36 +00:00
|
|
|
subscriptions : Model -> Sub Msg
|
|
|
|
subscriptions model =
|
2016-09-18 22:58:50 +00:00
|
|
|
replaceModel NewModel
|
|
|
|
|
2016-08-15 17:04:36 +00:00
|
|
|
|
|
|
|
|
|
|
|
-- VIEW
|
|
|
|
|
2016-09-18 22:58:50 +00:00
|
|
|
|
2016-08-15 17:04:36 +00:00
|
|
|
view : Model -> Html Msg
|
|
|
|
view model =
|
2016-09-18 22:58:50 +00:00
|
|
|
div []
|
2016-08-15 17:04:36 +00:00
|
|
|
[ StatusTag.view
|
|
|
|
{ code = model.statusCode
|
|
|
|
, message = model.statusMessage
|
|
|
|
, description = model.statusDescription
|
|
|
|
}
|
|
|
|
, TimeTag.view model.elapsedTime
|
|
|
|
, SizeTag.view model.bytesRead
|
|
|
|
]
|