Use elm-spa #1
|
@ -11,15 +11,17 @@
|
|||
"elm/html": "1.0.0",
|
||||
"elm/http": "2.0.0",
|
||||
"elm/json": "1.1.3",
|
||||
"elm/time": "1.0.0",
|
||||
"elm/url": "1.0.0",
|
||||
"mdgriffith/elm-ui": "1.1.5",
|
||||
"rtfeldman/elm-iso8601-date-strings": "1.1.3",
|
||||
"ryannhg/elm-spa": "3.0.0"
|
||||
},
|
||||
"indirect": {
|
||||
"elm/browser": "1.0.2",
|
||||
"elm/bytes": "1.0.8",
|
||||
"elm/file": "1.0.5",
|
||||
"elm/time": "1.0.0",
|
||||
"elm/parser": "1.1.0",
|
||||
"elm/virtual-dom": "1.0.2"
|
||||
}
|
||||
},
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
dist
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,64 @@
|
|||
module Mi.SwitchData exposing
|
||||
( Switch
|
||||
, decoder
|
||||
, frontURL
|
||||
, idURL
|
||||
, listURL
|
||||
, switchURL
|
||||
)
|
||||
|
||||
import Html exposing (..)
|
||||
import Html.Attributes exposing (..)
|
||||
import Iso8601
|
||||
import Json.Decode exposing (Decoder, field, int, map5, nullable, string)
|
||||
import Time exposing (Posix)
|
||||
import Url.Builder as UB
|
||||
|
||||
|
||||
type alias Switch =
|
||||
{ id : String
|
||||
, who : String
|
||||
, started_at : Posix
|
||||
, ended_at : Maybe Posix
|
||||
, duration : Int
|
||||
}
|
||||
|
||||
|
||||
decoder : Decoder Switch
|
||||
decoder =
|
||||
map5 Switch
|
||||
(field "id" string)
|
||||
(field "who" string)
|
||||
(field "started_at" Iso8601.decoder)
|
||||
(field "ended_at" (nullable Iso8601.decoder))
|
||||
(field "duration" int)
|
||||
|
||||
|
||||
switchURL : String
|
||||
switchURL =
|
||||
UB.absolute
|
||||
[ "switches", "switch" ]
|
||||
[]
|
||||
|
||||
|
||||
idURL : String -> String
|
||||
idURL id =
|
||||
UB.absolute
|
||||
[ "switches", "id", id ]
|
||||
[]
|
||||
|
||||
|
||||
frontURL : String
|
||||
frontURL =
|
||||
UB.absolute
|
||||
[ "switches", "current" ]
|
||||
[]
|
||||
|
||||
|
||||
listURL : Int -> Int -> String
|
||||
listURL limit page =
|
||||
UB.absolute
|
||||
[ "switches", "" ]
|
||||
[ UB.int "limit" limit
|
||||
, UB.int "page" page
|
||||
]
|
|
@ -1,9 +1,11 @@
|
|||
module Pages.Switches exposing (Model, Msg, page)
|
||||
|
||||
import Spa.Page
|
||||
import Element exposing (..)
|
||||
import Generated.Params as Params
|
||||
import Global
|
||||
import Mi
|
||||
import Mi.SwitchData
|
||||
import Spa.Page
|
||||
import Utils.Spa exposing (Page)
|
||||
|
||||
|
||||
|
@ -65,4 +67,4 @@ subscriptions model =
|
|||
|
||||
view : Model -> Element Msg
|
||||
view model =
|
||||
text "Switches"
|
||||
text "Switches"
|
||||
|
|
Loading…
Reference in New Issue