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

[ORG] Reading Code + User -> Annuaire.

parent cdd2a90d
...@@ -9,34 +9,49 @@ import Data.Tuple (Tuple(..)) ...@@ -9,34 +9,49 @@ import Data.Tuple (Tuple(..))
import React (ReactElement) import React (ReactElement)
import React.DOM (a, div, nav, text) import React.DOM (a, div, nav, text)
import React.DOM.Props (className, onClick) import React.DOM.Props (className, onClick)
import Thermite (PerformAction, Render, Spec, _render, modifyState, focus, simpleSpec, withState) import Thermite ( PerformAction, Render, Spec
, _render, modifyState, focus
, simpleSpec, withState)
type State = Int type State = Int
data Action = ChangeTab Int data Action = ChangeTab Int
tabs :: forall state props action . Lens' state State -> Prism' action Action -> List (Tuple String (Spec state props action)) -> Spec state props action tabs :: forall state props action.
Lens' state State -> Prism' action Action
-> List (Tuple String (Spec state props action))
-> Spec state props action
tabs l p ls = withState \st -> tabs l p ls = withState \st ->
fold fold
[ focus l p $ simpleSpec performAction (render (activeTab st) ls) [ focus l p $ simpleSpec performAction (render (activeTab st) ls)
, wrapper $ fold $ mapWithIndex (tab (activeTab st)) ls , wrapper $ fold $ mapWithIndex ( tab (activeTab st)) ls
] ]
where where
activeTab = view l activeTab = view l
wrapper = over _render \render d p s c -> wrapper = over _render \render d p s c ->
[div [className "tab-content"] $ render d p s c] [div [className "tab-content"] $ render d p s c]
tab :: forall state props action. Int -> Int -> Tuple String (Spec state props action) -> Spec state props action tab :: forall state props action.
Int -> Int -> Tuple String (Spec state props action)
-> Spec state props action
tab sid iid (Tuple name spec) = over _render tabRender spec tab sid iid (Tuple name spec) = over _render tabRender spec
where where
tabRender renderer d p s c = tabRender renderer d p s c =
[div [ className $ "tab-pane " <> if sid ==iid then " show active" else " fade"] $ renderer d p s c] [ div [ className $ "tab-pane " <>
if sid ==iid
then " show active"
else " fade"] $ renderer d p s c
]
performAction :: forall props. PerformAction State props Action performAction :: forall props.
performAction (ChangeTab i) _ _ = void $ modifyState $ const i PerformAction State props Action
performAction (ChangeTab i) _ _ =
void $ modifyState $ const i
render :: forall state props action. State -> List (Tuple String (Spec state props action)) -> Render State props Action render :: forall state props action.
State -> List (Tuple String (Spec state props action))
-> Render State props Action
render at ls d p s c = render at ls d p s c =
[ nav [] [ nav []
[ div [className "nav nav-tabs"] [ div [className "nav nav-tabs"]
...@@ -46,4 +61,7 @@ render at ls d p s c = ...@@ -46,4 +61,7 @@ render at ls d p s c =
where where
item :: forall a. Int -> Int -> (Tuple String a) -> ReactElement item :: forall a. Int -> Int -> (Tuple String a) -> ReactElement
item sid iid (Tuple name _) = item sid iid (Tuple name _) =
a [className $ "nav-item nav-link" <> if sid == iid then " active" else "", onClick \e -> d $ ChangeTab iid] [text name] a [className $ "nav-item nav-link" <>
if sid == iid
then " active"
else "", onClick \e -> d $ ChangeTab iid] [text name]
module Gargantext.Pages.Corpus.Annuaire where module Gargantext.Pages.Annuaire where
import Prelude import Prelude
...@@ -20,7 +20,7 @@ import Effect.Aff (Aff) ...@@ -20,7 +20,7 @@ import Effect.Aff (Aff)
import Gargantext.Config (toUrl, NodeType(..), End(..)) import Gargantext.Config (toUrl, NodeType(..), End(..))
import Gargantext.Config.REST (get) import Gargantext.Config.REST (get)
import Gargantext.Pages.Corpus.User.Users.Types.Types (User(..), HyperData(..)) import Gargantext.Pages.Annuaire.User.Users.Types.Types (User(..), HyperData(..))
import Gargantext.Utils.DecodeMaybe ((.?|)) import Gargantext.Utils.DecodeMaybe ((.?|))
import Data.Argonaut (class DecodeJson, decodeJson, (.?)) import Data.Argonaut (class DecodeJson, decodeJson, (.?))
...@@ -99,7 +99,6 @@ render dispatch _ state _ = [ div [className "row"] ...@@ -99,7 +99,6 @@ render dispatch _ state _ = [ div [className "row"]
] ]
] ]
] ]
, p [] [] , p [] []
, div [] [ text " Filter ", input []] , div [] [ text " Filter ", input []]
, br' , br'
...@@ -175,7 +174,6 @@ instance decodeAnnuaireTable :: DecodeJson AnnuaireTable where ...@@ -175,7 +174,6 @@ instance decodeAnnuaireTable :: DecodeJson AnnuaireTable where
decodeJson json = do decodeJson json = do
rows <- decodeJson json rows <- decodeJson json
pure $ AnnuaireTable { annuaireTable : rows} pure $ AnnuaireTable { annuaireTable : rows}
------------------------------------------------------------------------ ------------------------------------------------------------------------
performAction :: PerformAction State {} Action performAction :: PerformAction State {} Action
performAction (Load aId) _ _ = do performAction (Load aId) _ _ = do
......
module Gargantext.Pages.Corpus.User.Brevets where module Gargantext.Pages.Annuaire.User.Brevets where
import Prelude import Prelude
import Thermite (Render, Spec, defaultPerformAction, simpleSpec) import Thermite (Render, Spec, defaultPerformAction, simpleSpec)
......
module Gargantext.Pages.Annuaire.User.Users
(module Gargantext.Pages.Annuaire.User.Users.Types,
module Gargantext.Pages.Annuaire.User.Users.Specs)
where
import Gargantext.Pages.Annuaire.User.Users.Types
import Gargantext.Pages.Annuaire.User.Users.Specs
module Gargantext.Pages.Corpus.User.Users.API where module Gargantext.Pages.Annuaire.User.Users.API where
import Prelude import Prelude
...@@ -12,7 +12,7 @@ import Effect.Console (log) ...@@ -12,7 +12,7 @@ import Effect.Console (log)
import Gargantext.Config (toUrl, NodeType(..), End(..)) import Gargantext.Config (toUrl, NodeType(..), End(..))
import Gargantext.Config.REST (get) import Gargantext.Config.REST (get)
import Gargantext.Pages.Corpus.User.Users.Types (Action(..), State, User, _user) import Gargantext.Pages.Annuaire.User.Users.Types (Action(..), State, User, _user)
import Thermite (PerformAction, modifyState) import Thermite (PerformAction, modifyState)
getUser :: Int -> Aff (Either String User) getUser :: Int -> Aff (Either String User)
......
module Gargantext.Pages.Corpus.User.Users.Specs module Gargantext.Pages.Annuaire.User.Users.Specs
(module Gargantext.Pages.Corpus.User.Users.Specs.Renders, (module Gargantext.Pages.Annuaire.User.Users.Specs.Renders,
layoutUser) layoutUser)
where where
import Gargantext.Pages.Corpus.User.Users.Specs.Renders import Gargantext.Pages.Annuaire.User.Users.Specs.Renders
import Thermite (Spec, simpleSpec) import Thermite (Spec, simpleSpec)
import Gargantext.Pages.Corpus.User.Users.Types (Action, State) import Gargantext.Pages.Annuaire.User.Users.Types (Action, State)
import Gargantext.Pages.Corpus.User.Users.API (performAction) import Gargantext.Pages.Annuaire.User.Users.API (performAction)
layoutUser :: Spec State {} Action layoutUser :: Spec State {} Action
layoutUser = simpleSpec performAction render layoutUser = simpleSpec performAction render
module Gargantext.Pages.Corpus.User.Users.Specs.Documents where module Gargantext.Pages.Annuaire.User.Users.Specs.Documents where
import Prelude import Prelude
import React.DOM (table, tbody, td, text, th, thead, tr) import React.DOM (table, tbody, td, text, th, thead, tr)
......
module Gargantext.Pages.Corpus.User.Users.Specs.Renders module Gargantext.Pages.Annuaire.User.Users.Specs.Renders
where where
import Gargantext.Pages.Corpus.User.Users.Types import Gargantext.Pages.Annuaire.User.Users.Types
import Data.Maybe (Maybe(..)) import Data.Maybe (Maybe(..))
import Data.Tuple (Tuple(..)) import Data.Tuple (Tuple(..))
......
module Gargantext.Pages.Corpus.User.Users.Types module Gargantext.Pages.Annuaire.User.Users.Types
(module Gargantext.Pages.Corpus.User.Users.Types.Types, (module Gargantext.Pages.Annuaire.User.Users.Types.Types,
module Gargantext.Pages.Corpus.User.Users.Types.Lens, module Gargantext.Pages.Annuaire.User.Users.Types.Lens,
module Gargantext.Pages.Corpus.User.Users.Types.States, module Gargantext.Pages.Annuaire.User.Users.Types.States,
brevetSpec, brevetSpec,
projectSpec, projectSpec,
facets facets
...@@ -10,10 +10,10 @@ module Gargantext.Pages.Corpus.User.Users.Types ...@@ -10,10 +10,10 @@ module Gargantext.Pages.Corpus.User.Users.Types
import Prelude import Prelude
import Gargantext.Pages.Corpus.User.Users.Types.Lens import Gargantext.Pages.Annuaire.User.Users.Types.Lens
import Gargantext.Pages.Corpus.User.Users.Types.Types import Gargantext.Pages.Annuaire.User.Users.Types.Types
import Gargantext.Pages.Corpus.User.Users.Types.States import Gargantext.Pages.Annuaire.User.Users.Types.States
import Gargantext.Pages.Corpus.User.Brevets as B import Gargantext.Pages.Annuaire.User.Brevets as B
import Data.List (fromFoldable) import Data.List (fromFoldable)
import Data.Tuple (Tuple(..)) import Data.Tuple (Tuple(..))
import Gargantext.Components.Tab (tabs) import Gargantext.Components.Tab (tabs)
......
module Gargantext.Pages.Corpus.User.Users.Types.Lens where module Gargantext.Pages.Annuaire.User.Users.Types.Lens where
import Gargantext.Pages.Corpus.User.Brevets as B import Gargantext.Pages.Annuaire.User.Brevets as B
import Data.Either (Either(..)) import Data.Either (Either(..))
import Data.Lens (Lens', Prism', lens, prism) import Data.Lens (Lens', Prism', lens, prism)
import Data.Maybe (Maybe) import Data.Maybe (Maybe)
import Gargantext.Pages.Corpus.User.Users.Types.States (Action(..), State) import Gargantext.Pages.Annuaire.User.Users.Types.States (Action(..), State)
import Gargantext.Pages.Corpus.User.Users.Types.Types (User) import Gargantext.Pages.Annuaire.User.Users.Types.Types (User)
import Gargantext.Pages.Corpus.User.Users.Specs.Documents as P import Gargantext.Pages.Annuaire.User.Users.Specs.Documents as P
import Gargantext.Components.Tab as Tab import Gargantext.Components.Tab as Tab
import Thermite (Spec, noState) import Thermite (Spec, noState)
......
module Gargantext.Pages.Corpus.User.Users.Types.States where module Gargantext.Pages.Annuaire.User.Users.Types.States where
import Data.Maybe (Maybe(..)) import Data.Maybe (Maybe(..))
import Gargantext.Pages.Corpus.User.Users.Types.Types (User) import Gargantext.Pages.Annuaire.User.Users.Types.Types (User)
import Gargantext.Pages.Corpus.User.Users.Specs.Documents as P import Gargantext.Pages.Annuaire.User.Users.Specs.Documents as P
import Gargantext.Components.Tab as Tab import Gargantext.Components.Tab as Tab
data Action data Action
......
module Gargantext.Pages.Corpus.User.Users.Types.Types where module Gargantext.Pages.Annuaire.User.Users.Types.Types where
import Prelude import Prelude
......
...@@ -17,7 +17,7 @@ import Effect.Aff (Aff) ...@@ -17,7 +17,7 @@ import Effect.Aff (Aff)
import Effect.Class (liftEffect) import Effect.Class (liftEffect)
import Effect.Console (log) import Effect.Console (log)
import Gargantext.Config (NodeType(..), toUrl, End(Back)) import Gargantext.Config (NodeType(..), toUrl, End(..))
import Gargantext.Config.REST (get) import Gargantext.Config.REST (get)
import Gargantext.Utils.DecodeMaybe ((.|)) import Gargantext.Utils.DecodeMaybe ((.|))
...@@ -165,10 +165,7 @@ layoutDocview = simpleSpec performAction render ...@@ -165,10 +165,7 @@ layoutDocview = simpleSpec performAction render
[thead [ className "thead-dark"] [thead [ className "thead-dark"]
[tr [] [ th [scope "col"] [ b' [text ""] ] [tr [] [ th [scope "col"] [ b' [text ""] ]
, th [scope "col"] [ b' [text "Date"]] , th [scope "col"] [ b' [text "Date"]]
, th [scope "col"] [ b' [text "Name"] ] , th [scope "col"] [ b' [text "Title"] ]
--, th [scope "col"] [ b' [text "Title"] ]
--, th [scope "col"] [ b' [text "Source"] ]
, th [scope "col"] [ b' [text "Fonction"] ]
, th [scope "col"] [ b' [text "Delete"] ] , th [scope "col"] [ b' [text "Delete"] ]
] ]
] ]
...@@ -272,7 +269,7 @@ showRow {row : (CorpusView c), delete} = ...@@ -272,7 +269,7 @@ showRow {row : (CorpusView c), delete} =
[ td [] [div [className $ fa <> "fa-star"][]] [ td [] [div [className $ fa <> "fa-star"][]]
-- TODO show date: Year-Month-Day only -- TODO show date: Year-Month-Day only
, td [] [text c.date] , td [] [text c.date]
, td [] [ a [ href (toUrl Back Document 1) ] [ text c.title ] ] , td [] [ a [ href (toUrl Front Document c._id) ] [ text c.title ] ]
, td [] [text c.source] , td [] [text c.source]
, td [] [input [ _type "checkbox"]] , td [] [input [ _type "checkbox"]]
] ]
......
module Gargantext.Pages.Corpus.User.Users
(module Gargantext.Pages.Corpus.User.Users.Types,
module Gargantext.Pages.Corpus.User.Users.Specs)
where
import Gargantext.Pages.Corpus.User.Users.Types
import Gargantext.Pages.Corpus.User.Users.Specs
...@@ -11,8 +11,8 @@ import Gargantext.Pages.Corpus.Doc.Facets.Documents as DV ...@@ -11,8 +11,8 @@ import Gargantext.Pages.Corpus.Doc.Facets.Documents as DV
import Gargantext.Pages.Corpus.Doc.Facets.Graph as GE import Gargantext.Pages.Corpus.Doc.Facets.Graph as GE
-- import Gargantext.Pages.Corpus.Doc.Facets.Terms.NgramsTable as NG -- import Gargantext.Pages.Corpus.Doc.Facets.Terms.NgramsTable as NG
import Gargantext.Pages.Corpus.User.Users as U import Gargantext.Pages.Annuaire.User.Users as U
import Gargantext.Pages.Corpus.Annuaire as Annuaire import Gargantext.Pages.Annuaire as Annuaire
-- import Gargantext.Pages.Home as L -- import Gargantext.Pages.Home as L
-- import Gargantext.Pages.Layout.Specs.Search as S -- import Gargantext.Pages.Layout.Specs.Search as S
import Gargantext.Router (Routes(..)) import Gargantext.Router (Routes(..))
...@@ -39,6 +39,10 @@ dispatchAction dispatcher _ (DocView n) = do ...@@ -39,6 +39,10 @@ dispatchAction dispatcher _ (DocView n) = do
dispatcher $ SetRoute (DocView n) dispatcher $ SetRoute (DocView n)
dispatcher $ DocViewA $ DV.LoadData n dispatcher $ DocViewA $ DV.LoadData n
dispatchAction dispatcher _ (Corpus n) = do
dispatcher $ SetRoute $ Corpus n
dispatcher $ DocViewA $ DV.LoadData n
dispatchAction dispatcher _ SearchView = do dispatchAction dispatcher _ SearchView = do
dispatcher $ SetRoute SearchView dispatcher $ SetRoute SearchView
-- dispatcher $ SearchA TODO -- dispatcher $ SearchA TODO
...@@ -63,10 +67,6 @@ dispatchAction dispatcher _ Tabview = do ...@@ -63,10 +67,6 @@ dispatchAction dispatcher _ Tabview = do
dispatcher $ SetRoute Tabview dispatcher $ SetRoute Tabview
-- dispatcher $ TabViewA TODO -- dispatcher $ TabViewA TODO
dispatchAction dispatcher _ (Corpus n) = do
dispatcher $ SetRoute $ Corpus n
dispatcher $ DocViewA $ DV.LoadData n
dispatchAction dispatcher _ PGraphExplorer = do dispatchAction dispatcher _ PGraphExplorer = do
dispatcher $ SetRoute PGraphExplorer dispatcher $ SetRoute PGraphExplorer
dispatcher $ GraphExplorerA $ GE.LoadGraph "imtNew.json" dispatcher $ GraphExplorerA $ GE.LoadGraph "imtNew.json"
......
...@@ -15,8 +15,8 @@ import Gargantext.Components.Tree as Tree ...@@ -15,8 +15,8 @@ import Gargantext.Components.Tree as Tree
import Gargantext.Pages.Corpus.Doc.Annotation as D import Gargantext.Pages.Corpus.Doc.Annotation as D
import Gargantext.Pages.Corpus.Doc.Facets.Documents as DV import Gargantext.Pages.Corpus.Doc.Facets.Documents as DV
import Gargantext.Pages.Corpus.Doc.Facets.Graph as GE import Gargantext.Pages.Corpus.Doc.Facets.Graph as GE
import Gargantext.Pages.Corpus.User.Users as U import Gargantext.Pages.Annuaire.User.Users as U
import Gargantext.Pages.Corpus.Annuaire as Annuaire import Gargantext.Pages.Annuaire as Annuaire
import Gargantext.Pages.Layout.Specs.AddCorpus as AC import Gargantext.Pages.Layout.Specs.AddCorpus as AC
import Gargantext.Pages.Layout.Specs.Search as S import Gargantext.Pages.Layout.Specs.Search as S
import Gargantext.Pages.Layout.States (AppState) import Gargantext.Pages.Layout.States (AppState)
...@@ -53,6 +53,8 @@ performAction (ShowLogin) _ _ = void do ...@@ -53,6 +53,8 @@ performAction (ShowLogin) _ _ = void do
liftEffect $ modalShow "loginModal" liftEffect $ modalShow "loginModal"
modifyState $ _ {showLogin = true} modifyState $ _ {showLogin = true}
---------------------------------------------------------
-- TODO chose one of them
performAction (ShowAddcorpus) _ _ = void do performAction (ShowAddcorpus) _ _ = void do
liftEffect $ modalShow "addCorpus" liftEffect $ modalShow "addCorpus"
modifyState $ _ {showCorpus = true} modifyState $ _ {showCorpus = true}
...@@ -62,6 +64,7 @@ performAction Go _ _ = void do ...@@ -62,6 +64,7 @@ performAction Go _ _ = void do
modifyState $ _ {showCorpus = true} modifyState $ _ {showCorpus = true}
-- _ <- lift $ setHash "/addCorpus" -- _ <- lift $ setHash "/addCorpus"
--modifyState id --modifyState id
---------------------------------------------------------
performAction Initialize _ state = void do performAction Initialize _ state = void do
_ <- liftEffect $ log "loading Initial nodes" _ <- liftEffect $ log "loading Initial nodes"
......
...@@ -9,16 +9,16 @@ import Effect (Effect) ...@@ -9,16 +9,16 @@ import Effect (Effect)
import Gargantext.Components.Data.Lang (Lang(..)) import Gargantext.Components.Data.Lang (Lang(..))
import Gargantext.Components.Login as LN import Gargantext.Components.Login as LN
import Gargantext.Components.Tree as Tree import Gargantext.Components.Tree as Tree
import Gargantext.Pages.Corpus.Annuaire as A import Gargantext.Pages.Annuaire as A
import Gargantext.Folder as F import Gargantext.Folder as F
import Gargantext.Pages.Corpus as CA import Gargantext.Pages.Corpus as Corpus
import Gargantext.Pages.Corpus.Doc.Annotation as Annotation import Gargantext.Pages.Corpus.Doc.Annotation as Annotation
import Gargantext.Pages.Corpus.Doc.Facets as TV import Gargantext.Pages.Corpus.Doc.Facets as TV
import Gargantext.Pages.Corpus.Doc.Facets.Dashboard as Dsh import Gargantext.Pages.Corpus.Doc.Facets.Dashboard as Dsh
import Gargantext.Pages.Corpus.Doc.Facets.Documents as DV import Gargantext.Pages.Corpus.Doc.Facets.Documents as DV
import Gargantext.Pages.Corpus.Doc.Facets.Graph as GE import Gargantext.Pages.Corpus.Doc.Facets.Graph as GE
import Gargantext.Pages.Corpus.Doc.Facets.Terms.NgramsTable as NG import Gargantext.Pages.Corpus.Doc.Facets.Terms.NgramsTable as NG
import Gargantext.Pages.Corpus.User.Users as U import Gargantext.Pages.Annuaire.User.Users as U
import Gargantext.Pages.Home as L import Gargantext.Pages.Home as L
import Gargantext.Pages.Layout.Actions (Action(..), _addCorpusAction, _docAnnotationViewAction, _docViewAction, _graphExplorerAction, _loginAction, _searchAction, _treeAction, _userPageAction, performAction, _annuaireAction) import Gargantext.Pages.Layout.Actions (Action(..), _addCorpusAction, _docAnnotationViewAction, _docViewAction, _graphExplorerAction, _loginAction, _searchAction, _treeAction, _userPageAction, performAction, _annuaireAction)
import Gargantext.Pages.Layout.Specs.AddCorpus as AC import Gargantext.Pages.Layout.Specs.AddCorpus as AC
...@@ -62,8 +62,8 @@ pagesComponent s = ...@@ -62,8 +62,8 @@ pagesComponent s =
selectSpec (UserPage i) = layout0 $ focus _userPageState _userPageAction U.layoutUser selectSpec (UserPage i) = layout0 $ focus _userPageState _userPageAction U.layoutUser
selectSpec (DocAnnotation i) = layout0 $ focus _docAnnotationViewState selectSpec (DocAnnotation i) = layout0 $ focus _docAnnotationViewState
_docAnnotationViewAction Annotation.docview _docAnnotationViewAction Annotation.docview
selectSpec Tabview = layout0 $ noState TV.pureTab1
-- To be removed -- To be removed
selectSpec Tabview = layout0 $ noState TV.pureTab1
selectSpec SearchView = layout0 $ focus _searchState _searchAction S.searchSpec selectSpec SearchView = layout0 $ focus _searchState _searchAction S.searchSpec
selectSpec NGramsTable = layout0 $ noState NG.ngramsTableSpec selectSpec NGramsTable = layout0 $ noState NG.ngramsTableSpec
selectSpec PGraphExplorer = focus _graphExplorerState _graphExplorerAction GE.specOld selectSpec PGraphExplorer = focus _graphExplorerState _graphExplorerAction GE.specOld
......
...@@ -7,10 +7,10 @@ import Data.Maybe (Maybe(Just)) ...@@ -7,10 +7,10 @@ import Data.Maybe (Maybe(Just))
import Gargantext.Components.Login as LN import Gargantext.Components.Login as LN
import Gargantext.Components.Tree as Tree import Gargantext.Components.Tree as Tree
import Gargantext.Pages.Corpus.Doc.Annotation as D import Gargantext.Pages.Corpus.Doc.Annotation as D
import Gargantext.Pages.Corpus.Annuaire as Annuaire import Gargantext.Pages.Annuaire as Annuaire
import Gargantext.Pages.Corpus.Doc.Facets.Documents as DV import Gargantext.Pages.Corpus.Doc.Facets.Documents as DV
import Gargantext.Pages.Corpus.Doc.Facets.Graph as GE import Gargantext.Pages.Corpus.Doc.Facets.Graph as GE
import Gargantext.Pages.Corpus.User.Users as U import Gargantext.Pages.Annuaire.User.Users as U
import Gargantext.Pages.Layout.Specs.AddCorpus as AC import Gargantext.Pages.Layout.Specs.AddCorpus as AC
import Gargantext.Pages.Layout.Specs.Search as S import Gargantext.Pages.Layout.Specs.Search as S
import Gargantext.Router (Routes(..)) import Gargantext.Router (Routes(..))
......
...@@ -33,17 +33,17 @@ data Routes ...@@ -33,17 +33,17 @@ data Routes
instance showRoutes :: Show Routes where instance showRoutes :: Show Routes where
show Login = "Login" show Login = "Login"
show AddCorpus = "AddCorpus" show AddCorpus = "AddCorpus"
show (DocView i) = "DocView"
show SearchView = "Search" show SearchView = "Search"
show (UserPage i) = "User" <> show i show (UserPage i) = "User" <> show i
show (DocAnnotation i)= "Document" show (DocAnnotation i)= "Document"
show (Corpus i) = "Corpus" <> show i
show Tabview = "Tabview" show Tabview = "Tabview"
show PGraphExplorer = "graphExplorer" show (DocView i) = "DocView"
show NGramsTable = "NGramsTable" show NGramsTable = "NGramsTable"
show Dashboard = "Dashboard"
show (Corpus i) = "Corpus" <> show i
show (Annuaire i) = "Annuaire" <> show i show (Annuaire i) = "Annuaire" <> show i
show (Folder i) = "Folder" <> show i show (Folder i) = "Folder" <> show i
show Dashboard = "Dashboard"
show PGraphExplorer = "graphExplorer"
show Home = "Home" show Home = "Home"
int :: Match Int int :: Match Int
...@@ -68,14 +68,18 @@ routing = ...@@ -68,14 +68,18 @@ routing =
where where
route str = lit "" *> lit str route str = lit "" *> lit str
routeHandler :: (Maybe Routes -> Routes -> Effect Unit) -> Maybe Routes -> Routes -> Effect Unit routeHandler :: (Maybe Routes -> Routes -> Effect Unit)
-> Maybe Routes -> Routes -> Effect Unit
routeHandler dispatchAction old new = do routeHandler dispatchAction old new = do
liftEffect $ log $ "change route : " <> show new liftEffect $ log $ "change route : " <> show new
w <- window w <- window
ls <- localStorage w ls <- localStorage w
token <- getItem "accessToken" ls token <- getItem "accessToken" ls
let tkn = token let tkn = token
liftEffect $ log $ "JWToken : " <> show tkn liftEffect $ log $ "JWToken : " <> show tkn
case tkn of case tkn of
Nothing -> do Nothing -> do
dispatchAction old new dispatchAction old new
......
...@@ -9,7 +9,8 @@ import Foreign.Object (Object) ...@@ -9,7 +9,8 @@ import Foreign.Object (Object)
foreign import isNull :: forall a. a -> Boolean foreign import isNull :: forall a. a -> Boolean
getFieldOptional' :: forall a. DecodeJson a => Object Json -> String -> Either String (Maybe a) getFieldOptional' :: forall a. DecodeJson a =>
Object Json -> String -> Either String (Maybe a)
getFieldOptional' o s = (case _ of getFieldOptional' o s = (case _ of
Just v -> if isNull v then Nothing else v Just v -> if isNull v then Nothing else v
Nothing -> Nothing Nothing -> Nothing
...@@ -17,7 +18,9 @@ getFieldOptional' o s = (case _ of ...@@ -17,7 +18,9 @@ getFieldOptional' o s = (case _ of
infix 7 getFieldOptional' as .?| infix 7 getFieldOptional' as .?|
getFieldOptionalAsMempty :: forall a. DecodeJson a => Monoid a => Object Json -> String -> Either String a getFieldOptionalAsMempty :: forall a. DecodeJson a =>
getFieldOptionalAsMempty o s = fromMaybe mempty <$> (getFieldOptional' o s) Monoid a => Object Json -> String -> Either String a
getFieldOptionalAsMempty o s =
fromMaybe mempty <$> (getFieldOptional' o s)
infix 7 getFieldOptionalAsMempty as .| infix 7 getFieldOptionalAsMempty as .|
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