attempt :D

This commit is contained in:
Cadey Ratio 2020-01-15 22:40:17 +00:00
parent b36f2a3cf6
commit aac4592c53
3 changed files with 59 additions and 33 deletions

View File

@ -48,6 +48,12 @@ init flags url key =
) )
type Page
= NotFound
| Index
| SwitchData PSD.Model
type Msg type Msg
= LinkClicked Browser.UrlRequest = LinkClicked Browser.UrlRequest
| UrlChanged Url.Url | UrlChanged Url.Url
@ -113,8 +119,17 @@ update msg model =
, Nav.load "/" , Nav.load "/"
) )
_ -> GotSwitchDataMSG psd_msg ->
( model, Cmd.none ) let
( psd_model, cmd ) =
PSD.update
(Maybe.withDefault "" model.token)
psd_msg
model.switch_data_model
in
( { model | switch_data_model = psd_model }
, Cmd.map GotSwitchDataMSG cmd
)
subscriptions : Model -> Sub Msg subscriptions : Model -> Sub Msg
@ -156,6 +171,9 @@ view model =
] ]
] ]
"/switch" ->
PSD.view model.switch_data_model
other -> other ->
template "Not found" template "Not found"
[ h1 [] [ text "Not found" ] [ h1 [] [ text "Not found" ]

View File

@ -29,12 +29,14 @@ type Data
| Error String | Error String
init : Model init : ( Model, Cmd Msg )
init = init =
Model ( Model
0 0
40 40
Init Init
, NeedData
)
type Msg type Msg
@ -45,6 +47,10 @@ type Msg
update : String -> Msg -> Model -> ( Model, Cmd Msg ) update : String -> Msg -> Model -> ( Model, Cmd Msg )
update token msg model = update token msg model =
if token == "" then
( model, Cmd.none )
else
case msg of case msg of
NeedData -> NeedData ->
( model ( model

View File

@ -7,6 +7,8 @@ module SwitchData exposing
, switchURL , switchURL
) )
import Html exposing (..)
import Html.Attributes exposing (..)
import Iso8601 import Iso8601
import Json.Decode exposing (Decoder, field, int, map5, nullable, string) import Json.Decode exposing (Decoder, field, int, map5, nullable, string)
import Time exposing (Posix) import Time exposing (Posix)