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
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
...
@@ -6,9 +6,10 @@ module Gargantext.Components.Graph
where
where
import Prelude (bind, discard, pure, ($), unit)
import Prelude (bind, discard, pure, ($), unit)
import Data.Maybe (Maybe)
import Data.Maybe (Maybe)
import Data.Nullable (null)
import Data.Nullable (null
, Nullable
)
import Data.Sequence as Seq
import Data.Sequence as Seq
import DOM.Simple.Console (log, log2)
import DOM.Simple.Console (log, log2)
import DOM.Simple.Types (Element)
import FFI.Simple (delay)
import FFI.Simple (delay)
import Reactix as R
import Reactix as R
import Reactix.DOM.HTML as RH
import Reactix.DOM.HTML as RH
...
@@ -32,8 +33,9 @@ type Edge = ( id :: String, source :: String, target :: String )
...
@@ -32,8 +33,9 @@ type Edge = ( id :: String, source :: String, target :: String )
type Graph = Sigmax.Graph Node Edge
type Graph = Sigmax.Graph Node Edge
type Props sigma forceatlas2 =
type Props sigma forceatlas2 =
(
graph :: Graph
(
elRef :: R.Ref (Nullable Element)
, forceAtlas2Settings :: forceatlas2
, forceAtlas2Settings :: forceatlas2
, graph :: Graph
, sigmaSettings :: sigma
, sigmaSettings :: sigma
, sigmaRef :: R.Ref Sigma
, sigmaRef :: R.Ref Sigma
)
)
...
@@ -45,18 +47,15 @@ graphCpt :: forall s fa2. R.Component (Props s fa2)
...
@@ -45,18 +47,15 @@ graphCpt :: forall s fa2. R.Component (Props s fa2)
graphCpt = R.hooksComponent "Graph" cpt
graphCpt = R.hooksComponent "Graph" cpt
where
where
cpt props _ = do
cpt props _ = do
ref <- R.useRef null
--startSigma ref props.sigmaRef props.sigmaSettings props.forceAtlas2Settings props.graph
R.useEffectOnce $ do
R.useEffectOnce $ do
log "[graphCpt] calling startSigmaEff"
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
delay unit $ \_ -> do
log "[GraphCpt] cleaning up"
log "[GraphCpt] cleaning up"
pure $ pure unit
pure $ pure unit
pure $ RH.div { ref, style: {height: "95%"} } []
pure $ RH.div { ref
: props.elRef
, style: {height: "95%"} } []
type SigmaSettings =
type SigmaSettings =
( animationsTime :: Number
( animationsTime :: Number
...
...
src/Gargantext/Components/GraphExplorer.purs
View file @
9c4af297
...
@@ -6,9 +6,11 @@ import Data.FoldableWithIndex (foldMapWithIndex)
...
@@ -6,9 +6,11 @@ import Data.FoldableWithIndex (foldMapWithIndex)
import Data.Foldable (foldMap)
import Data.Foldable (foldMap)
import Data.Int (toNumber)
import Data.Int (toNumber)
import Data.Maybe (Maybe(..))
import Data.Maybe (Maybe(..))
import Data.Nullable (null, Nullable)
import Data.Sequence as Seq
import Data.Sequence as Seq
import Data.Tuple (fst,snd)
import Data.Tuple (fst,snd)
import Data.Tuple.Nested ((/\))
import Data.Tuple.Nested ((/\))
import DOM.Simple.Types (Element)
import Effect.Aff (Aff)
import Effect.Aff (Aff)
import Reactix as R
import Reactix as R
import Reactix.DOM.HTML as RH
import Reactix.DOM.HTML as RH
...
@@ -38,7 +40,10 @@ type LayoutProps =
...
@@ -38,7 +40,10 @@ type LayoutProps =
, frontends :: Frontends
, 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
explorerLayout :: Record LayoutProps -> R.Element
...
@@ -47,10 +52,12 @@ explorerLayout props = R.createElement explorerLayoutCpt props []
...
@@ -47,10 +52,12 @@ explorerLayout props = R.createElement explorerLayoutCpt props []
explorerLayoutCpt :: R.Component LayoutProps
explorerLayoutCpt :: R.Component LayoutProps
explorerLayoutCpt = R.hooksComponent "G.C.GraphExplorer.explorerLayout" cpt
explorerLayoutCpt = R.hooksComponent "G.C.GraphExplorer.explorerLayout" cpt
where
where
cpt {graphId, mCurrentRoute, treeId, session, sessions, frontends} _ =
cpt {graphId, mCurrentRoute, treeId, session, sessions, frontends} _ = do
useLoader graphId (getNodes session) handler
graphElRef <- R.useRef null
useLoader graphId (getNodes session) (handler graphElRef)
where
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)
where graph = Just (convert loaded)
--------------------------------------------------------------
--------------------------------------------------------------
...
@@ -60,7 +67,7 @@ explorer props = R.createElement explorerCpt props []
...
@@ -60,7 +67,7 @@ explorer props = R.createElement explorerCpt props []
explorerCpt :: R.Component Props
explorerCpt :: R.Component Props
explorerCpt = R.hooksComponent "G.C.GraphExplorer.explorer" cpt
explorerCpt = R.hooksComponent "G.C.GraphExplorer.explorer" cpt
where
where
cpt {sessions, session, graphId, mCurrentRoute, treeId, graph, frontends} _ = do
cpt {
graphElRef,
sessions, session, graphId, mCurrentRoute, treeId, graph, frontends} _ = do
controls <- Controls.useGraphControls
controls <- Controls.useGraphControls
state <- useExplorerState
state <- useExplorerState
x /\ setX <- R.useState' 0
x /\ setX <- R.useState' 0
...
@@ -80,7 +87,7 @@ explorerCpt = R.hooksComponent "G.C.GraphExplorer.explorer" cpt
...
@@ -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)) ]
, RH.div {on: {click: \e -> setX $ \x_ -> x_ + 1}} [ RH.text ("Counter: " <> (show x)) ]
]
]
, row [ tree {mCurrentRoute, treeId} controls showLogin
, row [ tree {mCurrentRoute, treeId} controls showLogin
, mGraph controls.sigmaRef {graphId, graph}
, mGraph
graphElRef
controls.sigmaRef {graphId, graph}
, Sidebar.sidebar {showSidePanel: fst controls.showSidePanel} ]
, Sidebar.sidebar {showSidePanel: fst controls.showSidePanel} ]
, row [
, row [
]
]
...
@@ -103,9 +110,9 @@ explorerCpt = R.hooksComponent "G.C.GraphExplorer.explorer" cpt
...
@@ -103,9 +110,9 @@ explorerCpt = R.hooksComponent "G.C.GraphExplorer.explorer" cpt
pullLeft = RH.div { className: "pull-left" }
pullLeft = RH.div { className: "pull-left" }
pullRight = RH.div { className: "pull-right" }
pullRight = RH.div { className: "pull-right" }
mGraph :: R.Ref Sigma -> {graphId :: GraphId, graph :: Maybe Graph.Graph} -> R.Element
mGraph :: R.Ref
(Nullable Element) -> R.Ref
Sigma -> {graphId :: GraphId, graph :: Maybe Graph.Graph} -> R.Element
mGraph _ {graph: Nothing} = RH.div {} []
mGraph _
_
{graph: Nothing} = RH.div {} []
mGraph
sigmaRef {graphId, graph: Just graph} = graphView
sigmaRef {graphId, graph}
mGraph
graphElRef sigmaRef {graphId, graph: Just graph} = graphView graphElRef
sigmaRef {graphId, graph}
useExplorerState :: R.Hooks (Record GET.State)
useExplorerState :: R.Hooks (Record GET.State)
useExplorerState = do pure {}
useExplorerState = do pure {}
...
@@ -130,9 +137,9 @@ type GraphProps = (
...
@@ -130,9 +137,9 @@ type GraphProps = (
, graph :: Graph.Graph
, 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 (R.memo el memoCmp) props []
graphView sigmaRef props = R.createElement el props []
graphView
elRef
sigmaRef props = R.createElement el props []
where
where
--memoCmp props1 props2 = props1.graphId == props2.graphId
--memoCmp props1 props2 = props1.graphId == props2.graphId
el = R.hooksComponent "GraphView" cpt
el = R.hooksComponent "GraphView" cpt
...
@@ -141,7 +148,8 @@ graphView sigmaRef props = R.createElement el props []
...
@@ -141,7 +148,8 @@ graphView sigmaRef props = R.createElement el props []
RH.div { id: "graph-view", className: "col-md-12" }
RH.div { id: "graph-view", className: "col-md-12" }
[
[
Graph.graph {
Graph.graph {
forceAtlas2Settings: Graph.forceAtlas2Settings
elRef
, forceAtlas2Settings: Graph.forceAtlas2Settings
, graph
, graph
, sigmaSettings: Graph.sigmaSettings
, sigmaSettings: Graph.sigmaSettings
, sigmaRef: sigmaRef
, sigmaRef: sigmaRef
...
...
src/Gargantext/Components/GraphExplorer/Controls.purs
View file @
9c4af297
...
@@ -83,16 +83,16 @@ controlsCpt = R.hooksComponent "GraphControls" cpt
...
@@ -83,16 +83,16 @@ controlsCpt = R.hooksComponent "GraphControls" cpt
--R.useEffect $ handleForceAtlasPause props.sigmaRef localControls.pauseForceAtlas mFAPauseRef
--R.useEffect $ handleForceAtlasPause props.sigmaRef localControls.pauseForceAtlas mFAPauseRef
R.useEffect $ handleForceAtlasPause props.sigmaRef localControls.pauseForceAtlas
R.useEffect $ handleForceAtlasPause props.sigmaRef localControls.pauseForceAtlas
R.useEffectOnce' $ do
--
R.useEffectOnce' $ do
timeoutId <- setTimeout 2000 $ do
--
timeoutId <- setTimeout 2000 $ do
--R.setRef mFAPauseRef Nothing
--
--R.setRef mFAPauseRef Nothing
let (toggled /\ setToggled) = localControls.pauseForceAtlas
--
let (toggled /\ setToggled) = localControls.pauseForceAtlas
if toggled then
--
if toggled then
setToggled $ const false
--
setToggled $ const false
else
--
else
pure unit
--
pure unit
--R.setRef mFAPauseRef $ Just timeoutId
--
--R.setRef mFAPauseRef $ Just timeoutId
pure unit
--
pure unit
pure $ case getShowControls props of
pure $ case getShowControls props of
false -> RH.div {} []
false -> RH.div {} []
...
@@ -121,10 +121,10 @@ controlsCpt = R.hooksComponent "GraphControls" cpt
...
@@ -121,10 +121,10 @@ controlsCpt = R.hooksComponent "GraphControls" cpt
where
where
--handleForceAtlasPause sigmaRef (toggled /\ setToggled) mFAPauseRef = do
--handleForceAtlasPause sigmaRef (toggled /\ setToggled) mFAPauseRef = do
handleForceAtlasPause sigmaRef (toggled /\ setToggled) = do
handleForceAtlasPause sigmaRef (toggled /\ setToggled) = do
let mSigma = Sigmax.readSigma $ R.readRef sigmaRef
let sigma = R.readRef sigmaRef
pure $ case mSigma of
pure $ Sigmax.dependOnSigma sigma "[handleForceAtlasPause] sigma: Nothing" $ \s -> do
Just s -> do
log2 "[handleForceAtlasPause] mSigma: Just " s
log2 "[handleForceAtlasPause] mSigma: Just " s
log2 "[handleForceAtlasPause] toggled: " toggled
if toggled then
if toggled then
Sigma.stopForceAtlas2 s
Sigma.stopForceAtlas2 s
else
else
...
@@ -135,9 +135,6 @@ controlsCpt = R.hooksComponent "GraphControls" cpt
...
@@ -135,9 +135,6 @@ controlsCpt = R.hooksComponent "GraphControls" cpt
-- Just timeoutId -> do
-- Just timeoutId -> do
-- R.setRef mFAPauseRef Nothing
-- R.setRef mFAPauseRef Nothing
-- clearTimeout timeoutId
-- 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/Hooks/Sigmax.purs
View file @
9c4af297
...
@@ -229,23 +229,25 @@ startSigmaEff ref sigmaRef settings forceAtlas2Settings graph = do
...
@@ -229,23 +229,25 @@ startSigmaEff ref sigmaRef settings forceAtlas2Settings graph = do
useForceAtlas2Eff sigma forceAtlas2Settings
useForceAtlas2Eff sigma forceAtlas2Settings
Just sig -> do
Just sig -> do
log "[startSigmaEff] sigma initialized already"
log "[startSigmaEff] sigma initialized already"
isFARunning <- Sigma.isForceAtlas2Running sig
log2 "[startSigmaEff] isFARunning" isFARunning
useCanvasRendererEff ref rSigma
useCanvasRendererEff ref rSigma
--useDataEff rSigma graph
--useDataEff rSigma graph
--useForceAtlas2Eff rSigma forceAtlas2Settings
--useForceAtlas2Eff rSigma forceAtlas2Settings
log "[startSigmaEff] refreshForceAtlas"
Sigma.refreshForceAtlas sig
Sigma.refreshForceAtlas sig
--if isFARunning then
-- Sigma.restartForceAtlas2 sig
--else
-- Sigma.stopForceAtlas2 sig
pure unit
pure unit
--handleRefresh sigma
--handleRefresh sigma
where
where
handleRefresh :: Sigma -> Effect Unit
handleRefresh :: Sigma -> Effect Unit
handleRefresh sigma = do
handleRefresh sigma = dependOnSigma sigma "[handleRefresh] can't refresh" $ \s -> do
let rSigma = readSigma sigma
_ <- case rSigma of
Nothing -> log2 "[handleRefresh] can't refresh" sigma
Just s -> do
Sigma.refreshForceAtlas s
Sigma.refreshForceAtlas s
pure unit
useSigmaEff :: forall settings. settings -> R.Ref Sigma -> Effect Sigma
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