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

[chart] some chart reloading simplifications

parent 42bc8a18
...@@ -13,7 +13,6 @@ import Gargantext.Prelude ...@@ -13,7 +13,6 @@ import Gargantext.Prelude
import Gargantext.Components.NgramsTable as NT import Gargantext.Components.NgramsTable as NT
import Gargantext.Components.Nodes.Corpus.Types (CorpusData) 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.Metrics (metrics)
import Gargantext.Components.Nodes.Corpus.Chart.Pie (pie, bar) import Gargantext.Components.Nodes.Corpus.Chart.Pie (pie, bar)
import Gargantext.Components.Nodes.Corpus.Chart.Tree (tree) import Gargantext.Components.Nodes.Corpus.Chart.Tree (tree)
...@@ -64,12 +63,13 @@ ngramsViewCpt = R2.hooksComponent thisModule "ngramsView" cpt ...@@ -64,12 +63,13 @@ ngramsViewCpt = R2.hooksComponent thisModule "ngramsView" cpt
, corpusId , corpusId
, mode , mode
, session } _ = do , session } _ = do
chartType <- R.useState' Histo chartType <- R.useState' Histo
chartsReload <- R.useState' 0 chartsReload <- R.useState' 0
pure $ R.fragment pure $ R.fragment
( charts tabNgramType chartType chartsReload ( charts tabNgramType chartType chartsReload
<> [ NT.mainNgramsTable { afterSync: afterSync (fst chartType) chartsReload <> [ NT.mainNgramsTable { afterSync: afterSync chartsReload
, cacheState , cacheState
, defaultListId , defaultListId
, nodeId: corpusId , nodeId: corpusId
...@@ -81,10 +81,13 @@ ngramsViewCpt = R2.hooksComponent thisModule "ngramsView" cpt ...@@ -81,10 +81,13 @@ ngramsViewCpt = R2.hooksComponent thisModule "ngramsView" cpt
] ]
) )
where where
afterSync chartType (_ /\ setChartsReload) _ = do afterSync (_ /\ setChartsReload) _ = do
case mNgramsType of case mNgramsType of
Just ngramsType -> do 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 liftEffect $ setChartsReload $ (+) 1
Nothing -> pure unit Nothing -> pure unit
...@@ -121,7 +124,7 @@ ngramsViewCpt = R2.hooksComponent thisModule "ngramsView" cpt ...@@ -121,7 +124,7 @@ ngramsViewCpt = R2.hooksComponent thisModule "ngramsView" cpt
] ]
charts _ _ _ = [ chart mode ] charts _ _ _ = [ chart mode ]
chart Authors = pie { session, path } chart Authors = pie { path, session }
chart Institutes = tree { session, path } chart Institutes = tree { path, session }
chart Sources = bar { session, path } chart Sources = bar { path, session }
chart Terms = metrics { session, path } chart Terms = metrics { path, session }
...@@ -119,7 +119,7 @@ sessionPath (R.Tab t i) = sessionPath (R.NodeAPI Node i (showTabType ...@@ -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.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.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.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 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 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) sessionPath (R.RecomputeListChart Histo nt nId lId) = "node/" <> (show nId) <> "/chart?" <> (defaultList lId) <> "&ngramsType=" <> (show nt)
......
...@@ -4,7 +4,9 @@ import Prelude ...@@ -4,7 +4,9 @@ import Prelude
import Data.Maybe (Maybe(..)) 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 import Gargantext.Types as GT
data AppRoute 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