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
Christian Merten
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
Changes
2
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
...
@@ -128,6 +128,8 @@ sideTabLegendCpt = here.component "sideTabLegend" cpt where
hyperdataGraph
hyperdataGraph
<- R2.useLive' store.hyperdataGraph
<- R2.useLive' store.hyperdataGraph
legend' /\ legendBox <- R2.useBox' legend
-- | Computed
-- | Computed
-- |
-- |
let
let
...
@@ -161,12 +163,13 @@ sideTabLegendCpt = here.component "sideTabLegend" cpt where
...
@@ -161,12 +163,13 @@ sideTabLegendCpt = here.component "sideTabLegend" cpt where
{ className: "graph-sidebar__legend-tab" }
{ className: "graph-sidebar__legend-tab" }
[
[
Legend.legend
Legend.legend
{ legendSeq: Seq.fromFoldable legend
{ legendSeq: Seq.fromFoldable legend
'
, extractedNodeList
, extractedNodeList
, nodeCountList
, nodeCountList
, selectedNodeIds: store.selectedNodeIds
, selectedNodeIds: store.selectedNodeIds
, session
, session
, graphId
, graphId
, legendBox
}
}
]
]
...
...
src/Gargantext/Components/GraphExplorer/Sidebar/Legend.purs
View file @
2c0ecaa9
...
@@ -5,14 +5,16 @@ module Gargantext.Components.GraphExplorer.Sidebar.Legend
...
@@ -5,14 +5,16 @@ module Gargantext.Components.GraphExplorer.Sidebar.Legend
import Prelude hiding (map)
import Prelude hiding (map)
import Control.Applicative (map)
import Control.Applicative (map)
import Data.Array (fromFoldable)
import Data.Array (fromFoldable
, snoc
)
import Data.Array as A
import Data.Array as A
import Data.Foldable (length)
import Data.Maybe (isJust, maybe)
import Data.Maybe (isJust, maybe)
import Data.Sequence (Seq, replace)
import Data.Sequence (Seq, replace)
import Data.Set as Set
import Data.Set as Set
import Data.Traversable (foldMap, intercalate)
import Data.Traversable (foldMap, intercalate)
import Effect (Effect)
import Effect (Effect)
import Effect.Aff (launchAff_)
import Effect.Aff (launchAff_)
import Effect.Class (liftEffect)
import Gargantext.Components.Bootstrap as B
import Gargantext.Components.Bootstrap as B
import Gargantext.Components.GraphExplorer.API (updateLegend)
import Gargantext.Components.GraphExplorer.API (updateLegend)
import Gargantext.Components.GraphExplorer.GraphTypes as GEGT
import Gargantext.Components.GraphExplorer.GraphTypes as GEGT
...
@@ -36,6 +38,7 @@ type Props =
...
@@ -36,6 +38,7 @@ type Props =
, selectedNodeIds :: T.Box ST.NodeIds
, selectedNodeIds :: T.Box ST.NodeIds
, session :: Session
, session :: Session
, graphId :: GET.GraphId
, graphId :: GET.GraphId
, legendBox :: T.Box (Array GET.Legend)
)
)
legend :: R2.Leaf Props
legend :: R2.Leaf Props
...
@@ -48,6 +51,7 @@ legendCpt = here.component "legend" cpt where
...
@@ -48,6 +51,7 @@ legendCpt = here.component "legend" cpt where
, selectedNodeIds
, selectedNodeIds
, session
, session
, graphId
, graphId
, legendBox
} _ = do
} _ = do
-- | Hooks
-- | Hooks
-- |
-- |
...
@@ -56,34 +60,47 @@ legendCpt = here.component "legend" cpt where
...
@@ -56,34 +60,47 @@ legendCpt = here.component "legend" cpt where
-- |
-- |
pure $
pure $
H.ul
R.fragment
{ className: "graph-legend" }
[
[
flip foldMap legendSeq \(GET.Legend { id_, label, color}) ->
H.ul
{ className: "graph-legend" }
[
flip foldMap legendSeq \(GET.Legend { id_, label, color}) ->
H.li
H.li
{ className: "graph-legend__item" }
{ className: "graph-legend__item" }
[
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 }
H.button
,
{ className: "graph-legend__code"
selectedNodes
, style: { backgroundColor: GET.intColor id_ }
{ selectedNodeIds
, on: { click: \_ -> selectNodes id_}
, extractedNodeList
, clusterId: id_
, nodeCount: getClusterNodeCount nodeCountList 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
where
rename :: String -> Int -> String -> Effect Unit
rename :: String -> Int -> String -> Effect Unit
...
@@ -98,6 +115,14 @@ legendCpt = here.component "legend" cpt where
...
@@ -98,6 +115,14 @@ legendCpt = here.component "legend" cpt where
let nodes = filterByCluster id extractedNodeList
let nodes = filterByCluster id extractedNodeList
T.write_ (Set.fromFoldable $ map (\(GEGT.Node { id_ }) -> id_) nodes) selectedNodeIds
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 :: Int -> Array GEGT.Node -> Array GEGT.Node
filterByCluster id
filterByCluster id
= A.filter
= 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