Unverified Commit 0ef30a74 authored by Mael NICOLAS's avatar Mael NICOLAS Committed by Nicolas Pouillard

[HELP] can't call the callback function

parent e69f0940
...@@ -40,17 +40,13 @@ exports.forceLinkClass = FL.default; ...@@ -40,17 +40,13 @@ exports.forceLinkClass = FL.default;
} }
const applyOnCamera = function(props){ const applyOnCamera = function(props, f){
console.log(props); if (props != null) {
//const camera = props.sigma.cameras[0]; const camera = props.sigma.cameras[0];
//f(camera) // console.log(camera);
// console.log(f);
f(camera);
}
}; };
/*const applyOnCamera = function(props, f){
console.log(props);
//const camera = props.sigma.cameras[0];
//f(camera)
};
*/
exports.applyOnCameraImpl = applyOnCamera; exports.applyOnCameraImpl = applyOnCamera;
...@@ -25,6 +25,7 @@ import Effect.Aff (Aff, attempt) ...@@ -25,6 +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 Effect.Uncurried (runEffectFn1, runEffectFn2)
import Gargantext.Components.GraphExplorer.Sigmajs (Camera, Color(Color), SigmaEasing, SigmaGraphData(SigmaGraphData), SigmaNode, SigmaSettings, canvas, edgeShape, edgeShapes, forceAtlas2, applyOnCamera, sStyle, sigma, sigmaEasing, sigmaEdge, sigmaEnableWebGL, sigmaNode, sigmaSettings) import Gargantext.Components.GraphExplorer.Sigmajs (Camera, 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)
...@@ -130,8 +131,10 @@ initialState = State ...@@ -130,8 +131,10 @@ initialState = State
-- This one is not used: specOld is the one being used. -- This one is not used: specOld is the one being used.
-- TODO: code duplication -- TODO: code duplication
{-
graphSpec :: Spec State {} Action graphSpec :: Spec State {} Action
graphSpec = simpleSpec performAction render graphSpec = simpleSpec performAction render
-}
performAction :: PerformAction State {} Action performAction :: PerformAction State {} Action
performAction (LoadGraph fp) _ _ = void do performAction (LoadGraph fp) _ _ = void do
...@@ -183,7 +186,7 @@ performAction (SaveCamera c) _ _ = ...@@ -183,7 +186,7 @@ performAction (SaveCamera c) _ _ =
-- State $ -- State $
convert :: GraphData -> SigmaGraphData convert :: GraphData -> SigmaGraphData
convert (GraphData r) = SigmaGraphData { nodes, edges} convert (GraphData r) = SigmaGraphData {nodes, edges}
where where
nodes = mapWithIndex nodeFn r.nodes nodes = mapWithIndex nodeFn r.nodes
nodeFn i (Node n) = nodeFn i (Node n) =
...@@ -199,7 +202,7 @@ convert (GraphData r) = SigmaGraphData { nodes, edges} ...@@ -199,7 +202,7 @@ convert (GraphData r) = SigmaGraphData { nodes, edges}
cDef (Cluster {clustDefault}) = clustDefault cDef (Cluster {clustDefault}) = clustDefault
edges = map edgeFn r.edges edges = map edgeFn r.edges
edgeFn (Edge e) = sigmaEdge {id : e.id_, source : e.source, target : e.target} edgeFn (Edge e) = sigmaEdge {id : e.id_, source : e.source, target : e.target}
{--
render :: Render State {} Action render :: Render State {} Action
render d p (State {sigmaGraphData, settings, legendData}) c = render d p (State {sigmaGraphData, settings, legendData}) c =
case sigmaGraphData of case sigmaGraphData of
...@@ -210,7 +213,7 @@ render d p (State {sigmaGraphData, settings, legendData}) c = ...@@ -210,7 +213,7 @@ render d p (State {sigmaGraphData, settings, legendData}) c =
, renderer : canvas , renderer : canvas
, style : sStyle { height : "96%"} , style : sStyle { height : "96%"}
-- , ref: applyOnCamera -- , ref: applyOnCamera
, ref: applyOnCamera $ (d <<< SaveCamera) , 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
...@@ -226,6 +229,7 @@ render d p (State {sigmaGraphData, settings, legendData}) c = ...@@ -226,6 +229,7 @@ render d p (State {sigmaGraphData, settings, legendData}) c =
-- TODO clean unused code: this seems to be not used -- TODO clean unused code: this seems to be not used
-- <> -- <>
-- [dispLegend legendData] -- [dispLegend legendData]
--}
forceAtlas2Config :: { slowDown :: Number forceAtlas2Config :: { slowDown :: Number
, startingIterations :: Number , startingIterations :: Number
...@@ -535,10 +539,11 @@ specOld = fold [treespec treeSpec, graphspec $ simpleSpec performAction render'] ...@@ -535,10 +539,11 @@ 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: applyOnCamera log -- d <<< SaveCamera
, onClickNode : \e -> unsafePerformEffect $ do , onClickNode : \e ->
unsafePerformEffect $ do
_ <- log " hello 2" _ <- log " hello 2"
--logs $ unsafeCoerce e _ <- log $ show st.camera
_ <- d $ ShowSidePanel true _ <- d $ ShowSidePanel true
_ <- d $ SelectNode $ SelectedNode {id : (unsafeCoerce e).data.node.id, label : (unsafeCoerce e).data.node.label} _ <- d $ SelectNode $ SelectedNode {id : (unsafeCoerce e).data.node.id, label : (unsafeCoerce e).data.node.label}
pure unit pure unit
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment