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
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;
}
const
applyOnCamera
=
function
(
f
,
props
){
const
camera
=
props
.
sigma
.
cameras
[
0
];
f
(
camera
);
const
applyOnCamera
=
function
(
props
,
f
){
console
.
log
(
props
);
//const camera = props.sigma.cameras[0];
//f(camera)
};
exports
.
applyOnCamera
=
applyOnCamera
;
src/Gargantext/Components/GraphExplorer/Sigmajs.purs
View file @
85ebfe5a
...
...
@@ -4,8 +4,8 @@ import Prelude
import Data.Nullable (Nullable)
import Effect (Effect)
import Effect.Uncurried (EffectFn2, runEffectFn2)
import React (Children, ReactClass, ReactElement, ReactRef, SyntheticEventHandler, createElement, unsafeCreateElement)
import React.DOM.Props (Props)
import Thermite (EventHandler)
import Unsafe.Coerce (unsafeCoerce)
import Gargantext.Types (class Optional)
...
...
@@ -254,14 +254,17 @@ type Camera =
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 =
( renderer :: Renderer
, settings :: SigmaSettings
, style :: SigmaStyle
, graph :: SigmaGraphData
, ref ::
SyntheticEventHandler (Nullable ReactRef)
, ref ::
(Nullable ReactRef) -> Effect Unit
, onClickNode :: SigmaNodeEvent -> Unit
, onOverNode :: SigmaNodeEvent -> Unit
, onOutNode :: SigmaNodeEvent -> Effect Unit
...
...
src/Gargantext/Pages/Corpus/Graph.purs
View file @
85ebfe5a
...
...
@@ -33,6 +33,7 @@ import Gargantext.Components.Tree as Tree
import Gargantext.Config as Config
import Gargantext.Config.REST (get, post)
import Gargantext.Pages.Corpus.Graph.Tabs as GT
import Gargantext.Prelude (flip)
import Gargantext.Utils (getter)
import Math (cos, sin)
import Partial.Unsafe (unsafePartial)
...
...
@@ -56,6 +57,7 @@ data Action
| ChangeNodeSize Number
| DisplayEdges
| SaveCamera Camera
-- | Zoom Boolean
newtype SelectedNode = SelectedNode {id :: String, label :: String}
...
...
@@ -176,6 +178,10 @@ performAction (SaveCamera c) _ _ =
modifyState_ $ \(State s) -> do
State $ ((_camera) .~ (Just c)) s
--performAction (Zoom True) _ _ =
-- modifyState_ $ \() -> do
-- State $
convert :: GraphData -> SigmaGraphData
convert (GraphData r) = SigmaGraphData { nodes, edges}
where
...
...
@@ -199,10 +205,11 @@ render d p (State {sigmaGraphData, settings, legendData}) c =
case sigmaGraphData of
Nothing -> []
Just graph ->
[ sigma { graph, settings
[ sigma { graph
, settings
, renderer : canvas
, style : sStyle { height : "96%"}
, ref:
applyOnCamera (d <<< SaveCamera)
, ref:
flip applyOnCamera <<< d <<< SaveCamera
, onClickNode : \e -> unsafePerformEffect $ do
_ <- log "this should be deleted"
-- _ <- logs $ unsafeCoerce e
...
...
@@ -503,7 +510,11 @@ specOld = fold [treespec treeSpec, graphspec $ simpleSpec performAction render']
[ span [] [text "Edges"],input [_type "range", _id "myRange", value "90"]
]
, 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']
[ sigma { graph, settings
, renderer : canvas
, style : sStyle { height : "95%"}
, ref:
applyOnCamera $
d <<< SaveCamera
, ref:
flip applyOnCamera <<<
d <<< SaveCamera
, onClickNode : \e -> unsafePerformEffect $ do
_ <- log " hello 2"
--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