[NGRAMS] connect components

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