Commit fa126ebf authored by James Laver's avatar James Laver

push for anoe

parent 41ea2a5c
...@@ -16,47 +16,36 @@ Institute of Paris Île-de-France (ISC-PIF) and its partners. ...@@ -16,47 +16,36 @@ Institute of Paris Île-de-France (ISC-PIF) and its partners.
## Development ## Development
### Installing dependencies ### System Dependencies
#### Debian * NodeJS (11+)
* Yarn (Recent)
* A webserver (anything that can serve a static directory will do)
#### NodeJS Installation
On debian testing, debian unstable or ubuntu:
##### Testing Distribution and above
```shell ```shell
sudo apt update && sudo apt install nodejs yarn sudo apt update && sudo apt install nodejs yarn
``` ```
##### Stable Distribution On debian stable:
```shell ```shell
curl -sL https://deb.nodesource.com/setup_11.x | sudo bash - curl -sL https://deb.nodesource.com/setup_11.x | sudo bash -
sudo apt update && sudo apt install nodejs sudo apt update && sudo apt install nodejs
``` ```
(For Ubuntu): On Mac OS (with Homebrew):
```shell
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt update && sudo apt install yarn
```
### OSX
```shell ```shell
brew install node yarn brew install node
``` ```
### Installing dependencies #### Yarn installation
#### Debian
##### Testing Distribution and above On ubuntu:
```shell
sudo apt update && sudo apt install nodejs yarn
```
##### Stable Distribution
```shell
curl -sL https://deb.nodesource.com/setup_11.x | sudo bash -
sudo apt update && sudo apt install nodejs
```
```shell ```shell
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
...@@ -64,35 +53,61 @@ echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/source ...@@ -64,35 +53,61 @@ echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/source
sudo apt update && sudo apt install yarn sudo apt update && sudo apt install yarn
``` ```
### OSX On Mac OS (with Homebrew):
```shell ```shell
brew install node yarn brew install yarn
``` ```
### Installing dependencies #### Webservers
Some options:
* The `python3` builtin webserver
* Caddy
Before building gargantext, you must install the dependencies. We use ### Purescript and Javascript dependencies
[yarn](https://yarnpkg.com/en/) for this. They have excellent
[installation instructions](https://yarnpkg.com/en/docs/install).
Once you have yarn installed, you may install everything else simply: Once you have node and yarn installed, you may install deps with:
```shell ```shell
yarn install && yarn install-ps yarn install && yarn install-ps
``` ```
You may now build: ### Development
You can compile the purescript code with:
```shell ```shell
yarn build yarn compile
``` ```
And run a repl: Or run a repl:
```shell ```shell
yarn repl yarn repl
``` ```
To test in the browser, you need to build a browser bundle:
```shell
yarn build
```
It is *not* necessary to `yarn compile` before running `yarn build`.
You can then serve the `dist` directory with your favourite webserver.
Examples:
* `python3 -m http.server dist`
<!-- To get a live-reloading development server -->
<!-- ```shell -->
<!-- yarn live -->
<!-- ``` -->
## Note to the contributors ## Note to the contributors
Please follow CONTRIBUTING.md Please follow CONTRIBUTING.md
...@@ -128,6 +143,8 @@ yarn rebuild-set ...@@ -128,6 +143,8 @@ yarn rebuild-set
yarn rebase-set && yarn rebuild-set yarn rebase-set && yarn rebuild-set
``` ```
This will occasionally result in swearing when you go on to build.
## Theory Introduction ## Theory Introduction
Making sense of out text isn't actually that hard, but it does require Making sense of out text isn't actually that hard, but it does require
......
module Gargantext.Components.Graph
-- ( graph, graphCpt
-- , sigmaSettings, SigmaSettings, SigmaOptionalSettings
-- , forceAtlas2Settings, ForceAtlas2Settings, ForceAtlas2OptionalSettings
-- )
where
import Prelude
import Control.Monad.Except.Trans
import Data.Array as A
import Data.Bitraversable (bitraverse)
import Data.Either (Either(..), either)
import Data.Maybe (Maybe(..), maybe)
import Data.Nullable (Nullable, null)
import Data.Sequence as Seq
import Data.Sequence (Seq)
import Data.Traversable (for, for_, traverse, traverse_)
import DOM.Simple.Types (Element)
import DOM.Simple.Console (log, log2)
import Effect (Effect)
import FFI.Simple (delay)
import Reactix as R
import Reactix.DOM.HTML as RH
import Gargantext.Utils.Reactix as R2
import Gargantext.Types (class Optional)
import Gargantext.Hooks.Sigmax
import Gargantext.Hooks.Sigmax.Types as Sigmax
import Gargantext.Hooks.Sigmax.Sigma (SigmaOpts)
import Gargantext.Hooks.Sigmax.Sigma as Sigma
import Gargantext.Hooks.Sigmax.Sigmajs ()
type OnProps = ()
type Node =
( id :: String
, label :: String
, x :: Number
, y :: Number
, size :: Number
, color :: String )
type Edge = ( id :: String, source :: String, target :: String )
type Graph = Sigmax.Graph Node Edge
type Props sigma forceatlas2 =
( graph :: Graph
, sigmaSettings :: sigma
, forceAtlas2Settings :: forceatlas2 )
graph :: forall s fa2. Record (Props s fa2) -> R.Element
graph props = R.createElement graphCpt props []
graphCpt :: forall s fa2. R.Component (Props s fa2)
graphCpt = R.hooksComponent "Graph" cpt
where
cpt props _ = do
ref <- R.useRef null
sigma <- useSigma ref props.sigmaSettings
useCanvasRenderer ref sigma
useData sigma props.graph
useForceAtlas2 sigma props.forceAtlas2Settings
pure $ RH.div { ref, style: {height: "95%"} } []
type SigmaSettings =
( animationsTime :: Number
, autoRescale :: Boolean
, autoResize :: Boolean
, batchEdgesDrawing :: Boolean
, borderSize :: Number
-- , canvasEdgesBatchSize :: Number
-- , clone :: Boolean
-- , defaultEdgeColor :: String
-- , defaultEdgeHoverColor :: String
, defaultEdgeType :: String
, defaultHoverLabelBGColor :: String
, defaultHoverLabelColor :: String
, defaultLabelColor :: String
-- , defaultLabelHoverColor :: String
-- , defaultLabelSize :: String
, defaultNodeBorderColor :: String
, defaultNodeColor :: String
-- , defaultNodeHoverColor :: String
-- , defaultNodeType :: String
-- , doubleClickEnabled :: Boolean
-- , doubleClickTimeout :: Number
-- , doubleClickZoomDuration :: Number
-- , doubleClickZoomingRatio :: Number
-- , doubleTapTimeout :: Number
-- , dragTimeout :: Number
, drawEdgeLabels :: Boolean
, drawEdges :: Boolean
, drawLabels :: Boolean
, drawNodes :: Boolean
-- , edgeColor :: String
-- , edgeHoverColor :: String
-- , edgeHoverExtremities :: Boolean
-- , edgeHoverPrecision :: Number
-- , edgeHoverSizeRatio :: Number
-- , edgesPowRatio :: Number
-- , enableCamera :: Boolean
, enableEdgeHovering :: Boolean
, enableHovering :: Boolean
-- , eventsEnabled :: Boolean
, font :: String
, fontStyle :: String
, hideEdgesOnMove :: Boolean
-- , hoverFont :: String
-- , hoverFontStyle :: String
-- , immutable :: Boolean
-- , labelColor :: String
-- , labelHoverBGColor :: String
-- , labelHoverColor :: String
-- , labelHoverShadow :: String
-- , labelHoverShadowColor :: String
, labelMaxSize :: Number
, labelSize :: String
, labelSizeRatio :: Number
, labelThreshold :: Number
, maxEdgeSize :: Number
, maxNodeSize :: Number
-- , minArrowSize :: Number
, minEdgeSize :: Number
, minNodeSize :: Number
, mouseEnabled :: Boolean
-- , mouseInertiaDuration :: Number
-- , mouseInertiaRatio :: Number
-- , mouseWheelEnabled :: Boolean
, mouseZoomDuration :: Number
, nodeBorderColor :: String
-- , nodeHoverColor :: String
-- , nodesPowRatio :: Number
, rescaleIgnoreSize :: Boolean
-- , scalingMode :: String
-- , sideMargin :: Number
, singleHover :: Boolean
-- , skipErrors :: Boolean
, touchEnabled :: Boolean
-- , touchInertiaDuration :: Number
-- , touchInertiaRatio :: Number
, twBorderGreyColor :: String
, twEdgeDefaultOpacity :: Number
, twEdgeGreyColor :: String
, twNodeRendBorderColor :: String
, twNodeRendBorderSize :: Number
, twNodesGreyOpacity :: Number
, twSelectedColor :: String
, verbose :: Boolean
-- , webglEdgesBatchSize :: Number
-- , webglOversamplingRatio :: Number
, zoomMax :: Number
, zoomMin :: Number
, zoomingRatio :: Number
)
-- not selected <=> (1-greyness)
-- selected nodes <=> special label
sigmaSettings :: {|SigmaSettings}
sigmaSettings =
{ animationsTime: 5500.0
, autoRescale: true
, autoResize: true
, batchEdgesDrawing: false
, borderSize: 3.0 -- for ex, bigger border when hover
, defaultEdgeType: "curve" -- 'curve' or 'line' (curve iff ourRendering)
, defaultHoverLabelBGColor: "#fff"
, defaultHoverLabelColor: "#000"
, defaultLabelColor: "#000" -- labels text color
, defaultNodeBorderColor: "black" -- <- if nodeBorderColor = 'default'
, defaultNodeColor: "#ddd"
, drawEdgeLabels: true
, drawEdges: true
, drawLabels: true
, drawNodes: true
, enableEdgeHovering: false
, enableHovering: true
, font: "Droid Sans" -- font params
, fontStyle: "bold"
, hideEdgesOnMove: true
, labelMaxSize: 3.0 -- (old tina: showLabelsIfZoom)
, labelSize : "proportional"
, labelSizeRatio: 2.0 -- label size in ratio of node size
, labelThreshold: 2.0 -- min node cam size to start showing label
, maxEdgeSize: 0.0
, maxNodeSize: 30.0
, minEdgeSize: 0.0 -- in fact used in tina as edge size
, minNodeSize: 5.0
, mouseEnabled: true
, mouseZoomDuration: 150.0
, nodeBorderColor: "node" -- choices: 'default' color vs. node color
-- , nodesPowRatio: 0.3
, rescaleIgnoreSize: false
, singleHover: true
, touchEnabled: true
, twBorderGreyColor: "rgba(100, 100, 100, 0.5)"
, twEdgeDefaultOpacity: 0.4 -- initial opacity added to src/tgt colors
, twEdgeGreyColor: "rgba(100, 100, 100, 0.25)"
, twNodeRendBorderColor: "#222"
, twNodeRendBorderSize: 0.5 -- node borders (only iff ourRendering)
, twNodesGreyOpacity: 5.5 -- smaller value: more grey
, twSelectedColor: "default" -- "node" for a label bg like the node color, "default" for white background
, verbose : true
, zoomMax: 1.7
, zoomMin: 0.0
, zoomingRatio: 3.2
}
type ForceAtlas2Settings =
( adjustSizes :: Boolean
, barnesHutOptimize :: Boolean
-- , barnesHutTheta :: Number
, edgeWeightInfluence :: Number
-- , fixedY :: Boolean
, gravity :: Number
, iterationsPerRender :: Number
, linLogMode :: Boolean
, outboundAttractionDistribution :: Boolean
, scalingRatio :: Number
, skipHidden :: Boolean
, slowDown :: Number
, startingIterations :: Number
, strongGravityMode :: Boolean
-- , timeout :: Number
-- , worker :: Boolean
)
forceAtlas2Settings :: {|ForceAtlas2Settings}
forceAtlas2Settings =
{ adjustSizes : false
, barnesHutOptimize : true
, edgeWeightInfluence : 0.0
-- fixedY : false
, gravity : 1.0
, iterationsPerRender : 4.0
, linLogMode : true -- false
, outboundAttractionDistribution: false
, scalingRatio : 4.0
, skipHidden: false
, slowDown : 0.7
, startingIterations : 2.0
, strongGravityMode : false
}
...@@ -46,8 +46,8 @@ searchFieldComponent = R.memo (R.hooksComponent "SearchField" cpt) hasChanged ...@@ -46,8 +46,8 @@ searchFieldComponent = R.memo (R.hooksComponent "SearchField" cpt) hasChanged
where where
cpt props _ = do cpt props _ = do
let search = maybe defaultSearch identity (fst props.search) let search = maybe defaultSearch identity (fst props.search)
term <- R.useState $ \_ -> search.term term <- R.useState' search.term
db <- R.useState $ \_ -> Nothing db <- R.useState' Nothing
pure $ pure $
div { className: "search-field input-group" } div { className: "search-field input-group" }
[ databaseInput db props.databases [ databaseInput db props.databases
......
...@@ -31,7 +31,7 @@ endConfig = endConfig' V10 ...@@ -31,7 +31,7 @@ endConfig = endConfig' V10
endConfig' :: ApiVersion -> EndConfig endConfig' :: ApiVersion -> EndConfig
endConfig' v = { front : frontRelative endConfig' v = { front : frontRelative
, back : backLocal v , back : backDev v
, static : staticRelative , static : staticRelative
} }
-- , back : backDemo v } -- , back : backDemo v }
......
module Gargantext.Hooks.Sigmax
-- (
-- )
where
import Prelude
import Data.Array as A
import Data.Bitraversable (bitraverse)
import Data.Either (Either(..), either)
import Data.Foldable (sequence_)
import Data.Maybe (Maybe(..), maybe)
import Data.Nullable (Nullable, null)
import Data.Sequence as Seq
import Data.Sequence (Seq)
import Data.Traversable (for, for_, traverse, traverse_)
import DOM.Simple.Types (Element)
import DOM.Simple.Console (log, log2)
import Effect (Effect)
import FFI.Simple (delay)
import Reactix as R
import Reactix.DOM.HTML as RH
import Gargantext.Utils.Reactix as R2
import Gargantext.Types (class Optional)
import Gargantext.Hooks.Sigmax.Sigma (SigmaOpts)
import Gargantext.Hooks.Sigmax.Sigma as Sigma
import Gargantext.Hooks.Sigmax.Types
type Sigma =
{ sigma :: R.Ref (Maybe Sigma.Sigma)
, cleanup :: R.Ref (Seq (Effect Unit))
}
type Data n e = { graph :: R.Ref (Graph n e) }
readSigma :: Sigma -> Maybe Sigma.Sigma
readSigma sigma = R.readRef sigma.sigma
writeSigma :: Sigma -> Maybe Sigma.Sigma -> Effect Unit
writeSigma sigma = R.setRef sigma.sigma
-- | Pushes to the back of the cleanup sequence. Cleanup happens
-- | *before* sigma is destroyed
cleanupLast :: Sigma -> Effect Unit -> Effect Unit
cleanupLast sigma = R.setRef sigma.cleanup <<< Seq.snoc existing
where existing = R.readRef sigma.cleanup
-- | Pushes to the front of the cleanup sequence. Cleanup happens
-- | *before* sigma is destroyed
cleanupFirst :: Sigma -> Effect Unit -> Effect Unit
cleanupFirst sigma =
R.setRef sigma.cleanup <<< (flip Seq.cons) (R.readRef sigma.cleanup)
-- | Manages a sigma with the given settings
useSigma :: forall settings. R.Ref (Nullable Element) -> settings -> R.Hooks Sigma
useSigma container settings = do
sigma <- newSigma <$> R2.nothingRef <*> R.useRef Seq.empty
R.useEffect2 container sigma.sigma $
delay unit $ handleSigma sigma (readSigma sigma)
pure sigma
where
newSigma sigma cleanup = { sigma, cleanup }
handleSigma sigma (Just _) _ = pure R.nothing
handleSigma sigma Nothing _ = do
ret <- createSigma settings
traverse_ (writeSigma sigma <<< Just) ret
pure (cleanupSigma sigma "useSigma")
-- | Manages a renderer for the sigma
useCanvasRenderer :: R.Ref (Nullable Element) -> Sigma -> R.Hooks Unit
useCanvasRenderer container sigma =
R.useEffect2' container sigma.sigma $
delay unit $ \_ ->
dependOnContainer container containerNotFoundMsg withContainer
where
withContainer c = dependOnSigma sigma sigmaNotFoundMsg withSigma
where -- close over c
withSigma sig = addRenderer sig renderer >>= handle
where -- close over sig
renderer = { "type": "canvas", container: c }
handle (Right _) = cleanupFirst sigma (Sigma.killRenderer sig renderer >>= logCleanup)
handle (Left e) =
log2 errorAddingMsg e *> cleanupSigma sigma "useCanvasRenderer"
logCleanup (Left e) = log2 errorKillingMsg e
logCleanup _ = log killedMsg
containerNotFoundMsg = "[useCanvasRenderer] Container not found, not adding renderer"
sigmaNotFoundMsg = "[useCanvasRenderer] Sigma not found, not adding renderer"
errorAddingMsg = "[useCanvasRenderer] Error adding canvas renderer: "
errorKillingMsg = "[useCanvasRenderer] Error killing renderer:"
killedMsg = "[useCanvasRenderer] Killed renderer"
createSigma :: forall settings err. settings -> Effect (Either err Sigma.Sigma)
createSigma settings = do
ret <- Sigma.sigma {settings}
ret <$ logStatus ret
where
logStatus (Left err) = log2 "[useSigma] Error during sigma creation:" err
logStatus _ = log "[useSigma] Initialised sigma successfully"
cleanupSigma :: Sigma -> String -> Effect Unit
cleanupSigma sigma context = traverse_ kill (readSigma sigma)
where
kill sig = runCleanups *> killSigma *> emptyOut
where -- close over sig
killSigma = Sigma.killSigma sig >>= report
runCleanups = sequence_ (R.readRef sigma.cleanup)
emptyOut = writeSigma sigma Nothing *> R.setRef sigma.cleanup Seq.empty
report = either (log2 errorMsg) (\_ -> log successMsg)
prefix = "[" <> context <> "] "
errorMsg = prefix <> "Error killing sigma:"
successMsg = prefix <> "Killed sigma"
addRenderer :: forall err. Sigma.Sigma -> Renderer -> Effect (Either err Unit)
addRenderer sigma renderer = do
ret <- Sigma.addRenderer sigma renderer
(const unit <$> ret) <$ report ret
where
report = either (log2 errorMsg) (\_ -> log successMsg)
errorMsg = "[useRenderer] Error adding renderer:"
successMsg = "[useRenderer] Added renderer successfully"
useData :: forall n e. Sigma -> Graph n e -> R.Hooks Unit
useData sigma graph =
R.useEffect2' sigma.sigma graph $
delay unit $ \_ -> dependOnSigma sigma sigmaNotFoundMsg withSigma
where
withSigma sig = refreshData sig (sigmafy graph)
sigmaNotFoundMsg = "[useData] Sigma not found, not adding data"
refreshData :: forall n e. Sigma.Sigma -> Sigma.Graph n e -> Effect Unit
refreshData sigma graph
= log clearingMsg
*> Sigma.clear sigma
*> log readingMsg
*> Sigma.graphRead sigma graph
>>= either (log2 errorMsg) refresh
where
refresh _ = log refreshingMsg *> Sigma.refresh sigma
clearingMsg = "[useData] Clearing existing graph data"
readingMsg = "[useData] Reading graph data"
refreshingMsg = "[useData] Refreshing graph"
errorMsg = "[useData] Error reading graph data:"
sigmafy :: forall n e. Graph n e -> Sigma.Graph n e
sigmafy (Graph g) = {nodes,edges}
where
nodes = A.fromFoldable g.nodes
edges = A.fromFoldable g.edges
useForceAtlas2 :: forall settings. Sigma -> settings -> R.Hooks Unit
useForceAtlas2 sigma settings =
R.useEffect1' sigma.sigma (delay unit effect)
where
effect _ = dependOnSigma sigma sigmaNotFoundMsg withSigma
withSigma sig = do
log startingMsg
Sigma.startForceAtlas2 sig settings
cleanupFirst sigma (Sigma.killForceAtlas2 sig)
startingMsg = "[Graph] Starting ForceAtlas2"
sigmaNotFoundMsg = "[Graph] Sigma not found, not initialising"
dependOnSigma :: Sigma -> String -> (Sigma.Sigma -> Effect Unit) -> Effect Unit
dependOnSigma sigma notFoundMsg f = do
case readSigma sigma of
Nothing -> log notFoundMsg
Just sig -> f sig
dependOnContainer :: R.Ref (Nullable Element) -> String -> (Element -> Effect Unit) -> Effect Unit
dependOnContainer container notFoundMsg f = do
case R.readNullableRef container of
Nothing -> log notFoundMsg
Just c -> f c
'use strict';
const s = require('sigma').sigma;
if (typeof window === 'undefined') {
window.sigma = s;
}
function _sigma(left, right, opts) {
try {
return right(new sigma(opts));
} catch(e) {
return left(e);
}
}
function graphRead(left, right, sigma, data) {
try {
return right(sigma.graph.read(data));
} catch(e) {
return left(e);
}
}
function addRenderer(left, right, sigma, renderer) {
try {
return right(sigma.addRenderer(renderer));
} catch(e) {
return left(e);
}
}
function killRenderer(left, right, sigma, renderer) {
try {
sigma.killRenderer(renderer);
return right(sigma)
} catch(e) {
return left(e);
}
}
function killSigma(left, right, sigma) {
try {
sigma.kill()
return right(null)
} catch(e) {
return left(e);
}
}
exports._sigma = _sigma;
exports._graphRead = graphRead;
exports._refresh = function refresh(sigma) { sigma.refresh(); };
exports._addRenderer = addRenderer;
exports._killRenderer = killRenderer;
exports._killSigma = killSigma
exports._clear = function clear(sigma) { sigma.graph.clear(); };
exports._bind = function bind(sigma, event, handler) { sigma.bind(event, handler); };
exports._startForceAtlas2 = function startForceAtlas2(sigma, settings) {
sigma.startForceAtlas2(settings);
};
exports._stopForceAtlas2 = function stopForceAtlas2(sigma) { sigma.stopForceAtlas2(); };
exports._killForceAtlas2 = function killForceAtlas2(sigma) { sigma.killForceAtlas2(); };
module Gargantext.Hooks.Sigmax.Sigma where
import Prelude
import Type.Row (class Union)
import Data.Either (Either(..))
import Data.Unit (Unit)
import Effect (Effect)
import FFI.Simple.Objects (named)
import Effect.Uncurried (EffectFn1, mkEffectFn1, runEffectFn1, EffectFn2, runEffectFn2, EffectFn3, runEffectFn3, EffectFn4, runEffectFn4)
foreign import data Sigma :: Type
type NodeRequiredProps = ( id :: String )
type EdgeRequiredProps = ( id :: String, source :: String, target :: String )
class NodeProps (all :: #Type) (extra :: #Type) | all -> extra
class EdgeProps (all :: #Type) (extra :: #Type) | all -> extra
instance nodeProps
:: Union NodeRequiredProps extra all
=> NodeProps all extra
instance edgeProps
:: Union EdgeRequiredProps extra all
=> EdgeProps all extra
type Graph n e = { nodes :: Array {|n}, edges :: Array {|e} }
type SigmaOpts s = { settings :: s }
sigma :: forall opts err. SigmaOpts opts -> Effect (Either err Sigma)
sigma = runEffectFn3 _sigma Left Right
foreign import _sigma ::
forall a b opts err.
EffectFn3 (a -> Either a b)
(b -> Either a b)
(SigmaOpts opts)
(Either err Sigma)
graphRead :: forall node edge err. Sigma -> Graph node edge -> Effect (Either err Unit)
graphRead = runEffectFn4 _graphRead Left Right
foreign import _graphRead ::
forall a b data_ err.
EffectFn4 (a -> Either a b)
(b -> Either a b)
Sigma
data_
(Either err Unit)
refresh :: Sigma -> Effect Unit
refresh = runEffectFn1 _refresh
foreign import _refresh :: EffectFn1 Sigma Unit
addRenderer :: forall r err. Sigma -> r -> Effect (Either err Unit)
addRenderer = runEffectFn4 _addRenderer Left Right
foreign import _addRenderer
:: forall a b r err.
EffectFn4 (a -> Either a b)
(b -> Either a b)
Sigma
r
(Either err Unit)
killRenderer :: forall r err. Sigma -> r -> Effect (Either err Unit)
killRenderer = runEffectFn4 _killRenderer Left Right
foreign import _killRenderer
:: forall a b r err.
EffectFn4 (a -> Either a b)
(b -> Either a b)
Sigma
r
(Either err Unit)
killSigma :: forall err. Sigma -> Effect (Either err Unit)
killSigma = runEffectFn3 _killSigma Left Right
clear :: Sigma -> Effect Unit
clear = runEffectFn1 _clear
foreign import _clear :: EffectFn1 Sigma Unit
foreign import _killSigma
:: forall a b err.
EffectFn3 (a -> Either a b)
(b -> Either a b)
Sigma
(Either err Unit)
bind_ :: forall e. Sigma -> String -> (e -> Effect Unit) -> Effect Unit
bind_ s e h = runEffectFn3 _bind s e (mkEffectFn1 h)
foreign import _bind :: forall e. EffectFn3 Sigma String (EffectFn1 e Unit) Unit
startForceAtlas2 :: forall settings. Sigma -> settings -> Effect Unit
startForceAtlas2 = runEffectFn2 _startForceAtlas2
stopForceAtlas2 :: Sigma -> Effect Unit
stopForceAtlas2 = runEffectFn1 _stopForceAtlas2
killForceAtlas2 :: Sigma -> Effect Unit
killForceAtlas2 = runEffectFn1 _killForceAtlas2
foreign import _startForceAtlas2 :: forall s. EffectFn2 Sigma s Unit
foreign import _stopForceAtlas2 :: EffectFn1 Sigma Unit
foreign import _killForceAtlas2 :: EffectFn1 Sigma Unit
module Gargantext.Components.GraphExplorer.Sigmajs where module Gargantext.Hooks.Sigmax.Sigmajs where
import Prelude import Prelude
...@@ -10,7 +10,6 @@ import Effect.Uncurried (EffectFn1, EffectFn2, mkEffectFn1, runEffectFn1) ...@@ -10,7 +10,6 @@ import Effect.Uncurried (EffectFn1, EffectFn2, mkEffectFn1, runEffectFn1)
import React (Children, ReactClass, ReactElement, ReactRef, SyntheticEventHandler, createElement, unsafeCreateElement) import React (Children, ReactClass, ReactElement, ReactRef, SyntheticEventHandler, createElement, unsafeCreateElement)
import React.SyntheticEvent (SyntheticMouseEvent) import React.SyntheticEvent (SyntheticMouseEvent)
import Record.Unsafe (unsafeGet) import Record.Unsafe (unsafeGet)
import Thermite (EventHandler)
import Unsafe.Coerce (unsafeCoerce) import Unsafe.Coerce (unsafeCoerce)
import Gargantext.Types (class Optional) import Gargantext.Types (class Optional)
...@@ -51,22 +50,6 @@ randomizeNodePositions = createElement randomizeNodePositionsClass {} [] ...@@ -51,22 +50,6 @@ randomizeNodePositions = createElement randomizeNodePositionsClass {} []
relativeSize :: {initialSize :: Number } -> ReactElement relativeSize :: {initialSize :: Number } -> ReactElement
relativeSize props = unsafeCreateElement randomizeNodePositionsClass (unsafeCoerce props) [] relativeSize props = unsafeCreateElement randomizeNodePositionsClass (unsafeCoerce props) []
forceAtlas2 :: forall o. Optional o ForceAtlas2OptProps => { | o } -> ReactElement
forceAtlas2 props = unsafeCreateElement forceAtlas2Class props []
sigma :: forall props. Optional props SigmaProps => { | props} -> Array ReactElement -> ReactElement
sigma props children = unsafeCreateElement sigmaClass (unsafeCoerce props) children
sigmaEnableWebGL :: ReactElement
sigmaEnableWebGL = createElement sigmaEnableWebGLClass {} []
edgeShapes :: { "default" :: EdgeShape } -> ReactElement
edgeShapes props = unsafeCreateElement edgeShapesClass props []
nodeShapes :: { "default" :: NodeShape } -> ReactElement
nodeShapes props = unsafeCreateElement nodeShapesClass (unsafeCoerce props) []
foreign import data SigmaNode :: Type foreign import data SigmaNode :: Type
foreign import data SigmaEdge :: Type foreign import data SigmaEdge :: Type
foreign import data SigmaSettings :: Type foreign import data SigmaSettings :: Type
...@@ -110,10 +93,12 @@ type ForceLinkOptProps = ...@@ -110,10 +93,12 @@ type ForceLinkOptProps =
newtype Randomize = Randomize String newtype Randomize = Randomize String
randomize :: { globally :: Randomize randomize ::
, locally :: Randomize { globally :: Randomize
, no :: Randomize , locally :: Randomize
} , no :: Randomize
}
randomize = randomize =
{ globally : Randomize "globally" { globally : Randomize "globally"
, locally : Randomize "locally" , locally : Randomize "locally"
...@@ -140,26 +125,6 @@ sigmaEasing = ...@@ -140,26 +125,6 @@ sigmaEasing =
, cubicInOut : SigmaEasing "cubicInOut" , cubicInOut : SigmaEasing "cubicInOut"
} }
type ForceAtlas2OptProps =
( worker :: Boolean
, barnesHutOptimize :: Boolean
, barnesHutTheta :: Number
, adjustSizes :: Boolean
, iterationsPerRender :: Number
, linLogMode :: Boolean
, outboundAttractionDistribution :: Boolean
, edgeWeightInfluence :: Number
, scalingRatio :: Number
, strongGravityMode :: Boolean
, slowDown :: Number
, gravity :: Number
, timeout :: Number
, fixedY :: Boolean
, startingIterations :: Number
, skipHidden :: Boolean
)
type NOverlapOptProps = type NOverlapOptProps =
( nodes :: Array SigmaNode ( nodes :: Array SigmaNode
, nodeMargin :: Number , nodeMargin :: Number
...@@ -200,8 +165,6 @@ webgl = Renderer "webgl" ...@@ -200,8 +165,6 @@ webgl = Renderer "webgl"
canvas :: Renderer canvas :: Renderer
canvas = Renderer "canvas" canvas = Renderer "canvas"
newtype Color = Color String
newtype SigmaGraphData = SigmaGraphData newtype SigmaGraphData = SigmaGraphData
{ nodes :: Array SigmaNode { nodes :: Array SigmaNode
, edges :: Array SigmaEdge , edges :: Array SigmaEdge
...@@ -211,7 +174,7 @@ type SigmaNodeOptProps = ...@@ -211,7 +174,7 @@ type SigmaNodeOptProps =
( x :: Number ( x :: Number
, y :: Number , y :: Number
, size :: Number , size :: Number
, color :: Color , color :: String
, label :: String , label :: String
) )
...@@ -221,7 +184,7 @@ type SigmaNodeReqProps o = ...@@ -221,7 +184,7 @@ type SigmaNodeReqProps o =
} }
type SigmaEdgeOptProps = type SigmaEdgeOptProps =
( color :: Color ( color :: String
, label :: String , label :: String
, "type" :: String , "type" :: String
) )
...@@ -245,9 +208,6 @@ sigmaEdge = unsafeCoerce ...@@ -245,9 +208,6 @@ sigmaEdge = unsafeCoerce
-- sn_ex01 :: SigmaNode -- sn_ex01 :: SigmaNode
-- sn_ex01 = sigmaNode { id : "", label : ""} -- sn_ex01 = sigmaNode { id : "", label : ""}
sigmaSettings :: forall o. Optional o SigmaSettingProps => { | o } -> SigmaSettings
sigmaSettings = unsafeCoerce
foreign import data SigmaStyle :: Type foreign import data SigmaStyle :: Type
type CameraProps = type CameraProps =
...@@ -338,104 +298,3 @@ nodeShape = ...@@ -338,104 +298,3 @@ nodeShape =
, square : NodeShape "square" , square : NodeShape "square"
} }
newtype ScalingMode = ScalingMode String
scalingMode :: { inside :: ScalingMode
, outside :: ScalingMode
}
scalingMode =
{ inside : ScalingMode "inside"
, outside : ScalingMode "outside"
}
type SigmaSettingProps =
( clone :: Boolean
, immutable :: Boolean
, verbose :: Boolean
, defaultNodeType :: String
, defaultEdgeType :: String
, defaultLabelColor :: String
, defaultEdgeCOlor :: String
, defaultNodeColor :: String
, defaultLabelSize :: String
, edgeColor :: String
, minArrowSize :: Number
, font :: String
, fontStyle :: String
, labelColor :: String
, labelSize :: String
, labelSizeRatio :: Number
, labelThreshold :: Number
, labelMaxSize :: Number
, webglOversamplingRatio :: Number
, borderSize :: Number
, nodeBorderColor :: String
, defaultNodeBorderColor :: String
, hoverFont :: String
, hoverFontStyle :: String
, labelHoverShadow :: String
, labelHoverShadowColor :: String
, nodeHoverColor :: String
, defaultNodeHoverColor :: String
, labelHoverBGColor :: String
, defaultHoverLabelBGColor :: String
, defaultHoverLabelColor :: String
, labelHoverColor :: String
, defaultLabelHoverColor :: String
, singleHover :: Boolean
, edgeHoverColor :: String
, defaultEdgeHoverColor :: String
, edgeHoverSizeRatio :: Number
, edgeHoverExtremities :: Boolean
, drawLabels :: Boolean
, drawEdgeLabels :: Boolean
, drawEdges :: Boolean
, drawNodes :: Boolean
, batchEdgesDrawing :: Boolean
, canvasEdgesBatchSize :: Number
, webglEdgesBatchSize :: Number
, hideEdgesOnMove :: Boolean
, scalingMode :: ScalingMode
, sideMargin :: Number
, minEdgeSize :: Number
, maxEdgeSize :: Number
, minNodeSize :: Number
, maxNodeSize :: Number
, touchEnabled :: Boolean
, mouseEnabled :: Boolean
, mouseWheelEnabled :: Boolean
, doubleClickEnabled :: Boolean
, eventsEnabled :: Boolean
, zoomingRatio :: Number
, doubleClickZoomingRatio :: Number
, zoomMin :: Number
, zoomMax :: Number
, mouseZoomDuration :: Number
, doubleClickZoomDuration :: Number
, mouseInertiaDuration :: Number
, mouseInertiaRatio :: Number
, touchInertiaDuration :: Number
, touchInertiaRatio :: Number
, doubleClickTimeout :: Number
, doubleTapTimeout :: Number
, dragTimeout :: Number
, autoResize :: Boolean
, autoRescale :: Boolean
, enableCamera :: Boolean
, enableHovering :: Boolean
, enableEdgeHovering :: Boolean
, edgeHoverPrecision :: Number
, rescaleIgnoreSize :: Boolean
, skipErrors :: Boolean
, nodesPowRatio :: Number
, edgesPowRatio :: Number
, animationsTime :: Number
, twNodeRendBorderSize :: Number
, twNodeRendBorderColor :: String
, twEdgeDefaultOpacity :: Number
, twSelectedColor :: String
, twNodesGreyOpacity :: Number
, twBorderGreyColor :: String
, twEdgeGreyColor :: String
)
module Gargantext.Hooks.Sigmax.Types where
import Data.Maybe (Maybe)
import Data.Sequence as Seq
import Data.Sequence (Seq)
import Reactix as R
import DOM.Simple.Types (Element)
newtype Graph n e = Graph { nodes :: Seq {|n}, edges :: Seq {|e} }
type Renderer = { "type" :: String, container :: Element }
This diff is collapsed.
...@@ -46,3 +46,9 @@ select = createDOMElement "select" ...@@ -46,3 +46,9 @@ select = createDOMElement "select"
effToggler :: forall e. R.State Boolean -> EffectFn1 e Unit effToggler :: forall e. R.State Boolean -> EffectFn1 e Unit
effToggler (_value /\ setValue) = mkEffectFn1 $ \e -> setValue not effToggler (_value /\ setValue) = mkEffectFn1 $ \e -> setValue not
nullRef :: forall t. R.Hooks (R.Ref (Nullable t))
nullRef = R.useRef null
nothingRef :: forall t. R.Hooks (R.Ref (Maybe t))
nothingRef = R.useRef Nothing
...@@ -3,7 +3,7 @@ module Gargantext.Components.NgramsTable.Spec where ...@@ -3,7 +3,7 @@ module Gargantext.Components.NgramsTable.Spec where
import Prelude import Prelude
import Data.Maybe (Maybe(..)) import Data.Maybe (Maybe(..))
import Data.Tuple (Tuple(..)) import Data.Tuple (Tuple(..))
import Gargantext.Components.NgramsTable (highlightNgrams, NgramsElement(..), NgramsTable(..)) import Gargantext.Components.NgramsTable.Core (highlightNgrams, NgramsElement(..), NgramsTable(..))
import Gargantext.Types (TermList(..)) import Gargantext.Types (TermList(..))
import Test.Spec (Spec, describe, it) import Test.Spec (Spec, describe, it)
import Test.Spec.Assertions (shouldEqual) import Test.Spec.Assertions (shouldEqual)
......
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