Commit f7b5558f authored by Abinaya Sudhir's avatar Abinaya Sudhir
parents f554f3ca f3f35ffb
...@@ -27,6 +27,7 @@ data Action ...@@ -27,6 +27,7 @@ data Action
= NoOp = NoOp
| Documentation | Documentation
| Enter | Enter
| Login
| SignUp | SignUp
...@@ -41,6 +42,10 @@ performAction Enter _ _ = void do ...@@ -41,6 +42,10 @@ performAction Enter _ _ = void do
lift $ setHash "/search" lift $ setHash "/search"
T.modifyState \state -> state T.modifyState \state -> state
performAction Login _ _ = void do
lift $ setHash "/login"
T.modifyState \state -> state
performAction SignUp _ _ = void do performAction SignUp _ _ = void do
T.modifyState \state -> state T.modifyState \state -> state
......
...@@ -18,45 +18,46 @@ import PageRouter (Routes(..)) ...@@ -18,45 +18,46 @@ import PageRouter (Routes(..))
import Prelude hiding (div) import Prelude hiding (div)
import React (ReactElement) import React (ReactElement)
import React.DOM (a, div, i, img, li, span, text, ul, map') import React.DOM (a, div, i, img, li, span, text, ul, map')
import React.DOM.Props (_data, _id, aria, className, href, role, src, style, tabIndex, target, title) import React.DOM.Props (_data, _id, aria, className, href, role, src, style, tabIndex, target, title, onClick)
import Thermite (PerformAction, Render, Spec, _render, defaultRender, focus, modifyState, simpleSpec, withState) import Thermite (PerformAction, Render, Spec, _render, defaultRender, focus, modifyState, simpleSpec, withState)
import DocView as DV import DocView as DV
import Landing as Landing
import SearchForm as S import SearchForm as S
import UserPage as UP import UserPage as UP
type E e = (dom :: DOM, ajax :: AJAX, console :: CONSOLE | e) type E e = (dom :: DOM, ajax :: AJAX, console :: CONSOLE | e)
type AppState = type AppState =
{ currentRoute :: Maybe Routes { currentRoute :: Maybe Routes
, landingState :: L.State , landingState :: L.State
, loginState :: LN.State , loginState :: LN.State
, addCorpusState :: AC.State , addCorpusState :: AC.State
, docViewState :: DV.State , docViewState :: DV.State
, searchState :: S.State , searchState :: S.State
, userPage :: UP.State , userPage :: UP.State
} }
initAppState :: AppState initAppState :: AppState
initAppState = initAppState =
{ currentRoute : Just Home { currentRoute : Just Home
, landingState : L.initialState , landingState : L.initialState
, loginState : LN.initialState , loginState : LN.initialState
, addCorpusState : AC.initialState , addCorpusState : AC.initialState
, docViewState : DV.tdata , docViewState : DV.tdata
, searchState : S.initialState , searchState : S.initialState
, userPage : UP.initialState , userPage : UP.initialState
} }
data Action data Action
= Initialize = Initialize
| LandingA L.Action | LandingA L.Action
| LoginA LN.Action | LoginA LN.Action
| SetRoute Routes | SetRoute Routes
| AddCorpusA AC.Action | AddCorpusA AC.Action
| DocViewA DV.Action | DocViewA DV.Action
| SearchA S.Action | SearchA S.Action
| UserPageA UP.Action | UserPageA UP.Action
performAction :: forall eff props. PerformAction (dom :: DOM |eff) AppState props Action performAction :: forall eff props. PerformAction (dom :: DOM |eff) AppState props Action
...@@ -92,7 +93,6 @@ _loginAction = prism LoginA \action -> ...@@ -92,7 +93,6 @@ _loginAction = prism LoginA \action ->
_-> Left action _-> Left action
_addCorpusState:: Lens' AppState AC.State _addCorpusState:: Lens' AppState AC.State
_addCorpusState = lens (\s -> s.addCorpusState) (\s ss -> s{addCorpusState = ss}) _addCorpusState = lens (\s -> s.addCorpusState) (\s ss -> s{addCorpusState = ss})
...@@ -219,7 +219,11 @@ sidebarnavSpec = simpleSpec performAction render ...@@ -219,7 +219,11 @@ sidebarnavSpec = simpleSpec performAction render
render :: Render AppState props Action render :: Render AppState props Action
render dispatch _ state _ = render dispatch _ state _ =
[ [
div [ _id "dafixedtop", className "navbar navbar-inverse navbar-fixed-top", role "navigation"] div [ _id "dafixedtop"
, className "navbar navbar-inverse navbar-fixed-top"
, role "navigation"
]
[ div [className "container"] [ div [className "container"]
[ divLogo [ divLogo
-- divDropdownLeft -- divDropdownLeft
...@@ -236,7 +240,9 @@ sidebarnavSpec = simpleSpec performAction render ...@@ -236,7 +240,9 @@ sidebarnavSpec = simpleSpec performAction render
, href "#", role "button" , href "#", role "button"
, title "Informations about Gargantext" , title "Informations about Gargantext"
] ]
[ span [ aria {hidden : true}, className "glyphicon glyphicon-info-sign" ] [] [ span [ aria {hidden : true}
, className "glyphicon glyphicon-info-sign"
] []
, text " Info" , text " Info"
] ]
, ul [className "dropdown-menu"] , ul [className "dropdown-menu"]
...@@ -274,8 +280,6 @@ sidebarnavSpec = simpleSpec performAction render ...@@ -274,8 +280,6 @@ sidebarnavSpec = simpleSpec performAction render
] ]
] ]
] ]
---------------------------------------------------------------------------
---------------------------------------------------------------------------
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
, divDropdownRight , divDropdownRight
] ]
...@@ -283,47 +287,24 @@ sidebarnavSpec = simpleSpec performAction render ...@@ -283,47 +287,24 @@ sidebarnavSpec = simpleSpec performAction render
] ]
] ]
--divDropdownRight :: Render AppState props Action
divDropdownRight :: ReactElement divDropdownRight :: ReactElement
divDropdownRight = ul [className "nav navbar-nav pull-right"] divDropdownRight = ul [className "nav navbar-nav pull-right"]
[ [
-- TODO if logged in : enable dropdown -- TODO if logged in : enable dropdown to logout
--li [className "dropdown"] li [className "dropdown"]
--[ [
a [ a [ aria {hidden : true}
className "dropdown-toggle navbar-text" , className "glyphicon glyphicon-log-in"
, _data {toggle : "dropdown"} , href "#/login"
, href "#", role "button" , style {color:"white"}
, title "Username" -- TODO hover: bold
] ]
-- FIXME not sure about the className "login"
[ i [ className "login" ] []
, span [ aria {hidden : true}
-- TODO if logged in
--, className "glyphicon glyphicon-user"
-- else
, className "glyphicon glyphicon-log-in"
, style {color:"white"}
]
[]
-- TODO if logged in -- TODO if logged in
--, text " username" --, text " username"
-- else -- else
, text " Login / Signup" [text " Login / Signup"]
] ]
-- , ul [className "dropdown-menu"]
-- [
-- , li [ className"divider"]
-- []
-- , li []
-- -- TODO if logged in show logout
-- [ a [tabIndex (-1), href "/auth/login" ]
-- [ span [className "glyphicon glyphicon-log-in",aria {hidden : true}] []
-- , text " Logout"
-- ]
-- ]
-- ]
--]
] ]
layoutSpec :: forall eff props. Spec (E eff) AppState props Action layoutSpec :: forall eff props. Spec (E eff) AppState props Action
...@@ -345,11 +326,11 @@ dispatchAction dispatcher _ Home = do ...@@ -345,11 +326,11 @@ dispatchAction dispatcher _ Home = do
pure unit pure unit
dispatchAction dispatcher _ Login = do dispatchAction dispatcher _ Login = do
_ <- dispatcher $ SetRoute $ Login _ <- dispatcher $ SetRoute $ Login
_ <- dispatcher $ LoginA $ LN.NoOp _ <- dispatcher $ LoginA $ LN.NoOp
pure unit pure unit
dispatchAction dispatcher _ AddCorpus = do dispatchAction dispatcher _ AddCorpus = do
_ <- dispatcher $ SetRoute $ AddCorpus _ <- dispatcher $ SetRoute $ AddCorpus
_ <- dispatcher $ AddCorpusA $ AC.LoadDatabaseDetails _ <- dispatcher $ AddCorpusA $ AC.LoadDatabaseDetails
pure unit pure unit
...@@ -361,16 +342,12 @@ dispatchAction dispatcher _ DocView = do ...@@ -361,16 +342,12 @@ dispatchAction dispatcher _ DocView = do
dispatchAction dispatcher _ SearchView = do dispatchAction dispatcher _ SearchView = do
_ <- dispatcher $ SetRoute $ SearchView _ <- dispatcher $ SetRoute $ SearchView
_ <- dispatcher $ SearchA $ S.NoOp _ <- dispatcher $ SearchA $ S.NoOp
pure unit pure unit
dispatchAction dispatcher _ UserPage = do dispatchAction dispatcher _ UserPage = do
_ <- dispatcher $ SetRoute $ UserPage _ <- dispatcher $ SetRoute $ UserPage
_ <- dispatcher $ UserPageA $ UP.NoOp _ <- dispatcher $ UserPageA $ UP.NoOp
pure unit pure unit
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment