Commit 475a69dc authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[chart] some chart reloading simplifications

parent 42bc8a18
......@@ -13,7 +13,6 @@ import Gargantext.Prelude
import Gargantext.Components.NgramsTable as NT
import Gargantext.Components.Nodes.Corpus.Types (CorpusData)
import Gargantext.Components.Nodes.Corpus.Chart.API (recomputeChart)
import Gargantext.Components.Nodes.Corpus.Chart.Metrics (metrics)
import Gargantext.Components.Nodes.Corpus.Chart.Pie (pie, bar)
import Gargantext.Components.Nodes.Corpus.Chart.Tree (tree)
......@@ -64,12 +63,13 @@ ngramsViewCpt = R2.hooksComponent thisModule "ngramsView" cpt
, corpusId
, mode
, session } _ = do
chartType <- R.useState' Histo
chartsReload <- R.useState' 0
pure $ R.fragment
( charts tabNgramType chartType chartsReload
<> [ NT.mainNgramsTable { afterSync: afterSync (fst chartType) chartsReload
<> [ NT.mainNgramsTable { afterSync: afterSync chartsReload
, cacheState
, defaultListId
, nodeId: corpusId
......@@ -81,10 +81,13 @@ ngramsViewCpt = R2.hooksComponent thisModule "ngramsView" cpt
]
)
where
afterSync chartType (_ /\ setChartsReload) _ = do
afterSync (_ /\ setChartsReload) _ = do
case mNgramsType of
Just ngramsType -> do
_ <- recomputeChart session chartType ngramsType corpusId listId
-- NOTE: No need to recompute chart, after ngrams are sync this
-- should be recomputed already
-- We just refresh it
-- _ <- recomputeChart session chartType ngramsType corpusId listId
liftEffect $ setChartsReload $ (+) 1
Nothing -> pure unit
......@@ -121,7 +124,7 @@ ngramsViewCpt = R2.hooksComponent thisModule "ngramsView" cpt
]
charts _ _ _ = [ chart mode ]
chart Authors = pie { session, path }
chart Institutes = tree { session, path }
chart Sources = bar { session, path }
chart Terms = metrics { session, path }
chart Authors = pie { path, session }
chart Institutes = tree { path, session }
chart Sources = bar { path, session }
chart Terms = metrics { path, session }
......@@ -119,7 +119,7 @@ sessionPath (R.Tab t i) = sessionPath (R.NodeAPI Node i (showTabType
sessionPath (R.Children n o l s i) = sessionPath (R.NodeAPI Node i ("children?type=" <> show n <> offsetUrl o <> limitUrl l <> orderUrl s))
sessionPath (R.NodeAPI Phylo pId p) = "phyloscape?nodeId=" <> (show $ fromMaybe 0 pId) <> p
sessionPath (R.RecomputeNgrams nt nId lId) = "node/" <> (show nId) <> "/ngrams/recompute?" <> (defaultList lId) <> "&ngramsType=" <> (show nt)
sessionPath (R.RecomputeListChart ChartBar nt nId lId) = "node/" <> (show nId) <> "/chart?" <> (defaultList lId) <> "&ngramsType=" <> (show nt)
sessionPath (R.RecomputeListChart ChartBar nt nId lId) = "node/" <> (show nId) <> "/pie?" <> (defaultList lId) <> "&ngramsType=" <> (show nt)
sessionPath (R.RecomputeListChart ChartPie nt nId lId) = "node/" <> (show nId) <> "/pie?" <> (defaultList lId) <> "&ngramsType=" <> (show nt)
sessionPath (R.RecomputeListChart ChartTree nt nId lId) = "node/" <> (show nId) <> "/tree?" <> (defaultList lId) <> "&ngramsType=" <> (show nt) <> "&listType=" <> show MapTerm
sessionPath (R.RecomputeListChart Histo nt nId lId) = "node/" <> (show nId) <> "/chart?" <> (defaultList lId) <> "&ngramsType=" <> (show nt)
......
......@@ -4,7 +4,9 @@ import Prelude
import Data.Maybe (Maybe(..))
import Gargantext.Types (ChartOpts, ChartType, CorpusMetricOpts, CTabNgramType, Id, Limit, ListId, NgramsGetOpts, NodeType, Offset, OrderBy, SearchOpts, SessionId, TabSubType, TabType, TermList, NgramsGetTableAllOpts)
import Gargantext.Types (ChartOpts, ChartType, CorpusMetricOpts, CTabNgramType, Id, Limit,
ListId, NgramsGetOpts, NgramsGetTableAllOpts, NodeType,
Offset, OrderBy, SearchOpts, SessionId, TabSubType, TabType, TermList)
import Gargantext.Types as GT
data AppRoute
......
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