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
143
Issues
143
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
9c4af297
Commit
9c4af297
authored
Nov 14, 2019
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Graph] trying to get graph not refresh, without success still
parent
d31416bc
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
59 additions
and
53 deletions
+59
-53
Graph.purs
src/Gargantext/Components/Graph.purs
+6
-7
GraphExplorer.purs
src/Gargantext/Components/GraphExplorer.purs
+20
-12
Controls.purs
src/Gargantext/Components/GraphExplorer/Controls.purs
+24
-27
Sigmax.purs
src/Gargantext/Hooks/Sigmax.purs
+9
-7
No files found.
src/Gargantext/Components/Graph.purs
View file @
9c4af297
...
...
@@ -6,9 +6,10 @@ module Gargantext.Components.Graph
where
import Prelude (bind, discard, pure, ($), unit)
import Data.Maybe (Maybe)
import Data.Nullable (null)
import Data.Nullable (null
, Nullable
)
import Data.Sequence as Seq
import DOM.Simple.Console (log, log2)
import DOM.Simple.Types (Element)
import FFI.Simple (delay)
import Reactix as R
import Reactix.DOM.HTML as RH
...
...
@@ -32,8 +33,9 @@ type Edge = ( id :: String, source :: String, target :: String )
type Graph = Sigmax.Graph Node Edge
type Props sigma forceatlas2 =
(
graph :: Graph
(
elRef :: R.Ref (Nullable Element)
, forceAtlas2Settings :: forceatlas2
, graph :: Graph
, sigmaSettings :: sigma
, sigmaRef :: R.Ref Sigma
)
...
...
@@ -45,18 +47,15 @@ graphCpt :: forall s fa2. R.Component (Props s fa2)
graphCpt = R.hooksComponent "Graph" cpt
where
cpt props _ = do
ref <- R.useRef null
--startSigma ref props.sigmaRef props.sigmaSettings props.forceAtlas2Settings props.graph
R.useEffectOnce $ do
log "[graphCpt] calling startSigmaEff"
startSigmaEff
r
ef props.sigmaRef props.sigmaSettings props.forceAtlas2Settings props.graph
startSigmaEff
props.elR
ef props.sigmaRef props.sigmaSettings props.forceAtlas2Settings props.graph
delay unit $ \_ -> do
log "[GraphCpt] cleaning up"
pure $ pure unit
pure $ RH.div { ref, style: {height: "95%"} } []
pure $ RH.div { ref
: props.elRef
, style: {height: "95%"} } []
type SigmaSettings =
( animationsTime :: Number
...
...
src/Gargantext/Components/GraphExplorer.purs
View file @
9c4af297
...
...
@@ -6,9 +6,11 @@ import Data.FoldableWithIndex (foldMapWithIndex)
import Data.Foldable (foldMap)
import Data.Int (toNumber)
import Data.Maybe (Maybe(..))
import Data.Nullable (null, Nullable)
import Data.Sequence as Seq
import Data.Tuple (fst,snd)
import Data.Tuple.Nested ((/\))
import DOM.Simple.Types (Element)
import Effect.Aff (Aff)
import Reactix as R
import Reactix.DOM.HTML as RH
...
...
@@ -38,7 +40,10 @@ type LayoutProps =
, frontends :: Frontends
)
type Props = ( graph :: Maybe Graph.Graph | LayoutProps )
type Props = (
graphElRef :: R.Ref (Nullable Element)
, graph :: Maybe Graph.Graph | LayoutProps
)
--------------------------------------------------------------
explorerLayout :: Record LayoutProps -> R.Element
...
...
@@ -47,10 +52,12 @@ explorerLayout props = R.createElement explorerLayoutCpt props []
explorerLayoutCpt :: R.Component LayoutProps
explorerLayoutCpt = R.hooksComponent "G.C.GraphExplorer.explorerLayout" cpt
where
cpt {graphId, mCurrentRoute, treeId, session, sessions, frontends} _ =
useLoader graphId (getNodes session) handler
cpt {graphId, mCurrentRoute, treeId, session, sessions, frontends} _ = do
graphElRef <- R.useRef null
useLoader graphId (getNodes session) (handler graphElRef)
where
handler loaded = explorer {graphId, mCurrentRoute, treeId, session, sessions, graph, frontends}
handler graphElRef loaded =
explorer {graphElRef, graphId, mCurrentRoute, treeId, session, sessions, graph, frontends}
where graph = Just (convert loaded)
--------------------------------------------------------------
...
...
@@ -60,7 +67,7 @@ explorer props = R.createElement explorerCpt props []
explorerCpt :: R.Component Props
explorerCpt = R.hooksComponent "G.C.GraphExplorer.explorer" cpt
where
cpt {sessions, session, graphId, mCurrentRoute, treeId, graph, frontends} _ = do
cpt {
graphElRef,
sessions, session, graphId, mCurrentRoute, treeId, graph, frontends} _ = do
controls <- Controls.useGraphControls
state <- useExplorerState
x /\ setX <- R.useState' 0
...
...
@@ -80,7 +87,7 @@ explorerCpt = R.hooksComponent "G.C.GraphExplorer.explorer" cpt
, RH.div {on: {click: \e -> setX $ \x_ -> x_ + 1}} [ RH.text ("Counter: " <> (show x)) ]
]
, row [ tree {mCurrentRoute, treeId} controls showLogin
, mGraph controls.sigmaRef {graphId, graph}
, mGraph
graphElRef
controls.sigmaRef {graphId, graph}
, Sidebar.sidebar {showSidePanel: fst controls.showSidePanel} ]
, row [
]
...
...
@@ -103,9 +110,9 @@ explorerCpt = R.hooksComponent "G.C.GraphExplorer.explorer" cpt
pullLeft = RH.div { className: "pull-left" }
pullRight = RH.div { className: "pull-right" }
mGraph :: R.Ref Sigma -> {graphId :: GraphId, graph :: Maybe Graph.Graph} -> R.Element
mGraph _ {graph: Nothing} = RH.div {} []
mGraph
sigmaRef {graphId, graph: Just graph} = graphView
sigmaRef {graphId, graph}
mGraph :: R.Ref
(Nullable Element) -> R.Ref
Sigma -> {graphId :: GraphId, graph :: Maybe Graph.Graph} -> R.Element
mGraph _
_
{graph: Nothing} = RH.div {} []
mGraph
graphElRef sigmaRef {graphId, graph: Just graph} = graphView graphElRef
sigmaRef {graphId, graph}
useExplorerState :: R.Hooks (Record GET.State)
useExplorerState = do pure {}
...
...
@@ -130,9 +137,9 @@ type GraphProps = (
, graph :: Graph.Graph
)
graphView :: R.Ref Sigma -> Record GraphProps -> R.Element
graphView :: R.Ref
(Nullable Element) -> R.Ref
Sigma -> Record GraphProps -> R.Element
--graphView sigmaRef props = R.createElement (R.memo el memoCmp) props []
graphView sigmaRef props = R.createElement el props []
graphView
elRef
sigmaRef props = R.createElement el props []
where
--memoCmp props1 props2 = props1.graphId == props2.graphId
el = R.hooksComponent "GraphView" cpt
...
...
@@ -141,7 +148,8 @@ graphView sigmaRef props = R.createElement el props []
RH.div { id: "graph-view", className: "col-md-12" }
[
Graph.graph {
forceAtlas2Settings: Graph.forceAtlas2Settings
elRef
, forceAtlas2Settings: Graph.forceAtlas2Settings
, graph
, sigmaSettings: Graph.sigmaSettings
, sigmaRef: sigmaRef
...
...
src/Gargantext/Components/GraphExplorer/Controls.purs
View file @
9c4af297
...
...
@@ -83,16 +83,16 @@ controlsCpt = R.hooksComponent "GraphControls" cpt
--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
--
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
false -> RH.div {} []
...
...
@@ -121,10 +121,10 @@ 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
let sigma = R.readRef sigmaRef
pure $ Sigmax.dependOnSigma sigma "[handleForceAtlasPause] sigma: Nothing" $ \s -> do
log2 "[handleForceAtlasPause] mSigma: Just " s
log2 "[handleForceAtlasPause] toggled: " toggled
if toggled then
Sigma.stopForceAtlas2 s
else
...
...
@@ -135,9 +135,6 @@ controlsCpt = R.hooksComponent "GraphControls" cpt
-- Just timeoutId -> do
-- R.setRef mFAPauseRef Nothing
-- clearTimeout timeoutId
_ -> do
log "[handleForceAtlasPause] mSigma: Nothing"
pure unit
useGraphControls :: R.Hooks (Record Controls)
useGraphControls = do
...
...
src/Gargantext/Hooks/Sigmax.purs
View file @
9c4af297
...
...
@@ -229,23 +229,25 @@ startSigmaEff ref sigmaRef settings forceAtlas2Settings graph = do
useForceAtlas2Eff sigma forceAtlas2Settings
Just sig -> do
log "[startSigmaEff] sigma initialized already"
isFARunning <- Sigma.isForceAtlas2Running sig
log2 "[startSigmaEff] isFARunning" isFARunning
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 = do
let rSigma = readSigma sigma
_ <- case rSigma of
Nothing -> log2 "[handleRefresh] can't refresh" sigma
Just s -> do
handleRefresh sigma = dependOnSigma sigma "[handleRefresh] can't refresh" $ \s -> do
Sigma.refreshForceAtlas s
pure unit
useSigmaEff :: forall settings. settings -> R.Ref Sigma -> Effect Sigma
...
...
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