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
f32bd31b
Commit
f32bd31b
authored
Nov 13, 2019
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Graph] some refactoring of FA pausing
Also, attempt to make automatic FA pause almost working.
parent
65165d69
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
21 deletions
+46
-21
Controls.purs
src/Gargantext/Components/GraphExplorer/Controls.purs
+42
-1
ToggleButton.purs
src/Gargantext/Components/GraphExplorer/ToggleButton.purs
+1
-8
Sigmax.purs
src/Gargantext/Hooks/Sigmax.purs
+3
-12
No files found.
src/Gargantext/Components/GraphExplorer/Controls.purs
View file @
f32bd31b
...
@@ -11,9 +11,11 @@ module Gargantext.Components.GraphExplorer.Controls
...
@@ -11,9 +11,11 @@ module Gargantext.Components.GraphExplorer.Controls
, getMultiNodeSelect, setMultiNodeSelect
, getMultiNodeSelect, setMultiNodeSelect
) where
) where
import Data.Maybe (Maybe)
import Data.Maybe (Maybe(..))
import DOM.Simple.Console (log, log2)
import Data.Tuple.Nested ((/\))
import Data.Tuple.Nested ((/\))
import Effect (Effect)
import Effect (Effect)
import Effect.Timer (clearTimeout, setTimeout)
import Prelude
import Prelude
import Reactix as R
import Reactix as R
import Reactix.DOM.HTML as RH
import Reactix.DOM.HTML as RH
...
@@ -24,6 +26,7 @@ import Gargantext.Components.GraphExplorer.RangeControl (edgeSizeControl, nodeSi
...
@@ -24,6 +26,7 @@ import Gargantext.Components.GraphExplorer.RangeControl (edgeSizeControl, nodeSi
import Gargantext.Components.GraphExplorer.SlideButton (cursorSizeButton, labelSizeButton)
import Gargantext.Components.GraphExplorer.SlideButton (cursorSizeButton, labelSizeButton)
import Gargantext.Components.GraphExplorer.ToggleButton (edgesToggleButton, pauseForceAtlasButton)
import Gargantext.Components.GraphExplorer.ToggleButton (edgesToggleButton, pauseForceAtlasButton)
import Gargantext.Hooks.Sigmax as Sigmax
import Gargantext.Hooks.Sigmax as Sigmax
import Gargantext.Hooks.Sigmax.Sigma as Sigma
import Gargantext.Utils.Range as Range
import Gargantext.Utils.Range as Range
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Reactix as R2
...
@@ -72,6 +75,24 @@ controlsCpt = R.hooksComponent "GraphControls" cpt
...
@@ -72,6 +75,24 @@ controlsCpt = R.hooksComponent "GraphControls" cpt
where
where
cpt props _ = do
cpt props _ = do
localControls <- initialLocalControls
localControls <- initialLocalControls
-- 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
--R.useEffect $ handleForceAtlasPause props.sigmaRef localControls.pauseForceAtlas mFAPauseRef
R.useEffect $ handleForceAtlasPause props.sigmaRef localControls.pauseForceAtlas
R.useEffectOnce' $ do
timeoutId <- setTimeout 2000 $ do
--R.setRef mFAPauseRef Nothing
let (toggled /\ setToggled) = localControls.pauseForceAtlas
if toggled then
setToggled $ const false
else
pure unit
--R.setRef mFAPauseRef $ Just timeoutId
pure unit
pure $ case getShowControls props of
pure $ case getShowControls props of
false -> RH.div {} []
false -> RH.div {} []
...
@@ -97,6 +118,26 @@ controlsCpt = R.hooksComponent "GraphControls" cpt
...
@@ -97,6 +118,26 @@ controlsCpt = R.hooksComponent "GraphControls" cpt
]
]
]
]
]
]
where
--handleForceAtlasPause sigmaRef (toggled /\ setToggled) mFAPauseRef = do
handleForceAtlasPause sigmaRef (toggled /\ setToggled) = do
let mSigma = Sigmax.readSigma $ R.readRef sigmaRef
pure $ case mSigma of
Just s -> do
log2 "[handleForceAtlasPause] mSigma: Just " s
if toggled then
Sigma.stopForceAtlas2 s
else
Sigma.restartForceAtlas2 s
-- handle case when user pressed pause/start fa button before timeout fired
--case R.readRef mFAPauseRef of
-- Nothing -> pure unit
-- Just timeoutId -> do
-- R.setRef mFAPauseRef Nothing
-- clearTimeout timeoutId
_ -> do
log "[handleForceAtlasPause] mSigma: Nothing"
pure unit
useGraphControls :: R.Hooks (Record Controls)
useGraphControls :: R.Hooks (Record Controls)
useGraphControls = do
useGraphControls = do
...
...
src/Gargantext/Components/GraphExplorer/ToggleButton.purs
View file @
f32bd31b
...
@@ -81,14 +81,7 @@ pauseForceAtlasButton sigmaRef state =
...
@@ -81,14 +81,7 @@ pauseForceAtlasButton sigmaRef state =
, onMessage: "Pause Force Atlas"
, onMessage: "Pause Force Atlas"
, offMessage: "Start Force Atlas"
, offMessage: "Start Force Atlas"
, onClick: \_ -> do
, onClick: \_ -> do
let mSigma = Sigmax.readSigma $ R.readRef sigmaRef
let (_ /\ setToggled) = state
let (toggled /\ setToggled) = state
case mSigma of
Just s -> if toggled then
Sigma.stopForceAtlas2 s
else
Sigma.restartForceAtlas2 s
_ -> pure unit
setToggled not
setToggled not
}
}
...
...
src/Gargantext/Hooks/Sigmax.purs
View file @
f32bd31b
...
@@ -14,7 +14,6 @@ import Data.Sequence (Seq)
...
@@ -14,7 +14,6 @@ import Data.Sequence (Seq)
import Data.Sequence as Seq
import Data.Sequence as Seq
import Data.Traversable (traverse_)
import Data.Traversable (traverse_)
import Effect (Effect)
import Effect (Effect)
import Effect.Timer (setTimeout)
import FFI.Simple (delay)
import FFI.Simple (delay)
import Gargantext.Hooks.Sigmax.Sigma as Sigma
import Gargantext.Hooks.Sigmax.Sigma as Sigma
import Gargantext.Hooks.Sigmax.Types (Graph(..))
import Gargantext.Hooks.Sigmax.Types (Graph(..))
...
@@ -28,8 +27,6 @@ type Sigma =
...
@@ -28,8 +27,6 @@ type Sigma =
, cleanup :: R.Ref (Seq (Effect Unit))
, cleanup :: R.Ref (Seq (Effect Unit))
}
}
type ForceAtlas2Timeout = Int
type Data n e = { graph :: R.Ref (Graph n e) }
type Data n e = { graph :: R.Ref (Graph n e) }
initSigma :: R.Hooks Sigma
initSigma :: R.Hooks Sigma
...
@@ -234,7 +231,7 @@ startSigmaEff ref sigmaRef settings forceAtlas2Settings graph = do
...
@@ -234,7 +231,7 @@ startSigmaEff ref sigmaRef settings forceAtlas2Settings graph = do
log "[startSigmaEff] calling useDataEff"
log "[startSigmaEff] calling useDataEff"
useDataEff sigma graph
useDataEff sigma graph
log "[startSigmaEff] calling useForceAtlas2Eff"
log "[startSigmaEff] calling useForceAtlas2Eff"
useForceAtlas2Eff sigma forceAtlas2Settings
(Just 2000)
useForceAtlas2Eff sigma forceAtlas2Settings
Just sig -> do
Just sig -> do
log "[startSigmaEff] sigma initialized already"
log "[startSigmaEff] sigma initialized already"
useCanvasRendererEff ref rSigma
useCanvasRendererEff ref rSigma
...
@@ -300,8 +297,8 @@ useCanvasRendererEff container sigma =
...
@@ -300,8 +297,8 @@ useCanvasRendererEff container sigma =
errorKillingMsg = "[useCanvasRenderer] Error killing renderer:"
errorKillingMsg = "[useCanvasRenderer] Error killing renderer:"
killedMsg = "[useCanvasRenderer] Killed renderer"
killedMsg = "[useCanvasRenderer] Killed renderer"
useForceAtlas2Eff :: forall settings. Sigma -> settings ->
Maybe ForceAtlas2Timeout ->
Effect Unit
useForceAtlas2Eff :: forall settings. Sigma -> settings -> Effect Unit
useForceAtlas2Eff sigma settings
mFATimeout
= effect
useForceAtlas2Eff sigma settings = effect
where
where
effect = dependOnSigma sigma sigmaNotFoundMsg withSigma
effect = dependOnSigma sigma sigmaNotFoundMsg withSigma
withSigma sig = do
withSigma sig = do
...
@@ -309,11 +306,5 @@ useForceAtlas2Eff sigma settings mFATimeout = effect
...
@@ -309,11 +306,5 @@ useForceAtlas2Eff sigma settings mFATimeout = effect
log sigma
log sigma
Sigma.startForceAtlas2 sig settings
Sigma.startForceAtlas2 sig settings
--cleanupFirst sigma (Sigma.killForceAtlas2 sig)
--cleanupFirst sigma (Sigma.killForceAtlas2 sig)
case mFATimeout of
Nothing -> pure unit
Just timeout -> do
_ <- setTimeout timeout $ do
Sigma.stopForceAtlas2 sig
pure unit
startingMsg = "[Graph] Starting ForceAtlas2"
startingMsg = "[Graph] Starting ForceAtlas2"
sigmaNotFoundMsg = "[Graph] Sigma not found, not initialising"
sigmaNotFoundMsg = "[Graph] Sigma not found, not initialising"
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