fix frontend

This commit is contained in:
Cadey Ratio 2020-01-14 23:41:11 +00:00
parent a97b14ff33
commit f1e1ed7ca5
3 changed files with 9 additions and 28 deletions

View File

@ -31,8 +31,6 @@ type alias Model =
, url : Url.Url
, token : Maybe String
, token_data : Maybe TokenData
, switch_cursor : ( Int, Int )
, switch_data : Maybe (List SwitchData.Switch)
}
@ -43,8 +41,6 @@ init flags url key =
url
Nothing
Nothing
( 40, 0 )
Nothing
, Cmd.none
)
@ -75,7 +71,11 @@ update msg model =
UrlChanged url ->
case url.path of
"/logout" ->
( model, Nav.load "/" )
( { model | token = Nothing, token_data = Nothing }
, Nav.pushUrl
model.key
"/"
)
default ->
( { model | url = url }

View File

@ -6,25 +6,6 @@ import Html.Attributes exposing (href, placeholder, type_, value)
import Html.Events exposing (onInput)
type Page
= Login
| TokenData
| NotFound String
fromPath : String -> Page
fromPath path =
case path of
"/" ->
TokenData
"/login" ->
Login
other ->
NotFound other
template : String -> List (Html msg) -> Browser.Document msg
template title body =
{ title = title

View File

@ -26,14 +26,14 @@ init =
type Msg
= GotToken String
= Init
| GotTokenData (Result Http.Error TokenData)
update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
update : Msg -> String -> Model -> ( Model, Cmd Msg )
update msg token model =
case msg of
GotToken token ->
Init ->
( { model | token = Just token }
, Mi.request
"GET"