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
a6636be4
Commit
a6636be4
authored
Sep 26, 2022
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[sigma] forceatlas pause/resume is working
parent
399e3b00
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
58 additions
and
73865 deletions
+58
-73865
index.js
dist/index.js
+0
-73823
Layout.purs
src/Gargantext/Components/GraphExplorer/Layout.purs
+13
-6
Resources.purs
src/Gargantext/Components/GraphExplorer/Resources.purs
+4
-5
Store.purs
src/Gargantext/Components/GraphExplorer/Store.purs
+1
-0
Controls.purs
...Gargantext/Components/GraphExplorer/Toolbar/Controls.purs
+7
-5
Graph.purs
src/Gargantext/Components/Nodes/Graph.purs
+5
-4
Sigmax.purs
src/Gargantext/Hooks/Sigmax.purs
+23
-21
ForceAtlas2.purs
src/Gargantext/Hooks/Sigmax/ForceAtlas2.purs
+5
-1
No files found.
dist/index.js
deleted
100644 → 0
View file @
399e3b00
This diff is collapsed.
Click to expand it.
src/Gargantext/Components/GraphExplorer/Layout.purs
View file @
a6636be4
...
...
@@ -27,6 +27,7 @@ import Gargantext.Components.GraphExplorer.Types as GET
import Gargantext.Config (defaultFrontends)
import Gargantext.Data.Louvain as Louvain
import Gargantext.Hooks.Session (useSession)
import Gargantext.Hooks.Sigmax.ForceAtlas2 as ForceAtlas
import Gargantext.Hooks.Sigmax as Sigmax
import Gargantext.Hooks.Sigmax.Types as SigmaxT
import Gargantext.Types as GT
...
...
@@ -43,15 +44,16 @@ here :: R2.Here
here = R2.here "Gargantext.Components.GraphExplorer.Layout"
type Props =
( sigmaRef :: R.Ref Sigmax.Sigma
( fa2Ref :: R.Ref (Maybe ForceAtlas.FA2Layout)
, sigmaRef :: R.Ref Sigmax.Sigma
)
layout :: R2.Leaf Props
layout = R2.leaf layoutCpt
layoutCpt :: R.Memo Props
layoutCpt = R.memo' $ here.component "explorerWriteGraph" cpt where
cpt { sigmaRef
cpt { fa2Ref
, sigmaRef
} _ = do
-- | States
-- |
...
...
@@ -187,7 +189,8 @@ layoutCpt = R.memo' $ here.component "explorerWriteGraph" cpt where
}
[
Controls.controls
{ reloadForest: reloadForest
{ fa2Ref
, reloadForest: reloadForest
, sigmaRef
}
]
...
...
@@ -200,6 +203,7 @@ layoutCpt = R.memo' $ here.component "explorerWriteGraph" cpt where
[
graphView
{ elRef: graphRef
, fa2Ref
, sigmaRef
}
]
...
...
@@ -208,8 +212,9 @@ layoutCpt = R.memo' $ here.component "explorerWriteGraph" cpt where
--------------------------------------------------------------
type GraphProps =
( elRef :: R.Ref (Nullable Element)
, sigmaRef :: R.Ref Sigmax.Sigma
( elRef :: R.Ref (Nullable Element)
, fa2Ref :: R.Ref (Maybe ForceAtlas.FA2Layout)
, sigmaRef :: R.Ref Sigmax.Sigma
)
graphView :: R2.Leaf GraphProps
...
...
@@ -217,6 +222,7 @@ graphView = R2.leaf graphViewCpt
graphViewCpt :: R.Memo GraphProps
graphViewCpt = R.memo' $ here.component "graphView" cpt where
cpt { elRef
, fa2Ref
, sigmaRef
} _ = do
-- | States
...
...
@@ -265,6 +271,7 @@ graphViewCpt = R.memo' $ here.component "graphView" cpt where
Graph.drawGraph
{ elRef
, fa2Ref
, forceAtlas2Settings: Graph.forceAtlas2Settings
, sigmaRef
, sigmaSettings: Graph.sigmaSettings
...
...
src/Gargantext/Components/GraphExplorer/Resources.purs
View file @
a6636be4
...
...
@@ -30,10 +30,11 @@ import Record (merge)
import Toestand as T
here :: R2.Here
here = R2.here "Gargantext.Components.Graph"
here = R2.here "Gargantext.Components.Graph
Explorer.Resources
"
type Props sigma forceatlas2 =
( elRef :: R.Ref (Nullable Element)
, fa2Ref :: R.Ref (Maybe ForceAtlas2.FA2Layout)
, forceAtlas2Settings :: forceatlas2
, sigmaRef :: R.Ref Sigmax.Sigma
, sigmaSettings :: sigma
...
...
@@ -49,6 +50,7 @@ drawGraphCpt = R.memo' $ here.component "graph" cpt where
-- | Component
-- |
cpt { elRef
, fa2Ref
, sigmaRef
, forceAtlas2Settings: fa2
, transformedGraph
...
...
@@ -56,8 +58,6 @@ drawGraphCpt = R.memo' $ here.component "graph" cpt where
boxes <- AppStore.use
fa2Ref <- R.useRef (Nothing :: Maybe ForceAtlas2.FA2Layout)
{ showEdges
, graphStage
, graph
...
...
@@ -85,10 +85,9 @@ drawGraphCpt = R.memo' $ here.component "graph" cpt where
Just fa2 -> do
ForceAtlas2.stop fa2
ForceAtlas2.kill fa2
here.log2 "[graphCpt (Cleanup)] forceAtlas stopped for" fa2
R.setRef fa2Ref Nothing
Sigmax.dependOnSigma (R.readRef sigmaRef) "[graphCpt (Cleanup)] no sigma" $ \sigma -> do
--Sigma.stopForceAtlas2 sigma
here.log2 "[graphCpt (Cleanup)] forceAtlas stopped for" sigma
Sigma.kill sigma
here.log "[graphCpt (Cleanup)] sigma killed"
...
...
src/Gargantext/Components/GraphExplorer/Store.purs
View file @
a6636be4
...
...
@@ -12,6 +12,7 @@ import Gargantext.Prelude
import Data.Maybe (Maybe(..))
import Data.Set as Set
import Gargantext.Components.GraphExplorer.Types as GET
import Gargantext.Hooks.Sigmax.ForceAtlas2 as ForceAtlas
import Gargantext.Hooks.Sigmax.Types as SigmaxT
import Gargantext.Types as GT
import Gargantext.Utils (getter)
...
...
src/Gargantext/Components/GraphExplorer/Toolbar/Controls.purs
View file @
a6636be4
...
...
@@ -19,6 +19,7 @@ import Gargantext.Components.GraphExplorer.Toolbar.RangeControl (edgeConfluenceC
import Gargantext.Components.GraphExplorer.Toolbar.SlideButton (labelSizeButton, mouseSelectorSizeButton)
import Gargantext.Components.GraphExplorer.Types as GET
import Gargantext.Hooks.Session (useSession)
import Gargantext.Hooks.Sigmax.ForceAtlas2 as ForceAtlas
import Gargantext.Hooks.Sigmax as Sigmax
import Gargantext.Hooks.Sigmax.Types as SigmaxT
import Gargantext.Types as GT
...
...
@@ -33,16 +34,17 @@ here :: R2.Here
here = R2.here "Gargantext.Components.GraphExplorer.Toolbar.Controls"
type Controls =
( reloadForest :: T2.ReloadS
, sigmaRef :: R.Ref Sigmax.Sigma
( fa2Ref :: R.Ref (Maybe ForceAtlas.FA2Layout)
, reloadForest :: T2.ReloadS
, sigmaRef :: R.Ref Sigmax.Sigma
)
controls :: R2.Leaf Controls
controls = R2.leaf controlsCpt
controlsCpt :: R.Memo Controls
controlsCpt = R.memo' $ here.component "controls" cpt where
cpt { reloadForest
cpt { fa2Ref
, reloadForest
, sigmaRef
} _ = do
-- | States
...
...
@@ -91,7 +93,7 @@ controlsCpt = R.memo' $ here.component "controls" cpt where
_ -> pure unit
-- Handle case when FA is paused from outside events, eg. the automatic timer.
R.useEffect' $ Sigmax.handleForceAtlas2Pause
sigma
Ref forceAtlasState mFAPauseRef Graph.forceAtlas2Settings
R.useEffect' $ Sigmax.handleForceAtlas2Pause
fa2
Ref forceAtlasState mFAPauseRef Graph.forceAtlas2Settings
-- Handle automatic edge hiding when FA is running (to prevent flickering).
-- TODO Commented temporarily: this breaks forceatlas rendering after reset
...
...
src/Gargantext/Components/Nodes/Graph.purs
View file @
a6636be4
...
...
@@ -20,6 +20,7 @@ import Gargantext.Config.REST (logRESTError)
import Gargantext.Hooks.FirstEffect (useFirstEffect')
import Gargantext.Hooks.Loader (useLoaderEffect)
import Gargantext.Hooks.Session (useSession)
import Gargantext.Hooks.Sigmax.ForceAtlas2 as ForceAtlas
import Gargantext.Hooks.Sigmax as Sigmax
import Gargantext.Hooks.Sigmax.Types as SigmaxT
import Gargantext.Utils (getter)
...
...
@@ -29,7 +30,7 @@ import Reactix as R
import Record as Record
type Props =
( graphId
:: GET.GraphId
( graphId :: GET.GraphId
)
here :: R2.Here
...
...
@@ -37,7 +38,6 @@ here = R2.here "Gargantext.Components.Nodes.Corpus.Graph"
node :: R2.Leaf ( key :: String | Props )
node = R2.leaf nodeCpt
nodeCpt :: R.Component ( key :: String | Props )
nodeCpt = here.component "node" cpt where
cpt { graphId } _ = do
...
...
@@ -118,7 +118,6 @@ type HydrateStoreProps =
hydrateStore:: R2.Leaf HydrateStoreProps
hydrateStore = R2.leaf hydrateStoreCpt
hydrateStoreCpt :: R.Component HydrateStoreProps
hydrateStoreCpt = here.component "hydrateStore" cpt where
cpt { mMetaData
...
...
@@ -142,6 +141,7 @@ hydrateStoreCpt = here.component "hydrateStore" cpt where
-- |
sigmaRef <- Sigmax.initSigma >>= R.useRef
fa2Ref <- R.useRef (Nothing :: Maybe ForceAtlas.FA2Layout)
-- Hydrate GraphStore
(state :: Record GraphStore.State) <- pure $
...
...
@@ -171,5 +171,6 @@ hydrateStoreCpt = here.component "hydrateStore" cpt where
state
[
layout
{ sigmaRef }
{ fa2Ref
, sigmaRef }
]
src/Gargantext/Hooks/Sigmax.purs
View file @
a6636be4
...
...
@@ -18,6 +18,7 @@ import Effect (Effect)
import Effect.Class.Console (error)
import Effect.Timer (TimeoutId, clearTimeout)
import FFI.Simple ((.=))
import Gargantext.Hooks.Sigmax.ForceAtlas2 as ForceAtlas
import Gargantext.Hooks.Sigmax.Graphology as Graphology
import Gargantext.Hooks.Sigmax.Sigma as Sigma
import Gargantext.Hooks.Sigmax.Types as ST
...
...
@@ -115,28 +116,29 @@ dependOnContainer container notFoundMsg f = do
-- | Effect for handling pausing FA via state changes. We need this because
-- | pausing can be done not only via buttons but also from the initial
-- | setTimer.
handleForceAtlas2Pause :: forall settings. R.Ref Sigma -> T.Box ST.ForceAtlasState -> R.Ref (Maybe TimeoutId) -> settings -> Effect Unit
handleForceAtlas2Pause sigmaRef forceAtlasState mFAPauseRef settings = do
let sigma = R.readRef sigmaRef
handleForceAtlas2Pause :: forall settings. R.Ref (Maybe ForceAtlas.FA2Layout)
-> T.Box ST.ForceAtlasState
-> R.Ref (Maybe TimeoutId)
-> settings
-> Effect Unit
handleForceAtlas2Pause fa2Ref forceAtlasState mFAPauseRef settings = do
let fa2_ = R.readRef fa2Ref
toggled <- T.read forceAtlasState
dependOnSigma sigma "[handleForceAtlas2Pause] sigma: Nothing" $ \s -> do
-- TODO Rewrite using R.Ref FA2Layout instead of a Sigma ref
--let isFARunning = Sigma.isForceAtlas2Running s
let isFARunning = false
case Tuple toggled isFARunning of
Tuple ST.InitialRunning false -> do
--Sigma.restartForceAtlas2 s settings
pure unit
Tuple ST.Running false -> do
--Sigma.restartForceAtlas2 s settings
pure unit
case R.readRef mFAPauseRef of
Nothing -> pure unit
Just timeoutId -> clearTimeout timeoutId
Tuple ST.Paused true -> do
--Sigma.stopForceAtlas2 s
pure unit
_ -> pure unit
case fa2_ of
Nothing -> pure unit
Just fa2 -> do
isFARunning <- ForceAtlas.isRunning fa2
case Tuple toggled isFARunning of
Tuple ST.InitialRunning false -> do
ForceAtlas.restart fa2
Tuple ST.Running false -> do
ForceAtlas.restart fa2
case R.readRef mFAPauseRef of
Nothing -> pure unit
Just timeoutId -> clearTimeout timeoutId
Tuple ST.Paused true -> do
ForceAtlas.stop fa2
_ -> pure unit
setEdges :: Sigma.Sigma -> Boolean -> Effect Unit
setEdges sigma val = do
...
...
src/Gargantext/Hooks/Sigmax/ForceAtlas2.purs
View file @
a6636be4
...
...
@@ -44,7 +44,11 @@ isRunning = runEffectFn1 _isRunning
-- TODO?
restart :: FA2Layout -> Effect Unit
restart = start
restart fa2 = do
stop fa2
_ <- setTimeout 100 $ do
start fa2
pure unit
refresh :: FA2Layout -> Effect Unit
refresh f = do
...
...
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