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