Skip to content

Commit

Permalink
feat(elm): Basic user profile page (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
pmrukot authored and mrapacz committed Aug 14, 2017
1 parent 41cefd9 commit 669d6ed
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 5 deletions.
1 change: 1 addition & 0 deletions aion/web/elm/src/General/Models.elm
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ type Route
| RoomListRoute
| RoomRoute RoomId
| PanelRoute
| UserRoute
| NotFoundRoute


Expand Down
7 changes: 4 additions & 3 deletions aion/web/elm/src/General/View.elm
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
module General.View exposing (..)

import General.Models exposing (Model)
import Html exposing (Html, a, div, i, li, p, text, ul)
import Html exposing (Html, a, div, h3, i, li, p, text, ul)
import Html.Attributes exposing (href)
import Msgs exposing (Msg)
import Routing exposing (panelPath, roomsPath)
import Routing exposing (panelPath, roomsPath, userPath)
import RemoteData exposing (WebData)
import Room.Models exposing (RoomsData)

Expand All @@ -19,10 +19,11 @@ notFoundView =
homeView : Model -> Html Msg
homeView model =
div []
[ p [] [ text "Welcome to Aion!" ]
[ h3 [] [ text "Welcome to Aion!" ]
, ul []
[ li [] [ a [ href roomsPath ] [ text "Rooms" ] ]
, li [] [ a [ href panelPath ] [ text "Panel" ] ]
, li [] [ a [ href userPath ] [ text "Profile" ] ]
]
]

Expand Down
8 changes: 7 additions & 1 deletion aion/web/elm/src/Routing.elm
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Routing exposing (..)

import General.Models exposing (Route(LoginRoute, NotFoundRoute, PanelRoute, RoomListRoute, RoomRoute))
import General.Models exposing (Route(LoginRoute, NotFoundRoute, PanelRoute, RoomListRoute, RoomRoute, UserRoute))
import Navigation exposing (Location)
import UrlParser exposing (..)

Expand All @@ -12,6 +12,7 @@ matchers =
, map RoomRoute (s "rooms" </> int)
, map RoomListRoute (s "rooms")
, map PanelRoute (s "panel")
, map UserRoute (s "profile")
]


Expand All @@ -33,3 +34,8 @@ roomsPath =
panelPath : String
panelPath =
"#panel"


userPath : String
userPath =
"#profile"
25 changes: 25 additions & 0 deletions aion/web/elm/src/User/View.elm
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module User.View exposing (..)

import General.Models exposing (Model)
import Html exposing (..)
import Msgs exposing (Msg(..))
import RemoteData


userView : Model -> Html Msg
userView model =
case model.user of
RemoteData.Success user ->
div []
[ h3 [] [ text ("Username: " ++ user.name) ]
, h3 [] [ text ("Email: " ++ user.email) ]
]

RemoteData.NotAsked ->
text ""

RemoteData.Loading ->
text "Loading..."

RemoteData.Failure error ->
text (toString error)
6 changes: 5 additions & 1 deletion aion/web/elm/src/View.elm
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
module View exposing (..)

import General.Models exposing (Model, Route(LoginRoute, NotFoundRoute, PanelRoute, RoomListRoute, RoomRoute))
import General.Models exposing (Model, Route(LoginRoute, NotFoundRoute, PanelRoute, RoomListRoute, RoomRoute, UserRoute))
import General.View exposing (homeView, notFoundView, roomListView)
import Html exposing (..)
import Msgs exposing (Msg(..))
import Panel.View exposing (panelView)
import Room.View exposing (roomView)
import User.View exposing (userView)


view : Model -> Html Msg
Expand All @@ -29,5 +30,8 @@ page model =
PanelRoute ->
panelView model

UserRoute ->
userView model

NotFoundRoute ->
notFoundView

0 comments on commit 669d6ed

Please sign in to comment.