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
85ebfe5a
Unverified
Commit
85ebfe5a
authored
Feb 13, 2019
by
Mael NICOLAS
Committed by
Nicolas Pouillard
Apr 15, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[HELP] Can't make the "i pass a callback to ref" idea compile
parent
429b318a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
10 deletions
+25
-10
Sigmajs.js
src/Gargantext/Components/GraphExplorer/Sigmajs.js
+4
-3
Sigmajs.purs
src/Gargantext/Components/GraphExplorer/Sigmajs.purs
+6
-3
Graph.purs
src/Gargantext/Pages/Corpus/Graph.purs
+15
-4
No files found.
src/Gargantext/Components/GraphExplorer/Sigmajs.js
View file @
85ebfe5a
...
@@ -40,9 +40,10 @@ exports.forceLinkClass = FL.default;
...
@@ -40,9 +40,10 @@ exports.forceLinkClass = FL.default;
}
}
const
applyOnCamera
=
function
(
f
,
props
){
const
applyOnCamera
=
function
(
props
,
f
){
const
camera
=
props
.
sigma
.
cameras
[
0
];
console
.
log
(
props
);
f
(
camera
);
//const camera = props.sigma.cameras[0];
//f(camera)
};
};
exports
.
applyOnCamera
=
applyOnCamera
;
exports
.
applyOnCamera
=
applyOnCamera
;
src/Gargantext/Components/GraphExplorer/Sigmajs.purs
View file @
85ebfe5a
...
@@ -4,8 +4,8 @@ import Prelude
...
@@ -4,8 +4,8 @@ import Prelude
import Data.Nullable (Nullable)
import Data.Nullable (Nullable)
import Effect (Effect)
import Effect (Effect)
import Effect.Uncurried (EffectFn2, runEffectFn2)
import React (Children, ReactClass, ReactElement, ReactRef, SyntheticEventHandler, createElement, unsafeCreateElement)
import React (Children, ReactClass, ReactElement, ReactRef, SyntheticEventHandler, createElement, unsafeCreateElement)
import React.DOM.Props (Props)
import Thermite (EventHandler)
import Thermite (EventHandler)
import Unsafe.Coerce (unsafeCoerce)
import Unsafe.Coerce (unsafeCoerce)
import Gargantext.Types (class Optional)
import Gargantext.Types (class Optional)
...
@@ -254,14 +254,17 @@ type Camera =
...
@@ -254,14 +254,17 @@ type Camera =
angle :: Number
angle :: Number
}
}
foreign import applyOnCamera :: forall a. (a -> EventHandler) -> SyntheticEventHandler (Nullable ReactRef)
foreign import applyOnCameraImpl :: forall a. EffectFn2 (Nullable ReactRef) (a -> EventHandler) Unit
applyOnCamera :: forall a. (Nullable ReactRef) -> (a -> EventHandler) -> Effect Unit
applyOnCamera = runEffectFn2 applyOnCameraImpl
type SigmaProps =
type SigmaProps =
( renderer :: Renderer
( renderer :: Renderer
, settings :: SigmaSettings
, settings :: SigmaSettings
, style :: SigmaStyle
, style :: SigmaStyle
, graph :: SigmaGraphData
, graph :: SigmaGraphData
, ref ::
SyntheticEventHandler (Nullable ReactRef)
, ref ::
(Nullable ReactRef) -> Effect Unit
, onClickNode :: SigmaNodeEvent -> Unit
, onClickNode :: SigmaNodeEvent -> Unit
, onOverNode :: SigmaNodeEvent -> Unit
, onOverNode :: SigmaNodeEvent -> Unit
, onOutNode :: SigmaNodeEvent -> Effect Unit
, onOutNode :: SigmaNodeEvent -> Effect Unit
...
...
src/Gargantext/Pages/Corpus/Graph.purs
View file @
85ebfe5a
...
@@ -33,6 +33,7 @@ import Gargantext.Components.Tree as Tree
...
@@ -33,6 +33,7 @@ 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)
import Gargantext.Pages.Corpus.Graph.Tabs as GT
import Gargantext.Pages.Corpus.Graph.Tabs as GT
import Gargantext.Prelude (flip)
import Gargantext.Utils (getter)
import Gargantext.Utils (getter)
import Math (cos, sin)
import Math (cos, sin)
import Partial.Unsafe (unsafePartial)
import Partial.Unsafe (unsafePartial)
...
@@ -56,6 +57,7 @@ data Action
...
@@ -56,6 +57,7 @@ data Action
| ChangeNodeSize Number
| ChangeNodeSize Number
| DisplayEdges
| DisplayEdges
| SaveCamera Camera
| SaveCamera Camera
-- | Zoom Boolean
newtype SelectedNode = SelectedNode {id :: String, label :: String}
newtype SelectedNode = SelectedNode {id :: String, label :: String}
...
@@ -176,6 +178,10 @@ performAction (SaveCamera c) _ _ =
...
@@ -176,6 +178,10 @@ performAction (SaveCamera c) _ _ =
modifyState_ $ \(State s) -> do
modifyState_ $ \(State s) -> do
State $ ((_camera) .~ (Just c)) s
State $ ((_camera) .~ (Just c)) s
--performAction (Zoom True) _ _ =
-- modifyState_ $ \() -> do
-- State $
convert :: GraphData -> SigmaGraphData
convert :: GraphData -> SigmaGraphData
convert (GraphData r) = SigmaGraphData { nodes, edges}
convert (GraphData r) = SigmaGraphData { nodes, edges}
where
where
...
@@ -199,10 +205,11 @@ render d p (State {sigmaGraphData, settings, legendData}) c =
...
@@ -199,10 +205,11 @@ render d p (State {sigmaGraphData, settings, legendData}) c =
case sigmaGraphData of
case sigmaGraphData of
Nothing -> []
Nothing -> []
Just graph ->
Just graph ->
[ sigma { graph, settings
[ sigma { graph
, settings
, renderer : canvas
, renderer : canvas
, style : sStyle { height : "96%"}
, style : sStyle { height : "96%"}
, ref:
applyOnCamera (d <<< SaveCamera)
, ref:
flip 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
...
@@ -503,7 +510,11 @@ specOld = fold [treespec treeSpec, graphspec $ simpleSpec performAction render']
...
@@ -503,7 +510,11 @@ specOld = fold [treespec treeSpec, graphspec $ simpleSpec performAction render']
[ span [] [text "Edges"],input [_type "range", _id "myRange", value "90"]
[ span [] [text "Edges"],input [_type "range", _id "myRange", value "90"]
]
]
, li'
, li'
[ button [className "btn btn-primary"] [text "Save"] -- TODO: Implement Save!
[ button [className "btn btn-primary"
, onClick \_ -> do
_ <- log "Hey there" -- $ show st.camera
pure unit
] [text "Save"] -- TODO: Implement Save!
]
]
]
]
...
@@ -523,7 +534,7 @@ specOld = fold [treespec treeSpec, graphspec $ simpleSpec performAction render']
...
@@ -523,7 +534,7 @@ specOld = fold [treespec treeSpec, graphspec $ simpleSpec performAction render']
[ sigma { graph, settings
[ sigma { graph, settings
, renderer : canvas
, renderer : canvas
, style : sStyle { height : "95%"}
, style : sStyle { height : "95%"}
, ref:
applyOnCamera $
d <<< SaveCamera
, ref:
flip 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