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
ab4137eb
Commit
ab4137eb
authored
Aug 08, 2019
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Graph] GraphExplorer modifications
parent
1df15338
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
26 deletions
+34
-26
GraphExplorer.purs
src/Gargantext/Components/GraphExplorer.purs
+34
-26
No files found.
src/Gargantext/Components/GraphExplorer.purs
View file @
ab4137eb
...
@@ -30,6 +30,7 @@ import Gargantext.Components.GraphExplorer.Controls as Controls
...
@@ -30,6 +30,7 @@ import Gargantext.Components.GraphExplorer.Controls as Controls
import Gargantext.Components.GraphExplorer.Legend (legend)
import Gargantext.Components.GraphExplorer.Legend (legend)
import Gargantext.Components.GraphExplorer.ToggleButton as Toggle
import Gargantext.Components.GraphExplorer.ToggleButton as Toggle
import Gargantext.Components.Graph as Graph
import Gargantext.Components.Graph as Graph
import Gargantext.Components.Loader2 as Loader
import Gargantext.Components.Login.Types (AuthData(..), TreeId)
import Gargantext.Components.Login.Types (AuthData(..), TreeId)
import Gargantext.Components.RandomText (words)
import Gargantext.Components.RandomText (words)
import Gargantext.Components.Tree as Tree
import Gargantext.Components.Tree as Tree
...
@@ -49,8 +50,11 @@ import Web.Storage.Storage (getItem)
...
@@ -49,8 +50,11 @@ import Web.Storage.Storage (getItem)
import Reactix as R
import Reactix as R
import Reactix.DOM.HTML as RH
import Reactix.DOM.HTML as RH
type GraphId = Int
type Props = (
type Props = (
mCurrentRoute :: Maybe Routes
graphId :: GraphId
, mCurrentRoute :: Maybe Routes
, treeId :: Maybe Int
, treeId :: Maybe Int
)
)
...
@@ -76,7 +80,7 @@ explorer state props = R.createElement (explorerCpt state) props []
...
@@ -76,7 +80,7 @@ explorer state props = R.createElement (explorerCpt state) props []
--explorerCpt :: GET.State -> R.Component Props
--explorerCpt :: GET.State -> R.Component Props
explorerCpt state = R.hooksComponent "GraphExplorer" cpt
explorerCpt state = R.hooksComponent "GraphExplorer" cpt
where
where
cpt {mCurrentRoute, treeId} _ = do
cpt {
graphId,
mCurrentRoute, treeId} _ = do
controls <- Controls.useGraphControls
controls <- Controls.useGraphControls
pure $
pure $
row
row
...
@@ -89,7 +93,7 @@ explorerCpt state = R.hooksComponent "GraphExplorer" cpt
...
@@ -89,7 +93,7 @@ explorerCpt state = R.hooksComponent "GraphExplorer" cpt
, col [ pullRight [ Toggle.sidebarToggleButton controls.showSidePanel ] ]
, col [ pullRight [ Toggle.sidebarToggleButton controls.showSidePanel ] ]
]
]
, row [ Controls.controls controls ]
, row [ Controls.controls controls ]
, row [ tree {mCurrentRoute, treeId} controls, graph controls, sidebar controls ]
, row [ tree {mCurrentRoute, treeId} controls, graph
Loader graphId
controls, sidebar controls ]
, row [ ]
, row [ ]
]
]
]
]
...
@@ -105,9 +109,32 @@ explorerCpt state = R.hooksComponent "GraphExplorer" cpt
...
@@ -105,9 +109,32 @@ explorerCpt state = R.hooksComponent "GraphExplorer" cpt
tree {treeId: Nothing} _ = RH.div {} []
tree {treeId: Nothing} _ = RH.div {} []
tree _ {showTree: false /\ _} = RH.div {} []
tree _ {showTree: false /\ _} = RH.div {} []
tree {mCurrentRoute, treeId: Just treeId} _ = RH.div {} [ Tree.elTreeview {mCurrentRoute, root: treeId} ]
tree {mCurrentRoute, treeId: Just treeId} _ = RH.div {} [ Tree.elTreeview {mCurrentRoute, root: treeId} ]
graph _ = RH.div {} []
sidebar _ = RH.div {} []
sidebar _ = RH.div {} []
graphLoader :: GraphId -> Record Controls.Controls -> R.Element
graphLoader graphId controls = R.createElement el {} []
where
el = R.hooksComponent "GraphLoader" cpt
cpt {} _children = do
Loader.useLoader graphId getNodes $ \{loaded} ->
loadedGraphView controls {graphId, graph: convert loaded}
type GraphProps = (
graphId :: GraphId
, graph :: Graph.Graph
)
loadedGraphView :: Record Controls.Controls -> Record GraphProps -> R.Element
loadedGraphView controls props = R.createElement el props []
where
el = R.hooksComponent "GraphView" cpt
cpt {graphId, graph} _children = do
pure $ Graph.graph {
graph
, sigmaSettings: Graph.sigmaSettings
, forceAtlas2Settings: Graph.forceAtlas2Settings
}
convert :: GET.GraphData -> Graph.Graph
convert :: GET.GraphData -> Graph.Graph
convert (GET.GraphData r) = Sigmax.Graph {nodes, edges}
convert (GET.GraphData r) = Sigmax.Graph {nodes, edges}
where
where
...
@@ -119,7 +146,7 @@ convert (GET.GraphData r) = Sigmax.Graph {nodes, edges}
...
@@ -119,7 +146,7 @@ convert (GET.GraphData r) = Sigmax.Graph {nodes, edges}
, label : n.label
, label : n.label
, x : n.x -- cos (toNumber i)
, x : n.x -- cos (toNumber i)
, y : n.y -- sin (toNumber i)
, y : n.y -- sin (toNumber i)
, color : intColor (cDef n.attributes)
, color :
GET.
intColor (cDef n.attributes)
}
}
where
where
cDef (GET.Cluster {clustDefault}) = clustDefault
cDef (GET.Cluster {clustDefault}) = clustDefault
...
@@ -133,24 +160,5 @@ defaultPalette = ["#5fa571","#ab9ba2","#da876d","#bdd3ff","#b399df","#ffdfed","#
...
@@ -133,24 +160,5 @@ defaultPalette = ["#5fa571","#ab9ba2","#da876d","#bdd3ff","#b399df","#ffdfed","#
-- clusterColor (Cluster {clustDefault}) = unsafePartial $ fromJust $ defaultPalette !! (clustDefault `mod` length defaultPalette)
-- clusterColor (Cluster {clustDefault}) = unsafePartial $ fromJust $ defaultPalette !! (clustDefault `mod` length defaultPalette)
intColor :: Int -> String
getNodes :: GraphId -> Aff GET.GraphData
intColor i = unsafePartial $ fromJust $ defaultPalette !! (i `mod` length defaultPalette)
getNodes :: Int -> Aff GET.GraphData
getNodes graphId = get $ Config.toUrl Config.Back Config.Graph $ Just graphId
getNodes graphId = get $ Config.toUrl Config.Back Config.Graph $ Just graphId
\ No newline at end of file
getAuthData :: Effect (Maybe AuthData)
getAuthData = do
w <- window
ls <- localStorage w
mto <- getItem "token" ls
mti <- getItem "tree_id" ls
pure do
token <- mto
tree_id <- Int.fromString =<< mti
pure $ AuthData {token, tree_id}
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