Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
purescript-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Grégoire Locqueville
purescript-gargantext
Commits
68949ae9
Commit
68949ae9
authored
Nov 17, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Merge] local cache
parent
cd8f3ba2
Changes
17
Show whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
534 additions
and
333 deletions
+534
-333
AsyncTasks.purs
src/Gargantext/AsyncTasks.purs
+17
-11
App.purs
src/Gargantext/Components/App.purs
+66
-25
Forest.purs
src/Gargantext/Components/Forest.purs
+31
-13
Tree.purs
src/Gargantext/Components/Forest/Tree.purs
+53
-62
Node.purs
src/Gargantext/Components/Forest/Tree/Node.purs
+11
-5
Tools.purs
src/Gargantext/Components/Forest/Tree/Node/Tools.purs
+13
-10
Task.purs
src/Gargantext/Components/Forest/Tree/Node/Tools/Task.purs
+0
-34
GraphExplorer.purs
src/Gargantext/Components/GraphExplorer.purs
+26
-14
Loader.purs
src/Gargantext/Components/Loader.purs
+1
-0
NgramsTable.purs
src/Gargantext/Components/NgramsTable.purs
+111
-42
Core.purs
src/Gargantext/Components/NgramsTable/Core.purs
+12
-13
Contacts.purs
src/Gargantext/Components/Nodes/Annuaire/User/Contacts.purs
+41
-12
Tabs.purs
...gantext/Components/Nodes/Annuaire/User/Contacts/Tabs.purs
+44
-29
Pie.purs
src/Gargantext/Components/Nodes/Corpus/Chart/Pie.purs
+1
-0
Lists.purs
src/Gargantext/Components/Nodes/Lists.purs
+10
-4
Tabs.purs
src/Gargantext/Components/Nodes/Lists/Tabs.purs
+51
-24
Texts.purs
src/Gargantext/Components/Nodes/Texts.purs
+46
-35
No files found.
src/Gargantext/AsyncTasks.purs
View file @
68949ae9
...
...
@@ -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
type ReductorProps = (
reload :: R.State Int
appReload :: R.State Int
, treeReload :: R.State Int
, storage :: Storage
)
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
eload = R2.useReductor act initializer unit
useTasks :: R.State Int -> R.
State Int -> R.
Hooks Reductor
useTasks
appReload treeR
eload = R2.useReductor act initializer unit
where
act :: R2.Actor (Record ReductorProps) Action
act a s = action s a
initializer _ = do
storage <- getAsyncTasks
pure {
r
eload, storage }
pure {
appReload, treeR
eload, storage }
data Action =
Insert NodeId GT.AsyncTaskWithType
| Finish NodeId GT.AsyncTaskWithType
| Remove NodeId GT.AsyncTaskWithType
action :: Record ReductorProps -> Action -> Effect (Record ReductorProps)
action
{ r
eload, storage } (Insert nodeId t) = do
_ <- snd
r
eload $ (_ + 1)
action
p@{ treeR
eload, storage } (Insert nodeId t) = do
_ <- snd
treeR
eload $ (_ + 1)
let newStorage = Map.alter (maybe (Just [t]) (\ts -> Just $ A.cons t ts)) nodeId storage
pure { reload, storage: newStorage }
action { reload, storage } (Remove nodeId t) = do
_ <- snd reload $ (_ + 1)
pure $ p { storage = newStorage }
action p (Finish nodeId t) = do
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
pure
{ reload, storage:
newStorage }
pure
$ p { storage =
newStorage }
src/Gargantext/Components/App.purs
View file @
68949ae9
...
...
@@ -52,12 +52,13 @@ appCpt = R.hooksComponentWithModule thisModule "app" cpt where
sessions <- useSessions
route <- useHashRouter router Home
asyncTasksRef <- R.useRef Nothing
treeReloadRef <- R.useRef Nothing
showLogin <- R.useState' false
backend <- R.useState' Nothing
treeReload <- R.useState' 0
asyncTasks <- GAT.useTasks treeReload
reload <- R.useState' 0
showCorpus <- R.useState' false
...
...
@@ -65,15 +66,16 @@ appCpt = R.hooksComponentWithModule thisModule "app" cpt where
let backends = fromFoldable defaultBackends
let ff f session = R.fragment [ f session, footer { session } ]
let forested child = forestLayout { asyncTasks
let forested child = forestLayout { appReload: reload
, asyncTasksRef
, backend
, child
, frontends
, handed
, reload: treeReload
, route: fst route
, sessions: fst sessions
, showLogin: snd showLogin
,
backend
,
treeReloadRef
}
let defaultView _ = forested $ homeLayout { backend
, lang: LL_EN
...
...
@@ -91,9 +93,17 @@ appCpt = R.hooksComponentWithModule thisModule "app" cpt where
false ->
case fst route of
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 }
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 }
Document sid listId nodeId ->
withSession sid $
...
...
@@ -103,13 +113,20 @@ appCpt = R.hooksComponentWithModule thisModule "app" cpt where
FolderPublic 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 }
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 }
PGraphExplorer sid graphId ->
withSession sid $
\session ->
simpleLayout handed $
explorerLayout { asyncTasks
explorerLayout { asyncTasks
Ref
, backend
, frontends
, graphId
...
...
@@ -118,7 +135,6 @@ appCpt = R.hooksComponentWithModule thisModule "app" cpt where
, session
, sessions: (fst sessions)
, showLogin
--, treeReload
}
RouteFile sid nodeId -> withSession sid $ \session -> forested $ fileLayout { nodeId, session }
RouteFrameCalc sid nodeId -> withSession sid $ \session -> forested $ frameLayout { nodeId, session, nodeType: GT.NodeFrameCalc }
...
...
@@ -126,18 +142,26 @@ appCpt = R.hooksComponentWithModule thisModule "app" cpt where
RouteFrameCode sid nodeId -> withSession sid $ \session -> forested $ frameLayout { nodeId, session, nodeType: GT.NodeFrameNotebook }
Team sid nodeId -> withSession sid $ \session -> forested $ corpusLayout { nodeId, session }
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
, asyncTasksRef
, frontends
, nodeId
, session
, treeReloadRef
}
type ForestLayoutProps =
( asyncTasks :: GAT.Reductor
type ForestLayoutProps = (
appReload :: R.State Int
, asyncTasksRef :: R.Ref (Maybe GAT.Reductor)
, backend :: R.State (Maybe Backend)
, child :: R.Element
, frontends :: Frontends
, handed :: R.State GT.Handed
, reload :: R.State Int
, route :: AppRoute
, sessions :: Sessions
, showLogin :: R.Setter Boolean
, treeReloadRef :: R.Ref (Maybe (R.State Int))
)
forestLayout :: Record ForestLayoutProps -> R.Element
...
...
@@ -155,7 +179,16 @@ forestLayoutMain props = R.createElement forestLayoutMainCpt props []
forestLayoutMainCpt :: R.Component ForestLayoutProps
forestLayoutMainCpt = R.hooksComponentWithModule thisModule "forestLayoutMain" cpt
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 =
case fst handed of
GT.LeftHanded -> reverse
...
...
@@ -163,7 +196,15 @@ forestLayoutMainCpt = R.hooksComponentWithModule thisModule "forestLayoutMain" c
pure $ R2.row $ ordering [
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
]
...
...
src/Gargantext/Components/Forest.purs
View file @
68949ae9
...
...
@@ -21,15 +21,16 @@ import Gargantext.Utils.Reactix as R2
thisModule :: String
thisModule = "Gargantext.Components.Forest"
type Props =
( asyncTasks :: GAT.Reductor
type Props = (
appReload :: R.State Int
, asyncTasksRef :: R.Ref (Maybe GAT.Reductor)
, backend :: R.State (Maybe Backend)
, frontends :: Frontends
, handed :: Handed
, reload :: R.State Int
, route :: AppRoute
, sessions :: Sessions
, showLogin :: R.Setter Boolean
, treeReloadRef :: R.Ref (Maybe (R.State Int))
)
forest :: Record Props -> R.Element
...
...
@@ -37,16 +38,33 @@ forest props = R.createElement forestCpt props []
forestCpt :: R.Component Props
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
reload <- R.useState' (0 :: Reload)
asyncTasks <- GAT.useTasks appReload reload
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
/\ sessions
/\ fst openNodes
/\ fst
ext
Reload
/\ fst
app
Reload
/\ fst reload
/\ (fst asyncTasks).storage
/\ handed
...
...
src/Gargantext/Components/Forest/Tree.purs
View file @
68949ae9
...
...
@@ -167,7 +167,7 @@ toHtml :: Record ToHtmlProps -> R.Element
toHtml p = R.createElement toHtmlCpt p []
toHtmlCpt :: R.Component ToHtmlProps
toHtmlCpt = R.hooksComponentWithModule thisModule "
toHtml
" cpt
toHtmlCpt = R.hooksComponentWithModule thisModule "
nodeView
" cpt
where
cpt p@{ asyncTasks
, frontends
...
...
@@ -176,10 +176,6 @@ toHtmlCpt = R.hooksComponentWithModule thisModule "toHtml" cpt
, openNodes
, reload: reload@(_ /\ setReload)
, session
-- , tasks: tasks@{ onTaskAdd
-- , onTaskFinish
-- , tasks: tasks'
-- }
, tree: tree@(NTree (LNode { id
, name
, nodeType
...
...
@@ -199,8 +195,8 @@ toHtmlCpt = R.hooksComponentWithModule thisModule "toHtml" cpt
let withId (NTree (LNode {id: id'}) _) = id'
pure $ H.li { className: if A.null ary then "no-children" else "with-children" } $
[ nodeMainSpan
{
asyncTasks
[ nodeMainSpan { appReload: reload
,
asyncTasks
, dispatch: pAction
, folderOpen
, frontends
...
...
@@ -224,10 +220,6 @@ toHtmlCpt = R.hooksComponentWithModule thisModule "toHtml" cpt
, handed
}
)
where
commonProps = RecordE.pick p :: Record CommonProps
pAction a = performAction a (RecordE.pick p :: Record PerformActionProps)
type ChildNodesProps =
...
...
@@ -293,7 +285,6 @@ performAction (DoSearch task) { asyncTasks: (_ /\ dispatch)
-------
performAction (UpdateNode params) { asyncTasks: (_ /\ dispatch)
, session
-- , tasks: {onTaskAdd}
, tree: (NTree (LNode {id}) _)
} =
do
...
...
src/Gargantext/Components/Forest/Tree/Node.purs
View file @
68949ae9
...
...
@@ -3,6 +3,7 @@ module Gargantext.Components.Forest.Tree.Node where
import Data.Array (reverse)
import Data.Maybe (Maybe(..))
import Data.Nullable (null)
import Data.Tuple (snd)
import Data.Tuple.Nested ((/\))
import Effect.Aff (Aff, launchAff)
import Effect.Class (liftEffect)
...
...
@@ -40,8 +41,9 @@ thisModule = "Gargantext.Components.Forest.Tree.Node"
-- Main Node
type NodeMainSpanProps =
( asyncTasks :: GAT.Reductor
type NodeMainSpanProps = (
appReload :: R.State Int
, asyncTasks :: GAT.Reductor
, folderOpen :: R.State Boolean
, frontends :: Frontends
, id :: ID
...
...
@@ -61,7 +63,8 @@ nodeMainSpan p = R.createElement nodeMainSpanCpt p []
nodeMainSpanCpt :: R.Component NodeMainSpanProps
nodeMainSpanCpt = R.hooksComponentWithModule thisModule "nodeMainSpan" cpt
where
cpt props@{ asyncTasks: (asyncTasks /\ dispatchAsyncTasks)
cpt props@{ appReload
, asyncTasks: (asyncTasks /\ dispatchAsyncTasks)
, dispatch
, folderOpen
, frontends
...
...
@@ -104,7 +107,7 @@ nodeMainSpanCpt = R.hooksComponentWithModule thisModule "nodeMainSpan" cpt
, H.div {} (map (\t -> asyncProgressBar { asyncTask: t
, barType: Pie
, nodeId: id
, onFinish:
const $ dispatchAsyncTasks $ GAT.Remove
id t
, onFinish:
onTaskFinish
id t
, session
}
) $ GAT.getTasks asyncTasks id
...
...
@@ -124,7 +127,6 @@ nodeMainSpanCpt = R.hooksComponentWithModule thisModule "nodeMainSpan" cpt
]
else H.div {} []
, nodeActions { id
, nodeType
, refreshTree: const $ dispatch RefreshTree
...
...
@@ -134,6 +136,10 @@ nodeMainSpanCpt = R.hooksComponentWithModule thisModule "nodeMainSpan" cpt
]
where
onTaskFinish id t _ = do
dispatchAsyncTasks $ GAT.Finish id t
snd appReload $ (_ + 1)
SettingsBox {show: showBox} = settingsBox nodeType
onPopoverClose popoverRef _ = Popover.setOpen popoverRef false
...
...
src/Gargantext/Components/Forest/Tree/Node/Tools.purs
View file @
68949ae9
...
...
@@ -25,6 +25,7 @@ import Gargantext.Utils (toggleSet)
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.ReactTooltip as ReactTooltip
thisModule :: String
thisModule = "Gargantext.Components.Forest.Tree.Node.Tools"
------------------------------------------------------------------------
...
...
@@ -247,7 +248,9 @@ checkboxes :: forall a
-> R.State (Set a)
-> R.Element
checkboxes xs (val /\ set) =
H.fieldset {} $ map (\a -> H.div {} [ H.input { type: "checkbox"
H.fieldset {} $ map (
\a -> H.div {} [
H.input { type: "checkbox"
, checked: Set.member a val
, on: { click: \_ -> set
$ const
...
...
src/Gargantext/Components/Forest/Tree/Node/Tools/Task.purs
deleted
100644 → 0
View file @
cd8f3ba2
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
src/Gargantext/Components/GraphExplorer.purs
View file @
68949ae9
...
...
@@ -42,7 +42,7 @@ thisModule :: String
thisModule = "Gargantext.Components.GraphExplorer"
type LayoutProps = (
asyncTasks
:: GAT.Reductor
asyncTasks
Ref :: R.Ref (Maybe GAT.Reductor)
, backend :: R.State (Maybe Backend)
, frontends :: Frontends
, graphId :: GET.GraphId
...
...
@@ -92,7 +92,8 @@ explorer props = R.createElement explorerCpt props []
explorerCpt :: R.Component Props
explorerCpt = R.hooksComponentWithModule thisModule "explorer" cpt
where
cpt props@{ asyncTasks
cpt props@{ asyncTasksRef
, backend
, frontends
, graph
, graphId
...
...
@@ -104,7 +105,6 @@ explorerCpt = R.hooksComponentWithModule thisModule "explorer" cpt
, session
, sessions
, showLogin
, backend
} _ = do
let startForceAtlas = maybe true (\(GET.MetaData { startForceAtlas }) -> startForceAtlas) mMetaData
...
...
@@ -117,6 +117,7 @@ explorerCpt = R.hooksComponentWithModule thisModule "explorer" cpt
graphRef <- R.useRef null
graphVersionRef <- R.useRef (fst graphVersion)
treeReload <- R.useState' 0
treeReloadRef <- R.useRef $ Just treeReload
controls <- Controls.useGraphControls { forceAtlasS
, graph
, graphId
...
...
@@ -157,7 +158,7 @@ explorerCpt = R.hooksComponentWithModule thisModule "explorer" cpt
[ inner handed
[ rowControls [ Controls.controls controls ]
, R2.row $ mainLayout handed $
tree { asyncTasks
tree { asyncTasks
Ref
, backend
, frontends
, handed
...
...
@@ -165,7 +166,9 @@ explorerCpt = R.hooksComponentWithModule thisModule "explorer" cpt
, reload: treeReload
, sessions
, show: fst controls.showTree
, showLogin: snd showLogin }
, showLogin: snd showLogin
, treeReloadRef
}
/\
RH.div { ref: graphRef, id: "graph-view", className: "col-md-12" } []
/\
...
...
@@ -212,9 +215,17 @@ explorerCpt = R.hooksComponentWithModule thisModule "explorer" cpt
tree :: Record TreeProps -> R.Element
tree { show: false } = RH.div { id: "tree" } []
tree { asyncTasks
, backend, frontends, handed, mCurrentRoute: route, reload, sessions, showLogin
} =
tree { asyncTasks
Ref, backend, frontends, handed, mCurrentRoute: route, reload, sessions, showLogin, treeReloadRef
} =
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
...
...
@@ -226,7 +237,7 @@ explorerCpt = R.hooksComponentWithModule thisModule "explorer" cpt
type TreeProps =
(
asyncTasks
:: GAT.Reductor
asyncTasks
Ref :: R.Ref (Maybe GAT.Reductor)
, backend :: R.State (Maybe Backend)
, frontends :: Frontends
, handed :: Types.Handed
...
...
@@ -235,6 +246,7 @@ type TreeProps =
, sessions :: Sessions
, show :: Boolean
, showLogin :: R.Setter Boolean
, treeReloadRef :: R.Ref (Maybe (R.State Int))
)
type MSidebarProps =
...
...
src/Gargantext/Components/Loader.purs
View file @
68949ae9
...
...
@@ -10,6 +10,7 @@ import Reactix as R
import Gargantext.Components.LoadingSpinner (loadingSpinner)
import Gargantext.Utils.Reactix as R2
thisModule :: String
thisModule = "Gargantext.Components.Loader"
type Props path loaded =
...
...
src/Gargantext/Components/NgramsTable.purs
View file @
68949ae9
...
...
@@ -22,7 +22,7 @@ import Data.Set as Set
import Data.Symbol (SProxy(..))
import Data.Tuple (Tuple(..), fst, snd)
import Data.Tuple.Nested ((/\))
import DOM.Simple.Console (log2)
import DOM.Simple.Console (log
, log
2)
import Effect (Effect)
import Effect.Aff (Aff, launchAff_)
import Effect.Class (liftEffect)
...
...
@@ -31,6 +31,8 @@ import Reactix.DOM.HTML as H
import Record as Record
import Unsafe.Coerce (unsafeCoerce)
import Gargantext.Prelude
import Gargantext.AsyncTasks as GAT
import Gargantext.Components.AutoUpdate (autoUpdateElt)
import Gargantext.Hooks.Loader (useLoader)
...
...
@@ -39,7 +41,6 @@ import Gargantext.Components.NgramsTable.Core
import Gargantext.Components.NgramsTable.Loader (useLoaderWithCacheAPI)
import Gargantext.Components.Nodes.Lists.Types as NT
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.Sessions (Session, get)
import Gargantext.Types (CTabNgramType, OrderBy(..), SearchQuery, TabType, TermList(..), TermSize, termLists, termSizes)
...
...
@@ -279,11 +280,13 @@ tableContainerCpt { dispatch
-- NEXT
type Props = (
afterSync :: Unit -> Aff Unit
, asyncTasks :: GAT.Reductor
appReload :: R.State Int
, afterSync :: Unit -> Aff Unit
, asyncTasksRef :: R.Ref (Maybe GAT.Reductor)
, path :: R.State PageParams
, state :: R.State State
, tabNgramType :: CTabNgramType
, treeReloadRef :: R.Ref (Maybe (R.State Int))
, versioned :: VersionedNgramsTable
, withAutoUpdate :: Boolean
)
...
...
@@ -295,7 +298,8 @@ loadedNgramsTableCpt :: R.Component Props
loadedNgramsTableCpt = R.hooksComponentWithModule thisModule "loadedNgramsTable" cpt
where
cpt { afterSync
, asyncTasks
, appReload
, asyncTasksRef
, path: path@(path'@{ listIds, nodeId, params, searchQuery, scoreType, termListFilter, termSizeFilter } /\ setPath)
, state: (state@{ ngramsChildren
, ngramsLocalPatch
...
...
@@ -303,13 +307,16 @@ loadedNgramsTableCpt = R.hooksComponentWithModule thisModule "loadedNgramsTable"
, ngramsSelection
, ngramsVersion } /\ setState)
, tabNgramType
, treeReloadRef
, versioned: Versioned { data: initTable }
, withAutoUpdate } _ = do
let syncResetBtns = [syncResetButtons { afterSync: chartsAfterSync
let syncResetBtns = [
syncResetButtons { afterSync: chartsAfterSync
, ngramsLocalPatch
, performAction: performAction <<< CoreAction
}]
}
]
pure $ R.fragment $
autoUpdate <> syncResetBtns <> [
...
...
@@ -340,8 +347,16 @@ loadedNgramsTableCpt = R.hooksComponentWithModule thisModule "loadedNgramsTable"
chartsAfterSync _ = do
task <- postNgramsChartsAsync path'
liftEffect $ do
log2 "[performAction] Synchronize task" task
log2 "[chartsAfterSync] Synchronize task" 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 = if withAutoUpdate then
...
...
@@ -495,14 +510,17 @@ selectNgramsOnFirstPage rows = Set.fromFoldable $ (view $ _NgramsElement <<< _ng
type MainNgramsTableProps = (
afterSync :: Unit -> Aff Unit
, asyncTasks :: GAT.Reductor
, appReload :: R.State Int
, asyncTasksRef :: R.Ref (Maybe GAT.Reductor)
, cacheState :: R.State NT.CacheState
, defaultListId :: Int
, nodeId :: Int
-- ^ This node can be a corpus or contact.
, pathS :: R.State PageParams
, session :: Session
, tabNgramType :: CTabNgramType
, tabType :: TabType
, treeReloadRef :: R.Ref (Maybe (R.State Int))
, withAutoUpdate :: Boolean
)
...
...
@@ -513,33 +531,48 @@ mainNgramsTableCpt :: R.Component MainNgramsTableProps
mainNgramsTableCpt = R.hooksComponentWithModule thisModule "mainNgramsTable" cpt
where
cpt props@{ afterSync
, asyncTasks
, appReload
, asyncTasksRef
, cacheState
, defaultListId
, nodeId
, pathS
, session
, tabNgramType
, tabType
, treeReloadRef
, withAutoUpdate } _ = do
let path = initialPageParams session nodeId [defaultListId] tabType
-- let path = initialPageParams session nodeId [defaultListId] tabType
case cacheState of
(NT.CacheOn /\ _) -> do
let render versioned = mainNgramsTablePaint { afterSync
, asyncTasks
, path
, appReload
, asyncTasksRef
, path: fst pathS
, tabNgramType
, treeReloadRef
, versioned
, withAutoUpdate }
case cacheState of
(NT.CacheOn /\ _) -> do
useLoaderWithCacheAPI {
cacheEndpoint: versionEndpoint props
, handleResponse
, mkRequest
, path
, path
: fst pathS
, renderer: render
}
(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 { defaultListId, nodeId, session, tabType } _ = get session $ R.GetNgramsTableVersion { listId: defaultListId, tabType } (Just nodeId)
...
...
@@ -587,9 +620,11 @@ mainNgramsTableCpt = R.hooksComponentWithModule thisModule "mainNgramsTable" cpt
type MainNgramsTablePaintProps = (
afterSync :: Unit -> Aff Unit
, asyncTasks :: GAT.Reductor
, appReload :: R.State Int
, asyncTasksRef :: R.Ref (Maybe GAT.Reductor)
, path :: PageParams
, tabNgramType :: CTabNgramType
, treeReloadRef :: R.Ref (Maybe (R.State Int))
, versioned :: VersionedNgramsTable
, withAutoUpdate :: Boolean
)
...
...
@@ -600,48 +635,82 @@ mainNgramsTablePaint p = R.createElement mainNgramsTablePaintCpt p []
mainNgramsTablePaintCpt :: R.Component MainNgramsTablePaintProps
mainNgramsTablePaintCpt = R.hooksComponentWithModule thisModule "mainNgramsTablePaint" cpt
where
cpt props@{ afterSync, a
syncTasks, path, tabNgramType
, versioned, withAutoUpdate } _ = do
cpt props@{ afterSync, a
ppReload, asyncTasksRef, path, tabNgramType, treeReloadRef
, versioned, withAutoUpdate } _ = do
pathS <- R.useState' path
state <- R.useState' $ initialState versioned
pure $ loadedNgramsTable {
afterSync
, asyncTasks
, appReload
, asyncTasksRef
, path: pathS
, state
, tabNgramType
, treeReloadRef
, versioned
, withAutoUpdate
}
type MainNgramsTablePaint
WithStat
eProps = (
type MainNgramsTablePaint
NoCach
eProps = (
afterSync :: Unit -> Aff Unit
, asyncTasks :: GAT.Reductor
, path :: R.State PageParams
, appReload :: R.State Int
, asyncTasksRef :: R.Ref (Maybe GAT.Reductor)
, pathS :: R.State PageParams
, tabNgramType :: CTabNgramType
, treeReloadRef :: R.Ref (Maybe (R.State Int))
, versioned :: VersionedNgramsTable
, withAutoUpdate :: Boolean
)
mainNgramsTablePaint
WithState :: Record MainNgramsTablePaintWithStat
eProps -> R.Element
mainNgramsTablePaint
WithState p = R.createElement mainNgramsTablePaintWithStat
eCpt p []
mainNgramsTablePaint
NoCache :: Record MainNgramsTablePaintNoCach
eProps -> R.Element
mainNgramsTablePaint
NoCache p = R.createElement mainNgramsTablePaintNoCach
eCpt p []
mainNgramsTablePaint
WithStateCpt :: R.Component MainNgramsTablePaintWithStat
eProps
mainNgramsTablePaint
WithStateCpt = R.hooksComponentWithModule thisModule "mainNgramsTablePaintWithStat
e" cpt
mainNgramsTablePaint
NoCacheCpt :: R.Component MainNgramsTablePaintNoCach
eProps
mainNgramsTablePaint
NoCacheCpt = R.hooksComponentWithModule thisModule "mainNgramsTablePaintNoCach
e" cpt
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
pure $ loadedNgramsTable {
afterSync
, asyncTasks
, path
, appReload
, asyncTasksRef
, path: pathS
, state
, tabNgramType
, treeReloadRef
, versioned
, 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 }
ngramsElementToNgramsOcc :: NgramsElement -> NgramsOcc
...
...
src/Gargantext/Components/NgramsTable/Core.purs
View file @
68949ae9
...
...
@@ -158,8 +158,8 @@ type PageParams =
initialPageParams :: Session -> Int -> Array Int -> TabType -> PageParams
initialPageParams session nodeId listIds tabType =
{
nodeId
,
listIds
{
listIds
,
nodeId
, params
, tabType
, termSizeFilter: Nothing
...
...
@@ -932,15 +932,10 @@ syncPatches props ({ ngramsLocalPatch: ngramsLocalPatch@{ ngramsPatches }
, ngramsVersion
} /\ setState) callback = do
when (isEmptyNgramsTablePatch ngramsStagePatch) $ do
-- setState $ \s ->
-- s { ngramsLocalPatch = fromNgramsPatches mempty
-- , ngramsStagePatch = ngramsLocalPatch
-- }
let pt = Versioned { data: ngramsPatches, version: ngramsVersion }
launchAff_ $ do
Versioned { data: newPatch, version: newVersion } <- putNgramsPatches props pt
callback unit
-- task <- postNgramsChartsAsync props
liftEffect $ do
log2 "[syncPatches] setting state, newVersion" newVersion
setState $ \s ->
...
...
@@ -1090,20 +1085,24 @@ syncResetButtonsCpt = R.hooksComponentWithModule thisModule "syncResetButtons" c
let
hasChanges = ngramsLocalPatch /= mempty
hasChangesClass = if hasChanges then "" else " disabled"
newAfterSync x = do
afterSync x
liftEffect $ setSynchronizing $ const false
resetClick _ = do
performAction ResetPatches
synchronizeClick _ = delay unit $ \_ -> do
setSynchronizing $ const true
performAction $ Synchronize { afterSync: newAfterSync }
newAfterSync x = do
afterSync x
liftEffect $ setSynchronizing $ const false
pure $ H.div {} [
H.button { className: "btn btn-danger " <>
if hasChanges then "" else " disabled"
, on: { click:
\_ -> performAction ResetPatches
}
H.button { className: "btn btn-danger " <>
hasChangesClass
, on: { click:
resetClick
}
} [ 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 }
} [ H.text "Sync" ]
]
src/Gargantext/Components/Nodes/Annuaire/User/Contacts.purs
View file @
68949ae9
...
...
@@ -145,10 +145,12 @@ infoRender (Tuple title content) =
, H.span {} [H.text content] ]
type LayoutProps = (
asyncTasks :: GAT.Reductor
appReload :: R.State Int
, asyncTasksRef :: R.Ref (Maybe GAT.Reductor)
, frontends :: Frontends
, nodeId :: Int
, session :: Session
, treeReloadRef :: R.Ref (Maybe (R.State Int))
)
type KeyLayoutProps = (
...
...
@@ -162,10 +164,18 @@ userLayout props = R.createElement userLayoutCpt props []
userLayoutCpt :: R.Component LayoutProps
userLayoutCpt = R.hooksComponentWithModule thisModule "userLayout" cpt
where
cpt { a
syncTasks, frontends, nodeId, session
} _ = do
cpt { a
ppReload, asyncTasksRef, frontends, nodeId, session, treeReloadRef
} _ = do
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 props = R.createElement userLayoutWithKeyCpt props []
...
...
@@ -173,7 +183,7 @@ userLayoutWithKey props = R.createElement userLayoutWithKeyCpt props []
userLayoutWithKeyCpt :: R.Component KeyLayoutProps
userLayoutWithKeyCpt = R.hooksComponentWithModule thisModule "userLayoutWithKey" cpt
where
cpt { a
syncTasks, frontends, nodeId, session
} _ = do
cpt { a
ppReload, asyncTasksRef, frontends, nodeId, session, treeReloadRef
} _ = do
reload <- R.useState' 0
cacheState <- R.useState' NT.CacheOn
...
...
@@ -182,7 +192,16 @@ userLayoutWithKeyCpt = R.hooksComponentWithModule thisModule "userLayoutWithKey"
\contactData@{contactNode: Contact {name, hyperdata}} ->
H.ul { className: "col-md-12 list-group" } [
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
onUpdateHyperdata :: R.State Int -> HyperdataUser -> Effect Unit
...
...
@@ -224,14 +243,24 @@ annuaireUserLayout props = R.createElement annuaireUserLayoutCpt props []
annuaireUserLayoutCpt :: R.Component AnnuaireLayoutProps
annuaireUserLayoutCpt = R.hooksComponentWithModule thisModule "annuaireUserLayout" cpt
where
cpt { annuaireId, a
syncTasks, frontends, nodeId, session
} _ = do
cpt { annuaireId, a
ppReload, asyncTasksRef, frontends, nodeId, session, treeReloadRef
} _ = do
cacheState <- R.useState' NT.CacheOn
useLoader nodeId (getAnnuaireContact session annuaireId) $
\contactData@{contactNode: Contact {name, hyperdata}} ->
H.ul { className: "col-md-12 list-group" }
[ display (fromMaybe "no name" name) (contactInfos hyperdata onUpdateHyperdata)
, Tabs.tabs { asyncTasks, cacheState, contactData, frontends, nodeId, session } ]
H.ul { className: "col-md-12 list-group" } [
display (fromMaybe "no name" name) (contactInfos hyperdata onUpdateHyperdata)
, Tabs.tabs {
appReload
, asyncTasksRef
, cacheState
, contactData
, frontends
, nodeId
, session
, treeReloadRef
}
]
where
onUpdateHyperdata :: HyperdataUser -> Effect Unit
...
...
src/Gargantext/Components/Nodes/Annuaire/User/Contacts/Tabs.purs
View file @
68949ae9
...
...
@@ -12,6 +12,7 @@ import Reactix as R
import Gargantext.AsyncTasks as GAT
import Gargantext.Components.DocsTable as DT
import Gargantext.Components.NgramsTable as NT
import Gargantext.Components.NgramsTable.Core as NTC
import Gargantext.Components.Tab as Tab
import Gargantext.Components.Nodes.Annuaire.User.Contacts.Types (ContactData)
import Gargantext.Components.Nodes.Lists.Types as NTypes
...
...
@@ -44,12 +45,14 @@ modeTabType' Books = CTabAuthors
modeTabType' Communication = CTabAuthors
type TabsProps = (
asyncTasks :: GAT.Reductor
appReload :: R.State Int
, asyncTasksRef :: R.Ref (Maybe GAT.Reductor)
, cacheState :: R.State NTypes.CacheState
, contactData :: ContactData
, frontends :: Frontends
, nodeId :: Int
, session :: Session
, treeReloadRef :: R.Ref (Maybe (R.State Int))
)
tabs :: Record TabsProps -> R.Element
...
...
@@ -58,7 +61,7 @@ tabs props = R.createElement tabsCpt props []
tabsCpt :: R.Component TabsProps
tabsCpt = R.hooksComponentWithModule thisModule "tabs" cpt
where
cpt { a
syncTasks, cacheState, contactData: {defaultListId}, frontends, nodeId, session
} _ = do
cpt { a
ppReload, asyncTasksRef, cacheState, contactData: {defaultListId}, frontends, nodeId, session, treeReloadRef
} _ = do
active <- R.useState' 0
pure $
Tab.tabs { selected: fst active, tabs: tabs' }
...
...
@@ -71,9 +74,9 @@ tabsCpt = R.hooksComponentWithModule thisModule "tabs" cpt
, "Trash" /\ docs -- TODO pass-in trash mode
]
where
patentsView = { a
syncTasks, cacheState, defaultListId, mode: Patents, nodeId, session
}
booksView = { a
syncTasks, cacheState, defaultListId, mode: Books, nodeId, session
}
commView = { a
syncTasks, cacheState, defaultListId, mode: Communication, nodeId, session
}
patentsView = { a
ppReload, asyncTasksRef, cacheState, defaultListId, mode: Patents, nodeId, session, treeReloadRef
}
booksView = { a
ppReload, asyncTasksRef, cacheState, defaultListId, mode: Books, nodeId, session, treeReloadRef
}
commView = { a
ppReload, asyncTasksRef, cacheState, defaultListId, mode: Communication, nodeId, session, treeReloadRef
}
chart = mempty
totalRecords = 4736 -- TODO
docs = DT.docViewLayout
...
...
@@ -91,25 +94,37 @@ tabsCpt = R.hooksComponentWithModule thisModule "tabs" cpt
type NgramsViewTabsProps = (
asyncTasks :: GAT.Reductor
appReload :: R.State Int
, asyncTasksRef :: R.Ref (Maybe GAT.Reductor)
, cacheState :: R.State NTypes.CacheState
, defaultListId :: Int
, mode :: Mode
, nodeId :: Int
, session :: Session
, treeReloadRef :: R.Ref (Maybe (R.State Int))
)
ngramsView :: Record NgramsViewTabsProps -> R.Element
ngramsView { asyncTasks, cacheState, defaultListId, mode, nodeId, session } =
NT.mainNgramsTable {
afterSync: \_ -> pure unit
, asyncTasks
ngramsView props = R.createElement ngramsViewCpt props []
ngramsViewCpt :: R.Component NgramsViewTabsProps
ngramsViewCpt = R.hooksComponentWithModule thisModule "ngramsView" cpt
where
cpt { appReload, asyncTasksRef, cacheState, defaultListId, mode, nodeId, session, treeReloadRef } _ = do
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
...
...
src/Gargantext/Components/Nodes/Corpus/Chart/Pie.purs
View file @
68949ae9
...
...
@@ -28,6 +28,7 @@ import Gargantext.Types (ChartType(..), TabType)
import Gargantext.Utils.CacheAPI as GUC
import Gargantext.Utils.Reactix as R2
thisModule :: String
thisModule = "Gargantext.Components.Nodes.Corpus.Chart.Pie"
newtype ChartMetrics = ChartMetrics {
...
...
src/Gargantext/Components/Nodes/Lists.purs
View file @
68949ae9
module Gargantext.Components.Nodes.Lists where
import Data.Maybe (Maybe(..))
import Data.Tuple (fst)
import Effect (Effect)
import Effect.Aff (launchAff_)
...
...
@@ -25,10 +26,12 @@ thisModule = "Gargantext.Components.Nodes.Lists"
------------------------------------------------------------------------
type Props = (
asyncTasks :: GAT.Reductor
appReload :: R.State Int
, asyncTasksRef :: R.Ref (Maybe GAT.Reductor)
, nodeId :: Int
, session :: Session
, sessionUpdate :: Session -> Effect Unit
, treeReloadRef :: R.Ref (Maybe (R.State Int))
)
listsLayout :: Record Props -> R.Element
...
...
@@ -53,7 +56,7 @@ listsLayoutWithKey props = R.createElement listsLayoutWithKeyCpt props []
listsLayoutWithKeyCpt :: R.Component KeyProps
listsLayoutWithKeyCpt = R.hooksComponentWithModule thisModule "listsLayoutWithKey" cpt
where
cpt { a
syncTasks, nodeId, session, sessionUpdate
} _ = do
cpt { a
ppReload, asyncTasksRef, nodeId, session, sessionUpdate, treeReloadRef
} _ = do
let path = { nodeId, session }
cacheState <- R.useState' $ getCacheState NT.CacheOn session nodeId
...
...
@@ -74,12 +77,15 @@ listsLayoutWithKeyCpt = R.hooksComponentWithModule thisModule "listsLayoutWithKe
, title: "Corpus " <> name
, user: authors }
, Tabs.tabs {
asyncTasks
appReload
, asyncTasksRef
, cacheState
, corpusData
, corpusId
, key: "listsLayoutWithKey-tabs-" <> (show $ fst cacheState)
, session }
, session
, treeReloadRef
}
]
where
afterCacheStateChange cacheState = do
...
...
src/Gargantext/Components/Nodes/Lists/Tabs.purs
View file @
68949ae9
module Gargantext.Components.Nodes.Lists.Tabs where
import Data.Array as A
import Data.Maybe (Maybe(..), fromMaybe)
import Data.Tuple (fst)
import Data.Tuple.Nested ((/\))
import Effect.Class (liftEffect)
import Reactix as R
import Reactix.DOM.HTML as H
import Record as Record
import Gargantext.Prelude
import Gargantext.AsyncTasks as GAT
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.Chart.Metrics (metrics)
import Gargantext.Components.Nodes.Corpus.Chart.Pie (pie, bar)
...
...
@@ -26,11 +30,13 @@ thisModule :: String
thisModule = "Gargantext.Components.Nodes.Lists.Tabs"
type Props = (
asyncTasks :: GAT.Reductor
appReload :: R.State Int
, asyncTasksRef :: R.Ref (Maybe GAT.Reductor)
, cacheState :: R.State NTypes.CacheState
, corpusData :: CorpusData
, corpusId :: Int
, session :: Session
, treeReloadRef :: R.Ref (Maybe (R.State Int))
)
type PropsWithKey = (
...
...
@@ -44,7 +50,7 @@ tabs props = R.createElement tabsCpt props []
tabsCpt :: R.Component PropsWithKey
tabsCpt = R.hooksComponentWithModule thisModule "tabs" cpt
where
cpt { a
syncTasks, cacheState, corpusData: corpusData@{ defaultListId }, corpusId, session
} _ = do
cpt { a
ppReload, asyncTasksRef, cacheState, corpusData, corpusId, session, treeReloadRef
} _ = do
(selected /\ setSelected) <- R.useState' 0
pure $ Tab.tabs { selected, tabs: tabs' }
...
...
@@ -53,7 +59,7 @@ tabsCpt = R.hooksComponentWithModule thisModule "tabs" cpt
, "Institutes" /\ view Institutes
, "Sources" /\ view Sources
, "Terms" /\ view Terms ]
view mode = ngramsView { a
syncTasks, cacheState, corpusData, corpusId, mode, session
}
view mode = ngramsView { a
ppReload, asyncTasksRef, cacheState, corpusData, corpusId, mode, session, treeReloadRef
}
type NgramsViewProps = ( mode :: Mode | Props )
...
...
@@ -63,26 +69,46 @@ ngramsView props = R.createElement ngramsViewCpt props []
ngramsViewCpt :: R.Component NgramsViewProps
ngramsViewCpt = R.hooksComponentWithModule thisModule "ngramsView" cpt
where
cpt { asyncTasks
cpt { appReload
, asyncTasksRef
, cacheState
, corpusData: { defaultListId }
, corpusId
, mode
, session } _ = do
, session
, treeReloadRef
} _ = do
chartType <- R.useState' Histo
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
( charts tabNgramType chartType chartsReload
( charts
chartParams
tabNgramType chartType chartsReload
<> [ NT.mainNgramsTable { afterSync: afterSync chartsReload
, asyncTasks
, appReload
, asyncTasksRef
, cacheState
, defaultListId
, nodeId: corpusId
, pathS
, session
, tabNgramType
, tabType
, treeReloadRef
, withAutoUpdate: false
}
]
...
...
@@ -102,23 +128,24 @@ ngramsViewCpt = R.hooksComponentWithModule thisModule "ngramsView" cpt
tabType = TabCorpus (TabNgramType tabNgramType)
mNgramsType = mNgramsTypeFromTabType tabType
listId = defaultListId
path
= { corpusId
, limit: Just 1000
initialPath
= { corpusId
--
, limit: Just 1000
, listId
, tabType
}
charts CTabTerms (chartType /\ setChartType) _ = [
charts
params
CTabTerms (chartType /\ setChartType) _ = [
H.div { className: "row chart-type-selector" } [
H.div { className: "col-md-3" } [
R2.select { className: "form-control"
, defaultValue: show chartType
, on: { change: \e -> setChartType
$ const
$ fromMaybe Histo
$ chartTypeFromString
$ R.unsafeEventValue e
}
, defaultValue: show chartType
} [
} [
H.option { value: show Histo } [ H.text $ show Histo ]
, H.option { value: show Scatter } [ H.text $ show Scatter ]
, H.option { value: show ChartBar } [ H.text $ show ChartBar ]
...
...
@@ -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 Institutes = tree { path, session }
chart Sources = bar { path, session }
chart Terms = metrics { path, session }
chart
path
Authors = pie { path, session }
chart
path
Institutes = tree { path, session }
chart
path
Sources = bar { path, session }
chart
path
Terms = metrics { path, session }
src/Gargantext/Components/Nodes/Texts.purs
View file @
68949ae9
...
...
@@ -11,6 +11,7 @@ import Effect.Aff (launchAff_)
import Reactix as R
import Reactix.DOM.HTML as H
--------------------------------------------------------
import Gargantext.AsyncTasks as GAT
import Gargantext.Components.DocsTable as DT
import Gargantext.Components.Loader (loader)
import Gargantext.Components.NgramsTable.Loader (clearCache)
...
...
@@ -163,58 +164,68 @@ docViewCpt = R.hooksComponentWithModule thisModule "docView" cpt
-- docViewLayoutRec :: forall a. DocViewProps a -> Record DT.LayoutProps
docViewLayoutRec { cacheState, corpusData: { defaultListId }, corpusId, frontends, session, tabType: TabDocs } =
{ nodeId: corpusId
-- ^ TODO merge nodeId and corpusId in DT
, cacheState
{ cacheState
, chart : H.div {} []
, tabType: TabCorpus TabDocs
, totalRecords: 4737
, listId: defaultListId
, corpusId: Just corpusId
, frontends
, listId: defaultListId
, nodeId: corpusId
-- ^ TODO merge nodeId and corpusId in DT
, session
, showSearch: true
, frontends, session }
, tabType: TabCorpus TabDocs
, totalRecords: 4737
}
docViewLayoutRec { cacheState, corpusData: { defaultListId }, corpusId, frontends, session, tabType: TabMoreLikeFav } =
{ nodeId: corpusId
-- ^ TODO merge nodeId and corpusId in DT
, cacheState
{ cacheState
, chart : H.div {} []
, tabType: TabCorpus TabMoreLikeFav
, totalRecords: 4737
, listId: defaultListId
, corpusId: Just corpusId
, frontends
, listId: defaultListId
, nodeId: corpusId
-- ^ TODO merge nodeId and corpusId in DT
, session
, showSearch: false
, frontends, session }
, tabType: TabCorpus TabMoreLikeFav
, totalRecords: 4737
}
docViewLayoutRec { cacheState, corpusData: { defaultListId }, corpusId, frontends, session, tabType: TabMoreLikeTrash } =
{ nodeId: corpusId
-- ^ TODO merge nodeId and corpusId in DT
, cacheState
{ cacheState
, chart : H.div {} []
, tabType: TabCorpus TabMoreLikeTrash
, totalRecords: 4737
, listId: defaultListId
, corpusId: Just corpusId
, frontends
, listId: defaultListId
, nodeId: corpusId
-- ^ TODO merge nodeId and corpusId in DT
, session
, showSearch: false
, frontends, session }
, tabType: TabCorpus TabMoreLikeTrash
, totalRecords: 4737
}
docViewLayoutRec { cacheState, corpusData: { defaultListId }, corpusId, frontends, session, tabType: TabTrash } =
{ nodeId: corpusId
-- ^ TODO merge nodeId and corpusId in DT
, cacheState
{ cacheState
, chart : H.div {} []
, tabType: TabCorpus TabTrash
, totalRecords: 4737
, listId: defaultListId
, corpusId: Nothing
, frontends
, listId: defaultListId
, nodeId: corpusId
-- ^ TODO merge nodeId and corpusId in DT
, session
, showSearch: true
, frontends, session }
, tabType: TabCorpus TabTrash
, totalRecords: 4737
}
-- DUMMY
docViewLayoutRec { cacheState, corpusData: { defaultListId }, corpusId, frontends, session, tabType } =
{ nodeId: corpusId
-- ^ TODO merge nodeId and corpusId in DT
, cacheState
{ cacheState
, chart : H.div {} []
, tabType: TabCorpus TabTrash
, totalRecords: 4737
, listId: defaultListId
, corpusId: Nothing
, frontends
, listId: defaultListId
, nodeId: corpusId
-- ^ TODO merge nodeId and corpusId in DT
, session
, showSearch: true
, frontends, session }
, tabType: TabCorpus TabTrash
, totalRecords: 4737
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment