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
7a71ae7d
Commit
7a71ae7d
authored
Nov 12, 2020
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[tasks] reload app only on task finish
Otherwise, reload only tree.
parent
97a649f4
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
245 additions
and
100 deletions
+245
-100
AsyncTasks.purs
src/Gargantext/AsyncTasks.purs
+15
-16
App.purs
src/Gargantext/Components/App.purs
+30
-7
Forest.purs
src/Gargantext/Components/Forest.purs
+18
-5
Node.purs
src/Gargantext/Components/Forest/Tree/Node.purs
+2
-2
GraphExplorer.purs
src/Gargantext/Components/GraphExplorer.purs
+22
-10
NgramsTable.purs
src/Gargantext/Components/NgramsTable.purs
+72
-17
Core.purs
src/Gargantext/Components/NgramsTable/Core.purs
+2
-2
Contacts.purs
src/Gargantext/Components/Nodes/Annuaire/User/Contacts.purs
+7
-3
Tabs.purs
...gantext/Components/Nodes/Annuaire/User/Contacts/Tabs.purs
+31
-19
Pie.purs
src/Gargantext/Components/Nodes/Corpus/Chart/Pie.purs
+1
-0
Lists.purs
src/Gargantext/Components/Nodes/Lists.purs
+5
-2
Tabs.purs
src/Gargantext/Components/Nodes/Lists/Tabs.purs
+40
-17
No files found.
src/Gargantext/AsyncTasks.purs
View file @
7a71ae7d
...
...
@@ -49,38 +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
, storage :: Storage
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
OnFinish
| 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 p@{ reload, storage } (Finish nodeId t onFinish) = do
ret <- action p (Remove nodeId t)
onFinish
pure ret
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 @
7a71ae7d
...
...
@@ -53,6 +53,7 @@ appCpt = R.hooksComponentWithModule thisModule "app" cpt where
route <- useHashRouter router Home
asyncTasksRef <- R.useRef Nothing
treeReloadRef <- R.useRef Nothing
showLogin <- R.useState' false
backend <- R.useState' Nothing
...
...
@@ -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 { asyncTasksRef
let forested child = forestLayout { appReload: reload
, asyncTasksRef
, backend
, child
, frontends
, handed
, reload
, route: fst route
, sessions: fst sessions
, showLogin: snd showLogin
,
backend
,
treeReloadRef
}
let defaultView _ = forested $ homeLayout { backend
, lang: LL_EN
...
...
@@ -98,6 +100,7 @@ appCpt = R.hooksComponentWithModule thisModule "app" cpt where
, frontends
, nodeId
, session
, treeReloadRef
}
Corpus sid nodeId -> withSession sid $ \session -> forested $ corpusLayout { nodeId, session }
CorpusDocument sid corpusId listId nodeId -> withSession sid $ \session -> forested $ documentLayout { corpusId: Just corpusId, nodeId, listId, session }
...
...
@@ -116,6 +119,7 @@ appCpt = R.hooksComponentWithModule thisModule "app" cpt where
, nodeId
, session
, sessionUpdate
, treeReloadRef
}
Login -> login { backend, backends, sessions, visible: showLogin }
PGraphExplorer sid graphId ->
...
...
@@ -144,18 +148,20 @@ appCpt = R.hooksComponentWithModule thisModule "app" cpt where
, frontends
, nodeId
, session
, treeReloadRef
}
type ForestLayoutProps = (
asyncTasksRef :: R.Ref (Maybe GAT.Reductor)
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
...
...
@@ -173,7 +179,16 @@ forestLayoutMain props = R.createElement forestLayoutMainCpt props []
forestLayoutMainCpt :: R.Component ForestLayoutProps
forestLayoutMainCpt = R.hooksComponentWithModule thisModule "forestLayoutMain" cpt
where
cpt { asyncTasksRef, 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
...
...
@@ -181,7 +196,15 @@ forestLayoutMainCpt = R.hooksComponentWithModule thisModule "forestLayoutMain" c
pure $ R2.row $ ordering [
H.div { className: "col-md-2", style: { paddingTop: "60px" } }
[ forest { asyncTasksRef, 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 @
7a71ae7d
...
...
@@ -22,14 +22,15 @@ thisModule :: String
thisModule = "Gargantext.Components.Forest"
type Props = (
asyncTasksRef :: R.Ref (Maybe GAT.Reductor)
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,21 +38,33 @@ forest props = R.createElement forestCpt props []
forestCpt :: R.Component Props
forestCpt = R.hooksComponentWithModule thisModule "forest" cpt where
cpt { asyncTasksRef, 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 reload
asyncTasks <- GAT.useTasks
appReload
reload
openNodes <- R2.useLocalStorageState R2.openNodesKey (Set.empty :: OpenNodes)
-- 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/Node.purs
View file @
7a71ae7d
...
...
@@ -127,7 +127,6 @@ nodeMainSpanCpt = R.hooksComponentWithModule thisModule "nodeMainSpan" cpt
]
else H.div {} []
, nodeActions { id
, nodeType
, refreshTree: const $ dispatch RefreshTree
...
...
@@ -138,7 +137,8 @@ nodeMainSpanCpt = R.hooksComponentWithModule thisModule "nodeMainSpan" cpt
]
where
onTaskFinish id t _ = do
dispatchAsyncTasks $ GAT.Finish id t (snd appReload $ (_ + 1))
dispatchAsyncTasks $ GAT.Finish id t
snd appReload $ (_ + 1)
SettingsBox {show: showBox} = settingsBox nodeType
onPopoverClose popoverRef _ = Popover.setOpen popoverRef false
...
...
src/Gargantext/Components/GraphExplorer.purs
View file @
7a71ae7d
...
...
@@ -93,6 +93,7 @@ explorerCpt :: R.Component Props
explorerCpt = R.hooksComponentWithModule thisModule "explorer" cpt
where
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,13 +117,14 @@ 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
, hyperdataGraph
, session
, treeReload: \_ -> (snd treeReload) $ (+) 1
}
, graph
, graphId
, hyperdataGraph
, session
, treeReload: \_ -> (snd treeReload) $ (+) 1
}
multiSelectEnabledRef <- R.useRef $ fst controls.multiSelectEnabled
R.useEffect' $ do
...
...
@@ -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 { asyncTasksRef, 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"} [
forest { asyncTasksRef, backend, frontends, handed, reload, route, sessions, showLogin }
forest { appReload: reload
, asyncTasksRef
, backend
, frontends
, handed
, route
, sessions
, showLogin
, treeReloadRef }
]
mSidebar :: Maybe GET.MetaData
...
...
@@ -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/NgramsTable.purs
View file @
7a71ae7d
...
...
@@ -286,6 +286,7 @@ type Props = (
, path :: R.State PageParams
, state :: R.State State
, tabNgramType :: CTabNgramType
, treeReloadRef :: R.Ref (Maybe (R.State Int))
, versioned :: VersionedNgramsTable
, withAutoUpdate :: Boolean
)
...
...
@@ -306,14 +307,15 @@ loadedNgramsTableCpt = R.hooksComponentWithModule thisModule "loadedNgramsTable"
, ngramsSelection
, ngramsVersion } /\ setState)
, tabNgramType
, treeReloadRef
, versioned: Versioned { data: initTable }
, withAutoUpdate } _ = do
let syncResetBtns = [
syncResetButtons { afterSync: chartsAfterSync
, ngramsLocalPatch
, performAction: performAction <<< CoreAction
}
, ngramsLocalPatch
, performAction: performAction <<< CoreAction
}
]
pure $ R.fragment $
...
...
@@ -345,12 +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 "[
performAction
] asyncTasksRef is Nothing"
Nothing -> log "[
chartsAfterSync
] asyncTasksRef is Nothing"
Just asyncTasks -> do
snd asyncTasks $ GAT.Insert nodeId task
snd appReload $ (_ + 1)
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
...
...
@@ -510,9 +516,11 @@ type MainNgramsTableProps = (
, 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
)
...
...
@@ -528,30 +536,43 @@ mainNgramsTableCpt = R.hooksComponentWithModule thisModule "mainNgramsTable" cpt
, cacheState
, defaultListId
, nodeId
, pathS
, session
, tabNgramType
, tabType
, treeReloadRef
, withAutoUpdate } _ = do
let path = initialPageParams session nodeId [defaultListId] tabType
let render versioned = mainNgramsTablePaint { afterSync
, appReload
, asyncTasksRef
, path
, tabNgramType
, versioned
, withAutoUpdate }
-- let path = initialPageParams session nodeId [defaultListId] tabType
case cacheState of
(NT.CacheOn /\ _) -> do
let render versioned = mainNgramsTablePaint { afterSync
, appReload
, asyncTasksRef
, path: fst pathS
, tabNgramType
, treeReloadRef
, versioned
, withAutoUpdate }
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)
...
...
@@ -603,6 +624,7 @@ type MainNgramsTablePaintProps = (
, asyncTasksRef :: R.Ref (Maybe GAT.Reductor)
, path :: PageParams
, tabNgramType :: CTabNgramType
, treeReloadRef :: R.Ref (Maybe (R.State Int))
, versioned :: VersionedNgramsTable
, withAutoUpdate :: Boolean
)
...
...
@@ -613,7 +635,7 @@ mainNgramsTablePaint p = R.createElement mainNgramsTablePaintCpt p []
mainNgramsTablePaintCpt :: R.Component MainNgramsTablePaintProps
mainNgramsTablePaintCpt = R.hooksComponentWithModule thisModule "mainNgramsTablePaint" cpt
where
cpt props@{ afterSync, appReload, asyncTasksRef, path, tabNgramType, versioned, withAutoUpdate } _ = do
cpt props@{ afterSync, appReload, asyncTasksRef, path, tabNgramType,
treeReloadRef,
versioned, withAutoUpdate } _ = do
pathS <- R.useState' path
state <- R.useState' $ initialState versioned
...
...
@@ -624,6 +646,39 @@ mainNgramsTablePaintCpt = R.hooksComponentWithModule thisModule "mainNgramsTable
, path: pathS
, state
, tabNgramType
, treeReloadRef
, versioned
, withAutoUpdate
}
type MainNgramsTablePaintNoCacheProps = (
afterSync :: Unit -> Aff Unit
, 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
)
mainNgramsTablePaintNoCache :: Record MainNgramsTablePaintNoCacheProps -> R.Element
mainNgramsTablePaintNoCache p = R.createElement mainNgramsTablePaintNoCacheCpt p []
mainNgramsTablePaintNoCacheCpt :: R.Component MainNgramsTablePaintNoCacheProps
mainNgramsTablePaintNoCacheCpt = R.hooksComponentWithModule thisModule "mainNgramsTablePaintNoCache" cpt
where
cpt props@{ afterSync, appReload, asyncTasksRef, pathS, tabNgramType, treeReloadRef, versioned, withAutoUpdate } _ = do
state <- R.useState' $ initialState versioned
pure $ loadedNgramsTable {
afterSync
, appReload
, asyncTasksRef
, path: pathS
, state
, tabNgramType
, treeReloadRef
, versioned
, withAutoUpdate
}
...
...
src/Gargantext/Components/NgramsTable/Core.purs
View file @
7a71ae7d
...
...
@@ -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
...
...
src/Gargantext/Components/Nodes/Annuaire/User/Contacts.purs
View file @
7a71ae7d
...
...
@@ -150,6 +150,7 @@ type LayoutProps = (
, frontends :: Frontends
, nodeId :: Int
, session :: Session
, treeReloadRef :: R.Ref (Maybe (R.State Int))
)
type KeyLayoutProps = (
...
...
@@ -163,7 +164,7 @@ userLayout props = R.createElement userLayoutCpt props []
userLayoutCpt :: R.Component LayoutProps
userLayoutCpt = R.hooksComponentWithModule thisModule "userLayout" cpt
where
cpt { appReload, asyncTasksRef, frontends, nodeId, session } _ = do
cpt { appReload, asyncTasksRef, frontends, nodeId, session
, treeReloadRef
} _ = do
let sid = sessionId session
pure $ userLayoutWithKey {
...
...
@@ -173,6 +174,7 @@ userLayoutCpt = R.hooksComponentWithModule thisModule "userLayout" cpt
, key: show sid <> "-" <> show nodeId
, nodeId
, session
, treeReloadRef
}
userLayoutWithKey :: Record KeyLayoutProps -> R.Element
...
...
@@ -181,7 +183,7 @@ userLayoutWithKey props = R.createElement userLayoutWithKeyCpt props []
userLayoutWithKeyCpt :: R.Component KeyLayoutProps
userLayoutWithKeyCpt = R.hooksComponentWithModule thisModule "userLayoutWithKey" cpt
where
cpt { appReload, asyncTasksRef, frontends, nodeId, session } _ = do
cpt { appReload, asyncTasksRef, frontends, nodeId, session
, treeReloadRef
} _ = do
reload <- R.useState' 0
cacheState <- R.useState' NT.CacheOn
...
...
@@ -198,6 +200,7 @@ userLayoutWithKeyCpt = R.hooksComponentWithModule thisModule "userLayoutWithKey"
, frontends
, nodeId
, session
, treeReloadRef
}
]
where
...
...
@@ -240,7 +243,7 @@ annuaireUserLayout props = R.createElement annuaireUserLayoutCpt props []
annuaireUserLayoutCpt :: R.Component AnnuaireLayoutProps
annuaireUserLayoutCpt = R.hooksComponentWithModule thisModule "annuaireUserLayout" cpt
where
cpt { annuaireId, appReload, asyncTasksRef, frontends, nodeId, session } _ = do
cpt { annuaireId, appReload, asyncTasksRef, frontends, nodeId, session
, treeReloadRef
} _ = do
cacheState <- R.useState' NT.CacheOn
useLoader nodeId (getAnnuaireContact session annuaireId) $
...
...
@@ -255,6 +258,7 @@ annuaireUserLayoutCpt = R.hooksComponentWithModule thisModule "annuaireUserLayou
, frontends
, nodeId
, session
, treeReloadRef
}
]
...
...
src/Gargantext/Components/Nodes/Annuaire/User/Contacts/Tabs.purs
View file @
7a71ae7d
...
...
@@ -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
...
...
@@ -51,6 +52,7 @@ type TabsProps = (
, frontends :: Frontends
, nodeId :: Int
, session :: Session
, treeReloadRef :: R.Ref (Maybe (R.State Int))
)
tabs :: Record TabsProps -> R.Element
...
...
@@ -59,7 +61,7 @@ tabs props = R.createElement tabsCpt props []
tabsCpt :: R.Component TabsProps
tabsCpt = R.hooksComponentWithModule thisModule "tabs" cpt
where
cpt { appReload, asyncTasksRef, cacheState, contactData: {defaultListId}, frontends, nodeId, session} _ = do
cpt { appReload, asyncTasksRef, cacheState, contactData: {defaultListId}, frontends, nodeId, session
, treeReloadRef
} _ = do
active <- R.useState' 0
pure $
Tab.tabs { selected: fst active, tabs: tabs' }
...
...
@@ -72,9 +74,9 @@ tabsCpt = R.hooksComponentWithModule thisModule "tabs" cpt
, "Trash" /\ docs -- TODO pass-in trash mode
]
where
patentsView = { appReload, asyncTasksRef, cacheState, defaultListId, mode: Patents, nodeId, session }
booksView = { appReload, asyncTasksRef, cacheState, defaultListId, mode: Books, nodeId, session }
commView = { appReload, asyncTasksRef, cacheState, defaultListId, mode: Communication, nodeId, session }
patentsView = { appReload, asyncTasksRef, cacheState, defaultListId, mode: Patents, nodeId, session
, treeReloadRef
}
booksView = { appReload, asyncTasksRef, cacheState, defaultListId, mode: Books, nodeId, session
, treeReloadRef
}
commView = { appReload, asyncTasksRef, cacheState, defaultListId, mode: Communication, nodeId, session
, treeReloadRef
}
chart = mempty
totalRecords = 4736 -- TODO
docs = DT.docViewLayout
...
...
@@ -99,22 +101,32 @@ type NgramsViewTabsProps = (
, mode :: Mode
, nodeId :: Int
, session :: Session
, treeReloadRef :: R.Ref (Maybe (R.State Int))
)
ngramsView :: Record NgramsViewTabsProps -> R.Element
ngramsView { appReload, asyncTasksRef, cacheState, defaultListId, mode, nodeId, session } =
NT.mainNgramsTable {
appReload
, afterSync: \_ -> pure unit
, asyncTasksRef
, cacheState
, defaultListId
, nodeId
, tabType
, session
, tabNgramType
, withAutoUpdate: false
}
ngramsView props = R.createElement ngramsViewCpt props []
ngramsViewCpt :: R.Component NgramsViewTabsProps
ngramsViewCpt = R.hooksComponentWithModule thisModule "ngramsView" cpt
where
tabNgramType = modeTabType' mode
tabType = TabPairing $ TabNgramType $ modeTabType mode
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
tabNgramType = modeTabType' mode
tabType = TabPairing $ TabNgramType $ modeTabType mode
src/Gargantext/Components/Nodes/Corpus/Chart/Pie.purs
View file @
7a71ae7d
...
...
@@ -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 @
7a71ae7d
...
...
@@ -31,6 +31,7 @@ type Props = (
, nodeId :: Int
, session :: Session
, sessionUpdate :: Session -> Effect Unit
, treeReloadRef :: R.Ref (Maybe (R.State Int))
)
listsLayout :: Record Props -> R.Element
...
...
@@ -55,7 +56,7 @@ listsLayoutWithKey props = R.createElement listsLayoutWithKeyCpt props []
listsLayoutWithKeyCpt :: R.Component KeyProps
listsLayoutWithKeyCpt = R.hooksComponentWithModule thisModule "listsLayoutWithKey" cpt
where
cpt { appReload, asyncTasksRef, nodeId, session, sessionUpdate } _ = do
cpt { appReload, asyncTasksRef, nodeId, session, sessionUpdate
, treeReloadRef
} _ = do
let path = { nodeId, session }
cacheState <- R.useState' $ getCacheState NT.CacheOn session nodeId
...
...
@@ -82,7 +83,9 @@ listsLayoutWithKeyCpt = R.hooksComponentWithModule thisModule "listsLayoutWithKe
, corpusData
, corpusId
, key: "listsLayoutWithKey-tabs-" <> (show $ fst cacheState)
, session }
, session
, treeReloadRef
}
]
where
afterCacheStateChange cacheState = do
...
...
src/Gargantext/Components/Nodes/Lists/Tabs.purs
View file @
7a71ae7d
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
...
...
@@ -11,6 +13,7 @@ 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)
...
...
@@ -33,6 +36,7 @@ type Props = (
, corpusData :: CorpusData
, corpusId :: Int
, session :: Session
, treeReloadRef :: R.Ref (Maybe (R.State Int))
)
type PropsWithKey = (
...
...
@@ -46,7 +50,7 @@ tabs props = R.createElement tabsCpt props []
tabsCpt :: R.Component PropsWithKey
tabsCpt = R.hooksComponentWithModule thisModule "tabs" cpt
where
cpt { appReload, asyncTasksRef, cacheState, corpusData, corpusId, session } _ = do
cpt { appReload, asyncTasksRef, cacheState, corpusData, corpusId, session
, treeReloadRef
} _ = do
(selected /\ setSelected) <- R.useState' 0
pure $ Tab.tabs { selected, tabs: tabs' }
...
...
@@ -55,7 +59,7 @@ tabsCpt = R.hooksComponentWithModule thisModule "tabs" cpt
, "Institutes" /\ view Institutes
, "Sources" /\ view Sources
, "Terms" /\ view Terms ]
view mode = ngramsView { appReload, asyncTasksRef, cacheState, corpusData, corpusId, mode, session }
view mode = ngramsView { appReload, asyncTasksRef, cacheState, corpusData, corpusId, mode, session
, treeReloadRef
}
type NgramsViewProps = ( mode :: Mode | Props )
...
...
@@ -71,22 +75,40 @@ ngramsViewCpt = R.hooksComponentWithModule thisModule "ngramsView" cpt
, 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
, appReload
, asyncTasksRef
, cacheState
, defaultListId
, nodeId: corpusId
, pathS
, session
, tabNgramType
, tabType
, treeReloadRef
, withAutoUpdate: false
}
]
...
...
@@ -104,25 +126,26 @@ ngramsViewCpt = R.hooksComponentWithModule thisModule "ngramsView" cpt
tabNgramType = modeTabType mode
tabType = TabCorpus (TabNgramType tabNgramType)
mNgramsType = mNgramsTypeFromTabType tabType
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"
, on: { change: \e -> setChartType
, 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 ]
...
...
@@ -131,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 }
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