[NGRAMS] connect components

parent faa2a272
...@@ -29,6 +29,13 @@ import Gargantext.Config ...@@ -29,6 +29,13 @@ import Gargantext.Config
import Gargantext.Config.REST import Gargantext.Config.REST
import Gargantext.Components.Tree (NTree(..)) import Gargantext.Components.Tree (NTree(..))
import Gargantext.Components.Loader as Loader import Gargantext.Components.Loader as Loader
import Gargantext.Pages.Corpus.Tabs.Types (CorpusInfo(..), PropsRow)
type Props = { mode :: Mode | PropsRow }
type Props' = { path :: Int
, loaded :: Maybe NgramsTable
}
type NgramsTable = Array (NTree NgramsElement) type NgramsTable = Array (NTree NgramsElement)
...@@ -52,13 +59,9 @@ data Action ...@@ -52,13 +59,9 @@ data Action
| SetTermTypeFilter (Maybe TermType) | SetTermTypeFilter (Maybe TermType)
| SetSearchQuery String | SetSearchQuery String
type Dispatch = Action -> Effect Unit data Mode = Authors | Sources | Terms
performAction :: PerformAction State {} Action type Dispatch = Action -> Effect Unit
performAction (SetTermListFilter c) _ _ = modifyState_ $ _ { termListFilter = c }
performAction (SetTermTypeFilter c) _ _ = modifyState_ $ _ { termTypeFilter = c }
performAction (SetSearchQuery s) _ _ = modifyState_ $ _ { searchQuery = s }
performAction (SetTermListItem _i _l) _ _ = pure unit -- TODO
tableContainer :: {searchQuery :: String, dispatch :: Dispatch} -> T.TableContainerProps -> Array ReactElement tableContainer :: {searchQuery :: String, dispatch :: Dispatch} -> T.TableContainerProps -> Array ReactElement
tableContainer {searchQuery, dispatch} props = tableContainer {searchQuery, dispatch} props =
...@@ -122,20 +125,23 @@ tableContainer {searchQuery, dispatch} props = ...@@ -122,20 +125,23 @@ tableContainer {searchQuery, dispatch} props =
] ]
] ]
ngramsTableSpec' :: Spec State Props' Action
ngramsTableSpec'' = simpleSpec defaultPerformAction (\_ _ _ _ -> [])
ngramsTableSpec' :: Spec State {} Action
ngramsTableSpec' = simpleSpec performAction render ngramsTableSpec' = simpleSpec performAction render
where where
render :: Render State {} Action performAction :: PerformAction State Props' Action
render dispatch { {-path: nodeId, loaded-} } {searchQuery {- TODO more state -} } _ = performAction (SetTermListFilter c) _ _ = modifyState_ $ _ { termListFilter = c }
performAction (SetTermTypeFilter c) _ _ = modifyState_ $ _ { termTypeFilter = c }
performAction (SetSearchQuery s) _ _ = modifyState_ $ _ { searchQuery = s }
performAction (SetTermListItem _i _l) _ _ = pure unit -- TODO
render :: Render State Props' Action
render dispatch {path: nodeId, loaded} {searchQuery {- TODO more state -} } _ =
[ T.tableElt [ T.tableElt
{ loadRows { loadRows
, container: tableContainer {searchQuery, dispatch} , container: tableContainer {searchQuery, dispatch}
, colNames: , colNames:
T.ColumnName <$> T.ColumnName <$>
[ "Map" [ "Graph"
, "Stop" , "Stop"
, "Terms" , "Terms"
, "Occurences (nb)" , "Occurences (nb)"
...@@ -189,13 +195,14 @@ ngramsLoaderClass = Loader.createLoaderClass "NgramsLoader" getNgramsTable ...@@ -189,13 +195,14 @@ ngramsLoaderClass = Loader.createLoaderClass "NgramsLoader" getNgramsTable
ngramsLoader :: Loader.Props Int NgramsTable -> ReactElement ngramsLoader :: Loader.Props Int NgramsTable -> ReactElement
ngramsLoader = React.createLeafElement ngramsLoaderClass ngramsLoader = React.createLeafElement ngramsLoaderClass
ngramsTableSpec :: Spec {} {nodeId :: Int} Void ngramsTableSpec :: Spec {} Props Void
ngramsTableSpec = simpleSpec defaultPerformAction render ngramsTableSpec = simpleSpec defaultPerformAction render
where where
render :: Render {} {nodeId :: Int} Void render :: Render {} Props Void
render _ {nodeId} _ _ = render _ {path: nodeId} _ _ =
-- TODO: ignored mode, ignored loaded: corpusInfo
[ ngramsLoader { path: nodeId [ ngramsLoader { path: nodeId
, component: createClass "Layout" ngramsTableSpec'' initialState , component: createClass "Layout" ngramsTableSpec' initialState
} ] } ]
renderNgramsItem :: { ngrams :: String renderNgramsItem :: { ngrams :: String
......
...@@ -10,7 +10,7 @@ import Gargantext.Pages.Corpus.Tabs.States (State(), _doclens, _ngramsView, _tab ...@@ -10,7 +10,7 @@ import Gargantext.Pages.Corpus.Tabs.States (State(), _doclens, _ngramsView, _tab
import Gargantext.Pages.Corpus.Tabs.Actions (Action(), _docAction, _NgramViewA, _tabAction) import Gargantext.Pages.Corpus.Tabs.Actions (Action(), _docAction, _NgramViewA, _tabAction)
import Gargantext.Pages.Corpus.Tabs.Documents as DV import Gargantext.Pages.Corpus.Tabs.Documents as DV
import Gargantext.Pages.Corpus.Tabs.Ngrams as NV import Gargantext.Pages.Corpus.Tabs.Ngrams.NgramsTable as NV
import Gargantext.Components.Tab as Tab import Gargantext.Components.Tab as Tab
import Thermite (Spec, focus, hideState, cmapProps) import Thermite (Spec, focus, hideState, cmapProps)
...@@ -30,8 +30,10 @@ statefulTabs = ...@@ -30,8 +30,10 @@ statefulTabs =
docPageSpec :: Spec State Props Action docPageSpec :: Spec State Props Action
docPageSpec = focus _doclens _docAction DV.layoutDocview docPageSpec = focus _doclens _docAction DV.layoutDocview
ngramsViewSpec :: NV.Props -> Spec State Props Action ngramsViewSpec :: {mode :: NV.Mode} -> Spec State Props Action
ngramsViewSpec props = cmapProps (const props) (focus _ngramsView _NgramViewA NV.ngramsSpec) ngramsViewSpec {mode} =
cmapProps (\{loaded, path} -> {mode,loaded,path})
(focus _ngramsView _NgramViewA NV.ngramsTableSpec)
authorPageSpec :: Spec State Props Action authorPageSpec :: Spec State Props Action
authorPageSpec = ngramsViewSpec {mode: NV.Authors} authorPageSpec = ngramsViewSpec {mode: NV.Authors}
......
...@@ -43,7 +43,8 @@ instance decodeCorpusInfo :: DecodeJson CorpusInfo where ...@@ -43,7 +43,8 @@ instance decodeCorpusInfo :: DecodeJson CorpusInfo where
pure $ CorpusInfo {title, desc, query, authors, chart, totalRecords} pure $ CorpusInfo {title, desc, query, authors, chart, totalRecords}
-- TODO type Props = {nodeId :: Int, info :: Maybe (NodePoly CorpusInfo) } -- TODO type Props = {nodeId :: Int, info :: Maybe (NodePoly CorpusInfo) }
type Props = {path :: Int, loaded :: Maybe (NodePoly CorpusInfo) } type PropsRow = (path :: Int, loaded :: Maybe (NodePoly CorpusInfo))
type Props = Record PropsRow
-- TODO include Gargantext.Pages.Corpus.Tabs.States -- TODO include Gargantext.Pages.Corpus.Tabs.States
-- TODO include Gargantext.Pages.Corpus.Tabs.Actions -- TODO include Gargantext.Pages.Corpus.Tabs.Actions
...@@ -59,9 +59,5 @@ dispatchAction dispatcher _ PGraphExplorer = do ...@@ -59,9 +59,5 @@ dispatchAction dispatcher _ PGraphExplorer = do
dispatcher $ SetRoute PGraphExplorer dispatcher $ SetRoute PGraphExplorer
dispatcher $ GraphExplorerA $ GE.LoadGraph "imtNew.json" dispatcher $ GraphExplorerA $ GE.LoadGraph "imtNew.json"
dispatchAction dispatcher _ NGramsTable = do
dispatcher $ SetRoute NGramsTable
-- dispatcher $ NgramsA TODO
dispatchAction dispatcher _ Dashboard = do dispatchAction dispatcher _ Dashboard = do
dispatcher $ SetRoute Dashboard dispatcher $ SetRoute Dashboard
...@@ -64,9 +64,6 @@ pagesComponent s = case s.currentRoute of ...@@ -64,9 +64,6 @@ pagesComponent s = case s.currentRoute of
selectSpec (Annuaire i) = layout0 $ cmapProps (const {annuaireId: i}) $ noState A.layout selectSpec (Annuaire i) = layout0 $ cmapProps (const {annuaireId: i}) $ noState A.layout
selectSpec (UserPage i) = layout0 $ focus _userPageState _userPageAction C.layoutUser selectSpec (UserPage i) = layout0 $ focus _userPageState _userPageAction C.layoutUser
-- To be removed
selectSpec NGramsTable = layout0 $ cmapProps (const {nodeId: i}) $ noState NG.ngramsTableSpec
where i = 0 -- TODO
-- selectSpec _ = simpleSpec defaultPerformAction defaultRender -- selectSpec _ = simpleSpec defaultPerformAction defaultRender
......
...@@ -21,7 +21,6 @@ data Routes ...@@ -21,7 +21,6 @@ data Routes
| AddCorpus | AddCorpus
| Document Int | Document Int
| PGraphExplorer | PGraphExplorer
| NGramsTable
| Dashboard | Dashboard
| Annuaire Int | Annuaire Int
| UserPage Int | UserPage Int
...@@ -33,7 +32,6 @@ routing = ...@@ -33,7 +32,6 @@ routing =
<|> AddCorpus <$ route "addCorpus" <|> AddCorpus <$ route "addCorpus"
<|> Folder <$> (route "folder" *> int) <|> Folder <$> (route "folder" *> int)
<|> Corpus <$> (route "corpus" *> int) <|> Corpus <$> (route "corpus" *> int)
<|> NGramsTable <$ route "ngrams"
<|> Document <$> (route "document" *> int) <|> Document <$> (route "document" *> int)
<|> Dashboard <$ route "dashboard" <|> Dashboard <$ route "dashboard"
<|> PGraphExplorer <$ route "graph" <|> PGraphExplorer <$ route "graph"
...@@ -54,7 +52,6 @@ instance showRoutes :: Show Routes where ...@@ -54,7 +52,6 @@ instance showRoutes :: Show Routes where
show (UserPage i) = "User" <> show i show (UserPage i) = "User" <> show i
show (Document i) = "Document" show (Document i) = "Document"
show (Corpus i) = "Corpus" <> show i show (Corpus i) = "Corpus" <> show i
show NGramsTable = "NGramsTable"
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 Dashboard = "Dashboard"
......
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