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

[HELP] working on a basic alert ffi

Problem with type for myGoto
parent 0538f5ee
...@@ -39,3 +39,9 @@ exports.sigmaEnableWebGLClass = SJS.SigmaEnableWebGL; ...@@ -39,3 +39,9 @@ exports.sigmaEnableWebGLClass = SJS.SigmaEnableWebGL;
exports.forceLinkClass = FL.default; exports.forceLinkClass = FL.default;
} }
const myGoto = function(sigma){
alert("My goto ffi");
};
exports.myGoto = myGoto;
...@@ -2,8 +2,11 @@ module Gargantext.Components.GraphExplorer.Sigmajs where ...@@ -2,8 +2,11 @@ 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 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)
import Gargantext.Types (class Optional) import Gargantext.Types (class Optional)
...@@ -242,12 +245,14 @@ sigmaSettings :: forall o. Optional o SigmaSettingProps => { | o } -> SigmaSetti ...@@ -242,12 +245,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
, onClickNode :: SigmaNodeEvent -> Unit , onClickNode :: SigmaNodeEvent -> Unit
, onOverNode :: SigmaNodeEvent -> Unit , onOverNode :: SigmaNodeEvent -> Unit
, onOutNode :: SigmaNodeEvent -> Effect Unit , onOutNode :: SigmaNodeEvent -> Effect Unit
...@@ -311,13 +316,12 @@ newtype ScalingMode = ScalingMode String ...@@ -311,13 +316,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