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
2c0ecaa9
Commit
2c0ecaa9
authored
Aug 23, 2024
by
Karen Konou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Graph Explorer] Add cluster button
parent
694a2d1e
Pipeline
#6527
passed with stages
in 22 minutes and 49 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
25 deletions
+53
-25
Sidebar.purs
src/Gargantext/Components/GraphExplorer/Sidebar.purs
+4
-1
Legend.purs
src/Gargantext/Components/GraphExplorer/Sidebar/Legend.purs
+49
-24
No files found.
src/Gargantext/Components/GraphExplorer/Sidebar.purs
View file @
2c0ecaa9
...
...
@@ -128,6 +128,8 @@ sideTabLegendCpt = here.component "sideTabLegend" cpt where
hyperdataGraph
<- R2.useLive' store.hyperdataGraph
legend' /\ legendBox <- R2.useBox' legend
-- | Computed
-- |
let
...
...
@@ -161,12 +163,13 @@ sideTabLegendCpt = here.component "sideTabLegend" cpt where
{ className: "graph-sidebar__legend-tab" }
[
Legend.legend
{ legendSeq: Seq.fromFoldable legend
{ legendSeq: Seq.fromFoldable legend
'
, extractedNodeList
, nodeCountList
, selectedNodeIds: store.selectedNodeIds
, session
, graphId
, legendBox
}
]
...
...
src/Gargantext/Components/GraphExplorer/Sidebar/Legend.purs
View file @
2c0ecaa9
...
...
@@ -5,14 +5,16 @@ module Gargantext.Components.GraphExplorer.Sidebar.Legend
import Prelude hiding (map)
import Control.Applicative (map)
import Data.Array (fromFoldable)
import Data.Array (fromFoldable
, snoc
)
import Data.Array as A
import Data.Foldable (length)
import Data.Maybe (isJust, maybe)
import Data.Sequence (Seq, replace)
import Data.Set as Set
import Data.Traversable (foldMap, intercalate)
import Effect (Effect)
import Effect.Aff (launchAff_)
import Effect.Class (liftEffect)
import Gargantext.Components.Bootstrap as B
import Gargantext.Components.GraphExplorer.API (updateLegend)
import Gargantext.Components.GraphExplorer.GraphTypes as GEGT
...
...
@@ -36,6 +38,7 @@ type Props =
, selectedNodeIds :: T.Box ST.NodeIds
, session :: Session
, graphId :: GET.GraphId
, legendBox :: T.Box (Array GET.Legend)
)
legend :: R2.Leaf Props
...
...
@@ -48,6 +51,7 @@ legendCpt = here.component "legend" cpt where
, selectedNodeIds
, session
, graphId
, legendBox
} _ = do
-- | Hooks
-- |
...
...
@@ -56,34 +60,47 @@ legendCpt = here.component "legend" cpt where
-- |
pure $
H.ul
{ className: "graph-legend" }
R.fragment
[
flip foldMap legendSeq \(GET.Legend { id_, label, color}) ->
H.ul
{ className: "graph-legend" }
[
flip foldMap legendSeq \(GET.Legend { id_, label, color}) ->
H.li
{ className: "graph-legend__item" }
[
H.button
{ className: "graph-legend__code"
, style: { backgroundColor: GET.intColor id_ }
, on: { click: \_ -> selectNodes id_}
}
[]
,
B.wad
[ "flex-grow-1" ]
H.li
{ className: "graph-legend__item" }
[
renameable { text: label, className: "graph-legend__label", onRename: \s -> rename s id_ color }
,
selectedNodes
{ selectedNodeIds
, extractedNodeList
, clusterId: id_
, nodeCount: getClusterNodeCount nodeCountList id_
H.button
{ className: "graph-legend__code"
, style: { backgroundColor: GET.intColor id_ }
, on: { click: \_ -> selectNodes id_}
}
[]
,
B.wad
[ "flex-grow-1" ]
[
renameable { text: label, className: "graph-legend__label", onRename: \s -> rename s id_ color }
,
selectedNodes
{ selectedNodeIds
, extractedNodeList
, clusterId: id_
, nodeCount: getClusterNodeCount nodeCountList id_
}
]
]
]
]
,
H.li
{ className: "graph-legend__item" }
[
H.button
{ className: "fa fa-plus"
, on: { click: \_ -> addCluster }
}
[]
]
]
where
rename :: String -> Int -> String -> Effect Unit
...
...
@@ -98,6 +115,14 @@ legendCpt = here.component "legend" cpt where
let nodes = filterByCluster id extractedNodeList
T.write_ (Set.fromFoldable $ map (\(GEGT.Node { id_ }) -> id_) nodes) selectedNodeIds
addCluster :: Effect Unit
addCluster = do
let newLegend = snoc (fromFoldable legendSeq) $ GET.Legend { id_: (length legendSeq) + 1, label: "Cluster" <> show ((length legendSeq) + 1), color: "#ffffff" }
launchAff_ do
_ <- updateLegend { legend: newLegend, graphId, session }
_ <- liftEffect $ T.write newLegend legendBox
pure unit
filterByCluster :: Int -> Array GEGT.Node -> Array GEGT.Node
filterByCluster id
= A.filter
...
...
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