Commit 9aec3303 authored by Mael NICOLAS's avatar Mael NICOLAS

[HELP] working on a basic alert ffi

Problem with type for myGoto
parent 4807e9ee
Pipeline #134 canceled with stages
...@@ -18,3 +18,9 @@ exports.sigmaClass = SJS.Sigma; ...@@ -18,3 +18,9 @@ exports.sigmaClass = SJS.Sigma;
exports.sigmaEnableSVGClass = SJS.SigmaEnableSVG; exports.sigmaEnableSVGClass = SJS.SigmaEnableSVG;
exports.sigmaEnableWebGLClass = SJS.SigmaEnableWebGL; exports.sigmaEnableWebGLClass = SJS.SigmaEnableWebGL;
exports.forceLinkClass = FL.default; exports.forceLinkClass = FL.default;
const myGoto = function(sigma){
alert("My goto ffi");
};
exports.myGoto = myGoto;
...@@ -2,9 +2,12 @@ module Gargantext.Components.GraphExplorer.Sigmajs where ...@@ -2,9 +2,12 @@ module Gargantext.Components.GraphExplorer.Sigmajs where
import Prelude import Prelude
import Data.Nullable (Nullable)
import Data.Unit (Unit)
import Effect (Effect) import Effect (Effect)
import Prim.Row (class Union) import Prim.Row (class Union)
import React (Children, ReactClass, ReactElement, createElement, unsafeCreateElement) import React (Children, ReactClass, ReactElement, ReactRef, createElement, unsafeCreateElement)
import React.DOM.Props (Props)
import Unsafe.Coerce (unsafeCoerce) import Unsafe.Coerce (unsafeCoerce)
foreign import edgeShapesClass :: forall props. ReactClass props foreign import edgeShapesClass :: forall props. ReactClass props
...@@ -248,12 +251,14 @@ sigmaSettings :: forall o. Optional o SigmaSettingProps => { | o } -> SigmaSetti ...@@ -248,12 +251,14 @@ 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 :: Nullable ReactRef -> Effect Unit
type SigmaProps = type SigmaProps =
( renderer :: Renderer ( renderer :: Renderer
, settings :: SigmaSettings , settings :: SigmaSettings
, style :: SigmaStyle , style :: SigmaStyle
, graph :: SigmaGraphData , graph :: SigmaGraphData
, ref :: (Nullable ReactRef -> Effect Unit) -> Props
  • I do not understand the -> Props. Why isn't it ref :: Nullable ReactRef -> Effect Unit?

Please register or sign in to reply
, onClickNode :: SigmaNodeEvent -> Unit , onClickNode :: SigmaNodeEvent -> Unit
, onOverNode :: SigmaNodeEvent -> Unit , onOverNode :: SigmaNodeEvent -> Unit
, onOutNode :: SigmaNodeEvent -> Effect Unit , onOutNode :: SigmaNodeEvent -> Effect Unit
...@@ -317,13 +322,12 @@ newtype ScalingMode = ScalingMode String ...@@ -317,13 +322,12 @@ newtype ScalingMode = ScalingMode String
scalingMode :: { inside :: ScalingMode scalingMode :: { inside :: ScalingMode
, outside :: ScalingMode , outside :: ScalingMode
} }
scalingMode = scalingMode =
{ inside : ScalingMode "inside" { inside : ScalingMode "inside"
, outside : ScalingMode "outside" , outside : ScalingMode "outside"
} }
type SigmaSettingProps = type SigmaSettingProps =
( clone :: Boolean ( clone :: Boolean
, immutable :: Boolean , immutable :: Boolean
......
...@@ -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 (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, myGoto, 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)
...@@ -192,6 +192,7 @@ render d p (State {sigmaGraphData, settings, legendData}) c = ...@@ -192,6 +192,7 @@ render d p (State {sigmaGraphData, settings, legendData}) c =
[ sigma { graph, settings [ sigma { graph, settings
, renderer : canvas , renderer : canvas
, style : sStyle { height : "95%"} , style : sStyle { height : "95%"}
, ref: myGoto
, onClickNode : \e -> unsafePerformEffect $ do , onClickNode : \e -> unsafePerformEffect $ do
_ <- log "hello" _ <- log "hello"
-- _ <- logs $ unsafeCoerce e -- _ <- logs $ unsafeCoerce e
......
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