Commit bcc6aaa6 authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[ngrams] asyncTasks – pass action only

parent c37cc12f
...@@ -54,6 +54,7 @@ type ReductorProps = ( ...@@ -54,6 +54,7 @@ type ReductorProps = (
) )
type Reductor = R2.Reductor (Record ReductorProps) Action type Reductor = R2.Reductor (Record ReductorProps) Action
type ReductorAction = Action -> Effect Unit
useTasks :: R.State Int -> R.Hooks Reductor useTasks :: R.State Int -> R.Hooks Reductor
useTasks reload = R2.useReductor act initializer unit useTasks reload = R2.useReductor act initializer unit
......
...@@ -91,7 +91,12 @@ appCpt = R.hooksComponentWithModule thisModule "app" cpt where ...@@ -91,7 +91,12 @@ appCpt = R.hooksComponentWithModule thisModule "app" cpt where
false -> false ->
case fst route of case fst route of
Annuaire sid nodeId -> withSession sid $ \session -> forested $ annuaireLayout { frontends, nodeId, session } Annuaire sid nodeId -> withSession sid $ \session -> forested $ annuaireLayout { frontends, nodeId, session }
ContactPage sid aId nodeId -> withSession sid $ \session -> forested $ annuaireUserLayout { annuaireId: aId, asyncTasks, frontends, nodeId, session } ContactPage sid aId nodeId -> withSession sid $ \session -> forested $ annuaireUserLayout {
annuaireId: aId
, asyncTasks: snd asyncTasks, frontends
, nodeId
, session
}
Corpus sid nodeId -> withSession sid $ \session -> forested $ corpusLayout { nodeId, session } Corpus sid nodeId -> withSession sid $ \session -> forested $ corpusLayout { nodeId, session }
CorpusDocument sid corpusId listId nodeId -> withSession sid $ \session -> forested $ documentLayout { nodeId, listId, session, corpusId: Just corpusId } CorpusDocument sid corpusId listId nodeId -> withSession sid $ \session -> forested $ documentLayout { nodeId, listId, session, corpusId: Just corpusId }
Dashboard sid nodeId -> withSession sid $ \session -> forested $ dashboardLayout { nodeId, session } Dashboard sid nodeId -> withSession sid $ \session -> forested $ dashboardLayout { nodeId, session }
...@@ -103,7 +108,12 @@ appCpt = R.hooksComponentWithModule thisModule "app" cpt where ...@@ -103,7 +108,12 @@ appCpt = R.hooksComponentWithModule thisModule "app" cpt where
FolderPublic sid nodeId -> withSession sid $ \session -> forested $ corpusLayout { nodeId, session } FolderPublic sid nodeId -> withSession sid $ \session -> forested $ corpusLayout { nodeId, session }
FolderShared sid nodeId -> withSession sid $ \session -> forested $ corpusLayout { nodeId, session } FolderShared sid nodeId -> withSession sid $ \session -> forested $ corpusLayout { nodeId, session }
Home -> forested $ homeLayout { backend, lang:LL_EN, publicBackend, sessions, visible: showLogin } Home -> forested $ homeLayout { backend, lang:LL_EN, publicBackend, sessions, visible: showLogin }
Lists sid nodeId -> withSession sid $ \session -> forested $ listsLayout { asyncTasks, nodeId, session, sessionUpdate } Lists sid nodeId -> withSession sid $ \session -> forested $ listsLayout {
asyncTasks: snd asyncTasks
, nodeId
, session
, sessionUpdate
}
Login -> login { backend, backends, sessions, visible: showLogin } Login -> login { backend, backends, sessions, visible: showLogin }
PGraphExplorer sid graphId -> PGraphExplorer sid graphId ->
withSession sid $ withSession sid $
...@@ -126,7 +136,12 @@ appCpt = R.hooksComponentWithModule thisModule "app" cpt where ...@@ -126,7 +136,12 @@ appCpt = R.hooksComponentWithModule thisModule "app" cpt where
RouteFrameWrite sid nodeId -> withSession sid $ \session -> forested $ frameLayout { nodeId, session, nodeType: GT.NodeFrameWrite} RouteFrameWrite sid nodeId -> withSession sid $ \session -> forested $ frameLayout { nodeId, session, nodeType: GT.NodeFrameWrite}
Team sid nodeId -> withSession sid $ \session -> forested $ corpusLayout { nodeId, session } Team sid nodeId -> withSession sid $ \session -> forested $ corpusLayout { nodeId, session }
Texts sid nodeId -> withSession sid $ \session -> forested $ textsLayout { frontends, nodeId, session, sessionUpdate } Texts sid nodeId -> withSession sid $ \session -> forested $ textsLayout { frontends, nodeId, session, sessionUpdate }
UserPage sid nodeId -> withSession sid $ \session -> forested $ userLayout { asyncTasks, frontends, nodeId, session } UserPage sid nodeId -> withSession sid $ \session -> forested $ userLayout {
asyncTasks: snd asyncTasks
, frontends
, nodeId
, session
}
type ForestLayoutProps = type ForestLayoutProps =
( asyncTasks :: GAT.Reductor ( asyncTasks :: GAT.Reductor
......
...@@ -280,7 +280,7 @@ tableContainerCpt { dispatch ...@@ -280,7 +280,7 @@ tableContainerCpt { dispatch
-- NEXT -- NEXT
type Props = ( type Props = (
afterSync :: Unit -> Aff Unit afterSync :: Unit -> Aff Unit
, asyncTasks :: GAT.Reductor , asyncTasks :: GAT.ReductorAction
, path :: R.State PageParams , path :: R.State PageParams
, state :: R.State State , state :: R.State State
, tabNgramType :: CTabNgramType , tabNgramType :: CTabNgramType
...@@ -341,7 +341,7 @@ loadedNgramsTableCpt = R.hooksComponentWithModule thisModule "loadedNgramsTable" ...@@ -341,7 +341,7 @@ loadedNgramsTableCpt = R.hooksComponentWithModule thisModule "loadedNgramsTable"
task <- postNgramsChartsAsync path' task <- postNgramsChartsAsync path'
liftEffect $ do liftEffect $ do
log2 "[performAction] Synchronize task" task log2 "[performAction] Synchronize task" task
snd asyncTasks $ GAT.Insert nodeId task asyncTasks $ GAT.Insert nodeId task
autoUpdate :: Array R.Element autoUpdate :: Array R.Element
autoUpdate = if withAutoUpdate then autoUpdate = if withAutoUpdate then
...@@ -495,7 +495,7 @@ selectNgramsOnFirstPage rows = Set.fromFoldable $ (view $ _NgramsElement <<< _ng ...@@ -495,7 +495,7 @@ selectNgramsOnFirstPage rows = Set.fromFoldable $ (view $ _NgramsElement <<< _ng
type MainNgramsTableProps = ( type MainNgramsTableProps = (
afterSync :: Unit -> Aff Unit afterSync :: Unit -> Aff Unit
, asyncTasks :: GAT.Reductor , asyncTasks :: GAT.ReductorAction
, cacheState :: R.State NT.CacheState , cacheState :: R.State NT.CacheState
, defaultListId :: Int , defaultListId :: Int
, nodeId :: Int , nodeId :: Int
...@@ -587,7 +587,7 @@ mainNgramsTableCpt = R.hooksComponentWithModule thisModule "mainNgramsTable" cpt ...@@ -587,7 +587,7 @@ mainNgramsTableCpt = R.hooksComponentWithModule thisModule "mainNgramsTable" cpt
type MainNgramsTablePaintProps = ( type MainNgramsTablePaintProps = (
afterSync :: Unit -> Aff Unit afterSync :: Unit -> Aff Unit
, asyncTasks :: GAT.Reductor , asyncTasks :: GAT.ReductorAction
, path :: PageParams , path :: PageParams
, tabNgramType :: CTabNgramType , tabNgramType :: CTabNgramType
, versioned :: VersionedNgramsTable , versioned :: VersionedNgramsTable
...@@ -614,33 +614,33 @@ mainNgramsTablePaintCpt = R.hooksComponentWithModule thisModule "mainNgramsTable ...@@ -614,33 +614,33 @@ mainNgramsTablePaintCpt = R.hooksComponentWithModule thisModule "mainNgramsTable
, withAutoUpdate , withAutoUpdate
} }
type MainNgramsTablePaintWithStateProps = ( -- type MainNgramsTablePaintWithStateProps = (
afterSync :: Unit -> Aff Unit -- afterSync :: Unit -> Aff Unit
, asyncTasks :: GAT.Reductor -- , asyncTasks :: GAT.Reductor
, path :: R.State PageParams -- , path :: R.State PageParams
, tabNgramType :: CTabNgramType -- , tabNgramType :: CTabNgramType
, versioned :: VersionedNgramsTable -- , versioned :: VersionedNgramsTable
, withAutoUpdate :: Boolean -- , withAutoUpdate :: Boolean
) -- )
mainNgramsTablePaintWithState :: Record MainNgramsTablePaintWithStateProps -> R.Element -- mainNgramsTablePaintWithState :: Record MainNgramsTablePaintWithStateProps -> R.Element
mainNgramsTablePaintWithState p = R.createElement mainNgramsTablePaintWithStateCpt p [] -- mainNgramsTablePaintWithState p = R.createElement mainNgramsTablePaintWithStateCpt p []
mainNgramsTablePaintWithStateCpt :: R.Component MainNgramsTablePaintWithStateProps -- mainNgramsTablePaintWithStateCpt :: R.Component MainNgramsTablePaintWithStateProps
mainNgramsTablePaintWithStateCpt = R.hooksComponentWithModule thisModule "mainNgramsTablePaintWithState" cpt -- mainNgramsTablePaintWithStateCpt = R.hooksComponentWithModule thisModule "mainNgramsTablePaintWithState" cpt
where -- where
cpt { afterSync, asyncTasks, path, tabNgramType, versioned, withAutoUpdate } _ = do -- cpt { afterSync, asyncTasks, path, tabNgramType, versioned, withAutoUpdate } _ = do
state <- R.useState' $ initialState versioned -- state <- R.useState' $ initialState versioned
pure $ loadedNgramsTable { -- pure $ loadedNgramsTable {
afterSync -- afterSync
, asyncTasks -- , asyncTasks
, path -- , path
, state -- , state
, tabNgramType -- , tabNgramType
, versioned -- , versioned
, withAutoUpdate -- , withAutoUpdate
} -- }
type NgramsOcc = { occurrences :: Additive Int, children :: Set NgramsTerm } type NgramsOcc = { occurrences :: Additive Int, children :: Set NgramsTerm }
......
...@@ -145,10 +145,10 @@ infoRender (Tuple title content) = ...@@ -145,10 +145,10 @@ infoRender (Tuple title content) =
, H.span {} [H.text content] ] , H.span {} [H.text content] ]
type LayoutProps = ( type LayoutProps = (
asyncTasks :: GAT.Reductor asyncTasks :: GAT.ReductorAction
, frontends :: Frontends , frontends :: Frontends
, nodeId :: Int , nodeId :: Int
, session :: Session , session :: Session
) )
type KeyLayoutProps = ( type KeyLayoutProps = (
......
...@@ -44,12 +44,12 @@ modeTabType' Books = CTabAuthors ...@@ -44,12 +44,12 @@ modeTabType' Books = CTabAuthors
modeTabType' Communication = CTabAuthors modeTabType' Communication = CTabAuthors
type TabsProps = ( type TabsProps = (
asyncTasks :: GAT.Reductor asyncTasks :: GAT.ReductorAction
, cacheState :: R.State NTypes.CacheState , cacheState :: R.State NTypes.CacheState
, contactData :: ContactData , contactData :: ContactData
, frontends :: Frontends , frontends :: Frontends
, nodeId :: Int , nodeId :: Int
, session :: Session , session :: Session
) )
tabs :: Record TabsProps -> R.Element tabs :: Record TabsProps -> R.Element
...@@ -91,12 +91,12 @@ tabsCpt = R.hooksComponentWithModule thisModule "tabs" cpt ...@@ -91,12 +91,12 @@ tabsCpt = R.hooksComponentWithModule thisModule "tabs" cpt
type NgramsViewTabsProps = ( type NgramsViewTabsProps = (
asyncTasks :: GAT.Reductor asyncTasks :: GAT.ReductorAction
, cacheState :: R.State NTypes.CacheState , cacheState :: R.State NTypes.CacheState
, defaultListId :: Int , defaultListId :: Int
, mode :: Mode , mode :: Mode
, nodeId :: Int , nodeId :: Int
, session :: Session , session :: Session
) )
ngramsView :: Record NgramsViewTabsProps -> R.Element ngramsView :: Record NgramsViewTabsProps -> R.Element
......
...@@ -30,6 +30,7 @@ import Gargantext.Types (NodeType(..), AffTableResult) ...@@ -30,6 +30,7 @@ import Gargantext.Types (NodeType(..), AffTableResult)
import Gargantext.Utils.Crypto as Crypto import Gargantext.Utils.Crypto as Crypto
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
thisModule :: String
thisModule = "Gargantext.Components.Nodes.Corpus" thisModule = "Gargantext.Components.Nodes.Corpus"
type Props = type Props =
......
...@@ -25,7 +25,7 @@ thisModule = "Gargantext.Components.Nodes.Lists" ...@@ -25,7 +25,7 @@ thisModule = "Gargantext.Components.Nodes.Lists"
------------------------------------------------------------------------ ------------------------------------------------------------------------
type Props = ( type Props = (
asyncTasks :: GAT.Reductor asyncTasks :: GAT.ReductorAction
, nodeId :: Int , nodeId :: Int
, session :: Session , session :: Session
, sessionUpdate :: Session -> Effect Unit , sessionUpdate :: Session -> Effect Unit
......
...@@ -26,7 +26,7 @@ thisModule :: String ...@@ -26,7 +26,7 @@ thisModule :: String
thisModule = "Gargantext.Components.Nodes.Lists.Tabs" thisModule = "Gargantext.Components.Nodes.Lists.Tabs"
type Props = ( type Props = (
asyncTasks :: GAT.Reductor asyncTasks :: GAT.ReductorAction
, cacheState :: R.State NTypes.CacheState , cacheState :: R.State NTypes.CacheState
, corpusData :: CorpusData , corpusData :: CorpusData
, corpusId :: Int , corpusId :: Int
......
...@@ -11,6 +11,7 @@ import Effect.Aff (launchAff_) ...@@ -11,6 +11,7 @@ import Effect.Aff (launchAff_)
import Reactix as R import Reactix as R
import Reactix.DOM.HTML as H import Reactix.DOM.HTML as H
-------------------------------------------------------- --------------------------------------------------------
import Gargantext.AsyncTasks as GAT
import Gargantext.Components.DocsTable as DT import Gargantext.Components.DocsTable as DT
import Gargantext.Components.Loader (loader) import Gargantext.Components.Loader (loader)
import Gargantext.Components.NgramsTable.Loader (clearCache) import Gargantext.Components.NgramsTable.Loader (clearCache)
...@@ -163,58 +164,68 @@ docViewCpt = R.hooksComponentWithModule thisModule "docView" cpt ...@@ -163,58 +164,68 @@ docViewCpt = R.hooksComponentWithModule thisModule "docView" cpt
-- docViewLayoutRec :: forall a. DocViewProps a -> Record DT.LayoutProps -- docViewLayoutRec :: forall a. DocViewProps a -> Record DT.LayoutProps
docViewLayoutRec { cacheState, corpusData: { defaultListId }, corpusId, frontends, session, tabType: TabDocs } = docViewLayoutRec { cacheState, corpusData: { defaultListId }, corpusId, frontends, session, tabType: TabDocs } =
{ nodeId: corpusId { cacheState
-- ^ TODO merge nodeId and corpusId in DT
, cacheState
, chart : H.div {} [] , chart : H.div {} []
, tabType: TabCorpus TabDocs
, totalRecords: 4737
, listId: defaultListId
, corpusId: Just corpusId , corpusId: Just corpusId
, frontends
, listId: defaultListId
, nodeId: corpusId
-- ^ TODO merge nodeId and corpusId in DT
, session
, showSearch: true , showSearch: true
, frontends, session } , tabType: TabCorpus TabDocs
, totalRecords: 4737
}
docViewLayoutRec { cacheState, corpusData: { defaultListId }, corpusId, frontends, session, tabType: TabMoreLikeFav } = docViewLayoutRec { cacheState, corpusData: { defaultListId }, corpusId, frontends, session, tabType: TabMoreLikeFav } =
{ nodeId: corpusId { cacheState
-- ^ TODO merge nodeId and corpusId in DT
, cacheState
, chart : H.div {} [] , chart : H.div {} []
, tabType: TabCorpus TabMoreLikeFav
, totalRecords: 4737
, listId: defaultListId
, corpusId: Just corpusId , corpusId: Just corpusId
, frontends
, listId: defaultListId
, nodeId: corpusId
-- ^ TODO merge nodeId and corpusId in DT
, session
, showSearch: false , showSearch: false
, frontends, session } , tabType: TabCorpus TabMoreLikeFav
, totalRecords: 4737
}
docViewLayoutRec { cacheState, corpusData: { defaultListId }, corpusId, frontends, session, tabType: TabMoreLikeTrash } = docViewLayoutRec { cacheState, corpusData: { defaultListId }, corpusId, frontends, session, tabType: TabMoreLikeTrash } =
{ nodeId: corpusId { cacheState
-- ^ TODO merge nodeId and corpusId in DT
, cacheState
, chart : H.div {} [] , chart : H.div {} []
, tabType: TabCorpus TabMoreLikeTrash
, totalRecords: 4737
, listId: defaultListId
, corpusId: Just corpusId , corpusId: Just corpusId
, frontends
, listId: defaultListId
, nodeId: corpusId
-- ^ TODO merge nodeId and corpusId in DT
, session
, showSearch: false , showSearch: false
, frontends, session } , tabType: TabCorpus TabMoreLikeTrash
, totalRecords: 4737
}
docViewLayoutRec { cacheState, corpusData: { defaultListId }, corpusId, frontends, session, tabType: TabTrash } = docViewLayoutRec { cacheState, corpusData: { defaultListId }, corpusId, frontends, session, tabType: TabTrash } =
{ nodeId: corpusId { cacheState
-- ^ TODO merge nodeId and corpusId in DT
, cacheState
, chart : H.div {} [] , chart : H.div {} []
, tabType: TabCorpus TabTrash
, totalRecords: 4737
, listId: defaultListId
, corpusId: Nothing , corpusId: Nothing
, frontends
, listId: defaultListId
, nodeId: corpusId
-- ^ TODO merge nodeId and corpusId in DT
, session
, showSearch: true , showSearch: true
, frontends, session } , tabType: TabCorpus TabTrash
, totalRecords: 4737
}
-- DUMMY -- DUMMY
docViewLayoutRec { cacheState, corpusData: { defaultListId }, corpusId, frontends, session, tabType } = docViewLayoutRec { cacheState, corpusData: { defaultListId }, corpusId, frontends, session, tabType } =
{ nodeId: corpusId { cacheState
-- ^ TODO merge nodeId and corpusId in DT
, cacheState
, chart : H.div {} [] , chart : H.div {} []
, tabType: TabCorpus TabTrash
, totalRecords: 4737
, listId: defaultListId
, corpusId: Nothing , corpusId: Nothing
, frontends
, listId: defaultListId
, nodeId: corpusId
-- ^ TODO merge nodeId and corpusId in DT
, session
, showSearch: true , showSearch: true
, frontends, session } , tabType: TabCorpus TabTrash
, totalRecords: 4737
}
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