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
7a74bebd
Commit
7a74bebd
authored
Dec 20, 2018
by
Sudhir Kumar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
multi node
parent
80ba4297
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
15 deletions
+33
-15
Graph.purs
src/Gargantext/Pages/Corpus/Graph.purs
+33
-15
No files found.
src/Gargantext/Pages/Corpus/Graph.purs
View file @
7a74bebd
...
@@ -9,24 +9,24 @@ import Affjax.ResponseFormat as ResponseFormat
...
@@ -9,24 +9,24 @@ import Affjax.ResponseFormat as ResponseFormat
import Control.Monad.Cont.Trans (lift)
import Control.Monad.Cont.Trans (lift)
import Data.Argonaut (class DecodeJson, class EncodeJson, decodeJson, jsonEmptyObject, (.?), (.??), (:=), (~>))
import Data.Argonaut (class DecodeJson, class EncodeJson, decodeJson, jsonEmptyObject, (.?), (.??), (:=), (~>))
import Data.Argonaut (decodeJson)
import Data.Argonaut (decodeJson)
import Data.Array (
fold
, length, mapWithIndex, (!!))
import Data.Array (
difference, fold, insert, intersect
, length, mapWithIndex, (!!))
import Data.Either (Either(..))
import Data.Either (Either(..))
import Data.HTTP.Method (Method(..))
import Data.HTTP.Method (Method(..))
import Data.Int (fromString, toNumber)
import Data.Int (fromString, toNumber)
import Data.Int as Int
import Data.Int as Int
import Data.Lens (over)
import Data.Maybe (Maybe(..), fromJust, fromMaybe)
import Data.Maybe (Maybe(..), fromJust, fromMaybe)
import Data.Newtype (class Newtype)
import Data.Newtype (class Newtype)
import Data.String (joinWith)
import Data.String (joinWith)
import Data.Lens (over)
import Effect (Effect)
import Effect (Effect)
import Effect.Aff (Aff, attempt)
import Effect.Aff (Aff, attempt)
import Effect.Aff.Class (liftAff)
import Effect.Aff.Class (liftAff)
import Effect.Class (liftEffect)
import Effect.Class (liftEffect)
import Effect.Console (log)
import Effect.Console (log)
import Gargantext.Components.RandomText (words)
import Gargantext.Components.GraphExplorer.Sigmajs (Color(Color), SigmaEasing, SigmaGraphData(SigmaGraphData), SigmaNode, SigmaSettings, canvas, edgeShape, edgeShapes, forceAtlas2, sStyle, sigma, sigmaEasing, sigmaEdge, sigmaEnableWebGL, sigmaNode, sigmaSettings)
import Gargantext.Components.GraphExplorer.Sigmajs (Color(Color), SigmaEasing, SigmaGraphData(SigmaGraphData), SigmaNode, SigmaSettings, canvas, edgeShape, edgeShapes, forceAtlas2, sStyle, sigma, sigmaEasing, sigmaEdge, sigmaEnableWebGL, sigmaNode, sigmaSettings)
import Gargantext.Components.GraphExplorer.Types (Cluster(..), MetaData(..),Edge(..), GraphData(..), Legend(..), Node(..), getLegendData)
import Gargantext.Components.GraphExplorer.Types (Cluster(..), MetaData(..),
Edge(..), GraphData(..), Legend(..), Node(..), getLegendData)
import Gargantext.Components.Login.Types (AuthData(..), TreeId)
import Gargantext.Components.Login.Types (AuthData(..), TreeId)
import Gargantext.Components.RandomText (words)
import Gargantext.Components.Tree as Tree
import Gargantext.Components.Tree as Tree
import Gargantext.Config as Config
import Gargantext.Config as Config
import Gargantext.Config.REST (get, post)
import Gargantext.Config.REST (get, post)
...
@@ -35,15 +35,14 @@ import Gargantext.Utils (getter)
...
@@ -35,15 +35,14 @@ import Gargantext.Utils (getter)
import Math (cos, sin)
import Math (cos, sin)
import Partial.Unsafe (unsafePartial)
import Partial.Unsafe (unsafePartial)
import React (ReactElement)
import React (ReactElement)
import React.DOM (a, br', h2,button, div, form', input, li, li', menu, option, p, select, span, text, ul, ul')
import React.DOM (a, br', h2,
button, div, form', input, li, li', menu, option, p, select, span, text, ul, ul')
import React.DOM.Props (_id, _type, checked, className, href, name, onChange, onClick, placeholder, style, title, value)
import React.DOM.Props (_id, _type, checked, className, href, name, onChange, onClick, placeholder, style, title, value)
import Thermite (PerformAction, Render, Spec, _render,cmapProps, createClass, defaultPerformAction, defaultRender, modifyState, modifyState_, noState, simpleSpec, withState)
import Thermite (PerformAction, Render, Spec, _render,
cmapProps, createClass, defaultPerformAction, defaultRender, modifyState, modifyState_, noState, simpleSpec, withState)
import Unsafe.Coerce (unsafeCoerce)
import Unsafe.Coerce (unsafeCoerce)
import Web.HTML (window)
import Web.HTML (window)
import Web.HTML.Window (localStorage)
import Web.HTML.Window (localStorage)
import Web.Storage.Storage (getItem)
import Web.Storage.Storage (getItem)
data Action
data Action
= LoadGraph Int
= LoadGraph Int
| SelectNode SelectedNode
| SelectNode SelectedNode
...
@@ -55,13 +54,18 @@ newtype SelectedNode = SelectedNode {id :: String, label :: String}
...
@@ -55,13 +54,18 @@ newtype SelectedNode = SelectedNode {id :: String, label :: String}
derive instance eqSelectedNode :: Eq SelectedNode
derive instance eqSelectedNode :: Eq SelectedNode
derive instance newtypeSelectedNode :: Newtype SelectedNode _
derive instance newtypeSelectedNode :: Newtype SelectedNode _
derive instance ordSelectedNode :: Ord SelectedNode
instance showSelectedNode :: Show SelectedNode where
show (SelectedNode node) = node.label
newtype State = State
newtype State = State
{ graphData :: GraphData
{ graphData :: GraphData
, filePath :: String
, filePath :: String
, sigmaGraphData :: Maybe SigmaGraphData
, sigmaGraphData :: Maybe SigmaGraphData
, legendData :: Array Legend
, legendData :: Array Legend
, selectedNode
:: Maybe
SelectedNode
, selectedNode
s :: Array
SelectedNode
, showSidePanel :: Boolean
, showSidePanel :: Boolean
, showControls :: Boolean
, showControls :: Boolean
, showTree :: Boolean
, showTree :: Boolean
...
@@ -75,7 +79,7 @@ initialState = State
...
@@ -75,7 +79,7 @@ initialState = State
, filePath : ""
, filePath : ""
, sigmaGraphData : Nothing
, sigmaGraphData : Nothing
, legendData : []
, legendData : []
, selectedNode
: Nothing
, selectedNode
s : []
, showSidePanel : false
, showSidePanel : false
, showControls : false
, showControls : false
, showTree : false
, showTree : false
...
@@ -101,8 +105,15 @@ performAction (LoadGraph fp) _ _ = void do
...
@@ -101,8 +105,15 @@ performAction (LoadGraph fp) _ _ = void do
-- graph.
-- graph.
--modifyState \(State s) -> State s {graphData = resp, sigmaGraphData = Just $ convert resp, legendData = getLegendData resp}
--modifyState \(State s) -> State s {graphData = resp, sigmaGraphData = Just $ convert resp, legendData = getLegendData resp}
performAction (SelectNode (SelectedNode node)) _ (State state) =
performAction (SelectNode selectedNode@(SelectedNode node)) _ (State state) =
modifyState_ $ \(State s) -> State s {selectedNode = pure $ SelectedNode node}
modifyState_ $ \(State s) -> State s {selectedNodes = updateSet s.selectedNodes selectedNode}
where
updateSet :: Array SelectedNode -> SelectedNode -> Array SelectedNode
updateSet ary node =
if length (intersect ary [node]) > 0 then
difference ary [node]
else
insert node ary
performAction (ShowSidePanel b) _ (State state) = void do
performAction (ShowSidePanel b) _ (State state) = void do
modifyState $ \(State s) -> State s {showSidePanel = b }
modifyState $ \(State s) -> State s {showSidePanel = b }
...
@@ -541,10 +552,14 @@ specOld = fold [treespec treeSpec, graphspec $ simpleSpec performAction render']
...
@@ -541,10 +552,14 @@ specOld = fold [treespec treeSpec, graphspec $ simpleSpec performAction render']
[ div []
[ div []
[ p [] []
[ p [] []
, div [className "col-md-12"]
, div [className "col-md-12"]
[ case st.selectedNode of
[ if length st.selectedNodes > 0 then
Just (SelectedNode {label}) ->
p [] [text $ printSet st.selectedNodes] -- handle list of labels!
GT.tabsElt {query: words label, sides}
--GT.tabsElt {query: show <$> st.selectedNodes, sides}
Nothing -> p [] []
else
p [] []
-- Just (SelectedNode {label}) ->
-- Nothing -> p [] []
, p [] []
, p [] []
]
]
]
]
...
@@ -556,6 +571,9 @@ specOld = fold [treespec treeSpec, graphspec $ simpleSpec performAction render']
...
@@ -556,6 +571,9 @@ specOld = fold [treespec treeSpec, graphspec $ simpleSpec performAction render']
]
]
]
]
printSet :: Array SelectedNode -> String
printSet set = joinWith ", " $ show <$> set
getNodes :: Int -> Aff GraphData
getNodes :: Int -> Aff GraphData
getNodes graphId = get $ Config.toUrl Config.Back Config.Graph $ Just graphId
getNodes graphId = get $ Config.toUrl Config.Back Config.Graph $ Just graphId
...
...
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