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
e77d53ff
Commit
e77d53ff
authored
Dec 10, 2019
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Graph] some refactoring of graph explorer code
Eg. unnecessary Maybe types removed.
parent
a411ad1d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
42 deletions
+33
-42
GraphExplorer.purs
src/Gargantext/Components/GraphExplorer.purs
+24
-38
Controls.purs
src/Gargantext/Components/GraphExplorer/Controls.purs
+9
-4
No files found.
src/Gargantext/Components/GraphExplorer.purs
View file @
e77d53ff
...
...
@@ -47,7 +47,7 @@ type LayoutProps =
)
type Props = (
graph ::
Maybe
Graph.Graph
graph :: Graph.Graph
, mMetaData :: Maybe GET.MetaData
| LayoutProps
)
...
...
@@ -64,7 +64,7 @@ explorerLayoutCpt = R.hooksComponent "G.C.GraphExplorer.explorerLayout" cpt
where
handler loaded =
explorer { graphId, mCurrentRoute, mMetaData
, session, sessions, graph
: Just graph
, frontends, showLogin}
, session, sessions, graph, frontends, showLogin}
where (Tuple mMetaData graph) = convert loaded
--------------------------------------------------------------
...
...
@@ -77,19 +77,19 @@ explorerCpt = R.hooksComponent "G.C.GraphExplorer.explorer" cpt
cpt {frontends, graph, graphId, mCurrentRoute, mMetaData, session, sessions, showLogin} _ = do
dataRef <- R.useRef graph
graphRef <- R.useRef null
controls <- Controls.useGraphControls
controls <- Controls.useGraphControls
graph
R.useEffect' $ do
case Tuple (R.readRef dataRef) graph o
f
Tuple Nothing Nothing -> pure unit
Tuple (Just g1) (Just g2) | SigmaxTypes.eqGraph g1 g2 ->
pure unit
_ ->
do
let rSigma = R.readRef controls.sigmaRef
Sigmax.cleanupSigma rSigma "explorerCpt"
R.setRef dataRef graph
snd controls.selectedEdgeIds $ const Set.empty
snd controls.selectedNodeIds $ const Set.empty
snd controls.graphStage $ const Graph.Init
let readData = R.readRef dataRe
f
if SigmaxTypes.eqGraph readData graph then
pure unit
else
do
let rSigma = R.readRef controls.sigmaRef
Sigmax.cleanupSigma rSigma "explorerCpt"
R.setRef dataRef graph
snd controls.selectedEdgeIds $ const Set.empty
snd controls.selectedNodeIds $ const Set.empty
snd controls.graphStage $ const Graph.Init
pure $
RH.div
...
...
@@ -105,15 +105,15 @@ explorerCpt = R.hooksComponent "G.C.GraphExplorer.explorer" cpt
, row [ Controls.controls controls ]
, row [ tree (fst controls.showTree) {sessions, mCurrentRoute, frontends} (snd showLogin)
, RH.div { ref: graphRef, id: "graph-view", className: graphClassName controls, style: {height: "95%"} } [] -- graph container
,
mGraph
{ controls
, elRef: graphRef
, graphId
, graph
, graphStage: controls.graphStage
, selectedEdgeIds: controls.selectedEdgeIds
, selectedNodeIds: controls.selectedNodeIds
, sigmaRef: controls.sigmaRef
}
,
graphView
{ controls
, elRef: graphRef
, graphId
, graph
, graphStage: controls.graphStage
, selectedEdgeIds: controls.selectedEdgeIds
, selectedNodeIds: controls.selectedNodeIds
, sigmaRef: controls.sigmaRef
}
, mSidebar graph mMetaData { frontends
, session
, selectedNodeIds: controls.selectedNodeIds
...
...
@@ -150,29 +150,15 @@ explorerCpt = R.hooksComponent "G.C.GraphExplorer.explorer" cpt
RH.div {className: "col-md-2", style: {paddingTop: "60px"}}
[forest {sessions, route, frontends, showLogin}]
mGraph :: { controls :: Record Controls.Controls
, elRef :: R.Ref (Nullable Element)
, graphId :: GraphId
, graph :: Maybe Graph.Graph
, graphStage :: R.State Graph.Stage
, selectedNodeIds :: R.State SigmaxTypes.SelectedNodeIds
, selectedEdgeIds :: R.State SigmaxTypes.SelectedEdgeIds
, sigmaRef :: R.Ref Sigmax.Sigma
}
-> R.Element
mGraph {graph: Nothing} = RH.div {} []
mGraph r@{graph: Just graph} = graphView $ r { graph = graph }
mSidebar :: Maybe Graph.Graph
mSidebar :: Graph.Graph
-> Maybe GET.MetaData
-> { frontends :: Frontends
, showSidePanel :: GET.SidePanelState
, selectedNodeIds :: R.State SigmaxTypes.SelectedNodeIds
, session :: Session }
-> R.Element
mSidebar Nothing _ _ = RH.div {} []
mSidebar _ Nothing _ = RH.div {} []
mSidebar
(Just graph)
(Just metaData) {frontends, session, selectedNodeIds, showSidePanel} =
mSidebar
graph
(Just metaData) {frontends, session, selectedNodeIds, showSidePanel} =
Sidebar.sidebar { frontends
, graph
, metaData
...
...
src/Gargantext/Components/GraphExplorer/Controls.purs
View file @
e77d53ff
...
...
@@ -23,6 +23,7 @@ import Reactix.DOM.HTML as RH
import Gargantext.Components.Graph as Graph
import Gargantext.Components.GraphExplorer.Button (centerButton)
import Gargantext.Components.GraphExplorer.RangeControl (edgeSizeControl, nodeSizeControl)
import Gargantext.Components.GraphExplorer.Search (nodeSearchControl)
import Gargantext.Components.GraphExplorer.SlideButton (cursorSizeButton, labelSizeButton)
import Gargantext.Components.GraphExplorer.ToggleButton (edgesToggleButton, pauseForceAtlasButton)
import Gargantext.Components.GraphExplorer.Types as GET
...
...
@@ -33,11 +34,12 @@ import Gargantext.Utils.Reactix as R2
type Controls =
( cursorSize :: R.State Number
, graph :: Graph.Graph
, graphStage :: R.State Graph.Stage
, multiNodeSelect :: R.Ref Boolean
, nodeSize :: R.State Range.NumberRange
, selectedEdgeIds :: R.State
(Set.Set String)
, selectedNodeIds :: R.State
(Set.Set String)
, selectedEdgeIds :: R.State
SigmaxTypes.SelectedEdgeIds
, selectedNodeIds :: R.State
SigmaxTypes.SelectedNodeIds
, showControls :: R.State Boolean
, showSidePanel :: R.State GET.SidePanelState
, showTree :: R.State Boolean
...
...
@@ -60,6 +62,7 @@ initialLocalControls = do
labelSize <- R.useState' 14.0
--nodeSize <- R.useState' $ Range.Closed { min: 0.0, max: 10.0 }
pauseForceAtlas <- R.useState' true
search <- R.useState' ""
showEdges <- R.useState' true
pure $ {
...
...
@@ -128,12 +131,13 @@ controlsCpt = R.hooksComponent "GraphControls" cpt
-- zoom: 0 -100 - calculate ratio
-- toggle multi node selection
-- save button
, RH.li {} [ nodeSearchControl { selectedNodeIds: props.selectedNodeIds } ]
]
]
]
useGraphControls :: R.Hooks (Record Controls)
useGraphControls = do
useGraphControls ::
Graph.Graph ->
R.Hooks (Record Controls)
useGraphControls
graph
= do
cursorSize <- R.useState' 10.0
graphStage <- R.useState' Graph.Init
multiNodeSelect <- R.useRef false
...
...
@@ -147,6 +151,7 @@ useGraphControls = do
sigmaRef <- R.useRef sigma
pure { cursorSize
, graph
, graphStage
, multiNodeSelect
, nodeSize
...
...
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