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

View File

@ -6,25 +6,6 @@ import Html.Attributes exposing (href, placeholder, type_, value)
import Html.Events exposing (onInput) 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 : String -> List (Html msg) -> Browser.Document msg
template title body = template title body =
{ title = title { title = title

View File

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