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
71d3be64
Commit
71d3be64
authored
Nov 21, 2019
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Graph] implement crude node search on sidebar
parent
4b13b0ff
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
15 deletions
+33
-15
Graph.purs
src/Gargantext/Components/Graph.purs
+1
-0
GraphExplorer.purs
src/Gargantext/Components/GraphExplorer.purs
+17
-12
Sidebar.purs
src/Gargantext/Components/GraphExplorer/Sidebar.purs
+15
-3
No files found.
src/Gargantext/Components/Graph.purs
View file @
71d3be64
...
...
@@ -56,6 +56,7 @@ graphCpt = R.hooksComponent "Graph" cpt
Sigmax.dependOnSigma (R.readRef props.sigmaRef) "[graphCpt] no sigma" $ \sigma ->
Sigma.bindClickNode sigma $ \node -> do
log2 "[graphCpt] clickNode" node
setSelectedNodeIds \nids ->
if Set.member node.id nids then
Set.delete node.id nids
...
...
src/Gargantext/Components/GraphExplorer.purs
View file @
71d3be64
...
...
@@ -35,15 +35,17 @@ type GraphId = Int
type LayoutProps =
( graphId :: GraphId
, frontends :: Frontends
, mCurrentRoute :: AppRoute
, treeId :: Maybe Int
, session :: Session
, sessions :: Sessions
,
frontends :: Frontends
,
treeId :: Maybe Int
)
type Props = (
graph :: Maybe Graph.Graph | LayoutProps
graph :: Maybe Graph.Graph
, mMetaData :: Maybe GET.MetaData
| LayoutProps
)
--------------------------------------------------------------
...
...
@@ -57,8 +59,8 @@ explorerLayoutCpt = R.hooksComponent "G.C.GraphExplorer.explorerLayout" cpt
useLoader graphId (getNodes session) handler
where
handler loaded =
explorer {graphId, mCurrentRoute,
treeId, session, sessions,
graph, frontends}
where
graph = Just (convert loaded)
explorer {graphId, mCurrentRoute,
mMetaData, treeId, session, sessions, graph: Just
graph, frontends}
where
(Tuple mMetaData graph) = convert loaded
--------------------------------------------------------------
explorer :: Record Props -> R.Element
...
...
@@ -67,7 +69,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 {
frontends, graph, graphId, mCurrentRoute, mMetaData, session, sessions, treeId
} _ = do
graphRef <- R.useRef null
controls <- Controls.useGraphControls
state <- useExplorerState
...
...
@@ -89,7 +91,7 @@ explorerCpt = R.hooksComponent "G.C.GraphExplorer.explorer" cpt
, row [ tree {mCurrentRoute, treeId} controls showLogin
, RH.div { ref: graphRef, id: "graph-view", className: "col-md-12", style: {height: "95%"} } [] -- graph container
, mGraph graphRef controls.sigmaRef {graphId, graph, selectedNodeIds}
, mSidebar graph {session, selectedNodeIds, showSidePanel: fst controls.showSidePanel}
, mSidebar graph
mMetaData
{session, selectedNodeIds, showSidePanel: fst controls.showSidePanel}
]
, row [
]
...
...
@@ -122,13 +124,16 @@ explorerCpt = R.hooksComponent "G.C.GraphExplorer.explorer" cpt
mGraph graphRef sigmaRef {graphId, graph: Just graph, selectedNodeIds} = graphView graphRef sigmaRef {graphId, graph, selectedNodeIds}
mSidebar :: Maybe Graph.Graph
-> Maybe GET.MetaData
-> { showSidePanel :: Boolean
, selectedNodeIds :: R.State SigmaxTypes.SelectedNodeIds
, session :: Session }
-> R.Element
mSidebar Nothing _ = RH.div {} []
mSidebar (Just graph) {session, selectedNodeIds, showSidePanel} =
mSidebar Nothing _ _ = RH.div {} []
mSidebar _ Nothing _ = RH.div {} []
mSidebar (Just graph) (Just metaData) {session, selectedNodeIds, showSidePanel} =
Sidebar.sidebar { graph
, metaData
, session
, selectedNodeIds
, showSidePanel
...
...
@@ -174,8 +179,8 @@ graphView elRef sigmaRef props = R.createElement el props []
, sigmaRef: sigmaRef
}
convert :: GET.GraphData -> Graph.Graph
convert (GET.GraphData r) = SigmaxTypes.Graph {nodes, edges}
convert :: GET.GraphData ->
Tuple (Maybe GET.MetaData)
Graph.Graph
convert (GET.GraphData r) =
Tuple r.metaData $
SigmaxTypes.Graph {nodes, edges}
where
nodes = foldMapWithIndex nodeFn r.nodes
nodeFn i (GET.Node n) =
...
...
@@ -196,7 +201,7 @@ defaultPalette :: Array String
defaultPalette = ["#5fa571","#ab9ba2","#da876d","#bdd3ff","#b399df","#ffdfed","#33c8f3","#739e9a","#caeca3","#f6f7e5","#f9bcca","#ccb069","#c9ffde","#c58683","#6c9eb0","#ffd3cf","#ccffc7","#52a1b0","#d2ecff","#99fffe","#9295ae","#5ea38b","#fff0b3","#d99e68"]
-- clusterColor :: Cluster -> Color
-- clusterColor (Cluster {clustDefault}) = unsafePartial $ fromJust $ defaultPalette !! (clustDefault `mo
d` length defa
ultPalette)
-- clusterColor (Cluster {clustDefault}) = unsafePartial $ fromJust $ defaultPalette !! (clustDefault `mo
length defr
ultPalette)
-- div [className "col-md-12", style {"padding-bottom" : "10px"}]
-- [ menu [_id "toolbar"]
...
...
src/Gargantext/Components/GraphExplorer/Sidebar.purs
View file @
71d3be64
...
...
@@ -3,6 +3,7 @@ module Gargantext.Components.GraphExplorer.Sidebar
where
import Prelude
import Data.Array (head)
import Data.Map as Map
import Data.Maybe (Maybe(..))
import Data.Set as Set
...
...
@@ -13,11 +14,13 @@ import Reactix.DOM.HTML as RH
import Gargantext.Components.RandomText (words)
import Gargantext.Components.Nodes.Corpus.Graph.Tabs as GT
import Gargantext.Components.Graph as Graph
import Gargantext.Components.GraphExplorer.Types as GET
import Gargantext.Hooks.Sigmax.Types as SigmaxTypes
import Gargantext.Sessions (Session)
type Props =
( graph :: Graph.Graph
, metaData :: GET.MetaData
, selectedNodeIds :: R.State SigmaxTypes.SelectedNodeIds
, session :: Session
, showSidePanel :: Boolean
...
...
@@ -61,7 +64,7 @@ sidebarCpt = R.hooksComponent "Sidebar" cpt
]
, RH.div { className: "col-md-12", id: "query" }
[
query props.session nodesMap props.selectedNodeIds
query props.
metaData props.
session nodesMap props.selectedNodeIds
]
]
]
...
...
@@ -86,9 +89,18 @@ sidebarCpt = R.hooksComponent "Sidebar" cpt
, "complex systems"
, "wireless communications" ]
query session nodesMap (selectedNodeIds /\ _) =
GT.tabs {session, query: q <$> Set.toUnfoldable selectedNodeIds, sides: []}
query _ _ _ (selectedNodeIds /\ _) | Set.isEmpty selectedNodeIds = RH.div {} []
query (GET.MetaData metaData) session nodesMap (selectedNodeIds /\ _) =
query' (head metaData.corpusId)
where
query' Nothing = RH.div {} []
query' (Just corpusId) =
GT.tabs {session, query: q <$> Set.toUnfoldable selectedNodeIds, sides: [side corpusId]}
q id = case Map.lookup id nodesMap of
Nothing -> []
Just n -> words n.label
side corpusId = GET.GraphSideCorpus {
corpusId
, listId: metaData.listId
, corpusLabel: metaData.title
}
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