Commit 3bbdfd7c authored by Alexandre Delanoë's avatar Alexandre Delanoë

Merge branch 'dev-ngrams-table-online' of...

Merge branch 'dev-ngrams-table-online' of ssh://gitlab.iscpif.fr:20022/gargantext/purescript-gargantext into dev-merge
parents c1b775f8 7e393a3e
This diff is collapsed.
...@@ -18,9 +18,13 @@ module Gargantext.Components.NgramsTable.Core ...@@ -18,9 +18,13 @@ module Gargantext.Components.NgramsTable.Core
, findNgramTermList , findNgramTermList
, Version , Version
, Versioned(..) , Versioned(..)
, Count
, VersionedWithCount(..)
, toVersioned
, VersionedNgramsPatches , VersionedNgramsPatches
, AsyncNgramsChartsUpdate , AsyncNgramsChartsUpdate
, VersionedNgramsTable , VersionedNgramsTable
, VersionedWithCountNgramsTable
, NgramsTablePatch , NgramsTablePatch
, NgramsPatch(..) , NgramsPatch(..)
, CoreState , CoreState
...@@ -164,6 +168,32 @@ instance decodeJsonVersioned :: DecodeJson a => DecodeJson (Versioned a) where ...@@ -164,6 +168,32 @@ instance decodeJsonVersioned :: DecodeJson a => DecodeJson (Versioned a) where
version <- obj .: "version" version <- obj .: "version"
data_ <- obj .: "data" data_ <- obj .: "data"
pure $ Versioned {version, data: data_} pure $ Versioned {version, data: data_}
------------------------------------------------------------------------
type Count = Int
newtype VersionedWithCount a = VersionedWithCount
{ version :: Version
, count :: Count
, data :: a
}
instance encodeJsonVersionedWithCount :: EncodeJson a => EncodeJson (VersionedWithCount a) where
encodeJson (VersionedWithCount {count, version, data: data_})
= "version" := version
~> "count" := count
~> "data" := data_
~> jsonEmptyObject
instance decodeJsonVersionedWithCount :: DecodeJson a => DecodeJson (VersionedWithCount a) where
decodeJson json = do
obj <- decodeJson json
count <- obj .: "count"
data_ <- obj .: "data"
version <- obj .: "version"
pure $ VersionedWithCount {count, version, data: data_}
toVersioned :: forall a. VersionedWithCount a -> Tuple Count (Versioned a)
toVersioned (VersionedWithCount { count, data: d, version }) = Tuple count $ Versioned { data: d, version }
------------------------------------------------------------------------ ------------------------------------------------------------------------
-- TODO replace by NgramsPatches directly -- TODO replace by NgramsPatches directly
...@@ -535,6 +565,7 @@ highlightNgrams ntype table@(NgramsTable {ngrams_repo_elements: elts}) input0 = ...@@ -535,6 +565,7 @@ highlightNgrams ntype table@(NgramsTable {ngrams_repo_elements: elts}) input0 =
----------------------------------------------------------------------------------- -----------------------------------------------------------------------------------
type VersionedNgramsTable = Versioned NgramsTable type VersionedNgramsTable = Versioned NgramsTable
type VersionedWithCountNgramsTable = VersionedWithCount NgramsTable
----------------------------------------------------------------------------------- -----------------------------------------------------------------------------------
data Replace a data Replace a
......
...@@ -21,6 +21,7 @@ import Gargantext.Components.Nodes.Texts.Types as TTypes ...@@ -21,6 +21,7 @@ import Gargantext.Components.Nodes.Texts.Types as TTypes
import Gargantext.Ends (Frontends) import Gargantext.Ends (Frontends)
import Gargantext.Sessions (Session) import Gargantext.Sessions (Session)
import Gargantext.Types (CTabNgramType(..), NodeID, PTabNgramType(..), TabType(..), TabSubType(..)) import Gargantext.Types (CTabNgramType(..), NodeID, PTabNgramType(..), TabType(..), TabSubType(..))
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Reload as GUR import Gargantext.Utils.Reload as GUR
thisModule :: String thisModule :: String
...@@ -80,9 +81,9 @@ tabsCpt = R.hooksComponentWithModule thisModule "tabs" cpt ...@@ -80,9 +81,9 @@ tabsCpt = R.hooksComponentWithModule thisModule "tabs" cpt
where where
tabs' trg = tabs' trg =
[ "Documents" /\ docs trg [ "Documents" /\ docs trg
, "Patents" /\ ngramsView patentsView , "Patents" /\ ngramsView patentsView []
, "Books" /\ ngramsView booksView , "Books" /\ ngramsView booksView []
, "Communication" /\ ngramsView commView , "Communication" /\ ngramsView commView []
, "Trash" /\ docs trg -- TODO pass-in trash mode , "Trash" /\ docs trg -- TODO pass-in trash mode
] ]
where where
...@@ -141,12 +142,12 @@ type NgramsViewTabsProps = ( ...@@ -141,12 +142,12 @@ type NgramsViewTabsProps = (
, treeReloadRef :: GUR.ReloadWithInitializeRef , treeReloadRef :: GUR.ReloadWithInitializeRef
) )
ngramsView :: Record NgramsViewTabsProps -> R.Element ngramsView :: R2.Component NgramsViewTabsProps
ngramsView props = R.createElement ngramsViewCpt props [] ngramsView = R.createElement ngramsViewCpt
ngramsViewCpt :: R.Component NgramsViewTabsProps
ngramsViewCpt = R.hooksComponentWithModule thisModule "ngramsView" cpt
where where
ngramsViewCpt :: R.Component NgramsViewTabsProps
ngramsViewCpt = R.hooksComponentWithModule thisModule "ngramsView" cpt
cpt { appReload cpt { appReload
, asyncTasksRef , asyncTasksRef
, cacheState , cacheState
...@@ -172,7 +173,7 @@ ngramsViewCpt = R.hooksComponentWithModule thisModule "ngramsView" cpt ...@@ -172,7 +173,7 @@ ngramsViewCpt = R.hooksComponentWithModule thisModule "ngramsView" cpt
, tabNgramType , tabNgramType
, treeReloadRef , treeReloadRef
, withAutoUpdate: false , withAutoUpdate: false
} } []
where where
tabNgramType = modeTabType' mode tabNgramType = modeTabType' mode
tabType = TabPairing $ TabNgramType $ modeTabType mode tabType = TabPairing $ TabNgramType $ modeTabType mode
...@@ -35,10 +35,10 @@ type ListsWithForest = ( ...@@ -35,10 +35,10 @@ type ListsWithForest = (
listsWithForest :: R2.Component ListsWithForest listsWithForest :: R2.Component ListsWithForest
listsWithForest = R.createElement listsWithForestCpt listsWithForest = R.createElement listsWithForestCpt
listsWithForestCpt :: R.Component ListsWithForest
listsWithForestCpt = R.hooksComponentWithModule thisModule "listsWithForest" cpt
where where
listsWithForestCpt :: R.Component ListsWithForest
listsWithForestCpt = R.hooksComponentWithModule thisModule "listsWithForest" cpt
cpt { forestProps cpt { forestProps
, listsProps: listsProps@{ session } } _ = do , listsProps: listsProps@{ session } } _ = do
controls <- initialControls controls <- initialControls
...@@ -58,10 +58,10 @@ type TopBarProps = ( ...@@ -58,10 +58,10 @@ type TopBarProps = (
topBar :: R2.Component TopBarProps topBar :: R2.Component TopBarProps
topBar = R.createElement topBarCpt topBar = R.createElement topBarCpt
topBarCpt :: R.Component TopBarProps
topBarCpt = R.hooksComponentWithModule thisModule "topBar" cpt
where where
topBarCpt :: R.Component TopBarProps
topBarCpt = R.hooksComponentWithModule thisModule "topBar" cpt
cpt { controls } _ = do cpt { controls } _ = do
-- empty for now because the button is moved to the side panel -- empty for now because the button is moved to the side panel
pure $ H.div {} [] pure $ H.div {} []
...@@ -93,10 +93,10 @@ type WithTreeProps = ( ...@@ -93,10 +93,10 @@ type WithTreeProps = (
listsLayout :: R2.Component Props listsLayout :: R2.Component Props
listsLayout = R.createElement listsLayoutCpt listsLayout = R.createElement listsLayoutCpt
listsLayoutCpt :: R.Component Props
listsLayoutCpt = R.hooksComponentWithModule thisModule "listsLayout" cpt
where where
listsLayoutCpt :: R.Component Props
listsLayoutCpt = R.hooksComponentWithModule thisModule "listsLayout" cpt
cpt path@{ nodeId, session } _ = do cpt path@{ nodeId, session } _ = do
let sid = sessionId session let sid = sessionId session
...@@ -109,10 +109,10 @@ type KeyProps = ( ...@@ -109,10 +109,10 @@ type KeyProps = (
listsLayoutWithKey :: Record KeyProps -> R.Element listsLayoutWithKey :: Record KeyProps -> R.Element
listsLayoutWithKey props = R.createElement listsLayoutWithKeyCpt props [] listsLayoutWithKey props = R.createElement listsLayoutWithKeyCpt props []
listsLayoutWithKeyCpt :: R.Component KeyProps
listsLayoutWithKeyCpt = R.hooksComponentWithModule thisModule "listsLayoutWithKey" cpt
where where
listsLayoutWithKeyCpt :: R.Component KeyProps
listsLayoutWithKeyCpt = R.hooksComponentWithModule thisModule "listsLayoutWithKey" cpt
cpt { appReload cpt { appReload
, asyncTasksRef , asyncTasksRef
, controls , controls
...@@ -122,7 +122,7 @@ listsLayoutWithKeyCpt = R.hooksComponentWithModule thisModule "listsLayoutWithKe ...@@ -122,7 +122,7 @@ listsLayoutWithKeyCpt = R.hooksComponentWithModule thisModule "listsLayoutWithKe
, treeReloadRef } _ = do , treeReloadRef } _ = do
let path = { nodeId, session } let path = { nodeId, session }
cacheState <- R.useState' $ getCacheState CacheOn session nodeId cacheState <- R.useState' $ getCacheState CacheOff session nodeId
useLoader path loadCorpusWithChild $ useLoader path loadCorpusWithChild $
\corpusData@{ corpusId, corpusNode: NodePoly poly, defaultListId } -> \corpusData@{ corpusId, corpusNode: NodePoly poly, defaultListId } ->
...@@ -164,10 +164,10 @@ type SidePanelProps = ( ...@@ -164,10 +164,10 @@ type SidePanelProps = (
sidePanel :: R2.Component SidePanelProps sidePanel :: R2.Component SidePanelProps
sidePanel = R.createElement sidePanelCpt sidePanel = R.createElement sidePanelCpt
sidePanelCpt :: R.Component SidePanelProps
sidePanelCpt = R.hooksComponentWithModule thisModule "sidePanel" cpt
where where
sidePanelCpt :: R.Component SidePanelProps
sidePanelCpt = R.hooksComponentWithModule thisModule "sidePanel" cpt
cpt { controls: { triggers: { toggleSidePanel cpt { controls: { triggers: { toggleSidePanel
, triggerSidePanel , triggerSidePanel
} } } }
...@@ -208,10 +208,10 @@ type SidePanelDocView = ( ...@@ -208,10 +208,10 @@ type SidePanelDocView = (
sidePanelDocView :: R2.Component SidePanelDocView sidePanelDocView :: R2.Component SidePanelDocView
sidePanelDocView = R.createElement sidePanelDocViewCpt sidePanelDocView = R.createElement sidePanelDocViewCpt
sidePanelDocViewCpt :: R.Component SidePanelDocView
sidePanelDocViewCpt = R.hooksComponentWithModule thisModule "sidePanelDocView" cpt
where where
sidePanelDocViewCpt :: R.Component SidePanelDocView
sidePanelDocViewCpt = R.hooksComponentWithModule thisModule "sidePanelDocView" cpt
cpt { session } _ = do cpt { session } _ = do
-- pure $ H.h4 {} [ H.text txt ] -- pure $ H.h4 {} [ H.text txt ]
pure $ H.div {} [ H.text "Hello ngrams" ] pure $ H.div {} [ H.text "Hello ngrams" ]
...@@ -130,7 +130,7 @@ ngramsViewCpt = R.hooksComponentWithModule thisModule "ngramsView" cpt ...@@ -130,7 +130,7 @@ ngramsViewCpt = R.hooksComponentWithModule thisModule "ngramsView" cpt
, tabType , tabType
, treeReloadRef , treeReloadRef
, withAutoUpdate: false , withAutoUpdate: false
} } []
] ]
) )
where where
......
...@@ -60,10 +60,10 @@ initialParams = stateParams {page: 1, pageSize: PS10, orderBy: Nothing, searchTy ...@@ -60,10 +60,10 @@ initialParams = stateParams {page: 1, pageSize: PS10, orderBy: Nothing, searchTy
tableHeaderLayout :: Record TableHeaderLayoutProps -> R.Element tableHeaderLayout :: Record TableHeaderLayoutProps -> R.Element
tableHeaderLayout props = R.createElement tableHeaderLayoutCpt props [] tableHeaderLayout props = R.createElement tableHeaderLayoutCpt props []
tableHeaderLayoutCpt :: R.Component TableHeaderLayoutProps
tableHeaderLayoutCpt = R.hooksComponentWithModule thisModule "tableHeaderLayout" cpt
where where
tableHeaderLayoutCpt :: R.Component TableHeaderLayoutProps
tableHeaderLayoutCpt = R.hooksComponentWithModule thisModule "tableHeaderLayout" cpt
cpt { afterCacheStateChange, cacheState, date, desc, query, title, user } _ = cpt { afterCacheStateChange, cacheState, date, desc, query, title, user } _ =
pure $ R.fragment pure $ R.fragment
[ R2.row [ R2.row
...@@ -117,10 +117,10 @@ tableHeaderLayoutCpt = R.hooksComponentWithModule thisModule "tableHeaderLayout" ...@@ -117,10 +117,10 @@ tableHeaderLayoutCpt = R.hooksComponentWithModule thisModule "tableHeaderLayout"
table :: Record Props -> R.Element table :: Record Props -> R.Element
table props = R.createElement tableCpt props [] table props = R.createElement tableCpt props []
tableCpt :: R.Component Props
tableCpt = R.hooksComponentWithModule thisModule "table" cpt
where where
tableCpt :: R.Component Props
tableCpt = R.hooksComponentWithModule thisModule "table" cpt
cpt {container, syncResetButton, colNames, wrapColElts, totalRecords, rows, params} _ = do cpt {container, syncResetButton, colNames, wrapColElts, totalRecords, rows, params} _ = do
let let
state = paramsState $ fst params state = paramsState $ fst params
...@@ -196,10 +196,10 @@ type SizeDDProps = ...@@ -196,10 +196,10 @@ type SizeDDProps =
sizeDD :: Record SizeDDProps -> R.Element sizeDD :: Record SizeDDProps -> R.Element
sizeDD p = R.createElement sizeDDCpt p [] sizeDD p = R.createElement sizeDDCpt p []
sizeDDCpt :: R.Component SizeDDProps
sizeDDCpt = R.hooksComponentWithModule thisModule "sizeDD" cpt
where where
sizeDDCpt :: R.Component SizeDDProps
sizeDDCpt = R.hooksComponentWithModule thisModule "sizeDD" cpt
cpt {params: params /\ setParams} _ = do cpt {params: params /\ setParams} _ = do
pure $ H.span {} [ pure $ H.span {} [
R2.select { className, defaultValue: show pageSize, on: {change} } sizes R2.select { className, defaultValue: show pageSize, on: {change} } sizes
......
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