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
c6a70666
Commit
c6a70666
authored
Dec 11, 2018
by
Sudhir Kumar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change in graph layout
parent
e01b3e3a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
3 deletions
+28
-3
Graph.purs
src/Gargantext/Pages/Corpus/Graph.purs
+28
-3
No files found.
src/Gargantext/Pages/Corpus/Graph.purs
View file @
c6a70666
...
@@ -13,16 +13,18 @@ import Data.Array (fold, length, mapWithIndex, (!!))
...
@@ -13,16 +13,18 @@ import Data.Array (fold, 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.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 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.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(..), Edge(..), GraphData(..), Legend(..), Node(..), getLegendData)
import Gargantext.Components.GraphExplorer.Types (Cluster(..), Edge(..), GraphData(..), Legend(..), Node(..), getLegendData)
import Gargantext.Components.Login.Types (TreeId)
import Gargantext.Components.Login.Types (
AuthData(..),
TreeId)
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)
...
@@ -34,6 +36,9 @@ import React.DOM (a, br', button, div, form', input, li, li', menu, option, p, s
...
@@ -34,6 +36,9 @@ import React.DOM (a, br', button, div, form', input, li, li', menu, option, p, s
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, cmapProps, createClass, defaultPerformAction, defaultRender, modifyState, noState, simpleSpec, withState)
import Thermite (PerformAction, Render, Spec, cmapProps, createClass, defaultPerformAction, defaultRender, modifyState, noState, simpleSpec, withState)
import Unsafe.Coerce (unsafeCoerce)
import Unsafe.Coerce (unsafeCoerce)
import Web.HTML (window)
import Web.HTML.Window (localStorage)
import Web.Storage.Storage (getItem)
data Action
data Action
...
@@ -97,9 +102,16 @@ performAction (LoadGraph fp) _ _ = void do
...
@@ -97,9 +102,16 @@ performAction (LoadGraph fp) _ _ = void do
_ <- logs fp
_ <- logs fp
_ <- modifyState \(State s) -> State s {corpusId = fp, sigmaGraphData = Nothing}
_ <- modifyState \(State s) -> State s {corpusId = fp, sigmaGraphData = Nothing}
resp <- lift $ getNodes fp
resp <- lift $ getNodes fp
treeResp <- liftEffect $ getAuthData
case treeResp of
Just (AuthData {token,tree_id }) ->
modifyState \(State s) -> State s {graphData = resp, sigmaGraphData = Just $ convert resp, legendData = getLegendData resp, treeId = Just tree_id}
Nothing ->
modifyState identity
--modifyState \(State s) -> State s { graphData = resp, sigmaGraphData = Just $ convert resp, legendData = getLegendData resp, treeId = Just 998769}
-- TODO: here one might `catchError getNodes` to visually empty the
-- TODO: here one might `catchError getNodes` to visually empty the
-- 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) = void do
performAction (SelectNode (SelectedNode node)) _ (State state) = void do
_ <- modifyState $ \(State s) -> State s {selectedNode = pure $ SelectedNode node}
_ <- modifyState $ \(State s) -> State s {selectedNode = pure $ SelectedNode node}
...
@@ -304,7 +316,7 @@ dispLegend ary = div [] $ map dl ary
...
@@ -304,7 +316,7 @@ dispLegend ary = div [] $ map dl ary
specOld :: Spec State {} Action
specOld :: Spec State {} Action
specOld = fold [simpleSpec performAction render']
specOld = fold [
treeSpec,
simpleSpec performAction render']
where
where
treeSpec :: Spec State {} Action
treeSpec :: Spec State {} Action
treeSpec = withState \(State st) ->
treeSpec = withState \(State st) ->
...
@@ -582,3 +594,16 @@ getUrl :: String
...
@@ -582,3 +594,16 @@ getUrl :: String
getUrl = back.baseUrl <> back.prePath
getUrl = back.baseUrl <> back.prePath
where
where
back = Config.endConfig.back
back = Config.endConfig.back
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