Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
purescript-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Allen Lee
purescript-gargantext
Commits
e467737c
Commit
e467737c
authored
Sep 29, 2018
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ANNUAIRE] page main config.
parent
b39bf39a
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
141 additions
and
55 deletions
+141
-55
Annuaire.purs
src/Gargantext/Pages/Corpus/Annuaire.purs
+78
-10
Layout.purs
src/Gargantext/Pages/Layout.purs
+3
-1
Actions.purs
src/Gargantext/Pages/Layout/Actions.purs
+39
-29
Specs.purs
src/Gargantext/Pages/Layout/Specs.purs
+3
-3
States.purs
src/Gargantext/Pages/Layout/States.purs
+16
-10
Router.purs
src/Gargantext/Router.purs
+2
-2
No files found.
src/Gargantext/Pages/Corpus/Annuaire.purs
View file @
e467737c
module Gargantext.Pages.Corpus.Annuaire where
module Gargantext.Pages.Corpus.Annuaire where
import Prelude
import Prelude
import React.DOM (div, h1, text)
import Thermite (Render, Spec, simpleSpec, defaultPerformAction)
import Data.Array (concat)
import Data.Traversable (foldl)
import Control.Monad.Trans.Class (lift)
import Data.Either (Either(..))
import Data.Lens (Lens', Prism', lens, prism, (?~))
import Data.Maybe (Maybe(..), maybe)
import Effect.Class (liftEffect)
import React.DOM (div, h1, p, text)
import Thermite (Render, Spec
, simpleSpec, defaultPerformAction
, PerformAction, modifyState)
import Effect.Console (log)
import Effect.Aff (Aff)
import Gargantext.Config (toUrl, NodeType(..), End(..))
import Gargantext.Config.REST (get)
render :: Render {} {} Void
import Gargantext.Utils.DecodeMaybe ((.?|))
render dispatch _ state _ = [h1 [] [text "Annuaire"]]
import Data.Argonaut (class DecodeJson, decodeJson, (.?))
layoutAnnuaire :: Spec {} {} Void
layoutAnnuaire = simpleSpec defaultPerformAction render
defaultAnnuaire :: AnnuaireTable
defaultAnnuaire = AnnuaireTable {annuaireTable : [IndividuRow {id: 0, name :"nothing, error"}] }
toRows :: AnnuaireTable -> Array IndividuRow
toRows (AnnuaireTable {annuaireTable : default}) = default
render :: Render State {} Action
render dispatch _ state _ = [ h1 [] [text "Annuaire 2"]
, p [] [text $ foldl (<>) " "
$ map (\(IndividuRow {id:_,name:n}) -> n)
$ maybe (toRows defaultAnnuaire) toRows state.annuaire]
]
layoutAnnuaire :: Spec State {} Action
layoutAnnuaire = simpleSpec performAction render
------------------------------------------------------------------------------
newtype IndividuRow = IndividuRow { id :: Int
, name :: String
}
newtype AnnuaireTable = AnnuaireTable { annuaireTable :: Array IndividuRow}
instance decodeIndividuRow :: DecodeJson IndividuRow where
decodeJson json = do
obj <- decodeJson json
id <- obj .? "id"
name <- obj .? "name"
pure $ IndividuRow { id : id, name : name}
instance decodeAnnuaireTable :: DecodeJson AnnuaireTable where
decodeJson json = do
obj <- decodeJson json
annuaire' <- obj .? "annuaire"
pure $ AnnuaireTable { annuaireTable : annuaire'}
------------------------------------------------------------------------------
------------------------------------------------------------------------------
getAnnuaire :: Int -> Aff (Either String AnnuaireTable)
getAnnuaire id = get $ toUrl Back Children id
--data Action
performAction :: PerformAction State {} Action
-- = LoadData
performAction (Load aId) _ _ = do
eitherAnnuaire <- lift $ getAnnuaire aId
_ <- case eitherAnnuaire of
(Right annuaire') -> void $ modifyState $ _annuaire ?~ annuaire'
(Left err) -> do
liftEffect $ log err
liftEffect <<< log $ "Fetching annuaire..."
performAction _ _ _ = pure unit
------------------------------------------------------------------------------
------------------------------------------------------------------------------
type State = { annuaire :: Maybe AnnuaireTable}
initialState :: State
initialState = { annuaire : Nothing }
data Action
= Load Int
-- | ChangePageSize PageSizes
-- | ChangePageSize PageSizes
-- | ChangePage Int
-- | ChangePage Int
--
------------------------------------------------------------------------------
_annuaire :: Lens' State (Maybe AnnuaireTable)
_annuaire = lens (\s -> s.annuaire) (\s ss -> s{annuaire = ss})
------------------------------------------------------------------------------
------------------------------------------------------------------------------
src/Gargantext/Pages/Layout.purs
View file @
e467737c
...
@@ -12,6 +12,7 @@ import Gargantext.Pages.Corpus.Doc.Facets.Graph as GE
...
@@ -12,6 +12,7 @@ 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.Corpus.User.Users as U
import Gargantext.Pages.Corpus.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(..))
...
@@ -48,7 +49,8 @@ dispatchAction dispatcher _ (UserPage id) = do
...
@@ -48,7 +49,8 @@ dispatchAction dispatcher _ (UserPage id) = do
dispatcher $ UserPageA $ U.FetchUser id
dispatcher $ UserPageA $ U.FetchUser id
dispatchAction dispatcher _ (Annuaire id) = do
dispatchAction dispatcher _ (Annuaire id) = do
dispatcher $ SetRoute $ Annuaire id
dispatcher $ SetRoute $ Annuaire id
dispatcher $ AnnuaireAction $ Annuaire.Load id
dispatchAction dispatcher _ (Folder id) = do
dispatchAction dispatcher _ (Folder id) = do
dispatcher $ SetRoute $ Folder id
dispatcher $ SetRoute $ Folder id
...
...
src/Gargantext/Pages/Layout/Actions.purs
View file @
e467737c
-- | Module Description
module Gargantext.Pages.Layout.Actions where
module Gargantext.Pages.Layout.Actions where
import Prelude hiding (div)
import Prelude hiding (div)
import Control.Monad.Cont.Trans (lift)
import Control.Monad.Cont.Trans
(lift)
import Data.Either (Either(..))
import Data.Either
(Either(..))
import Data.Lens (Prism', prism)
import Data.Lens
(Prism', prism)
import Effect.Class (liftEffect)
import Effect.Class
(liftEffect)
import Effect.Console (log)
import Effect.Console
(log)
import Gargantext.Components.Login as LN
import Gargantext.Components.Login
as LN
import Gargantext.Components.Modals.Modal (modalShow)
import Gargantext.Components.Modals.Modal
(modalShow)
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.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.Corpus.User.Users as U
import Gargantext.Pages.Layout.Specs.AddCorpus as AC
import Gargantext.Pages.Corpus.Annuaire as Annuaire
import Gargantext.Pages.Layout.Specs.Search as S
import Gargantext.Pages.Layout.Specs.AddCorpus as AC
import Gargantext.Pages.Layout.States (AppState)
import Gargantext.Pages.Layout.Specs.Search as S
import Gargantext.Router (Routes)
import Gargantext.Pages.Layout.States (AppState)
import Thermite (PerformAction, modifyState)
import Gargantext.Router (Routes)
import Thermite (PerformAction, modifyState)
------------------------------------------------------------------------
data Action
data Action
= Initialize
= Initialize
...
@@ -29,10 +33,11 @@ data Action
...
@@ -29,10 +33,11 @@ data Action
| DocViewA DV.Action
| DocViewA DV.Action
| SearchA S.Action
| SearchA S.Action
| UserPageA U.Action
| UserPageA U.Action
| DocAnnotationViewA D.Action
| DocAnnotationViewA D.Action
| TreeViewA Tree.Action
| TreeViewA Tree.Action
| GraphExplorerA GE.Action
| GraphExplorerA GE.Action
| Search String
| Search String
| AnnuaireAction Annuaire.Action
| Go
| Go
| ShowLogin
| ShowLogin
| ShowAddcorpus
| ShowAddcorpus
...
@@ -62,9 +67,7 @@ performAction Initialize _ state = void do
...
@@ -62,9 +67,7 @@ performAction Initialize _ state = void do
_ <- liftEffect $ log "loading Initial nodes"
_ <- liftEffect $ log "loading Initial nodes"
case state.initialized of
case state.initialized of
false -> do
false -> do
lnodes <- lift $ Tree.loadDefaultNode
lnodes <- lift $ Tree.loadDefaultNode
case lnodes of
case lnodes of
Left err -> do
Left err -> do
pure unit
pure unit
...
@@ -88,14 +91,15 @@ performAction Initialize _ state = void do
...
@@ -88,14 +91,15 @@ performAction Initialize _ state = void do
_ -> do
_ -> do
pure unit
pure unit
performAction (LoginA _) _ _ = pure unit
performAction (LoginA
_) _ _ = pure unit
performAction (AddCorpusA _) _ _ = pure unit
performAction (AddCorpusA
_) _ _ = pure unit
performAction (DocViewA _) _ _ = pure unit
performAction (DocViewA
_) _ _ = pure unit
performAction (SearchA _) _ _ = pure unit
performAction (SearchA
_) _ _ = pure unit
performAction (UserPageA _) _ _ = pure unit
performAction (UserPageA
_) _ _ = pure unit
performAction (DocAnnotationViewA _) _ _ = pure unit
performAction (DocAnnotationViewA _) _ _ = pure unit
performAction (TreeViewA _) _ _ = pure unit
performAction (TreeViewA _) _ _ = pure unit
performAction (GraphExplorerA _) _ _ = pure unit
performAction (GraphExplorerA _) _ _ = pure unit
performAction (AnnuaireAction _) _ _ = pure unit
----------------------------------------------------------
----------------------------------------------------------
...
@@ -129,6 +133,12 @@ _userPageAction = prism UserPageA \action ->
...
@@ -129,6 +133,12 @@ _userPageAction = prism UserPageA \action ->
UserPageA caction -> Right caction
UserPageA caction -> Right caction
_-> Left action
_-> Left action
_annuaireAction :: Prism' Action Annuaire.Action
_annuaireAction = prism AnnuaireAction \action ->
case action of
AnnuaireAction a -> Right a
_ -> Left action
_docAnnotationViewAction :: Prism' Action D.Action
_docAnnotationViewAction :: Prism' Action D.Action
_docAnnotationViewAction = prism DocAnnotationViewA \action ->
_docAnnotationViewAction = prism DocAnnotationViewA \action ->
case action of
case action of
...
...
src/Gargantext/Pages/Layout/Specs.purs
View file @
e467737c
...
@@ -20,10 +20,10 @@ import Gargantext.Pages.Corpus.Doc.Facets.Graph as GE
...
@@ -20,10 +20,10 @@ 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.Corpus.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)
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
import Gargantext.Pages.Layout.Specs.Search as S
import Gargantext.Pages.Layout.Specs.Search as S
import Gargantext.Pages.Layout.States (AppState, _addCorpusState, _docAnnotationViewState, _docViewState, _graphExplorerState, _loginState, _searchState, _treeState, _userPageState)
import Gargantext.Pages.Layout.States (AppState, _addCorpusState, _docAnnotationViewState, _docViewState, _graphExplorerState, _loginState, _searchState, _treeState, _userPageState
, _annuaireState
)
import Gargantext.Router (Routes(..))
import Gargantext.Router (Routes(..))
import React (ReactElement)
import React (ReactElement)
import React.DOM (a, button, div, footer, hr', img, input, li, p, span, text, ul)
import React.DOM (a, button, div, footer, hr', img, input, li, p, span, text, ul)
...
@@ -67,7 +67,7 @@ pagesComponent s =
...
@@ -67,7 +67,7 @@ pagesComponent s =
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
selectSpec Dashboard = layout0 $ noState Dsh.layoutDashboard
selectSpec Dashboard = layout0 $ noState Dsh.layoutDashboard
selectSpec (Annuaire i) = layout0 $
noState
A.layoutAnnuaire
selectSpec (Annuaire i) = layout0 $
focus _annuaireState _annuaireAction
A.layoutAnnuaire
selectSpec (Folder i) = layout0 $ noState F.layoutFolder
selectSpec (Folder i) = layout0 $ noState F.layoutFolder
-- selectSpec _ = simpleSpec defaultPerformAction defaultRender
-- selectSpec _ = simpleSpec defaultPerformAction defaultRender
...
...
src/Gargantext/Pages/Layout/States.purs
View file @
e467737c
...
@@ -2,17 +2,18 @@ module Gargantext.Pages.Layout.States where
...
@@ -2,17 +2,18 @@ module Gargantext.Pages.Layout.States where
import Prelude hiding (div)
import Prelude hiding (div)
import Data.Lens (Lens', lens)
import Data.Lens (Lens', lens)
import Data.Maybe (Maybe(Just))
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.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.Corpus.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(..))
type AppState =
type AppState =
{ currentRoute :: Maybe Routes
{ currentRoute :: Maybe Routes
...
@@ -22,6 +23,7 @@ type AppState =
...
@@ -22,6 +23,7 @@ type AppState =
, searchState :: S.State
, searchState :: S.State
, userPageState :: U.State
, userPageState :: U.State
, docAnnotationState :: D.State
, docAnnotationState :: D.State
, annuaireState :: Annuaire.State
, ntreeState :: Tree.State
, ntreeState :: Tree.State
, search :: String
, search :: String
, showLogin :: Boolean
, showLogin :: Boolean
...
@@ -40,6 +42,7 @@ initAppState =
...
@@ -40,6 +42,7 @@ initAppState =
, userPageState : U.initialState
, userPageState : U.initialState
, docAnnotationState : D.initialState
, docAnnotationState : D.initialState
, ntreeState : Tree.exampleTree
, ntreeState : Tree.exampleTree
, annuaireState : Annuaire.initialState
, search : ""
, search : ""
, showLogin : false
, showLogin : false
, showCorpus : false
, showCorpus : false
...
@@ -63,6 +66,9 @@ _searchState = lens (\s -> s.searchState) (\s ss -> s{searchState = ss})
...
@@ -63,6 +66,9 @@ _searchState = lens (\s -> s.searchState) (\s ss -> s{searchState = ss})
_userPageState :: Lens' AppState U.State
_userPageState :: Lens' AppState U.State
_userPageState = lens (\s -> s.userPageState) (\s ss -> s{userPageState = ss})
_userPageState = lens (\s -> s.userPageState) (\s ss -> s{userPageState = ss})
_annuaireState :: Lens' AppState Annuaire.State
_annuaireState = lens (\s -> s.annuaireState) (\s ss -> s{annuaireState = ss})
_docAnnotationViewState :: Lens' AppState D.State
_docAnnotationViewState :: Lens' AppState D.State
_docAnnotationViewState = lens (\s -> s.docAnnotationState) (\s ss -> s{docAnnotationState = ss})
_docAnnotationViewState = lens (\s -> s.docAnnotationState) (\s ss -> s{docAnnotationState = ss})
...
...
src/Gargantext/Router.purs
View file @
e467737c
...
@@ -54,7 +54,7 @@ routing =
...
@@ -54,7 +54,7 @@ routing =
Login <$ route "login"
Login <$ route "login"
<|> Tabview <$ route "tabview"
<|> Tabview <$ route "tabview"
<|> DocAnnotation <$> (route "document" *> int)
<|> DocAnnotation <$> (route "document" *> int)
<|> UserPage <$> (route "user" *> int)
<|> UserPage <$> (route "user"
*> int)
<|> SearchView <$ route "search"
<|> SearchView <$ route "search"
<|> DocView <$ route "docView"
<|> DocView <$ route "docView"
<|> AddCorpus <$ route "addCorpus"
<|> AddCorpus <$ route "addCorpus"
...
@@ -63,7 +63,7 @@ routing =
...
@@ -63,7 +63,7 @@ routing =
<|> NGramsTable <$ route "ngrams"
<|> NGramsTable <$ route "ngrams"
<|> Dashboard <$ route "dashboard"
<|> Dashboard <$ route "dashboard"
<|> Annuaire <$> (route "annuaire" *> int)
<|> Annuaire <$> (route "annuaire" *> int)
<|> Folder <$> (route "folder" *> int)
<|> Folder <$> (route "folder"
*> int)
<|> Home <$ lit ""
<|> Home <$ lit ""
where
where
route str = lit "" *> lit str
route str = lit "" *> lit str
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment