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
429b318a
Unverified
Commit
429b318a
authored
Feb 07, 2019
by
Mael NICOLAS
Committed by
Nicolas Pouillard
Apr 15, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[WIP] Done FFI to save camera instance
parent
0874fa1b
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
9 deletions
+30
-9
Sigmajs.js
src/Gargantext/Components/GraphExplorer/Sigmajs.js
+4
-3
Sigmajs.purs
src/Gargantext/Components/GraphExplorer/Sigmajs.purs
+11
-1
Graph.purs
src/Gargantext/Pages/Corpus/Graph.purs
+15
-5
No files found.
src/Gargantext/Components/GraphExplorer/Sigmajs.js
View file @
429b318a
...
@@ -40,8 +40,9 @@ exports.forceLinkClass = FL.default;
...
@@ -40,8 +40,9 @@ exports.forceLinkClass = FL.default;
}
}
const
myGoto
=
function
(
sigma
){
const
applyOnCamera
=
function
(
f
,
props
){
const
camera
=
sigma
.
sigma
.
cameras
[
0
];
const
camera
=
props
.
sigma
.
cameras
[
0
];
f
(
camera
);
};
};
exports
.
myGoto
=
myGoto
;
exports
.
applyOnCamera
=
applyOnCamera
;
src/Gargantext/Components/GraphExplorer/Sigmajs.purs
View file @
429b318a
...
@@ -6,6 +6,7 @@ import Data.Nullable (Nullable)
...
@@ -6,6 +6,7 @@ import Data.Nullable (Nullable)
import Effect (Effect)
import Effect (Effect)
import React (Children, ReactClass, ReactElement, ReactRef, SyntheticEventHandler, createElement, unsafeCreateElement)
import React (Children, ReactClass, ReactElement, ReactRef, SyntheticEventHandler, createElement, unsafeCreateElement)
import React.DOM.Props (Props)
import React.DOM.Props (Props)
import Thermite (EventHandler)
import Unsafe.Coerce (unsafeCoerce)
import Unsafe.Coerce (unsafeCoerce)
import Gargantext.Types (class Optional)
import Gargantext.Types (class Optional)
...
@@ -244,7 +245,16 @@ sigmaSettings :: forall o. Optional o SigmaSettingProps => { | o } -> SigmaSetti
...
@@ -244,7 +245,16 @@ sigmaSettings :: forall o. Optional o SigmaSettingProps => { | o } -> SigmaSetti
sigmaSettings = unsafeCoerce
sigmaSettings = unsafeCoerce
foreign import data SigmaStyle :: Type
foreign import data SigmaStyle :: Type
foreign import myGoto :: SyntheticEventHandler (Nullable ReactRef)
type Camera =
{
x :: Number,
y :: Number,
ratio :: Number,
angle :: Number
}
foreign import applyOnCamera :: forall a. (a -> EventHandler) -> SyntheticEventHandler (Nullable ReactRef)
type SigmaProps =
type SigmaProps =
( renderer :: Renderer
( renderer :: Renderer
...
...
src/Gargantext/Pages/Corpus/Graph.purs
View file @
429b318a
...
@@ -25,7 +25,7 @@ import Effect.Aff (Aff, attempt)
...
@@ -25,7 +25,7 @@ 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 (C
olor(Color), SigmaEasing, SigmaGraphData(SigmaGraphData), SigmaNode, SigmaSettings, canvas, edgeShape, edgeShapes, forceAtlas2, myGoto
, sStyle, sigma, sigmaEasing, sigmaEdge, sigmaEnableWebGL, sigmaNode, sigmaSettings)
import Gargantext.Components.GraphExplorer.Sigmajs (C
amera, Color(Color), SigmaEasing, SigmaGraphData(SigmaGraphData), SigmaNode, SigmaSettings, canvas, edgeShape, edgeShapes, forceAtlas2, applyOnCamera
, 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.RandomText (words)
...
@@ -55,6 +55,7 @@ data Action
...
@@ -55,6 +55,7 @@ data Action
| ChangeLabelSize Number
| ChangeLabelSize Number
| ChangeNodeSize Number
| ChangeNodeSize Number
| DisplayEdges
| DisplayEdges
| SaveCamera Camera
newtype SelectedNode = SelectedNode {id :: String, label :: String}
newtype SelectedNode = SelectedNode {id :: String, label :: String}
...
@@ -89,6 +90,9 @@ _drawEdges' = prop (SProxy :: SProxy "drawEdges")
...
@@ -89,6 +90,9 @@ _drawEdges' = prop (SProxy :: SProxy "drawEdges")
_drawEdges :: Lens' SigmaSettings Boolean
_drawEdges :: Lens' SigmaSettings Boolean
_drawEdges f = unsafeCoerce $ _drawEdges' f
_drawEdges f = unsafeCoerce $ _drawEdges' f
_camera :: forall s a. Lens' { camera :: a | s } a
_camera = prop (SProxy :: SProxy "camera")
-- TODO remove newtype here
-- TODO remove newtype here
newtype State = State
newtype State = State
...
@@ -103,6 +107,7 @@ newtype State = State
...
@@ -103,6 +107,7 @@ newtype State = State
, corpusId :: Int
, corpusId :: Int
, treeId :: Maybe TreeId
, treeId :: Maybe TreeId
, settings :: SigmaSettings
, settings :: SigmaSettings
, camera :: Maybe Camera
}
}
initialState :: State
initialState :: State
...
@@ -118,6 +123,7 @@ initialState = State
...
@@ -118,6 +123,7 @@ initialState = State
, corpusId : 0
, corpusId : 0
, treeId : Nothing
, treeId : Nothing
, settings : mySettings
, settings : mySettings
, camera : Nothing
}
}
-- This one is not used: specOld is the one being used.
-- This one is not used: specOld is the one being used.
...
@@ -166,6 +172,10 @@ performAction DisplayEdges _ _ =
...
@@ -166,6 +172,10 @@ performAction DisplayEdges _ _ =
modifyState_ $ \(State s) -> do
modifyState_ $ \(State s) -> do
State $ ((_settings <<< _drawEdges) %~ not) s
State $ ((_settings <<< _drawEdges) %~ not) s
performAction (SaveCamera c) _ _ =
modifyState_ $ \(State s) -> do
State $ ((_camera) .~ (Just c)) s
convert :: GraphData -> SigmaGraphData
convert :: GraphData -> SigmaGraphData
convert (GraphData r) = SigmaGraphData { nodes, edges}
convert (GraphData r) = SigmaGraphData { nodes, edges}
where
where
...
@@ -192,7 +202,7 @@ render d p (State {sigmaGraphData, settings, legendData}) c =
...
@@ -192,7 +202,7 @@ render d p (State {sigmaGraphData, settings, legendData}) c =
[ sigma { graph, settings
[ sigma { graph, settings
, renderer : canvas
, renderer : canvas
, style : sStyle { height : "96%"}
, style : sStyle { height : "96%"}
, ref:
myGoto
, ref:
applyOnCamera (d <<< SaveCamera)
, onClickNode : \e -> unsafePerformEffect $ do
, onClickNode : \e -> unsafePerformEffect $ do
_ <- log "this should be deleted"
_ <- log "this should be deleted"
-- _ <- logs $ unsafeCoerce e
-- _ <- logs $ unsafeCoerce e
...
@@ -502,7 +512,7 @@ specOld = fold [treespec treeSpec, graphspec $ simpleSpec performAction render']
...
@@ -502,7 +512,7 @@ specOld = fold [treespec treeSpec, graphspec $ simpleSpec performAction render']
else div [] []
else div [] []
]
]
, div [className "row"]
, div [className "row"]
[
div [if (st.showSidePanel && st.showTree) then className "col-md-10" else if (st.showSidePanel || st.showTree) then className "col-md-10" else className "col-md-12"]
[div [if (st.showSidePanel && st.showTree) then className "col-md-10" else if (st.showSidePanel || st.showTree) then className "col-md-10" else className "col-md-12"]
[ div [style {height: "90%"}] $
[ div [style {height: "90%"}] $
[
[
]
]
...
@@ -512,8 +522,8 @@ specOld = fold [treespec treeSpec, graphspec $ simpleSpec performAction render']
...
@@ -512,8 +522,8 @@ specOld = fold [treespec treeSpec, graphspec $ simpleSpec performAction render']
Just graph ->
Just graph ->
[ sigma { graph, settings
[ sigma { graph, settings
, renderer : canvas
, renderer : canvas
, style : sStyle { height : "9
6
%"}
, style : sStyle { height : "9
5
%"}
, ref:
myGoto
, ref:
applyOnCamera $ d <<< SaveCamera
, onClickNode : \e -> unsafePerformEffect $ do
, onClickNode : \e -> unsafePerformEffect $ do
_ <- log " hello 2"
_ <- log " hello 2"
--logs $ unsafeCoerce e
--logs $ unsafeCoerce e
...
...
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