Commit 68949ae9 authored by Alexandre Delanoë's avatar Alexandre Delanoë

[Merge] local cache

parent cd8f3ba2
...@@ -49,31 +49,37 @@ removeTaskFromList ts (GT.AsyncTaskWithType { task: GT.AsyncTask { id: id' } }) ...@@ -49,31 +49,37 @@ removeTaskFromList ts (GT.AsyncTaskWithType { task: GT.AsyncTask { id: id' } })
A.filter (\(GT.AsyncTaskWithType { task: GT.AsyncTask { id: id'' } }) -> id' /= id'') ts A.filter (\(GT.AsyncTaskWithType { task: GT.AsyncTask { id: id'' } }) -> id' /= id'') ts
type ReductorProps = ( type ReductorProps = (
reload :: R.State Int appReload :: R.State Int
, storage :: Storage , treeReload :: R.State Int
, storage :: Storage
) )
type Reductor = R2.Reductor (Record ReductorProps) Action type Reductor = R2.Reductor (Record ReductorProps) Action
type ReductorAction = Action -> Effect Unit
type OnFinish = Effect Unit
useTasks :: R.State Int -> R.Hooks Reductor useTasks :: R.State Int -> R.State Int -> R.Hooks Reductor
useTasks reload = R2.useReductor act initializer unit useTasks appReload treeReload = R2.useReductor act initializer unit
where where
act :: R2.Actor (Record ReductorProps) Action act :: R2.Actor (Record ReductorProps) Action
act a s = action s a act a s = action s a
initializer _ = do initializer _ = do
storage <- getAsyncTasks storage <- getAsyncTasks
pure { reload, storage } pure { appReload, treeReload, storage }
data Action = data Action =
Insert NodeId GT.AsyncTaskWithType Insert NodeId GT.AsyncTaskWithType
| Finish NodeId GT.AsyncTaskWithType
| Remove NodeId GT.AsyncTaskWithType | Remove NodeId GT.AsyncTaskWithType
action :: Record ReductorProps -> Action -> Effect (Record ReductorProps) action :: Record ReductorProps -> Action -> Effect (Record ReductorProps)
action { reload, storage } (Insert nodeId t) = do action p@{ treeReload, storage } (Insert nodeId t) = do
_ <- snd reload $ (_ + 1) _ <- snd treeReload $ (_ + 1)
let newStorage = Map.alter (maybe (Just [t]) (\ts -> Just $ A.cons t ts)) nodeId storage let newStorage = Map.alter (maybe (Just [t]) (\ts -> Just $ A.cons t ts)) nodeId storage
pure { reload, storage: newStorage } pure $ p { storage = newStorage }
action { reload, storage } (Remove nodeId t) = do action p (Finish nodeId t) = do
_ <- snd reload $ (_ + 1) action p (Remove nodeId t)
action p@{ appReload, storage } (Remove nodeId t) = do
_ <- snd appReload $ (_ + 1)
let newStorage = Map.alter (maybe Nothing $ (\ts -> Just $ removeTaskFromList ts t)) nodeId storage let newStorage = Map.alter (maybe Nothing $ (\ts -> Just $ removeTaskFromList ts t)) nodeId storage
pure { reload, storage: newStorage } pure $ p { storage = newStorage }
...@@ -52,12 +52,13 @@ appCpt = R.hooksComponentWithModule thisModule "app" cpt where ...@@ -52,12 +52,13 @@ appCpt = R.hooksComponentWithModule thisModule "app" cpt where
sessions <- useSessions sessions <- useSessions
route <- useHashRouter router Home route <- useHashRouter router Home
asyncTasksRef <- R.useRef Nothing
treeReloadRef <- R.useRef Nothing
showLogin <- R.useState' false showLogin <- R.useState' false
backend <- R.useState' Nothing backend <- R.useState' Nothing
treeReload <- R.useState' 0 reload <- R.useState' 0
asyncTasks <- GAT.useTasks treeReload
showCorpus <- R.useState' false showCorpus <- R.useState' false
...@@ -65,15 +66,16 @@ appCpt = R.hooksComponentWithModule thisModule "app" cpt where ...@@ -65,15 +66,16 @@ appCpt = R.hooksComponentWithModule thisModule "app" cpt where
let backends = fromFoldable defaultBackends let backends = fromFoldable defaultBackends
let ff f session = R.fragment [ f session, footer { session } ] let ff f session = R.fragment [ f session, footer { session } ]
let forested child = forestLayout { asyncTasks let forested child = forestLayout { appReload: reload
, asyncTasksRef
, backend
, child , child
, frontends , frontends
, handed , handed
, reload: treeReload
, route: fst route , route: fst route
, sessions: fst sessions , sessions: fst sessions
, showLogin: snd showLogin , showLogin: snd showLogin
, backend , treeReloadRef
} }
let defaultView _ = forested $ homeLayout { backend let defaultView _ = forested $ homeLayout { backend
, lang: LL_EN , lang: LL_EN
...@@ -91,9 +93,17 @@ appCpt = R.hooksComponentWithModule thisModule "app" cpt where ...@@ -91,9 +93,17 @@ 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
, appReload: reload
, asyncTasksRef
, frontends
, nodeId
, session
, treeReloadRef
}
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 { corpusId: Just corpusId, nodeId, listId, session }
Dashboard sid nodeId -> withSession sid $ \session -> forested $ dashboardLayout { nodeId, session } Dashboard sid nodeId -> withSession sid $ \session -> forested $ dashboardLayout { nodeId, session }
Document sid listId nodeId -> Document sid listId nodeId ->
withSession sid $ withSession sid $
...@@ -103,13 +113,20 @@ appCpt = R.hooksComponentWithModule thisModule "app" cpt where ...@@ -103,13 +113,20 @@ 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 {
appReload: reload
, asyncTasksRef
, nodeId
, session
, sessionUpdate
, treeReloadRef
}
Login -> login { backend, backends, sessions, visible: showLogin } Login -> login { backend, backends, sessions, visible: showLogin }
PGraphExplorer sid graphId -> PGraphExplorer sid graphId ->
withSession sid $ withSession sid $
\session -> \session ->
simpleLayout handed $ simpleLayout handed $
explorerLayout { asyncTasks explorerLayout { asyncTasksRef
, backend , backend
, frontends , frontends
, graphId , graphId
...@@ -118,7 +135,6 @@ appCpt = R.hooksComponentWithModule thisModule "app" cpt where ...@@ -118,7 +135,6 @@ appCpt = R.hooksComponentWithModule thisModule "app" cpt where
, session , session
, sessions: (fst sessions) , sessions: (fst sessions)
, showLogin , showLogin
--, treeReload
} }
RouteFile sid nodeId -> withSession sid $ \session -> forested $ fileLayout { nodeId, session } RouteFile sid nodeId -> withSession sid $ \session -> forested $ fileLayout { nodeId, session }
RouteFrameCalc sid nodeId -> withSession sid $ \session -> forested $ frameLayout { nodeId, session, nodeType: GT.NodeFrameCalc } RouteFrameCalc sid nodeId -> withSession sid $ \session -> forested $ frameLayout { nodeId, session, nodeType: GT.NodeFrameCalc }
...@@ -126,18 +142,26 @@ appCpt = R.hooksComponentWithModule thisModule "app" cpt where ...@@ -126,18 +142,26 @@ appCpt = R.hooksComponentWithModule thisModule "app" cpt where
RouteFrameCode sid nodeId -> withSession sid $ \session -> forested $ frameLayout { nodeId, session, nodeType: GT.NodeFrameNotebook } RouteFrameCode sid nodeId -> withSession sid $ \session -> forested $ frameLayout { nodeId, session, nodeType: GT.NodeFrameNotebook }
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 {
appReload: reload
type ForestLayoutProps = , asyncTasksRef
( asyncTasks :: GAT.Reductor , frontends
, backend :: R.State (Maybe Backend) , nodeId
, child :: R.Element , session
, frontends :: Frontends , treeReloadRef
, handed :: R.State GT.Handed }
, reload :: R.State Int
, route :: AppRoute type ForestLayoutProps = (
, sessions :: Sessions appReload :: R.State Int
, showLogin :: R.Setter Boolean , asyncTasksRef :: R.Ref (Maybe GAT.Reductor)
, backend :: R.State (Maybe Backend)
, child :: R.Element
, frontends :: Frontends
, handed :: R.State GT.Handed
, route :: AppRoute
, sessions :: Sessions
, showLogin :: R.Setter Boolean
, treeReloadRef :: R.Ref (Maybe (R.State Int))
) )
forestLayout :: Record ForestLayoutProps -> R.Element forestLayout :: Record ForestLayoutProps -> R.Element
...@@ -155,7 +179,16 @@ forestLayoutMain props = R.createElement forestLayoutMainCpt props [] ...@@ -155,7 +179,16 @@ forestLayoutMain props = R.createElement forestLayoutMainCpt props []
forestLayoutMainCpt :: R.Component ForestLayoutProps forestLayoutMainCpt :: R.Component ForestLayoutProps
forestLayoutMainCpt = R.hooksComponentWithModule thisModule "forestLayoutMain" cpt forestLayoutMainCpt = R.hooksComponentWithModule thisModule "forestLayoutMain" cpt
where where
cpt { asyncTasks, child, frontends, handed, reload, route, sessions, showLogin, backend} _ = do cpt { appReload
, asyncTasksRef
, backend
, child
, frontends
, handed
, route
, sessions
, showLogin
, treeReloadRef } _ = do
let ordering = let ordering =
case fst handed of case fst handed of
GT.LeftHanded -> reverse GT.LeftHanded -> reverse
...@@ -163,7 +196,15 @@ forestLayoutMainCpt = R.hooksComponentWithModule thisModule "forestLayoutMain" c ...@@ -163,7 +196,15 @@ forestLayoutMainCpt = R.hooksComponentWithModule thisModule "forestLayoutMain" c
pure $ R2.row $ ordering [ pure $ R2.row $ ordering [
H.div { className: "col-md-2", style: { paddingTop: "60px" } } H.div { className: "col-md-2", style: { paddingTop: "60px" } }
[ forest { asyncTasks, backend, frontends, handed: fst handed, reload, route, sessions, showLogin } ] [ forest { appReload
, asyncTasksRef
, backend
, frontends
, handed: fst handed
, route
, sessions
, showLogin
, treeReloadRef } ]
, mainPage child , mainPage child
] ]
......
...@@ -21,15 +21,16 @@ import Gargantext.Utils.Reactix as R2 ...@@ -21,15 +21,16 @@ import Gargantext.Utils.Reactix as R2
thisModule :: String thisModule :: String
thisModule = "Gargantext.Components.Forest" thisModule = "Gargantext.Components.Forest"
type Props = type Props = (
( asyncTasks :: GAT.Reductor appReload :: R.State Int
, backend :: R.State (Maybe Backend) , asyncTasksRef :: R.Ref (Maybe GAT.Reductor)
, frontends :: Frontends , backend :: R.State (Maybe Backend)
, handed :: Handed , frontends :: Frontends
, reload :: R.State Int , handed :: Handed
, route :: AppRoute , route :: AppRoute
, sessions :: Sessions , sessions :: Sessions
, showLogin :: R.Setter Boolean , showLogin :: R.Setter Boolean
, treeReloadRef :: R.Ref (Maybe (R.State Int))
) )
forest :: Record Props -> R.Element forest :: Record Props -> R.Element
...@@ -37,16 +38,33 @@ forest props = R.createElement forestCpt props [] ...@@ -37,16 +38,33 @@ forest props = R.createElement forestCpt props []
forestCpt :: R.Component Props forestCpt :: R.Component Props
forestCpt = R.hooksComponentWithModule thisModule "forest" cpt where forestCpt = R.hooksComponentWithModule thisModule "forest" cpt where
cpt { asyncTasks, frontends, handed, reload: extReload, route, sessions, showLogin, backend} _ = do cpt { appReload
, asyncTasksRef
, backend
, frontends
, handed
, route
, sessions
, showLogin
, treeReloadRef } _ = do
-- NOTE: this is a hack to reload the tree view on demand -- NOTE: this is a hack to reload the tree view on demand
reload <- R.useState' (0 :: Reload) reload <- R.useState' (0 :: Reload)
asyncTasks <- GAT.useTasks appReload reload
openNodes <- R2.useLocalStorageState R2.openNodesKey (Set.empty :: OpenNodes) openNodes <- R2.useLocalStorageState R2.openNodesKey (Set.empty :: OpenNodes)
R2.useCache
( frontends -- TODO If `treeReloadRef` is set, `reload` state should be updated
R.useEffect' $ do
R.setRef asyncTasksRef $ Just asyncTasks
case R.readRef treeReloadRef of
Nothing -> R.setRef treeReloadRef $ Just reload
Just _ -> pure unit
R2.useCache (
frontends
/\ route /\ route
/\ sessions /\ sessions
/\ fst openNodes /\ fst openNodes
/\ fst extReload /\ fst appReload
/\ fst reload /\ fst reload
/\ (fst asyncTasks).storage /\ (fst asyncTasks).storage
/\ handed /\ handed
......
...@@ -167,67 +167,59 @@ toHtml :: Record ToHtmlProps -> R.Element ...@@ -167,67 +167,59 @@ toHtml :: Record ToHtmlProps -> R.Element
toHtml p = R.createElement toHtmlCpt p [] toHtml p = R.createElement toHtmlCpt p []
toHtmlCpt :: R.Component ToHtmlProps toHtmlCpt :: R.Component ToHtmlProps
toHtmlCpt = R.hooksComponentWithModule thisModule "toHtml" cpt toHtmlCpt = R.hooksComponentWithModule thisModule "nodeView" cpt
where where
cpt p@{ asyncTasks cpt p@{ asyncTasks
, frontends , frontends
, handed , handed
, mCurrentRoute , mCurrentRoute
, openNodes , openNodes
, reload: reload@(_ /\ setReload) , reload: reload@(_ /\ setReload)
, session , session
-- , tasks: tasks@{ onTaskAdd , tree: tree@(NTree (LNode { id
-- , onTaskFinish , name
-- , tasks: tasks' , nodeType
-- } }
, tree: tree@(NTree (LNode { id ) ary
, name )
, nodeType } _ = do
} let commonProps = RecordE.pick p :: Record CommonProps
) ary let pAction a = performAction a (RecordE.pick p :: Record PerformActionProps)
)
} _ = do let nodeId = mkNodeId session id
let commonProps = RecordE.pick p :: Record CommonProps let folderIsOpen = Set.member nodeId (fst openNodes)
let pAction a = performAction a (RecordE.pick p :: Record PerformActionProps) let setFn = if folderIsOpen then Set.delete else Set.insert
let toggleFolderIsOpen _ = (snd openNodes) (setFn nodeId)
let nodeId = mkNodeId session id let folderOpen = Tuple folderIsOpen toggleFolderIsOpen
let folderIsOpen = Set.member nodeId (fst openNodes)
let setFn = if folderIsOpen then Set.delete else Set.insert let withId (NTree (LNode {id: id'}) _) = id'
let toggleFolderIsOpen _ = (snd openNodes) (setFn nodeId)
let folderOpen = Tuple folderIsOpen toggleFolderIsOpen pure $ H.li { className: if A.null ary then "no-children" else "with-children" } $
[ nodeMainSpan { appReload: reload
let withId (NTree (LNode {id: id'}) _) = id' , asyncTasks
, dispatch: pAction
pure $ H.li { className: if A.null ary then "no-children" else "with-children" } $ , folderOpen
[ nodeMainSpan , frontends
{ asyncTasks , handed
, dispatch: pAction , id
, folderOpen , isLeaf: A.null ary
, frontends , mCurrentRoute
, handed , name
, id , nodeType
, isLeaf: A.null ary , session
, mCurrentRoute -- , tasks
, name } ]
, nodeType <> childNodes ( Record.merge commonProps
, session { asyncTasks
-- , tasks , children: if isPublic nodeType
} ] then map (\t -> map (\(LNode n@{ nodeType:nt } )
<> childNodes ( Record.merge commonProps -> (LNode (n { nodeType= publicize nt }))
{ asyncTasks ) t) ary
, children: if isPublic nodeType else ary
then map (\t -> map (\(LNode n@{ nodeType:nt } ) , folderOpen
-> (LNode (n { nodeType= publicize nt })) , handed
) t) ary }
else ary )
, folderOpen
, handed
}
)
where
commonProps = RecordE.pick p :: Record CommonProps
pAction a = performAction a (RecordE.pick p :: Record PerformActionProps)
type ChildNodesProps = type ChildNodesProps =
...@@ -293,7 +285,6 @@ performAction (DoSearch task) { asyncTasks: (_ /\ dispatch) ...@@ -293,7 +285,6 @@ performAction (DoSearch task) { asyncTasks: (_ /\ dispatch)
------- -------
performAction (UpdateNode params) { asyncTasks: (_ /\ dispatch) performAction (UpdateNode params) { asyncTasks: (_ /\ dispatch)
, session , session
-- , tasks: {onTaskAdd}
, tree: (NTree (LNode {id}) _) , tree: (NTree (LNode {id}) _)
} = } =
do do
......
...@@ -3,6 +3,7 @@ module Gargantext.Components.Forest.Tree.Node where ...@@ -3,6 +3,7 @@ module Gargantext.Components.Forest.Tree.Node where
import Data.Array (reverse) import Data.Array (reverse)
import Data.Maybe (Maybe(..)) import Data.Maybe (Maybe(..))
import Data.Nullable (null) import Data.Nullable (null)
import Data.Tuple (snd)
import Data.Tuple.Nested ((/\)) import Data.Tuple.Nested ((/\))
import Effect.Aff (Aff, launchAff) import Effect.Aff (Aff, launchAff)
import Effect.Class (liftEffect) import Effect.Class (liftEffect)
...@@ -40,8 +41,9 @@ thisModule = "Gargantext.Components.Forest.Tree.Node" ...@@ -40,8 +41,9 @@ thisModule = "Gargantext.Components.Forest.Tree.Node"
-- Main Node -- Main Node
type NodeMainSpanProps = type NodeMainSpanProps = (
( asyncTasks :: GAT.Reductor appReload :: R.State Int
, asyncTasks :: GAT.Reductor
, folderOpen :: R.State Boolean , folderOpen :: R.State Boolean
, frontends :: Frontends , frontends :: Frontends
, id :: ID , id :: ID
...@@ -61,7 +63,8 @@ nodeMainSpan p = R.createElement nodeMainSpanCpt p [] ...@@ -61,7 +63,8 @@ nodeMainSpan p = R.createElement nodeMainSpanCpt p []
nodeMainSpanCpt :: R.Component NodeMainSpanProps nodeMainSpanCpt :: R.Component NodeMainSpanProps
nodeMainSpanCpt = R.hooksComponentWithModule thisModule "nodeMainSpan" cpt nodeMainSpanCpt = R.hooksComponentWithModule thisModule "nodeMainSpan" cpt
where where
cpt props@{ asyncTasks: (asyncTasks /\ dispatchAsyncTasks) cpt props@{ appReload
, asyncTasks: (asyncTasks /\ dispatchAsyncTasks)
, dispatch , dispatch
, folderOpen , folderOpen
, frontends , frontends
...@@ -104,7 +107,7 @@ nodeMainSpanCpt = R.hooksComponentWithModule thisModule "nodeMainSpan" cpt ...@@ -104,7 +107,7 @@ nodeMainSpanCpt = R.hooksComponentWithModule thisModule "nodeMainSpan" cpt
, H.div {} (map (\t -> asyncProgressBar { asyncTask: t , H.div {} (map (\t -> asyncProgressBar { asyncTask: t
, barType: Pie , barType: Pie
, nodeId: id , nodeId: id
, onFinish: const $ dispatchAsyncTasks $ GAT.Remove id t , onFinish: onTaskFinish id t
, session , session
} }
) $ GAT.getTasks asyncTasks id ) $ GAT.getTasks asyncTasks id
...@@ -124,7 +127,6 @@ nodeMainSpanCpt = R.hooksComponentWithModule thisModule "nodeMainSpan" cpt ...@@ -124,7 +127,6 @@ nodeMainSpanCpt = R.hooksComponentWithModule thisModule "nodeMainSpan" cpt
] ]
else H.div {} [] else H.div {} []
, nodeActions { id , nodeActions { id
, nodeType , nodeType
, refreshTree: const $ dispatch RefreshTree , refreshTree: const $ dispatch RefreshTree
...@@ -134,6 +136,10 @@ nodeMainSpanCpt = R.hooksComponentWithModule thisModule "nodeMainSpan" cpt ...@@ -134,6 +136,10 @@ nodeMainSpanCpt = R.hooksComponentWithModule thisModule "nodeMainSpan" cpt
] ]
where where
onTaskFinish id t _ = do
dispatchAsyncTasks $ GAT.Finish id t
snd appReload $ (_ + 1)
SettingsBox {show: showBox} = settingsBox nodeType SettingsBox {show: showBox} = settingsBox nodeType
onPopoverClose popoverRef _ = Popover.setOpen popoverRef false onPopoverClose popoverRef _ = Popover.setOpen popoverRef false
......
...@@ -25,6 +25,7 @@ import Gargantext.Utils (toggleSet) ...@@ -25,6 +25,7 @@ import Gargantext.Utils (toggleSet)
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.ReactTooltip as ReactTooltip import Gargantext.Utils.ReactTooltip as ReactTooltip
thisModule :: String
thisModule = "Gargantext.Components.Forest.Tree.Node.Tools" thisModule = "Gargantext.Components.Forest.Tree.Node.Tools"
------------------------------------------------------------------------ ------------------------------------------------------------------------
...@@ -247,16 +248,18 @@ checkboxes :: forall a ...@@ -247,16 +248,18 @@ checkboxes :: forall a
-> R.State (Set a) -> R.State (Set a)
-> R.Element -> R.Element
checkboxes xs (val /\ set) = checkboxes xs (val /\ set) =
H.fieldset {} $ map (\a -> H.div {} [ H.input { type: "checkbox" H.fieldset {} $ map (
, checked: Set.member a val \a -> H.div {} [
, on: { click: \_ -> set H.input { type: "checkbox"
$ const , checked: Set.member a val
$ toggleSet a val , on: { click: \_ -> set
} $ const
} $ toggleSet a val
, H.div {} [H.text $ show a] }
] }
) xs , H.div {} [H.text $ show a]
]
) xs
prettyNodeType :: GT.NodeType -> String prettyNodeType :: GT.NodeType -> String
......
module Gargantext.Components.Forest.Tree.Node.Tools.Task
where
import Data.Array as A
import Data.Map as Map
import Data.Maybe (Maybe(..), maybe)
import Data.Tuple.Nested ((/\))
import Effect (Effect)
import Reactix as R
import Gargantext.AsyncTasks as GAT
import Gargantext.Prelude (Unit, discard, identity, ($), (+))
import Gargantext.Types (Reload)
import Gargantext.Types as GT
type Tasks =
( onTaskAdd :: GT.AsyncTaskWithType -> Effect Unit
, onTaskFinish :: GT.AsyncTaskWithType -> Effect Unit
, tasks :: Array GT.AsyncTaskWithType
)
tasksStruct :: Int
-> GAT.Reductor
-> R.State Reload
-> Record Tasks
tasksStruct id ({ storage } /\ dispatch) (_ /\ setReload) =
{ onTaskAdd, onTaskFinish, tasks }
where
tasks = maybe [] identity $ Map.lookup id storage
onTaskAdd t = dispatch $ GAT.Insert id t
onTaskFinish t = dispatch $ GAT.Remove id t
...@@ -42,7 +42,7 @@ thisModule :: String ...@@ -42,7 +42,7 @@ thisModule :: String
thisModule = "Gargantext.Components.GraphExplorer" thisModule = "Gargantext.Components.GraphExplorer"
type LayoutProps = ( type LayoutProps = (
asyncTasks :: GAT.Reductor asyncTasksRef :: R.Ref (Maybe GAT.Reductor)
, backend :: R.State (Maybe Backend) , backend :: R.State (Maybe Backend)
, frontends :: Frontends , frontends :: Frontends
, graphId :: GET.GraphId , graphId :: GET.GraphId
...@@ -92,7 +92,8 @@ explorer props = R.createElement explorerCpt props [] ...@@ -92,7 +92,8 @@ explorer props = R.createElement explorerCpt props []
explorerCpt :: R.Component Props explorerCpt :: R.Component Props
explorerCpt = R.hooksComponentWithModule thisModule "explorer" cpt explorerCpt = R.hooksComponentWithModule thisModule "explorer" cpt
where where
cpt props@{ asyncTasks cpt props@{ asyncTasksRef
, backend
, frontends , frontends
, graph , graph
, graphId , graphId
...@@ -104,7 +105,6 @@ explorerCpt = R.hooksComponentWithModule thisModule "explorer" cpt ...@@ -104,7 +105,6 @@ explorerCpt = R.hooksComponentWithModule thisModule "explorer" cpt
, session , session
, sessions , sessions
, showLogin , showLogin
, backend
} _ = do } _ = do
let startForceAtlas = maybe true (\(GET.MetaData { startForceAtlas }) -> startForceAtlas) mMetaData let startForceAtlas = maybe true (\(GET.MetaData { startForceAtlas }) -> startForceAtlas) mMetaData
...@@ -117,13 +117,14 @@ explorerCpt = R.hooksComponentWithModule thisModule "explorer" cpt ...@@ -117,13 +117,14 @@ explorerCpt = R.hooksComponentWithModule thisModule "explorer" cpt
graphRef <- R.useRef null graphRef <- R.useRef null
graphVersionRef <- R.useRef (fst graphVersion) graphVersionRef <- R.useRef (fst graphVersion)
treeReload <- R.useState' 0 treeReload <- R.useState' 0
treeReloadRef <- R.useRef $ Just treeReload
controls <- Controls.useGraphControls { forceAtlasS controls <- Controls.useGraphControls { forceAtlasS
, graph , graph
, graphId , graphId
, hyperdataGraph , hyperdataGraph
, session , session
, treeReload: \_ -> (snd treeReload) $ (+) 1 , treeReload: \_ -> (snd treeReload) $ (+) 1
} }
multiSelectEnabledRef <- R.useRef $ fst controls.multiSelectEnabled multiSelectEnabledRef <- R.useRef $ fst controls.multiSelectEnabled
R.useEffect' $ do R.useEffect' $ do
...@@ -157,7 +158,7 @@ explorerCpt = R.hooksComponentWithModule thisModule "explorer" cpt ...@@ -157,7 +158,7 @@ explorerCpt = R.hooksComponentWithModule thisModule "explorer" cpt
[ inner handed [ inner handed
[ rowControls [ Controls.controls controls ] [ rowControls [ Controls.controls controls ]
, R2.row $ mainLayout handed $ , R2.row $ mainLayout handed $
tree { asyncTasks tree { asyncTasksRef
, backend , backend
, frontends , frontends
, handed , handed
...@@ -165,7 +166,9 @@ explorerCpt = R.hooksComponentWithModule thisModule "explorer" cpt ...@@ -165,7 +166,9 @@ explorerCpt = R.hooksComponentWithModule thisModule "explorer" cpt
, reload: treeReload , reload: treeReload
, sessions , sessions
, show: fst controls.showTree , show: fst controls.showTree
, showLogin: snd showLogin } , showLogin: snd showLogin
, treeReloadRef
}
/\ /\
RH.div { ref: graphRef, id: "graph-view", className: "col-md-12" } [] RH.div { ref: graphRef, id: "graph-view", className: "col-md-12" } []
/\ /\
...@@ -212,9 +215,17 @@ explorerCpt = R.hooksComponentWithModule thisModule "explorer" cpt ...@@ -212,9 +215,17 @@ explorerCpt = R.hooksComponentWithModule thisModule "explorer" cpt
tree :: Record TreeProps -> R.Element tree :: Record TreeProps -> R.Element
tree { show: false } = RH.div { id: "tree" } [] tree { show: false } = RH.div { id: "tree" } []
tree { asyncTasks, backend, frontends, handed, mCurrentRoute: route, reload, sessions, showLogin } = tree { asyncTasksRef, backend, frontends, handed, mCurrentRoute: route, reload, sessions, showLogin, treeReloadRef } =
RH.div {className: "col-md-2 graph-tree"} [ RH.div {className: "col-md-2 graph-tree"} [
forest { asyncTasks, backend, frontends, handed, reload, route, sessions, showLogin } forest { appReload: reload
, asyncTasksRef
, backend
, frontends
, handed
, route
, sessions
, showLogin
, treeReloadRef }
] ]
mSidebar :: Maybe GET.MetaData mSidebar :: Maybe GET.MetaData
...@@ -226,7 +237,7 @@ explorerCpt = R.hooksComponentWithModule thisModule "explorer" cpt ...@@ -226,7 +237,7 @@ explorerCpt = R.hooksComponentWithModule thisModule "explorer" cpt
type TreeProps = type TreeProps =
( (
asyncTasks :: GAT.Reductor asyncTasksRef :: R.Ref (Maybe GAT.Reductor)
, backend :: R.State (Maybe Backend) , backend :: R.State (Maybe Backend)
, frontends :: Frontends , frontends :: Frontends
, handed :: Types.Handed , handed :: Types.Handed
...@@ -235,6 +246,7 @@ type TreeProps = ...@@ -235,6 +246,7 @@ type TreeProps =
, sessions :: Sessions , sessions :: Sessions
, show :: Boolean , show :: Boolean
, showLogin :: R.Setter Boolean , showLogin :: R.Setter Boolean
, treeReloadRef :: R.Ref (Maybe (R.State Int))
) )
type MSidebarProps = type MSidebarProps =
......
...@@ -10,6 +10,7 @@ import Reactix as R ...@@ -10,6 +10,7 @@ import Reactix as R
import Gargantext.Components.LoadingSpinner (loadingSpinner) import Gargantext.Components.LoadingSpinner (loadingSpinner)
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
thisModule :: String
thisModule = "Gargantext.Components.Loader" thisModule = "Gargantext.Components.Loader"
type Props path loaded = type Props path loaded =
......
...@@ -22,7 +22,7 @@ import Data.Set as Set ...@@ -22,7 +22,7 @@ import Data.Set as Set
import Data.Symbol (SProxy(..)) import Data.Symbol (SProxy(..))
import Data.Tuple (Tuple(..), fst, snd) import Data.Tuple (Tuple(..), fst, snd)
import Data.Tuple.Nested ((/\)) import Data.Tuple.Nested ((/\))
import DOM.Simple.Console (log2) import DOM.Simple.Console (log, log2)
import Effect (Effect) import Effect (Effect)
import Effect.Aff (Aff, launchAff_) import Effect.Aff (Aff, launchAff_)
import Effect.Class (liftEffect) import Effect.Class (liftEffect)
...@@ -31,6 +31,8 @@ import Reactix.DOM.HTML as H ...@@ -31,6 +31,8 @@ import Reactix.DOM.HTML as H
import Record as Record import Record as Record
import Unsafe.Coerce (unsafeCoerce) import Unsafe.Coerce (unsafeCoerce)
import Gargantext.Prelude
import Gargantext.AsyncTasks as GAT import Gargantext.AsyncTasks as GAT
import Gargantext.Components.AutoUpdate (autoUpdateElt) import Gargantext.Components.AutoUpdate (autoUpdateElt)
import Gargantext.Hooks.Loader (useLoader) import Gargantext.Hooks.Loader (useLoader)
...@@ -39,7 +41,6 @@ import Gargantext.Components.NgramsTable.Core ...@@ -39,7 +41,6 @@ import Gargantext.Components.NgramsTable.Core
import Gargantext.Components.NgramsTable.Loader (useLoaderWithCacheAPI) import Gargantext.Components.NgramsTable.Loader (useLoaderWithCacheAPI)
import Gargantext.Components.Nodes.Lists.Types as NT import Gargantext.Components.Nodes.Lists.Types as NT
import Gargantext.Components.Table as T import Gargantext.Components.Table as T
import Gargantext.Prelude (class Show, Unit, bind, const, discard, identity, map, mempty, not, pure, show, unit, (#), ($), (&&), (/=), (<$>), (<<<), (<>), (=<<), (==), (||), read, otherwise)
import Gargantext.Routes (SessionRoute(..)) as R import Gargantext.Routes (SessionRoute(..)) as R
import Gargantext.Sessions (Session, get) import Gargantext.Sessions (Session, get)
import Gargantext.Types (CTabNgramType, OrderBy(..), SearchQuery, TabType, TermList(..), TermSize, termLists, termSizes) import Gargantext.Types (CTabNgramType, OrderBy(..), SearchQuery, TabType, TermList(..), TermSize, termLists, termSizes)
...@@ -279,11 +280,13 @@ tableContainerCpt { dispatch ...@@ -279,11 +280,13 @@ tableContainerCpt { dispatch
-- NEXT -- NEXT
type Props = ( type Props = (
afterSync :: Unit -> Aff Unit appReload :: R.State Int
, asyncTasks :: GAT.Reductor , afterSync :: Unit -> Aff Unit
, asyncTasksRef :: R.Ref (Maybe GAT.Reductor)
, path :: R.State PageParams , path :: R.State PageParams
, state :: R.State State , state :: R.State State
, tabNgramType :: CTabNgramType , tabNgramType :: CTabNgramType
, treeReloadRef :: R.Ref (Maybe (R.State Int))
, versioned :: VersionedNgramsTable , versioned :: VersionedNgramsTable
, withAutoUpdate :: Boolean , withAutoUpdate :: Boolean
) )
...@@ -295,7 +298,8 @@ loadedNgramsTableCpt :: R.Component Props ...@@ -295,7 +298,8 @@ loadedNgramsTableCpt :: R.Component Props
loadedNgramsTableCpt = R.hooksComponentWithModule thisModule "loadedNgramsTable" cpt loadedNgramsTableCpt = R.hooksComponentWithModule thisModule "loadedNgramsTable" cpt
where where
cpt { afterSync cpt { afterSync
, asyncTasks , appReload
, asyncTasksRef
, path: path@(path'@{ listIds, nodeId, params, searchQuery, scoreType, termListFilter, termSizeFilter } /\ setPath) , path: path@(path'@{ listIds, nodeId, params, searchQuery, scoreType, termListFilter, termSizeFilter } /\ setPath)
, state: (state@{ ngramsChildren , state: (state@{ ngramsChildren
, ngramsLocalPatch , ngramsLocalPatch
...@@ -303,13 +307,16 @@ loadedNgramsTableCpt = R.hooksComponentWithModule thisModule "loadedNgramsTable" ...@@ -303,13 +307,16 @@ loadedNgramsTableCpt = R.hooksComponentWithModule thisModule "loadedNgramsTable"
, ngramsSelection , ngramsSelection
, ngramsVersion } /\ setState) , ngramsVersion } /\ setState)
, tabNgramType , tabNgramType
, treeReloadRef
, versioned: Versioned { data: initTable } , versioned: Versioned { data: initTable }
, withAutoUpdate } _ = do , withAutoUpdate } _ = do
let syncResetBtns = [syncResetButtons { afterSync: chartsAfterSync let syncResetBtns = [
, ngramsLocalPatch syncResetButtons { afterSync: chartsAfterSync
, performAction: performAction <<< CoreAction , ngramsLocalPatch
}] , performAction: performAction <<< CoreAction
}
]
pure $ R.fragment $ pure $ R.fragment $
autoUpdate <> syncResetBtns <> [ autoUpdate <> syncResetBtns <> [
...@@ -340,8 +347,16 @@ loadedNgramsTableCpt = R.hooksComponentWithModule thisModule "loadedNgramsTable" ...@@ -340,8 +347,16 @@ loadedNgramsTableCpt = R.hooksComponentWithModule thisModule "loadedNgramsTable"
chartsAfterSync _ = do chartsAfterSync _ = do
task <- postNgramsChartsAsync path' task <- postNgramsChartsAsync path'
liftEffect $ do liftEffect $ do
log2 "[performAction] Synchronize task" task log2 "[chartsAfterSync] Synchronize task" task
snd asyncTasks $ GAT.Insert nodeId task case R.readRef asyncTasksRef of
Nothing -> log "[chartsAfterSync] asyncTasksRef is Nothing"
Just asyncTasks -> do
snd asyncTasks $ GAT.Insert nodeId task
case R.readRef treeReloadRef of
Nothing -> log "[chartsAfterSync] can't reload tree: ref empty"
Just treeReload -> do
snd treeReload $ (_ + 1)
-- snd appReload $ (_ + 1)
autoUpdate :: Array R.Element autoUpdate :: Array R.Element
autoUpdate = if withAutoUpdate then autoUpdate = if withAutoUpdate then
...@@ -494,15 +509,18 @@ selectNgramsOnFirstPage rows = Set.fromFoldable $ (view $ _NgramsElement <<< _ng ...@@ -494,15 +509,18 @@ selectNgramsOnFirstPage rows = Set.fromFoldable $ (view $ _NgramsElement <<< _ng
type MainNgramsTableProps = ( type MainNgramsTableProps = (
afterSync :: Unit -> Aff Unit afterSync :: Unit -> Aff Unit
, asyncTasks :: GAT.Reductor , appReload :: R.State Int
, cacheState :: R.State NT.CacheState , asyncTasksRef :: R.Ref (Maybe GAT.Reductor)
, defaultListId :: Int , cacheState :: R.State NT.CacheState
, nodeId :: Int , defaultListId :: Int
, nodeId :: Int
-- ^ This node can be a corpus or contact. -- ^ This node can be a corpus or contact.
, session :: Session , pathS :: R.State PageParams
, tabNgramType :: CTabNgramType , session :: Session
, tabType :: TabType , tabNgramType :: CTabNgramType
, tabType :: TabType
, treeReloadRef :: R.Ref (Maybe (R.State Int))
, withAutoUpdate :: Boolean , withAutoUpdate :: Boolean
) )
...@@ -513,33 +531,48 @@ mainNgramsTableCpt :: R.Component MainNgramsTableProps ...@@ -513,33 +531,48 @@ mainNgramsTableCpt :: R.Component MainNgramsTableProps
mainNgramsTableCpt = R.hooksComponentWithModule thisModule "mainNgramsTable" cpt mainNgramsTableCpt = R.hooksComponentWithModule thisModule "mainNgramsTable" cpt
where where
cpt props@{ afterSync cpt props@{ afterSync
, asyncTasks , appReload
, asyncTasksRef
, cacheState , cacheState
, defaultListId , defaultListId
, nodeId , nodeId
, pathS
, session , session
, tabNgramType , tabNgramType
, tabType , tabType
, treeReloadRef
, withAutoUpdate } _ = do , withAutoUpdate } _ = do
let path = initialPageParams session nodeId [defaultListId] tabType
let render versioned = mainNgramsTablePaint { afterSync -- let path = initialPageParams session nodeId [defaultListId] tabType
, asyncTasks
, path
, tabNgramType
, versioned
, withAutoUpdate }
case cacheState of case cacheState of
(NT.CacheOn /\ _) -> do (NT.CacheOn /\ _) -> do
let render versioned = mainNgramsTablePaint { afterSync
, appReload
, asyncTasksRef
, path: fst pathS
, tabNgramType
, treeReloadRef
, versioned
, withAutoUpdate }
useLoaderWithCacheAPI { useLoaderWithCacheAPI {
cacheEndpoint: versionEndpoint props cacheEndpoint: versionEndpoint props
, handleResponse , handleResponse
, mkRequest , mkRequest
, path , path: fst pathS
, renderer: render , renderer: render
} }
(NT.CacheOff /\ _) -> do (NT.CacheOff /\ _) -> do
useLoader path loader render -- pathS <- R.useState' path
let render versioned = mainNgramsTablePaintNoCache { afterSync
, appReload
, asyncTasksRef
, pathS
, tabNgramType
, treeReloadRef
, versioned
, withAutoUpdate }
useLoader (fst pathS) loader render
versionEndpoint :: Record MainNgramsTableProps -> PageParams -> Aff Version versionEndpoint :: Record MainNgramsTableProps -> PageParams -> Aff Version
versionEndpoint { defaultListId, nodeId, session, tabType } _ = get session $ R.GetNgramsTableVersion { listId: defaultListId, tabType } (Just nodeId) versionEndpoint { defaultListId, nodeId, session, tabType } _ = get session $ R.GetNgramsTableVersion { listId: defaultListId, tabType } (Just nodeId)
...@@ -587,9 +620,11 @@ mainNgramsTableCpt = R.hooksComponentWithModule thisModule "mainNgramsTable" cpt ...@@ -587,9 +620,11 @@ mainNgramsTableCpt = R.hooksComponentWithModule thisModule "mainNgramsTable" cpt
type MainNgramsTablePaintProps = ( type MainNgramsTablePaintProps = (
afterSync :: Unit -> Aff Unit afterSync :: Unit -> Aff Unit
, asyncTasks :: GAT.Reductor , appReload :: R.State Int
, asyncTasksRef :: R.Ref (Maybe GAT.Reductor)
, path :: PageParams , path :: PageParams
, tabNgramType :: CTabNgramType , tabNgramType :: CTabNgramType
, treeReloadRef :: R.Ref (Maybe (R.State Int))
, versioned :: VersionedNgramsTable , versioned :: VersionedNgramsTable
, withAutoUpdate :: Boolean , withAutoUpdate :: Boolean
) )
...@@ -600,48 +635,82 @@ mainNgramsTablePaint p = R.createElement mainNgramsTablePaintCpt p [] ...@@ -600,48 +635,82 @@ mainNgramsTablePaint p = R.createElement mainNgramsTablePaintCpt p []
mainNgramsTablePaintCpt :: R.Component MainNgramsTablePaintProps mainNgramsTablePaintCpt :: R.Component MainNgramsTablePaintProps
mainNgramsTablePaintCpt = R.hooksComponentWithModule thisModule "mainNgramsTablePaint" cpt mainNgramsTablePaintCpt = R.hooksComponentWithModule thisModule "mainNgramsTablePaint" cpt
where where
cpt props@{ afterSync, asyncTasks, path, tabNgramType, versioned, withAutoUpdate } _ = do cpt props@{ afterSync, appReload, asyncTasksRef, path, tabNgramType, treeReloadRef, versioned, withAutoUpdate } _ = do
pathS <- R.useState' path pathS <- R.useState' path
state <- R.useState' $ initialState versioned state <- R.useState' $ initialState versioned
pure $ loadedNgramsTable { pure $ loadedNgramsTable {
afterSync afterSync
, asyncTasks , appReload
, asyncTasksRef
, path: pathS , path: pathS
, state , state
, tabNgramType , tabNgramType
, treeReloadRef
, versioned , versioned
, withAutoUpdate , withAutoUpdate
} }
type MainNgramsTablePaintWithStateProps = ( type MainNgramsTablePaintNoCacheProps = (
afterSync :: Unit -> Aff Unit afterSync :: Unit -> Aff Unit
, asyncTasks :: GAT.Reductor , appReload :: R.State Int
, path :: R.State PageParams , asyncTasksRef :: R.Ref (Maybe GAT.Reductor)
, pathS :: R.State PageParams
, tabNgramType :: CTabNgramType , tabNgramType :: CTabNgramType
, treeReloadRef :: R.Ref (Maybe (R.State Int))
, versioned :: VersionedNgramsTable , versioned :: VersionedNgramsTable
, withAutoUpdate :: Boolean , withAutoUpdate :: Boolean
) )
mainNgramsTablePaintWithState :: Record MainNgramsTablePaintWithStateProps -> R.Element mainNgramsTablePaintNoCache :: Record MainNgramsTablePaintNoCacheProps -> R.Element
mainNgramsTablePaintWithState p = R.createElement mainNgramsTablePaintWithStateCpt p [] mainNgramsTablePaintNoCache p = R.createElement mainNgramsTablePaintNoCacheCpt p []
mainNgramsTablePaintWithStateCpt :: R.Component MainNgramsTablePaintWithStateProps mainNgramsTablePaintNoCacheCpt :: R.Component MainNgramsTablePaintNoCacheProps
mainNgramsTablePaintWithStateCpt = R.hooksComponentWithModule thisModule "mainNgramsTablePaintWithState" cpt mainNgramsTablePaintNoCacheCpt = R.hooksComponentWithModule thisModule "mainNgramsTablePaintNoCache" cpt
where where
cpt { afterSync, asyncTasks, path, tabNgramType, versioned, withAutoUpdate } _ = do cpt props@{ afterSync, appReload, asyncTasksRef, pathS, tabNgramType, treeReloadRef, versioned, withAutoUpdate } _ = do
state <- R.useState' $ initialState versioned state <- R.useState' $ initialState versioned
pure $ loadedNgramsTable { pure $ loadedNgramsTable {
afterSync afterSync
, asyncTasks , appReload
, path , asyncTasksRef
, path: pathS
, state , state
, tabNgramType , tabNgramType
, treeReloadRef
, versioned , versioned
, withAutoUpdate , withAutoUpdate
} }
-- type MainNgramsTablePaintWithStateProps = (
-- afterSync :: Unit -> Aff Unit
-- , asyncTasksRef :: R.Ref (Maybe GAT.Reductor)
-- , path :: R.State PageParams
-- , tabNgramType :: CTabNgramType
-- , versioned :: VersionedNgramsTable
-- , withAutoUpdate :: Boolean
-- )
-- mainNgramsTablePaintWithState :: Record MainNgramsTablePaintWithStateProps -> R.Element
-- mainNgramsTablePaintWithState p = R.createElement mainNgramsTablePaintWithStateCpt p []
-- mainNgramsTablePaintWithStateCpt :: R.Component MainNgramsTablePaintWithStateProps
-- mainNgramsTablePaintWithStateCpt = R.hooksComponentWithModule thisModule "mainNgramsTablePaintWithState" cpt
-- where
-- cpt { afterSync, asyncTasksRef, path, tabNgramType, versioned, withAutoUpdate } _ = do
-- state <- R.useState' $ initialState versioned
-- pure $ loadedNgramsTable {
-- afterSync
-- , asyncTasksRef
-- , path
-- , state
-- , tabNgramType
-- , versioned
-- , withAutoUpdate
-- }
type NgramsOcc = { occurrences :: Additive Int, children :: Set NgramsTerm } type NgramsOcc = { occurrences :: Additive Int, children :: Set NgramsTerm }
ngramsElementToNgramsOcc :: NgramsElement -> NgramsOcc ngramsElementToNgramsOcc :: NgramsElement -> NgramsOcc
......
...@@ -158,8 +158,8 @@ type PageParams = ...@@ -158,8 +158,8 @@ type PageParams =
initialPageParams :: Session -> Int -> Array Int -> TabType -> PageParams initialPageParams :: Session -> Int -> Array Int -> TabType -> PageParams
initialPageParams session nodeId listIds tabType = initialPageParams session nodeId listIds tabType =
{ nodeId { listIds
, listIds , nodeId
, params , params
, tabType , tabType
, termSizeFilter: Nothing , termSizeFilter: Nothing
...@@ -932,15 +932,10 @@ syncPatches props ({ ngramsLocalPatch: ngramsLocalPatch@{ ngramsPatches } ...@@ -932,15 +932,10 @@ syncPatches props ({ ngramsLocalPatch: ngramsLocalPatch@{ ngramsPatches }
, ngramsVersion , ngramsVersion
} /\ setState) callback = do } /\ setState) callback = do
when (isEmptyNgramsTablePatch ngramsStagePatch) $ do when (isEmptyNgramsTablePatch ngramsStagePatch) $ do
-- setState $ \s ->
-- s { ngramsLocalPatch = fromNgramsPatches mempty
-- , ngramsStagePatch = ngramsLocalPatch
-- }
let pt = Versioned { data: ngramsPatches, version: ngramsVersion } let pt = Versioned { data: ngramsPatches, version: ngramsVersion }
launchAff_ $ do launchAff_ $ do
Versioned { data: newPatch, version: newVersion } <- putNgramsPatches props pt Versioned { data: newPatch, version: newVersion } <- putNgramsPatches props pt
callback unit callback unit
-- task <- postNgramsChartsAsync props
liftEffect $ do liftEffect $ do
log2 "[syncPatches] setting state, newVersion" newVersion log2 "[syncPatches] setting state, newVersion" newVersion
setState $ \s -> setState $ \s ->
...@@ -1090,20 +1085,24 @@ syncResetButtonsCpt = R.hooksComponentWithModule thisModule "syncResetButtons" c ...@@ -1090,20 +1085,24 @@ syncResetButtonsCpt = R.hooksComponentWithModule thisModule "syncResetButtons" c
let let
hasChanges = ngramsLocalPatch /= mempty hasChanges = ngramsLocalPatch /= mempty
hasChangesClass = if hasChanges then "" else " disabled"
newAfterSync x = do resetClick _ = do
afterSync x performAction ResetPatches
liftEffect $ setSynchronizing $ const false
synchronizeClick _ = delay unit $ \_ -> do synchronizeClick _ = delay unit $ \_ -> do
setSynchronizing $ const true setSynchronizing $ const true
performAction $ Synchronize { afterSync: newAfterSync } performAction $ Synchronize { afterSync: newAfterSync }
newAfterSync x = do
afterSync x
liftEffect $ setSynchronizing $ const false
pure $ H.div {} [ pure $ H.div {} [
H.button { className: "btn btn-danger " <> if hasChanges then "" else " disabled" H.button { className: "btn btn-danger " <> hasChangesClass
, on: { click: \_ -> performAction ResetPatches } , on: { click: resetClick }
} [ H.text "Reset" ] } [ H.text "Reset" ]
, H.button { className: "btn btn-primary " <> (if s || (not hasChanges) then "disabled" else "") , H.button { className: "btn btn-primary " <> hasChangesClass
, on: { click: synchronizeClick } , on: { click: synchronizeClick }
} [ H.text "Sync" ] } [ H.text "Sync" ]
] ]
...@@ -145,10 +145,12 @@ infoRender (Tuple title content) = ...@@ -145,10 +145,12 @@ infoRender (Tuple title content) =
, H.span {} [H.text content] ] , H.span {} [H.text content] ]
type LayoutProps = ( type LayoutProps = (
asyncTasks :: GAT.Reductor appReload :: R.State Int
, frontends :: Frontends , asyncTasksRef :: R.Ref (Maybe GAT.Reductor)
, nodeId :: Int , frontends :: Frontends
, session :: Session , nodeId :: Int
, session :: Session
, treeReloadRef :: R.Ref (Maybe (R.State Int))
) )
type KeyLayoutProps = ( type KeyLayoutProps = (
...@@ -162,10 +164,18 @@ userLayout props = R.createElement userLayoutCpt props [] ...@@ -162,10 +164,18 @@ userLayout props = R.createElement userLayoutCpt props []
userLayoutCpt :: R.Component LayoutProps userLayoutCpt :: R.Component LayoutProps
userLayoutCpt = R.hooksComponentWithModule thisModule "userLayout" cpt userLayoutCpt = R.hooksComponentWithModule thisModule "userLayout" cpt
where where
cpt { asyncTasks, frontends, nodeId, session } _ = do cpt { appReload, asyncTasksRef, frontends, nodeId, session, treeReloadRef } _ = do
let sid = sessionId session let sid = sessionId session
pure $ userLayoutWithKey { asyncTasks, frontends, key: show sid <> "-" <> show nodeId, nodeId, session } pure $ userLayoutWithKey {
appReload
, asyncTasksRef
, frontends
, key: show sid <> "-" <> show nodeId
, nodeId
, session
, treeReloadRef
}
userLayoutWithKey :: Record KeyLayoutProps -> R.Element userLayoutWithKey :: Record KeyLayoutProps -> R.Element
userLayoutWithKey props = R.createElement userLayoutWithKeyCpt props [] userLayoutWithKey props = R.createElement userLayoutWithKeyCpt props []
...@@ -173,7 +183,7 @@ userLayoutWithKey props = R.createElement userLayoutWithKeyCpt props [] ...@@ -173,7 +183,7 @@ userLayoutWithKey props = R.createElement userLayoutWithKeyCpt props []
userLayoutWithKeyCpt :: R.Component KeyLayoutProps userLayoutWithKeyCpt :: R.Component KeyLayoutProps
userLayoutWithKeyCpt = R.hooksComponentWithModule thisModule "userLayoutWithKey" cpt userLayoutWithKeyCpt = R.hooksComponentWithModule thisModule "userLayoutWithKey" cpt
where where
cpt { asyncTasks, frontends, nodeId, session } _ = do cpt { appReload, asyncTasksRef, frontends, nodeId, session, treeReloadRef } _ = do
reload <- R.useState' 0 reload <- R.useState' 0
cacheState <- R.useState' NT.CacheOn cacheState <- R.useState' NT.CacheOn
...@@ -182,7 +192,16 @@ userLayoutWithKeyCpt = R.hooksComponentWithModule thisModule "userLayoutWithKey" ...@@ -182,7 +192,16 @@ userLayoutWithKeyCpt = R.hooksComponentWithModule thisModule "userLayoutWithKey"
\contactData@{contactNode: Contact {name, hyperdata}} -> \contactData@{contactNode: Contact {name, hyperdata}} ->
H.ul { className: "col-md-12 list-group" } [ H.ul { className: "col-md-12 list-group" } [
display (fromMaybe "no name" name) (contactInfos hyperdata (onUpdateHyperdata reload)) display (fromMaybe "no name" name) (contactInfos hyperdata (onUpdateHyperdata reload))
, Tabs.tabs { asyncTasks, cacheState, contactData, frontends, nodeId, session } , Tabs.tabs {
appReload
, asyncTasksRef
, cacheState
, contactData
, frontends
, nodeId
, session
, treeReloadRef
}
] ]
where where
onUpdateHyperdata :: R.State Int -> HyperdataUser -> Effect Unit onUpdateHyperdata :: R.State Int -> HyperdataUser -> Effect Unit
...@@ -224,14 +243,24 @@ annuaireUserLayout props = R.createElement annuaireUserLayoutCpt props [] ...@@ -224,14 +243,24 @@ annuaireUserLayout props = R.createElement annuaireUserLayoutCpt props []
annuaireUserLayoutCpt :: R.Component AnnuaireLayoutProps annuaireUserLayoutCpt :: R.Component AnnuaireLayoutProps
annuaireUserLayoutCpt = R.hooksComponentWithModule thisModule "annuaireUserLayout" cpt annuaireUserLayoutCpt = R.hooksComponentWithModule thisModule "annuaireUserLayout" cpt
where where
cpt { annuaireId, asyncTasks, frontends, nodeId, session } _ = do cpt { annuaireId, appReload, asyncTasksRef, frontends, nodeId, session, treeReloadRef } _ = do
cacheState <- R.useState' NT.CacheOn cacheState <- R.useState' NT.CacheOn
useLoader nodeId (getAnnuaireContact session annuaireId) $ useLoader nodeId (getAnnuaireContact session annuaireId) $
\contactData@{contactNode: Contact {name, hyperdata}} -> \contactData@{contactNode: Contact {name, hyperdata}} ->
H.ul { className: "col-md-12 list-group" } H.ul { className: "col-md-12 list-group" } [
[ display (fromMaybe "no name" name) (contactInfos hyperdata onUpdateHyperdata) display (fromMaybe "no name" name) (contactInfos hyperdata onUpdateHyperdata)
, Tabs.tabs { asyncTasks, cacheState, contactData, frontends, nodeId, session } ] , Tabs.tabs {
appReload
, asyncTasksRef
, cacheState
, contactData
, frontends
, nodeId
, session
, treeReloadRef
}
]
where where
onUpdateHyperdata :: HyperdataUser -> Effect Unit onUpdateHyperdata :: HyperdataUser -> Effect Unit
......
...@@ -12,6 +12,7 @@ import Reactix as R ...@@ -12,6 +12,7 @@ import Reactix as R
import Gargantext.AsyncTasks as GAT import Gargantext.AsyncTasks as GAT
import Gargantext.Components.DocsTable as DT import Gargantext.Components.DocsTable as DT
import Gargantext.Components.NgramsTable as NT import Gargantext.Components.NgramsTable as NT
import Gargantext.Components.NgramsTable.Core as NTC
import Gargantext.Components.Tab as Tab import Gargantext.Components.Tab as Tab
import Gargantext.Components.Nodes.Annuaire.User.Contacts.Types (ContactData) import Gargantext.Components.Nodes.Annuaire.User.Contacts.Types (ContactData)
import Gargantext.Components.Nodes.Lists.Types as NTypes import Gargantext.Components.Nodes.Lists.Types as NTypes
...@@ -44,12 +45,14 @@ modeTabType' Books = CTabAuthors ...@@ -44,12 +45,14 @@ modeTabType' Books = CTabAuthors
modeTabType' Communication = CTabAuthors modeTabType' Communication = CTabAuthors
type TabsProps = ( type TabsProps = (
asyncTasks :: GAT.Reductor appReload :: R.State Int
, cacheState :: R.State NTypes.CacheState , asyncTasksRef :: R.Ref (Maybe GAT.Reductor)
, contactData :: ContactData , cacheState :: R.State NTypes.CacheState
, frontends :: Frontends , contactData :: ContactData
, nodeId :: Int , frontends :: Frontends
, session :: Session , nodeId :: Int
, session :: Session
, treeReloadRef :: R.Ref (Maybe (R.State Int))
) )
tabs :: Record TabsProps -> R.Element tabs :: Record TabsProps -> R.Element
...@@ -58,7 +61,7 @@ tabs props = R.createElement tabsCpt props [] ...@@ -58,7 +61,7 @@ tabs props = R.createElement tabsCpt props []
tabsCpt :: R.Component TabsProps tabsCpt :: R.Component TabsProps
tabsCpt = R.hooksComponentWithModule thisModule "tabs" cpt tabsCpt = R.hooksComponentWithModule thisModule "tabs" cpt
where where
cpt { asyncTasks, cacheState, contactData: {defaultListId}, frontends, nodeId, session} _ = do cpt { appReload, asyncTasksRef, cacheState, contactData: {defaultListId}, frontends, nodeId, session, treeReloadRef } _ = do
active <- R.useState' 0 active <- R.useState' 0
pure $ pure $
Tab.tabs { selected: fst active, tabs: tabs' } Tab.tabs { selected: fst active, tabs: tabs' }
...@@ -71,9 +74,9 @@ tabsCpt = R.hooksComponentWithModule thisModule "tabs" cpt ...@@ -71,9 +74,9 @@ tabsCpt = R.hooksComponentWithModule thisModule "tabs" cpt
, "Trash" /\ docs -- TODO pass-in trash mode , "Trash" /\ docs -- TODO pass-in trash mode
] ]
where where
patentsView = { asyncTasks, cacheState, defaultListId, mode: Patents, nodeId, session } patentsView = { appReload, asyncTasksRef, cacheState, defaultListId, mode: Patents, nodeId, session, treeReloadRef }
booksView = { asyncTasks, cacheState, defaultListId, mode: Books, nodeId, session } booksView = { appReload, asyncTasksRef, cacheState, defaultListId, mode: Books, nodeId, session, treeReloadRef }
commView = { asyncTasks, cacheState, defaultListId, mode: Communication, nodeId, session } commView = { appReload, asyncTasksRef, cacheState, defaultListId, mode: Communication, nodeId, session, treeReloadRef }
chart = mempty chart = mempty
totalRecords = 4736 -- TODO totalRecords = 4736 -- TODO
docs = DT.docViewLayout docs = DT.docViewLayout
...@@ -91,27 +94,39 @@ tabsCpt = R.hooksComponentWithModule thisModule "tabs" cpt ...@@ -91,27 +94,39 @@ tabsCpt = R.hooksComponentWithModule thisModule "tabs" cpt
type NgramsViewTabsProps = ( type NgramsViewTabsProps = (
asyncTasks :: GAT.Reductor appReload :: R.State Int
, cacheState :: R.State NTypes.CacheState , asyncTasksRef :: R.Ref (Maybe GAT.Reductor)
, cacheState :: R.State NTypes.CacheState
, defaultListId :: Int , defaultListId :: Int
, mode :: Mode , mode :: Mode
, nodeId :: Int , nodeId :: Int
, session :: Session , session :: Session
, treeReloadRef :: R.Ref (Maybe (R.State Int))
) )
ngramsView :: Record NgramsViewTabsProps -> R.Element ngramsView :: Record NgramsViewTabsProps -> R.Element
ngramsView { asyncTasks, cacheState, defaultListId, mode, nodeId, session } = ngramsView props = R.createElement ngramsViewCpt props []
NT.mainNgramsTable {
afterSync: \_ -> pure unit ngramsViewCpt :: R.Component NgramsViewTabsProps
, asyncTasks ngramsViewCpt = R.hooksComponentWithModule thisModule "ngramsView" cpt
, cacheState
, defaultListId
, nodeId
, tabType
, session
, tabNgramType
, withAutoUpdate: false
}
where where
tabNgramType = modeTabType' mode cpt { appReload, asyncTasksRef, cacheState, defaultListId, mode, nodeId, session, treeReloadRef } _ = do
tabType = TabPairing $ TabNgramType $ modeTabType mode pathS <- R.useState' $ NTC.initialPageParams session nodeId [defaultListId] (TabDocument TabDocs)
pure $ NT.mainNgramsTable {
appReload
, afterSync: \_ -> pure unit
, asyncTasksRef
, cacheState
, defaultListId
, nodeId
, pathS
, tabType
, session
, tabNgramType
, treeReloadRef
, withAutoUpdate: false
}
where
tabNgramType = modeTabType' mode
tabType = TabPairing $ TabNgramType $ modeTabType mode
...@@ -28,6 +28,7 @@ import Gargantext.Types (ChartType(..), TabType) ...@@ -28,6 +28,7 @@ import Gargantext.Types (ChartType(..), TabType)
import Gargantext.Utils.CacheAPI as GUC import Gargantext.Utils.CacheAPI as GUC
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
thisModule :: String
thisModule = "Gargantext.Components.Nodes.Corpus.Chart.Pie" thisModule = "Gargantext.Components.Nodes.Corpus.Chart.Pie"
newtype ChartMetrics = ChartMetrics { newtype ChartMetrics = ChartMetrics {
......
module Gargantext.Components.Nodes.Lists where module Gargantext.Components.Nodes.Lists where
import Data.Maybe (Maybe(..))
import Data.Tuple (fst) import Data.Tuple (fst)
import Effect (Effect) import Effect (Effect)
import Effect.Aff (launchAff_) import Effect.Aff (launchAff_)
...@@ -25,10 +26,12 @@ thisModule = "Gargantext.Components.Nodes.Lists" ...@@ -25,10 +26,12 @@ thisModule = "Gargantext.Components.Nodes.Lists"
------------------------------------------------------------------------ ------------------------------------------------------------------------
type Props = ( type Props = (
asyncTasks :: GAT.Reductor appReload :: R.State Int
, asyncTasksRef :: R.Ref (Maybe GAT.Reductor)
, nodeId :: Int , nodeId :: Int
, session :: Session , session :: Session
, sessionUpdate :: Session -> Effect Unit , sessionUpdate :: Session -> Effect Unit
, treeReloadRef :: R.Ref (Maybe (R.State Int))
) )
listsLayout :: Record Props -> R.Element listsLayout :: Record Props -> R.Element
...@@ -53,7 +56,7 @@ listsLayoutWithKey props = R.createElement listsLayoutWithKeyCpt props [] ...@@ -53,7 +56,7 @@ listsLayoutWithKey props = R.createElement listsLayoutWithKeyCpt props []
listsLayoutWithKeyCpt :: R.Component KeyProps listsLayoutWithKeyCpt :: R.Component KeyProps
listsLayoutWithKeyCpt = R.hooksComponentWithModule thisModule "listsLayoutWithKey" cpt listsLayoutWithKeyCpt = R.hooksComponentWithModule thisModule "listsLayoutWithKey" cpt
where where
cpt { asyncTasks, nodeId, session, sessionUpdate } _ = do cpt { appReload, asyncTasksRef, nodeId, session, sessionUpdate, treeReloadRef } _ = do
let path = { nodeId, session } let path = { nodeId, session }
cacheState <- R.useState' $ getCacheState NT.CacheOn session nodeId cacheState <- R.useState' $ getCacheState NT.CacheOn session nodeId
...@@ -74,12 +77,15 @@ listsLayoutWithKeyCpt = R.hooksComponentWithModule thisModule "listsLayoutWithKe ...@@ -74,12 +77,15 @@ listsLayoutWithKeyCpt = R.hooksComponentWithModule thisModule "listsLayoutWithKe
, title: "Corpus " <> name , title: "Corpus " <> name
, user: authors } , user: authors }
, Tabs.tabs { , Tabs.tabs {
asyncTasks appReload
, asyncTasksRef
, cacheState , cacheState
, corpusData , corpusData
, corpusId , corpusId
, key: "listsLayoutWithKey-tabs-" <> (show $ fst cacheState) , key: "listsLayoutWithKey-tabs-" <> (show $ fst cacheState)
, session } , session
, treeReloadRef
}
] ]
where where
afterCacheStateChange cacheState = do afterCacheStateChange cacheState = do
......
module Gargantext.Components.Nodes.Lists.Tabs where module Gargantext.Components.Nodes.Lists.Tabs where
import Data.Array as A
import Data.Maybe (Maybe(..), fromMaybe) import Data.Maybe (Maybe(..), fromMaybe)
import Data.Tuple (fst)
import Data.Tuple.Nested ((/\)) import Data.Tuple.Nested ((/\))
import Effect.Class (liftEffect) import Effect.Class (liftEffect)
import Reactix as R import Reactix as R
import Reactix.DOM.HTML as H import Reactix.DOM.HTML as H
import Record as Record
import Gargantext.Prelude import Gargantext.Prelude
import Gargantext.AsyncTasks as GAT import Gargantext.AsyncTasks as GAT
import Gargantext.Components.NgramsTable as NT import Gargantext.Components.NgramsTable as NT
import Gargantext.Components.NgramsTable.Core as NTC
import Gargantext.Components.Nodes.Corpus.Types (CorpusData) import Gargantext.Components.Nodes.Corpus.Types (CorpusData)
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)
...@@ -26,11 +30,13 @@ thisModule :: String ...@@ -26,11 +30,13 @@ thisModule :: String
thisModule = "Gargantext.Components.Nodes.Lists.Tabs" thisModule = "Gargantext.Components.Nodes.Lists.Tabs"
type Props = ( type Props = (
asyncTasks :: GAT.Reductor appReload :: R.State Int
, cacheState :: R.State NTypes.CacheState , asyncTasksRef :: R.Ref (Maybe GAT.Reductor)
, corpusData :: CorpusData , cacheState :: R.State NTypes.CacheState
, corpusId :: Int , corpusData :: CorpusData
, session :: Session , corpusId :: Int
, session :: Session
, treeReloadRef :: R.Ref (Maybe (R.State Int))
) )
type PropsWithKey = ( type PropsWithKey = (
...@@ -44,7 +50,7 @@ tabs props = R.createElement tabsCpt props [] ...@@ -44,7 +50,7 @@ tabs props = R.createElement tabsCpt props []
tabsCpt :: R.Component PropsWithKey tabsCpt :: R.Component PropsWithKey
tabsCpt = R.hooksComponentWithModule thisModule "tabs" cpt tabsCpt = R.hooksComponentWithModule thisModule "tabs" cpt
where where
cpt { asyncTasks, cacheState, corpusData: corpusData@{ defaultListId }, corpusId, session } _ = do cpt { appReload, asyncTasksRef, cacheState, corpusData, corpusId, session, treeReloadRef } _ = do
(selected /\ setSelected) <- R.useState' 0 (selected /\ setSelected) <- R.useState' 0
pure $ Tab.tabs { selected, tabs: tabs' } pure $ Tab.tabs { selected, tabs: tabs' }
...@@ -53,7 +59,7 @@ tabsCpt = R.hooksComponentWithModule thisModule "tabs" cpt ...@@ -53,7 +59,7 @@ tabsCpt = R.hooksComponentWithModule thisModule "tabs" cpt
, "Institutes" /\ view Institutes , "Institutes" /\ view Institutes
, "Sources" /\ view Sources , "Sources" /\ view Sources
, "Terms" /\ view Terms ] , "Terms" /\ view Terms ]
view mode = ngramsView { asyncTasks, cacheState, corpusData, corpusId, mode, session } view mode = ngramsView { appReload, asyncTasksRef, cacheState, corpusData, corpusId, mode, session, treeReloadRef }
type NgramsViewProps = ( mode :: Mode | Props ) type NgramsViewProps = ( mode :: Mode | Props )
...@@ -63,26 +69,46 @@ ngramsView props = R.createElement ngramsViewCpt props [] ...@@ -63,26 +69,46 @@ ngramsView props = R.createElement ngramsViewCpt props []
ngramsViewCpt :: R.Component NgramsViewProps ngramsViewCpt :: R.Component NgramsViewProps
ngramsViewCpt = R.hooksComponentWithModule thisModule "ngramsView" cpt ngramsViewCpt = R.hooksComponentWithModule thisModule "ngramsView" cpt
where where
cpt { asyncTasks cpt { appReload
, asyncTasksRef
, cacheState , cacheState
, corpusData: { defaultListId } , corpusData: { defaultListId }
, corpusId , corpusId
, mode , mode
, session } _ = do , session
, treeReloadRef
} _ = do
chartType <- R.useState' Histo chartType <- R.useState' Histo
chartsReload <- R.useState' 0 chartsReload <- R.useState' 0
pathS <- R.useState' $ NTC.initialPageParams session initialPath.corpusId [initialPath.listId] initialPath.tabType
let listId' = fromMaybe defaultListId $ A.head (fst pathS).listIds
let path = {
corpusId: (fst pathS).nodeId
, limit: (fst pathS).params.limit
, listId: listId'
, tabType: (fst pathS).tabType
}
let chartParams = {
corpusId: path.corpusId
, limit: Just path.limit
, listId: path.listId
, tabType: path.tabType
}
pure $ R.fragment pure $ R.fragment
( charts tabNgramType chartType chartsReload ( charts chartParams tabNgramType chartType chartsReload
<> [ NT.mainNgramsTable { afterSync: afterSync chartsReload <> [ NT.mainNgramsTable { afterSync: afterSync chartsReload
, asyncTasks , appReload
, asyncTasksRef
, cacheState , cacheState
, defaultListId , defaultListId
, nodeId: corpusId , nodeId: corpusId
, pathS
, session , session
, tabNgramType , tabNgramType
, tabType , tabType
, treeReloadRef
, withAutoUpdate: false , withAutoUpdate: false
} }
] ]
...@@ -100,25 +126,26 @@ ngramsViewCpt = R.hooksComponentWithModule thisModule "ngramsView" cpt ...@@ -100,25 +126,26 @@ ngramsViewCpt = R.hooksComponentWithModule thisModule "ngramsView" cpt
tabNgramType = modeTabType mode tabNgramType = modeTabType mode
tabType = TabCorpus (TabNgramType tabNgramType) tabType = TabCorpus (TabNgramType tabNgramType)
mNgramsType = mNgramsTypeFromTabType tabType mNgramsType = mNgramsTypeFromTabType tabType
listId = defaultListId listId = defaultListId
path = { corpusId initialPath = { corpusId
, limit: Just 1000 -- , limit: Just 1000
, listId , listId
, tabType , tabType
} }
charts CTabTerms (chartType /\ setChartType) _ = [ charts params CTabTerms (chartType /\ setChartType) _ = [
H.div { className: "row chart-type-selector" } [ H.div { className: "row chart-type-selector" } [
H.div { className: "col-md-3" } [ H.div { className: "col-md-3" } [
R2.select { className: "form-control" R2.select { className: "form-control"
, on: { change: \e -> setChartType , defaultValue: show chartType
, on: { change: \e -> setChartType
$ const $ const
$ fromMaybe Histo $ fromMaybe Histo
$ chartTypeFromString $ chartTypeFromString
$ R.unsafeEventValue e $ R.unsafeEventValue e
} }
, defaultValue: show chartType } [ } [
H.option { value: show Histo } [ H.text $ show Histo ] H.option { value: show Histo } [ H.text $ show Histo ]
, H.option { value: show Scatter } [ H.text $ show Scatter ] , H.option { value: show Scatter } [ H.text $ show Scatter ]
, H.option { value: show ChartBar } [ H.text $ show ChartBar ] , H.option { value: show ChartBar } [ H.text $ show ChartBar ]
...@@ -127,11 +154,11 @@ ngramsViewCpt = R.hooksComponentWithModule thisModule "ngramsView" cpt ...@@ -127,11 +154,11 @@ ngramsViewCpt = R.hooksComponentWithModule thisModule "ngramsView" cpt
] ]
] ]
] ]
, getChartFunction chartType $ { session, path } , getChartFunction chartType $ { path: params, session }
] ]
charts _ _ _ = [ chart mode ] charts params _ _ _ = [ chart params mode ]
chart Authors = pie { path, session } chart path Authors = pie { path, session }
chart Institutes = tree { path, session } chart path Institutes = tree { path, session }
chart Sources = bar { path, session } chart path Sources = bar { path, session }
chart Terms = metrics { path, session } chart path Terms = metrics { path, session }
...@@ -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