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
d31416bc
Commit
d31416bc
authored
Nov 14, 2019
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Graph] some refactoring (use dependOnSigma)
parent
f32bd31b
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
53 additions
and
65 deletions
+53
-65
Button.purs
src/Gargantext/Components/GraphExplorer/Button.purs
+3
-5
RangeControl.purs
src/Gargantext/Components/GraphExplorer/RangeControl.purs
+12
-14
SlideButton.purs
src/Gargantext/Components/GraphExplorer/SlideButton.purs
+4
-5
ToggleButton.purs
src/Gargantext/Components/GraphExplorer/ToggleButton.purs
+8
-10
Sigmax.purs
src/Gargantext/Hooks/Sigmax.purs
+13
-18
Sigma.purs
src/Gargantext/Hooks/Sigmax/Sigma.purs
+13
-13
No files found.
src/Gargantext/Components/GraphExplorer/Button.purs
View file @
d31416bc
...
...
@@ -37,10 +37,8 @@ simpleButtonCpt = R.hooksComponent "SimpleButton" cpt
centerButton :: R.Ref Sigmax.Sigma -> R.Element
centerButton sigmaRef = simpleButton {
onClick: \_ -> do
let mSigma = Sigmax.readSigma $ R.readRef sigmaRef
log2 "[centerButton] mSigma" mSigma
case mSigma of
Just s -> Sigma.goToAllCameras s {x: 0.0, y: 0.0, ratio: 1.0, angle: 0.0}
_ -> pure unit
let sigma = R.readRef sigmaRef
Sigmax.dependOnSigma sigma "[centerButton] sigma: Nothing" $ \s ->
Sigma.goToAllCameras s {x: 0.0, y: 0.0, ratio: 1.0, angle: 0.0}
, text: "Center"
}
src/Gargantext/Components/GraphExplorer/RangeControl.purs
View file @
d31416bc
...
...
@@ -46,13 +46,12 @@ edgeSizeControl sigmaRef (state /\ setState) =
, width: 10.0
, height: 5.0
, onChange: \range@(Range.Closed {min, max}) -> do
let mSigma = Sigmax.readSigma $ R.readRef sigmaRef
case mSigma of
Just s -> Sigma.setSettings s {
minEdgeSize: min
, maxEdgeSize: max
}
_ -> pure unit
let sigma = R.readRef sigmaRef
Sigmax.dependOnSigma sigma "[edgeSizeControl] sigma: Nothing" $ \s -> do
Sigma.setSettings s {
minEdgeSize: min
, maxEdgeSize: max
}
setState $ const range
}
}
...
...
@@ -69,13 +68,12 @@ nodeSizeControl sigmaRef (state /\ setState) =
, width: 10.0
, height: 5.0
, onChange: \range@(Range.Closed {min, max}) -> do
let mSigma = Sigmax.readSigma $ R.readRef sigmaRef
case mSigma of
Just s -> Sigma.setSettings s {
minNodeSize: min
, maxNodeSize: max
}
_ -> pure unit
let sigma = R.readRef sigmaRef
Sigmax.dependOnSigma sigma "[nodeSizeControl] sigma: Nothing" $ \s -> do
Sigma.setSettings s {
minNodeSize: min
, maxNodeSize: max
}
setState $ const range
}
}
src/Gargantext/Components/GraphExplorer/SlideButton.purs
View file @
d31416bc
...
...
@@ -64,13 +64,12 @@ labelSizeButton sigmaRef state =
, min: 5.0
, max: 30.0
, onChange: \e -> do
let
mSigma = Sigmax.readSigma $
R.readRef sigmaRef
let
sigma =
R.readRef sigmaRef
let newValue = readFloat $ R2.unsafeEventValue e
let (value /\ setValue) = state
case mSigma of
Just s ->
Sigma.setSettings s {
Sigmax.dependOnSigma sigma "[labelSizeButton] sigma: Nothing" $ \s -> do
Sigma.setSettings s {
defaultLabelSize: newValue
}
_ -> pure unit
}
setValue $ const newValue
}
src/Gargantext/Components/GraphExplorer/ToggleButton.purs
View file @
d31416bc
...
...
@@ -60,17 +60,15 @@ edgesToggleButton sigmaRef state =
, onMessage: "Hide Edges"
, offMessage: "Show Edges"
, onClick: \_ -> do
let
mSigma = Sigmax.readSigma $
R.readRef sigmaRef
let
sigma =
R.readRef sigmaRef
let (toggled /\ setToggled) = state
case mSigma of
Just s -> do
let settings = {
drawEdges: not toggled
, drawEdgeLabels: not toggled
, hideEdgesOnMove: toggled
}
Sigma.setSettings s settings
_ -> pure unit
Sigmax.dependOnSigma sigma "[edgesToggleButton] sigma: Nothing" $ \s -> do
let settings = {
drawEdges: not toggled
, drawEdgeLabels: not toggled
, hideEdgesOnMove: toggled
}
Sigma.setSettings s settings
setToggled not
}
...
...
src/Gargantext/Hooks/Sigmax.purs
View file @
d31416bc
...
...
@@ -68,13 +68,8 @@ startSigma ref sigmaRef settings forceAtlas2Settings graph = do
delay unit $ handleRefresh sigma
where
handleRefresh sigma _ = do
let rSigma = readSigma sigma
_ <- case rSigma of
Nothing -> log2 "[handleRefresh] can't refresh" sigma
Just s -> do
Sigma.refreshForceAtlas s
pure $ pure unit
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}
...
...
@@ -159,8 +154,8 @@ addRenderer sigma renderer = do
(const unit <$> ret) <$ report ret
where
report = either (log2 errorMsg) (\_ -> log successMsg)
errorMsg = "[
use
Renderer] Error adding renderer:"
successMsg = "[
use
Renderer] Added renderer successfully"
errorMsg = "[
add
Renderer] Error adding renderer:"
successMsg = "[
add
Renderer] Added renderer successfully"
useData :: forall n e. Sigma -> Graph n e -> R.Hooks Unit
useData sigma graph =
...
...
@@ -273,7 +268,7 @@ useDataEff :: forall n e. Sigma -> Graph n e -> Effect Unit
useDataEff sigma graph = dependOnSigma sigma sigmaNotFoundMsg withSigma
where
withSigma sig = refreshData sig (sigmafy graph)
sigmaNotFoundMsg = "[useData] Sigma not found, not adding data"
sigmaNotFoundMsg = "[useData
Eff
] Sigma not found, not adding data"
useCanvasRendererEff :: R.Ref (Nullable Element) -> Sigma -> Effect Unit
useCanvasRendererEff container sigma =
...
...
@@ -285,17 +280,17 @@ useCanvasRendererEff container sigma =
withSigma sig = addRenderer sig renderer >>= handle
where -- close over sig
renderer = { "type": "canvas", container: c }
handle _ = log "[useCanvasRenderer] cleanup handle"
handle _ = log "[useCanvasRenderer
Eff
] cleanup handle"
--handle (Right _) = cleanupFirst sigma (Sigma.killRenderer sig renderer >>= logCleanup)
--handle (Left e) =
-- log2 errorAddingMsg e *> cleanupSigma sigma "useCanvasRenderer"
logCleanup (Left e) = log2 errorKillingMsg e
logCleanup _ = log killedMsg
containerNotFoundMsg = "[useCanvasRenderer] Container not found, not adding renderer"
sigmaNotFoundMsg = "[useCanvasRenderer] Sigma not found, not adding renderer"
errorAddingMsg = "[useCanvasRenderer] Error adding canvas renderer: "
errorKillingMsg = "[useCanvasRenderer] Error killing renderer:"
killedMsg = "[useCanvasRenderer] Killed renderer"
containerNotFoundMsg = "[useCanvasRenderer
Eff
] Container not found, not adding renderer"
sigmaNotFoundMsg = "[useCanvasRenderer
Eff
] Sigma not found, not adding renderer"
errorAddingMsg = "[useCanvasRenderer
Eff
] Error adding canvas renderer: "
errorKillingMsg = "[useCanvasRenderer
Eff
] Error killing renderer:"
killedMsg = "[useCanvasRenderer
Eff
] Killed renderer"
useForceAtlas2Eff :: forall settings. Sigma -> settings -> Effect Unit
useForceAtlas2Eff sigma settings = effect
...
...
@@ -306,5 +301,5 @@ useForceAtlas2Eff sigma settings = effect
log sigma
Sigma.startForceAtlas2 sig settings
--cleanupFirst sigma (Sigma.killForceAtlas2 sig)
startingMsg = "[
Graph
] Starting ForceAtlas2"
sigmaNotFoundMsg = "[
Graph
] Sigma not found, not initialising"
startingMsg = "[
useForceAtlas2Eff
] Starting ForceAtlas2"
sigmaNotFoundMsg = "[
useForceAtlas2Eff
] Sigma not found, not initialising"
src/Gargantext/Hooks/Sigmax/Sigma.purs
View file @
d31416bc
...
...
@@ -53,19 +53,6 @@ refresh = runEffectFn1 _refresh
foreign import _refresh :: EffectFn1 Sigma Unit
refreshForceAtlas :: Sigma -> Effect Unit
refreshForceAtlas sigma = do
isRunning <- isForceAtlas2Running sigma
if isRunning then
pure unit
else do
_ <- setTimeout 100 $ do
restartForceAtlas2 sigma
_ <- setTimeout 100 $
stopForceAtlas2 sigma
pure unit
pure unit
addRenderer :: forall r err. Sigma -> r -> Effect (Either err Unit)
addRenderer = runEffectFn4 _addRenderer Left Right
...
...
@@ -135,6 +122,19 @@ foreign import _stopForceAtlas2 :: EffectFn1 Sigma Unit
foreign import _killForceAtlas2 :: EffectFn1 Sigma Unit
foreign import _isForceAtlas2Running :: EffectFn1 Sigma Boolean
refreshForceAtlas :: Sigma -> Effect Unit
refreshForceAtlas sigma = do
isRunning <- isForceAtlas2Running sigma
if isRunning then
pure unit
else do
_ <- setTimeout 100 $ do
restartForceAtlas2 sigma
_ <- setTimeout 100 $
stopForceAtlas2 sigma
pure unit
pure unit
newtype SigmaEasing = SigmaEasing String
sigmaEasing :: { linear :: SigmaEasing
...
...
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