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
142
Issues
142
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
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
gargantext
purescript-gargantext
Commits
2e48353f
Commit
2e48353f
authored
Nov 18, 2019
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev-graph-eff-rewrite' into dev
parents
c9c35f5d
ff8e2dc7
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
45 deletions
+42
-45
Controls.purs
src/Gargantext/Components/GraphExplorer/Controls.purs
+5
-4
ToggleButton.purs
src/Gargantext/Components/GraphExplorer/ToggleButton.purs
+1
-6
Types.purs
src/Gargantext/Components/GraphExplorer/Types.purs
+1
-0
Sigmax.purs
src/Gargantext/Hooks/Sigmax.purs
+35
-35
No files found.
src/Gargantext/Components/GraphExplorer/Controls.purs
View file @
2e48353f
...
...
@@ -13,7 +13,7 @@ module Gargantext.Components.GraphExplorer.Controls
import Data.Maybe (Maybe(..))
import DOM.Simple.Console (log, log2)
import Data.Tuple.Nested ((/\))
import Data.Tuple.Nested ((/\)
, get1
)
import Effect (Effect)
import Effect.Timer (clearTimeout, setTimeout)
import Prelude
...
...
@@ -78,10 +78,10 @@ controlsCpt = R.hooksComponent "GraphControls" cpt
-- ref to track automatic FA pausing
-- If user pauses FA before auto is triggered, clear the timeoutId
-- TODO: mFAPauseRef needs to be set higher up the tree
--
mFAPauseRef <- R.useRef Nothing
mFAPauseRef <- R.useRef Nothing
--R.useEffect $ handleForceAtlasPause props.sigmaRef localControls.pauseForceAtlas mFAPauseRef
R.useEffect' $ Sigmax.handleForceAtlas2Pause props.sigmaRef localControls.pauseForceAtlas
R.useEffect' $ Sigmax.handleForceAtlas2Pause props.sigmaRef localControls.pauseForceAtlas
(get1 localControls.showEdges) mFAPauseRef
R.useEffectOnce' $ do
timeoutId <- setTimeout 2000 $ do
...
...
@@ -91,7 +91,8 @@ controlsCpt = R.hooksComponent "GraphControls" cpt
setToggled $ const false
else
pure unit
--R.setRef mFAPauseRef $ Just timeoutId
R.setRef mFAPauseRef Nothing
R.setRef mFAPauseRef $ Just timeoutId
pure unit
pure $ case getShowControls props of
...
...
src/Gargantext/Components/GraphExplorer/ToggleButton.purs
View file @
2e48353f
...
...
@@ -63,12 +63,7 @@ edgesToggleButton sigmaRef state =
let sigma = R.readRef sigmaRef
let (toggled /\ setToggled) = state
Sigmax.dependOnSigma sigma "[edgesToggleButton] sigma: Nothing" $ \s -> do
let settings = {
drawEdges: not toggled
, drawEdgeLabels: not toggled
, hideEdgesOnMove: toggled
}
Sigma.setSettings s settings
Sigmax.setEdges s $ not toggled
setToggled not
}
...
...
src/Gargantext/Components/GraphExplorer/Types.purs
View file @
2e48353f
...
...
@@ -6,6 +6,7 @@ import Data.Array ((!!), length)
import Data.Maybe (Maybe(..), fromJust)
import Data.Newtype (class Newtype)
import Partial.Unsafe (unsafePartial)
import Reactix as R
newtype Node = Node
{ id_ :: String
...
...
src/Gargantext/Hooks/Sigmax.purs
View file @
2e48353f
...
...
@@ -16,11 +16,12 @@ import Data.Traversable (traverse_)
import Data.Tuple (Tuple(..))
import Data.Tuple.Nested((/\))
import Effect (Effect)
import Effect.Timer (TimeoutId, clearTimeout)
import FFI.Simple (delay)
import Gargantext.Hooks.Sigmax.Sigma as Sigma
import Gargantext.Hooks.Sigmax.Types (Graph(..))
import Gargantext.Utils.Reactix as R2
import Prelude (Unit, bind, const, discard, flip, pure, unit, ($), (*>), (<$), (<$>), (<<<), (<>), (>>=))
import Prelude (Unit, bind, const, discard, flip, pure, unit, ($), (*>), (<$), (<$>), (<<<), (<>), (>>=)
, not
)
import Reactix as R
type Sigma =
...
...
@@ -66,13 +67,6 @@ startSigma ref sigmaRef settings forceAtlas2Settings graph = do
else
pure unit
R.useEffect $ do
delay unit $ handleRefresh sigma
where
handleRefresh sigma _ = pure $
dependOnSigma sigma "[handleRefresh] can't refresh" Sigma.refreshForceAtlas
-- | Manages a sigma with the given settings
useSigma :: forall settings. settings -> R.Ref (Maybe Sigma) -> R.Hooks {sigma :: Sigma, isNew :: Boolean}
useSigma settings sigmaRef = do
...
...
@@ -220,37 +214,14 @@ startSigmaEff ref sigmaRef settings forceAtlas2Settings graph = do
let rSigma = R.readRef sigmaRef
case readSigma rSigma of
Nothing -> do
--log "[startSigmaEff] calling useSigmaEff"
sigma <- useSigmaEff settings sigmaRef
--log "[startSigmaEff] calling useCanvasRendererEff"
useCanvasRendererEff ref sigma
--log "[startSigmaEff] calling useDataEff"
useDataEff sigma graph
--log "[startSigmaEff] calling useForceAtlas2Eff"
useForceAtlas2Eff sigma forceAtlas2Settings
Just sig -> do
--log "[startSigmaEff] sigma initialized already"
--Sigma.swapRendererContainer ref sig
--dependOnContainer ref "[startSigmaEff] no container" $ Sigma.setRendererContainer sig
--useCanvasRendererEff ref rSigma
--useDataEff rSigma graph
--useForceAtlas2Eff rSigma forceAtlas2Settings
--log "[startSigmaEff] refreshForceAtlas"
--Sigma.refreshForceAtlas sig
--if isFARunning then
-- Sigma.restartForceAtlas2 sig
--else
-- Sigma.stopForceAtlas2 sig
pure unit
--handleRefresh sigma
where
handleRefresh :: Sigma -> Effect Unit
handleRefresh sigma = dependOnSigma sigma "[handleRefresh] can't refresh" $ \s -> do
Sigma.refreshForceAtlas s
useSigmaEff :: forall settings. settings -> R.Ref Sigma -> Effect Sigma
useSigmaEff settings sigmaRef = do
...
...
@@ -302,14 +273,18 @@ useForceAtlas2Eff sigma settings = effect
effect = dependOnSigma sigma sigmaNotFoundMsg withSigma
withSigma sig = do
--log2 startingMsg sigma
setEdges sig false
Sigma.startForceAtlas2 sig settings
--cleanupFirst sigma (Sigma.killForceAtlas2 sig)
startingMsg = "[useForceAtlas2Eff] Starting ForceAtlas2"
sigmaNotFoundMsg = "[useForceAtlas2Eff] Sigma not found, not initialising"
-- | 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.
--handleForceAtlasPause sigmaRef (toggled /\ setToggled) mFAPauseRef = do
handleForceAtlas2Pause :: R.Ref Sigma -> R.State Boolean -> Effect Unit
handleForceAtlas2Pause sigmaRef (toggled /\ setToggled) = do
handleForceAtlas2Pause :: R.Ref Sigma -> R.State Boolean ->
Boolean -> R.Ref (Maybe TimeoutId) ->
Effect Unit
handleForceAtlas2Pause sigmaRef (toggled /\ setToggled)
showEdges mFAPauseRef
= do
let sigma = R.readRef sigmaRef
dependOnSigma sigma "[handleForceAtlas2Pause] sigma: Nothing" $ \s -> do
--log2 "[handleForceAtlas2Pause] mSigma: Just " s
...
...
@@ -317,8 +292,17 @@ handleForceAtlas2Pause sigmaRef (toggled /\ setToggled) = do
isFARunning <- Sigma.isForceAtlas2Running s
--log2 "[handleForceAtlas2Pause] isFARunning: " isFARunning
case Tuple toggled isFARunning of
Tuple true false -> Sigma.restartForceAtlas2 s
Tuple false true -> Sigma.stopForceAtlas2 s
Tuple true false -> do
-- hide edges during forceAtlas rendering, this prevents flickering
Sigma.restartForceAtlas2 s
setEdges s false
case R.readRef mFAPauseRef of
Nothing -> pure unit
Just timeoutId -> clearTimeout timeoutId
Tuple false true -> do
-- restore edges state
Sigma.stopForceAtlas2 s
setEdges s showEdges
_ -> pure unit
-- handle case when user pressed pause/start fa button before timeout fired
--case R.readRef mFAPauseRef of
...
...
@@ -326,3 +310,19 @@ handleForceAtlas2Pause sigmaRef (toggled /\ setToggled) = do
-- Just timeoutId -> do
-- R.setRef mFAPauseRef Nothing
-- clearTimeout timeoutId
setEdges :: Sigma.Sigma -> Boolean -> Effect Unit
setEdges sigma val = do
let settings = {
drawEdges: val
, drawEdgeLabels: val
, hideEdgesOnMove: not val
}
-- prevent showing edges (via show edges button) when FA is running (flickering)
isFARunning <- Sigma.isForceAtlas2Running sigma
case Tuple val isFARunning of
Tuple false true ->
Sigma.setSettings sigma settings
Tuple true false ->
Sigma.setSettings sigma settings
_ -> pure unit
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