Commit a0c03fc1 authored by Alexandre Delanoë's avatar Alexandre Delanoë

[MERGE] conflit on filterSpec

parents 46d284c6 d478bd35
...@@ -94,14 +94,12 @@ instance decodeResponse :: DecodeJson Response where ...@@ -94,14 +94,12 @@ instance decodeResponse :: DecodeJson Response where
hyperdata <- obj .? "hyperdata" hyperdata <- obj .? "hyperdata"
pure $ Response { cid, created, favorite, ngramCount, hyperdata } pure $ Response { cid, created, favorite, ngramCount, hyperdata }
filterSpec :: forall eff props. Spec eff State props Action
filterSpec :: Spec _ State _ Action
filterSpec = simpleSpec defaultPerformAction render filterSpec = simpleSpec defaultPerformAction render
where where
render :: Render State _ Action render d p s c = [div [] [ text " Filter "
render dispatch _ state _ = [div [] [text "Filter ", input [] []]] , input [] []
]]
layoutDocview :: Spec _ State _ Action layoutDocview :: Spec _ State _ Action
layoutDocview = simpleSpec performAction render layoutDocview = simpleSpec performAction render
...@@ -113,7 +111,7 @@ layoutDocview = simpleSpec performAction render ...@@ -113,7 +111,7 @@ layoutDocview = simpleSpec performAction render
[ [
div [className "col-md-12"] div [className "col-md-12"]
[ p'' [ p''
, text "Filter ", input [] [] , div [] [ text " Filter ", input [] []]
, h3 [] [text "Chart Title"] , h3 [] [text "Chart Title"]
, histogram , histogram
, p'' , p''
......
module Login where module Login where
import Prelude hiding (div)
import Control.Monad.Aff (Aff, attempt) import Control.Monad.Aff (Aff, attempt)
import Control.Monad.Aff.Class (liftAff) import Control.Monad.Aff.Class (liftAff)
import Control.Monad.Aff.Console (log) import Control.Monad.Aff.Console (log)
...@@ -14,15 +16,16 @@ import DOM.WebStorage.Storage (getItem, setItem) ...@@ -14,15 +16,16 @@ import DOM.WebStorage.Storage (getItem, setItem)
import Data.Argonaut (class DecodeJson, class EncodeJson, decodeJson, encodeJson, jsonEmptyObject, (.?), (:=), (~>)) import Data.Argonaut (class DecodeJson, class EncodeJson, decodeJson, encodeJson, jsonEmptyObject, (.?), (:=), (~>))
import Data.Either (Either(..)) import Data.Either (Either(..))
import Data.HTTP.Method (Method(..)) import Data.HTTP.Method (Method(..))
import Data.Lens (over)
import Data.Maybe (Maybe(..)) import Data.Maybe (Maybe(..))
import Data.MediaType.Common (applicationJSON) import Data.MediaType.Common (applicationJSON)
import Modal (modalHide)
import Network.HTTP.Affjax (AJAX, affjax, defaultRequest) import Network.HTTP.Affjax (AJAX, affjax, defaultRequest)
import Network.HTTP.RequestHeader (RequestHeader(..)) import Network.HTTP.RequestHeader (RequestHeader(..))
import Prelude hiding (div) import React.DOM (a, button, div, h2, h4, h5, i, input, label, p, span, text)
import React.DOM (a, button, div, h2, h4, i, input, label, p, span, text) import React.DOM.Props (_data, _id, _type, aria, className, href, maxLength, name, onClick, onInput, placeholder, role, target, value)
import React.DOM.Props (_id, _type, className, href, maxLength, name, onClick, onInput, placeholder, target, value)
import Routing.Hash.Aff (setHash) import Routing.Hash.Aff (setHash)
import Thermite (PerformAction, Render, Spec, modifyState, simpleSpec) import Thermite (PerformAction, Render, Spec, _render, modifyState, simpleSpec)
import Unsafe.Coerce (unsafeCoerce) import Unsafe.Coerce (unsafeCoerce)
...@@ -72,7 +75,8 @@ performAction (SetPassword pwd) _ _ = void do ...@@ -72,7 +75,8 @@ performAction (SetPassword pwd) _ _ = void do
performAction Login _ (State state) = void do performAction Login _ (State state) = void do
lift $ setHash "/search" --lift $ setHash "/search"
liftEff $ modalHide "loginModal"
modifyState \(State state) -> State $ state {loginC = true} modifyState \(State state) -> State $ state {loginC = true}
-- res <- lift $ loginReq $ LoginReq { username : state.username, password : state.password } -- res <- lift $ loginReq $ LoginReq { username : state.username, password : state.password }
-- case res of -- case res of
...@@ -84,6 +88,36 @@ performAction Login _ (State state) = void do ...@@ -84,6 +88,36 @@ performAction Login _ (State state) = void do
-- modifyState \(State s) -> State $ s {response = r, errorMessage = ""} -- modifyState \(State s) -> State $ s {response = r, errorMessage = ""}
modalSpec :: forall eff props. Boolean -> String -> Spec eff State props Action -> Spec eff State props Action
modalSpec sm t = over _render \render d p s c ->
[ div [ _id "loginModal", className $ "modal myModal" <> if sm then "" else " fade"
, role "dialog"
, _data {show : true}
][ div [ className "modal-dialog"
, role "document"
] [ div [ className "modal-content"]
[ div [ className "modal-header"]
[ h5 [ className "modal-title"
]
[ text $ t
]
, button [ _type "button"
, className "close"
, _data { dismiss : "modal"}
] [ span [ aria {hidden : true}]
[ text "X"]
]
]
, div [ className "modal-body"]
(render d p s c)
]
]
]
]
spec' :: forall eff props. Spec (console:: CONSOLE, ajax :: AJAX, dom :: DOM | eff) State props Action
spec' = modalSpec true "Login" renderSpec
renderSpec :: forall props eff . Spec (console::CONSOLE, ajax::AJAX, dom::DOM | eff) State props Action renderSpec :: forall props eff . Spec (console::CONSOLE, ajax::AJAX, dom::DOM | eff) State props Action
renderSpec = simpleSpec performAction render renderSpec = simpleSpec performAction render
...@@ -121,7 +155,7 @@ renderSpec = simpleSpec performAction render ...@@ -121,7 +155,7 @@ renderSpec = simpleSpec performAction render
[] []
, div [className "form-group"] , div [className "form-group"]
[ p [] [text state.errorMessage] [ p [] [text state.errorMessage]
, input [className "form-control", _id "id_username",maxLength "254", name "username", placeholder "username", _type "text",value state.username, onInput \e -> dispatch (SetUserName (unsafeEventValue e))] [] , input [className "form-control", _id "id_username",maxLength "254", name "username", placeholder "username", _type "text",value state.username, onInput \e -> dispatch (SetUserName (unsafeEventValue e))] []
] ]
, div [className "form-group"] , div [className "form-group"]
[ input [className "form-control", _id "id_password", name "password", placeholder "password", _type "password",value state.password,onInput \e -> dispatch (SetPassword (unsafeEventValue e))] [] [ input [className "form-control", _id "id_password", name "password", placeholder "password", _type "password",value state.password,onInput \e -> dispatch (SetPassword (unsafeEventValue e))] []
...@@ -130,29 +164,26 @@ renderSpec = simpleSpec performAction render ...@@ -130,29 +164,26 @@ renderSpec = simpleSpec performAction render
, div [className "center"] , div [className "center"]
[ [
label [] [ label [] [
div [className "checkbox"] div [className "checkbox"]
[ input [_id "terms-accept", _type "checkbox", value "", className "checkbox"] [ input [_id "terms-accept", _type "checkbox", value "", className "checkbox"]
[ [
] ]
, text "I accept the terms of uses ", , text "I accept the terms of uses ",
a [href "http://gitlab.iscpif.fr/humanities/tofu/tree/master"] [text "[Read the terms of use]"] a [href "http://gitlab.iscpif.fr/humanities/tofu/tree/master"] [text "[Read the terms of use]"]
] ]
, button [_id "login-button",className "btn btn-primary btn-rounded", _type "submit", onClick \_ -> dispatch $ Login] [text "Login"] , button [_id "login-button",className "btn btn-primary btn-rounded", _type "submit", onClick \_ -> dispatch $ Login] [text "Login"]
] ]
] ]
] ]
] ]
] ]
] ]
] ]
] ]
] ]
-- div [ className "modal fade myModal"
-- , role "dialog"
-- div [ className "modal fade myModal"
-- , role "dialog"
-- , _data {show : true} -- , _data {show : true}
-- ][ div [ className "modal-dialog" -- ][ div [ className "modal-dialog"
-- , role "document" -- , role "document"
......
'use strict';
exports.modalShow = function(name) {
return function(){
var myModal = document.getElementById(name);
var myModalInstance = new Modal(myModal);
myModalInstance.show();
};
};
exports.modalHide = function(name){
return function() {
var myModal = document.getElementById(name);
var myModalInstance = new Modal(myModal);
myModalInstance.hide();
};
};
module Modal where
import Control.Monad.Eff (Eff)
import Prelude (Unit)
foreign import modalShow :: forall eff. String -> Eff eff Unit
foreign import modalHide :: forall eff. String -> Eff eff Unit
...@@ -2,10 +2,12 @@ module Navigation where ...@@ -2,10 +2,12 @@ module Navigation where
import DOM import DOM
import Gargantext.Data.Lang import Gargantext.Data.Lang
import Prelude hiding (div)
import AddCorpusview as AC import AddCorpusview as AC
import AnnotationDocumentView as D import AnnotationDocumentView as D
import Control.Monad.Cont.Trans (lift) import Control.Monad.Cont.Trans (lift)
import Control.Monad.Eff (Eff)
import Control.Monad.Eff.Class (liftEff) import Control.Monad.Eff.Class (liftEff)
import Control.Monad.Eff.Console (CONSOLE) import Control.Monad.Eff.Console (CONSOLE)
import CorpusAnalysis as CA import CorpusAnalysis as CA
...@@ -18,10 +20,10 @@ import Data.Tuple (Tuple(..)) ...@@ -18,10 +20,10 @@ import Data.Tuple (Tuple(..))
import DocView as DV import DocView as DV
import Landing as L import Landing as L
import Login as LN import Login as LN
import Modal (modalShow)
import NTree as NT import NTree as NT
import Network.HTTP.Affjax (AJAX) import Network.HTTP.Affjax (AJAX)
import PageRouter (Routes(..)) import PageRouter (Routes(..))
import Prelude hiding (div)
import React (ReactElement) import React (ReactElement)
import React.DOM (a, button, div, footer, form, hr, i, img, input, li, p, span, text, ul) import React.DOM (a, button, div, footer, form, hr, i, img, input, li, p, span, text, ul)
import React.DOM.Props (Props, _data, _id, _type, aria, className, href, name, onChange, onClick, placeholder, role, src, style, tabIndex, target, title) import React.DOM.Props (Props, _data, _id, _type, aria, className, href, name, onChange, onClick, placeholder, role, src, style, tabIndex, target, title)
...@@ -48,6 +50,7 @@ type AppState = ...@@ -48,6 +50,7 @@ type AppState =
, tabview :: TV.State , tabview :: TV.State
, search :: String , search :: String
, corpusAnalysis :: CA.State , corpusAnalysis :: CA.State
, showLogin :: Boolean
} }
initAppState :: AppState initAppState :: AppState
...@@ -64,6 +67,7 @@ initAppState = ...@@ -64,6 +67,7 @@ initAppState =
, tabview : TV.initialState , tabview : TV.initialState
, search : "" , search : ""
, corpusAnalysis : CA.initialState , corpusAnalysis : CA.initialState
, showLogin : false
} }
data Action data Action
...@@ -81,6 +85,7 @@ data Action ...@@ -81,6 +85,7 @@ data Action
| Search String | Search String
| Go | Go
| CorpusAnalysisA CA.Action | CorpusAnalysisA CA.Action
| ShowLogin
performAction :: forall eff props. PerformAction ( dom :: DOM performAction :: forall eff props. PerformAction ( dom :: DOM
...@@ -92,6 +97,9 @@ performAction (SetRoute route) _ _ = void do ...@@ -92,6 +97,9 @@ performAction (SetRoute route) _ _ = void do
performAction (Search s) _ _ = void do performAction (Search s) _ _ = void do
modifyState $ _ {search = s} modifyState $ _ {search = s}
performAction (ShowLogin) _ _ = void do
liftEff $ modalShow "loginModal"
modifyState $ _ {showLogin = true}
performAction Go _ _ = void do performAction Go _ _ = void do
_ <- lift $ setHash "/addCorpus" _ <- lift $ setHash "/addCorpus"
...@@ -101,8 +109,6 @@ performAction Go _ _ = void do ...@@ -101,8 +109,6 @@ performAction Go _ _ = void do
performAction _ _ _ = void do performAction _ _ _ = void do
modifyState id modifyState id
---- Lens and Prism ---- Lens and Prism
_landingState :: Lens' AppState L.State _landingState :: Lens' AppState L.State
_landingState = lens (\s -> s.landingState) (\s ss -> s{landingState = ss}) _landingState = lens (\s -> s.landingState) (\s ss -> s{landingState = ss})
...@@ -229,7 +235,7 @@ pagesComponent s = ...@@ -229,7 +235,7 @@ pagesComponent s =
| eff | eff
) AppState props Action ) AppState props Action
selectSpec CorpusAnalysis = layout0 $ focus _corpusState _corpusAction CA.spec' selectSpec CorpusAnalysis = layout0 $ focus _corpusState _corpusAction CA.spec'
selectSpec Login = focus _loginState _loginAction LN.renderSpec -- selectSpec Login = focus _loginState _loginAction LN.renderSpec
selectSpec Home = layout0 $ focus _landingState _landingAction (L.layoutLanding EN) selectSpec Home = layout0 $ focus _landingState _landingAction (L.layoutLanding EN)
selectSpec AddCorpus = layout0 $ focus _addCorpusState _addCorpusAction AC.layoutAddcorpus selectSpec AddCorpus = layout0 $ focus _addCorpusState _addCorpusAction AC.layoutAddcorpus
selectSpec DocView = layout0 $ focus _docViewState _docViewAction DV.layoutDocview selectSpec DocView = layout0 $ focus _docViewState _docViewAction DV.layoutDocview
...@@ -238,8 +244,7 @@ pagesComponent s = ...@@ -238,8 +244,7 @@ pagesComponent s =
selectSpec Tabview = layout0 $ focus _tabviewState _tabviewAction TV.tab1 selectSpec Tabview = layout0 $ focus _tabviewState _tabviewAction TV.tab1
-- To be removed -- To be removed
selectSpec SearchView = layout0 $ focus _searchState _searchAction S.searchSpec selectSpec SearchView = layout0 $ focus _searchState _searchAction S.searchSpec
selectSpec _ = simpleSpec defaultPerformAction defaultRender
routingSpec :: forall props eff. Spec (dom :: DOM |eff) AppState props Action routingSpec :: forall props eff. Spec (dom :: DOM |eff) AppState props Action
routingSpec = simpleSpec performAction defaultRender routingSpec = simpleSpec performAction defaultRender
...@@ -295,7 +300,7 @@ layoutSidebar = over _render \render d p s c -> ...@@ -295,7 +300,7 @@ layoutSidebar = over _render \render d p s c ->
, div [ className "collapse navbar-collapse"] , div [ className "collapse navbar-collapse"]
$ [ divDropdownLeft] $ [ divDropdownLeft]
<> render d p s c <> <> render d p s c <>
[ divDropdownRight ] [ divDropdownRight d]
] ]
] ]
] ]
...@@ -305,7 +310,7 @@ layoutSidebar = over _render \render d p s c -> ...@@ -305,7 +310,7 @@ layoutSidebar = over _render \render d p s c ->
divLogo :: ReactElement divLogo :: ReactElement
divLogo = a [ className "navbar-brand logoSmall" divLogo = a [ className "navbar-brand logoSmall"
, href "/index.html" , href "#/"
] [ img [ src "images/logoSmall.png" ] [ img [ src "images/logoSmall.png"
, title "Back to home." , title "Back to home."
] [] ] []
...@@ -448,8 +453,8 @@ divSearchBar = simpleSpec performAction render ...@@ -448,8 +453,8 @@ divSearchBar = simpleSpec performAction render
] ]
--divDropdownRight :: Render AppState props Action --divDropdownRight :: Render AppState props Action
divDropdownRight :: ReactElement divDropdownRight :: _ -> ReactElement
divDropdownRight = divDropdownRight d =
ul [className "nav navbar-nav pull-right"] ul [className "nav navbar-nav pull-right"]
[ [
-- TODO if logged in : enable dropdown to logout -- TODO if logged in : enable dropdown to logout
...@@ -457,7 +462,8 @@ divDropdownRight = ...@@ -457,7 +462,8 @@ divDropdownRight =
[ [
a [ aria {hidden : true} a [ aria {hidden : true}
, className "glyphicon glyphicon-log-in" , className "glyphicon glyphicon-log-in"
, href "#/login" , --href "#/login"
onClick $ \e -> d ShowLogin
, style {color:"white"} , style {color:"white"}
, title "Log in and save your time" , title "Log in and save your time"
-- TODO hover: bold -- TODO hover: bold
...@@ -498,12 +504,13 @@ layoutFooter = simpleSpec performAction render ...@@ -498,12 +504,13 @@ layoutFooter = simpleSpec performAction render
] ]
layoutSpec :: forall eff props. Spec (E eff) AppState props Action layoutSpec :: forall eff props. Spec (E eff) AppState props Action
layoutSpec = layoutSpec =
fold fold
[ routingSpec [ routingSpec
, container $ withState pagesComponent , container $ withState pagesComponent
, withState \st ->
focus _loginState _loginAction (LN.modalSpec st.showLogin "Login" LN.renderSpec)
] ]
where where
container :: Spec (E eff) AppState props Action -> Spec (E eff) AppState props Action container :: Spec (E eff) AppState props Action -> Spec (E eff) AppState props Action
......
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