Commit e0420b68 authored by Alexandre Delanoë's avatar Alexandre Delanoë

Merge remote-tracking branch...

Merge remote-tracking branch 'origin/451-dev-disable-controls-when-forceatlas-is-running' into dev-merge
parents 8b67c94f 54d0fdc9
...@@ -40,6 +40,7 @@ to generate this file without the comments in this block. ...@@ -40,6 +40,7 @@ to generate this file without the comments in this block.
, "foreign" , "foreign"
, "foreign-object" , "foreign-object"
, "form-urlencoded" , "form-urlencoded"
, "formatters"
, "formula" , "formula"
, "functions" , "functions"
, "graphql-client" , "graphql-client"
...@@ -47,9 +48,7 @@ to generate this file without the comments in this block. ...@@ -47,9 +48,7 @@ to generate this file without the comments in this block.
, "integers" , "integers"
, "js-timers" , "js-timers"
, "lists" , "lists"
-- , "markdown"
, "markdown-it" , "markdown-it"
--, "markdown-smolder"
, "maybe" , "maybe"
, "media-types" , "media-types"
, "milkis" , "milkis"
...@@ -75,7 +74,6 @@ to generate this file without the comments in this block. ...@@ -75,7 +74,6 @@ to generate this file without the comments in this block.
, "simple-json" , "simple-json"
, "simple-json-generics" , "simple-json-generics"
, "simplecrypto" , "simplecrypto"
-- , "smolder"
, "strings" , "strings"
, "strings-extra" , "strings-extra"
, "stringutils" , "stringutils"
......
...@@ -20,24 +20,24 @@ type Props = ...@@ -20,24 +20,24 @@ type Props =
) )
type Options = type Options =
( status :: ComponentStatus ( block :: Boolean
, size :: Sizing
, variant :: ButtonVariant
, type :: String
, className :: String , className :: String
, block :: Boolean , size :: Sizing
, status :: ComponentStatus
, title :: String , title :: String
, type :: String
, variant :: ButtonVariant
) )
options :: Record Options options :: Record Options
options = options =
{ status : Enabled { block : false
, size : MediumSize
, variant : ButtonVariant Primary
, type : "button"
, className : "" , className : ""
, block : false , status : Enabled
, size : MediumSize
, title : "" , title : ""
, type : "button"
, variant : ButtonVariant Primary
} }
-- | Structural Component for the Bootstrap button -- | Structural Component for the Bootstrap button
......
...@@ -11,15 +11,13 @@ module Gargantext.Components.GraphExplorer.Toolbar.Buttons ...@@ -11,15 +11,13 @@ module Gargantext.Components.GraphExplorer.Toolbar.Buttons
import Prelude import Prelude
import Data.Array as A import Data.Array as A
import Data.DateTime as DDT
import Data.DateTime.Instant as DDI
import Data.Either (Either(..)) import Data.Either (Either(..))
import Data.Enum (fromEnum) import Data.Formatter.DateTime as DFDT
import Data.Foldable (intercalate) import Data.Foldable (intercalate)
import Data.Maybe (Maybe(..)) import Data.Maybe (Maybe(..))
import Data.Sequence as Seq import Data.Sequence as Seq
import Data.String as DS
import DOM.Simple.Console (log2) import DOM.Simple.Console (log2)
import Effect (Effect)
import Effect.Aff (launchAff_) import Effect.Aff (launchAff_)
import Effect.Class (liftEffect) import Effect.Class (liftEffect)
import Effect.Now as EN import Effect.Now as EN
...@@ -49,68 +47,84 @@ here = R2.here "Gargantext.Components.GraphExplorer.Toolbar.Button" ...@@ -49,68 +47,84 @@ here = R2.here "Gargantext.Components.GraphExplorer.Toolbar.Button"
------------------------------------------------------ ------------------------------------------------------
centerButton :: R.Ref Sigmax.Sigma -> R.Element type CenterButtonProps =
centerButton sigmaRef = B.button ( forceAtlasState :: T.Box SigmaxTypes.ForceAtlasState
{ variant: OutlinedButtonVariant Secondary , sigmaRef :: R.Ref Sigmax.Sigma )
, callback: \_ -> do
let sigma = R.readRef sigmaRef centerButton :: R2.Leaf CenterButtonProps
Sigmax.dependOnSigma sigma "[centerButton] sigma: Nothing" $ \s -> centerButton = R2.leaf centerButtonCpt
Camera.updateCamera (Camera.camera s) Camera.defaultCamera centerButtonCpt :: R.Component CenterButtonProps
} centerButtonCpt = here.component "centerButton" cpt
[ H.text "Center" ] where
cpt { forceAtlasState
, sigmaRef } _ = do
forceAtlasState' <- R2.useLive' forceAtlasState
pure $ B.button
{ callback: \_ -> do
Sigmax.dependOnSigma (R.readRef sigmaRef) "[centerButton] sigma: Nothing" $ \s ->
Camera.updateCamera (Camera.camera s) Camera.defaultCamera
, status: SigmaxTypes.forceAtlasComponentStatus forceAtlasState'
, variant: OutlinedButtonVariant Secondary
}
[ H.text "Center" ]
------------------------------------------------------ ------------------------------------------------------
type CameraButtonProps = type CameraButtonProps =
( id :: Int ( id :: Int
, hyperdataGraph :: GET.HyperdataGraph , hyperdataGraph :: GET.HyperdataGraph
, session :: Session , forceAtlasState :: T.Box SigmaxTypes.ForceAtlasState
, sigmaRef :: R.Ref Sigmax.Sigma , reloadForest :: T2.ReloadS
, reloadForest :: T2.ReloadS , session :: Session
, sigmaRef :: R.Ref Sigmax.Sigma
) )
screenshotFilename :: Effect String
cameraButton :: Record CameraButtonProps -> R.Element screenshotFilename = do
cameraButton { id nowdt <- EN.nowDateTime
, hyperdataGraph: GET.HyperdataGraph { graph: GET.GraphData hyperdataGraph } pure $ case DFDT.formatDateTime "YYYY-MM-DDTHH:mm:ss" nowdt of
, session Left err -> err
, sigmaRef Right s -> s <> "-screenshot.png"
, reloadForest } = B.button
cameraButton :: R2.Leaf CameraButtonProps
{ variant: OutlinedButtonVariant Secondary cameraButton = R2.leaf cameraButtonCpt
, callback: \_ -> do cameraButtonCpt :: R.Component CameraButtonProps
let sigma = R.readRef sigmaRef cameraButtonCpt = here.component "cameraButton" cpt
Sigmax.dependOnSigma sigma "[cameraButton] sigma: Nothing" $ \s -> do where
screen <- Sigma.takeScreenshot s cpt { id
now <- EN.now , forceAtlasState
let nowdt = DDI.toDateTime now , hyperdataGraph: GET.HyperdataGraph { graph: GET.GraphData graphData' }
nowd = DDT.date nowdt , reloadForest
nowt = DDT.time nowdt , session
nowStr = DS.joinWith "-" [ show $ fromEnum $ DDT.year nowd , sigmaRef } _ = do
, show $ fromEnum $ DDT.month nowd forceAtlasState' <- R2.useLive' forceAtlasState
, show $ fromEnum $ DDT.day nowd
, show $ fromEnum $ DDT.hour nowt pure $ B.button
, show $ fromEnum $ DDT.minute nowt { callback: \_ -> do
, show $ fromEnum $ DDT.second nowt ] filename <- screenshotFilename
let graph = Sigma.graph s Sigmax.dependOnSigma (R.readRef sigmaRef) "[cameraButton] sigma: Nothing" $ \s -> do
edges = Graphology.edges graph screen <- Sigma.takeScreenshot s
nodes = Graphology.nodes graph let graph = Sigma.graph s
graphData = GET.GraphData $ hyperdataGraph { edges = A.fromFoldable $ Seq.map GEU.stEdgeToGET edges edges = Graphology.edges graph
, nodes = A.fromFoldable $ GEU.normalizeNodes $ Seq.map GEU.stNodeToGET nodes } nodes = Graphology.nodes graph
let camera = Camera.toCamera $ Camera.camera s graphData = GET.GraphData $ graphData' { edges = A.fromFoldable $ Seq.map GEU.stEdgeToGET edges
let hyperdataGraph' = GET.HyperdataGraph { graph: graphData, mCamera: Just camera } , nodes = A.fromFoldable $ GEU.normalizeNodes $ Seq.map GEU.stNodeToGET nodes }
launchAff_ $ do let camera = Camera.toCamera $ Camera.camera s
eClonedGraphId <- cloneGraph { id, hyperdataGraph: hyperdataGraph', session } let hyperdataGraph' = GET.HyperdataGraph { graph: graphData, mCamera: Just camera }
case eClonedGraphId of launchAff_ $ do
Left err -> liftEffect $ log2 "[cameraButton] RESTError" err eClonedGraphId <- cloneGraph { id, hyperdataGraph: hyperdataGraph', session }
Right clonedGraphId -> do case eClonedGraphId of
eRet <- uploadArbitraryData session clonedGraphId Plain (Just $ nowStr <> "-" <> "screenshot.png") screen Left err -> liftEffect $ log2 "[cameraButton] RESTError" err
case eRet of Right clonedGraphId -> do
Left err -> liftEffect $ log2 "[cameraButton] RESTError" err eRet <- uploadArbitraryData session clonedGraphId Plain (Just filename) screen
Right _ret -> do case eRet of
liftEffect $ T2.reload reloadForest Left err -> liftEffect $ log2 "[cameraButton] RESTError" err
} Right _ret -> do
[ H.text "Screenshot" ] liftEffect $ T2.reload reloadForest
, status: SigmaxTypes.forceAtlasComponentStatus forceAtlasState'
, variant: OutlinedButtonVariant Secondary
} [ H.text "Screenshot" ]
------------------------------------------------------ ------------------------------------------------------
...@@ -129,28 +143,23 @@ edgesToggleButtonCpt = here.component "edgesToggleButton" cpt ...@@ -129,28 +143,23 @@ edgesToggleButtonCpt = here.component "edgesToggleButton" cpt
state' <- R2.useLive' state state' <- R2.useLive' state
stateAtlas' <- R2.useLive' stateAtlas stateAtlas' <- R2.useLive' stateAtlas
-- Computed
let
cst SigmaxTypes.InitialRunning = Disabled
cst SigmaxTypes.Running = Disabled
cst _ = Enabled
-- Render -- Render
pure $ pure $
B.button B.button
{ variant: state' == SigmaxTypes.EShow ? { -- TODO: Move this to Graph.purs to the R.useEffect handler which renders nodes/edges
callback: \_ -> T.modify_ SigmaxTypes.toggleShowEdgesState state
, status: SigmaxTypes.forceAtlasComponentStatus stateAtlas'
, variant: state' == SigmaxTypes.EShow ?
ButtonVariant Secondary $ ButtonVariant Secondary $
OutlinedButtonVariant Secondary OutlinedButtonVariant Secondary
, status: cst stateAtlas'
-- TODO: Move this to Graph.purs to the R.useEffect handler which renders nodes/edges
, callback: \_ -> T.modify_ SigmaxTypes.toggleShowEdgesState state
} }
[ H.text "Edges" ] [ H.text "Edges" ]
------------------------------------------------------ ------------------------------------------------------
type LouvainToggleButtonProps = type LouvainToggleButtonProps =
( state :: T.Box Boolean ( forceAtlasState :: T.Box SigmaxTypes.ForceAtlasState
, state :: T.Box Boolean
) )
louvainToggleButton :: R2.Leaf LouvainToggleButtonProps louvainToggleButton :: R2.Leaf LouvainToggleButtonProps
...@@ -158,16 +167,17 @@ louvainToggleButton = R2.leaf louvainToggleButtonCpt ...@@ -158,16 +167,17 @@ louvainToggleButton = R2.leaf louvainToggleButtonCpt
louvainToggleButtonCpt :: R.Component LouvainToggleButtonProps louvainToggleButtonCpt :: R.Component LouvainToggleButtonProps
louvainToggleButtonCpt = here.component "louvainToggleButton" cpt louvainToggleButtonCpt = here.component "louvainToggleButton" cpt
where where
cpt { state } _ = do cpt { forceAtlasState, state } _ = do
state' <- R2.useLive' state state' <- R2.useLive' state
forceAtlasState' <- R2.useLive' forceAtlasState
pure $ pure $
B.button B.button
{ variant: state' ? { callback: \_ -> T.modify_ (not) state
, status: SigmaxTypes.forceAtlasComponentStatus forceAtlasState'
, variant: state' ?
ButtonVariant Secondary $ ButtonVariant Secondary $
OutlinedButtonVariant Secondary OutlinedButtonVariant Secondary
, callback: \_ -> T.modify_ (not) state
} }
[ H.text "Louvain" ] [ H.text "Louvain" ]
...@@ -238,7 +248,7 @@ resetForceAtlasButtonCpt = here.component "resetForceAtlasToggleButton" cpt ...@@ -238,7 +248,7 @@ resetForceAtlasButtonCpt = here.component "resetForceAtlasToggleButton" cpt
onClick forceAtlasState sigmaRef _ = do onClick forceAtlasState sigmaRef _ = do
-- TODO Sigma.killForceAtlas2 sigma -- TODO Sigma.killForceAtlas2 sigma
-- startForceAtlas2 sigma -- startForceAtlas2 sigma
Sigmax.dependOnSigma (R.readRef sigmaRef) "[resetForceAtlasButton] no sigma" $ \sigma -> do Sigmax.dependOnSigma (R.readRef sigmaRef) "[resetForceAtlasButton] no sigma" $ \_sigma -> do
-- TODO Use fa2Ref instead of sigmaRef -- TODO Use fa2Ref instead of sigmaRef
--Sigma.killForceAtlas2 sigma --Sigma.killForceAtlas2 sigma
--Sigma.refreshForceAtlas sigma Graph.forceAtlas2Settings --Sigma.refreshForceAtlas sigma Graph.forceAtlas2Settings
...@@ -247,7 +257,8 @@ resetForceAtlasButtonCpt = here.component "resetForceAtlasToggleButton" cpt ...@@ -247,7 +257,8 @@ resetForceAtlasButtonCpt = here.component "resetForceAtlasToggleButton" cpt
------------------------------------------------------------------ ------------------------------------------------------------------
type MultiSelectEnabledButtonProps = type MultiSelectEnabledButtonProps =
( state :: T.Box Boolean ( forceAtlasState :: T.Box SigmaxTypes.ForceAtlasState
, state :: T.Box Boolean
) )
multiSelectEnabledButton :: R2.Leaf MultiSelectEnabledButtonProps multiSelectEnabledButton :: R2.Leaf MultiSelectEnabledButtonProps
...@@ -255,29 +266,31 @@ multiSelectEnabledButton = R2.leaf multiSelectEnabledButtonCpt ...@@ -255,29 +266,31 @@ multiSelectEnabledButton = R2.leaf multiSelectEnabledButtonCpt
multiSelectEnabledButtonCpt :: R.Component MultiSelectEnabledButtonProps multiSelectEnabledButtonCpt :: R.Component MultiSelectEnabledButtonProps
multiSelectEnabledButtonCpt = here.component "multiSelectEnabledButton" cpt multiSelectEnabledButtonCpt = here.component "multiSelectEnabledButton" cpt
where where
cpt { state } _ = do cpt { forceAtlasState, state } _ = do
state' <- R2.useLive' state state' <- R2.useLive' state
forceAtlasState' <- R2.useLive' forceAtlasState
pure $ pure $
H.div H.div
{ className: "btn-group" { className: "btn-group"
, role: "group" , role: "group"
} }
[ [
B.button B.button
{ variant: state' ? { callback: \_ -> T.write_ false state
, status: SigmaxTypes.forceAtlasComponentStatus forceAtlasState'
, variant: state' ?
OutlinedButtonVariant Secondary $ OutlinedButtonVariant Secondary $
ButtonVariant Secondary ButtonVariant Secondary
, callback: \_ -> T.write_ false state
} }
[ H.text "Single" ] [ H.text "Single" ]
, ,
B.button B.button
{ variant: state' ? { callback: \_ -> T.write_ true state
, status: SigmaxTypes.forceAtlasComponentStatus forceAtlasState'
, variant: state' ?
ButtonVariant Secondary $ ButtonVariant Secondary $
OutlinedButtonVariant Secondary OutlinedButtonVariant Secondary
, callback: \_ -> T.write_ true state
} }
[ H.text "Multiple" ] [ H.text "Multiple" ]
] ]
...@@ -16,7 +16,7 @@ import Gargantext.Components.GraphExplorer.Resources as Graph ...@@ -16,7 +16,7 @@ import Gargantext.Components.GraphExplorer.Resources as Graph
import Gargantext.Components.GraphExplorer.Store as GraphStore import Gargantext.Components.GraphExplorer.Store as GraphStore
import Gargantext.Components.GraphExplorer.Toolbar.Buttons (centerButton, cameraButton, edgesToggleButton, louvainToggleButton, pauseForceAtlasButton, multiSelectEnabledButton) import Gargantext.Components.GraphExplorer.Toolbar.Buttons (centerButton, cameraButton, edgesToggleButton, louvainToggleButton, pauseForceAtlasButton, multiSelectEnabledButton)
import Gargantext.Components.GraphExplorer.Toolbar.RangeControl (edgeConfluenceControl, edgeWeightControl, nodeSizeControl) import Gargantext.Components.GraphExplorer.Toolbar.RangeControl (edgeConfluenceControl, edgeWeightControl, nodeSizeControl)
import Gargantext.Components.GraphExplorer.Toolbar.SlideButton (labelSizeButton, labelRenderedSizeThresholdButton, mouseSelectorSizeButton) import Gargantext.Components.GraphExplorer.Toolbar.SlideButton (labelSizeButton, labelRenderedSizeThresholdButton, mouseSelectorSizeSlider)
import Gargantext.Components.GraphExplorer.Types as GET import Gargantext.Components.GraphExplorer.Types as GET
import Gargantext.Hooks.Session (useSession) import Gargantext.Hooks.Session (useSession)
import Gargantext.Hooks.Sigmax.ForceAtlas2 as ForceAtlas import Gargantext.Hooks.Sigmax.ForceAtlas2 as ForceAtlas
...@@ -184,10 +184,11 @@ controlsCpt = R.memo' $ here.component "controls" cpt where ...@@ -184,10 +184,11 @@ controlsCpt = R.memo' $ here.component "controls" cpt where
, ,
cameraButton cameraButton
{ id: graphId' { id: graphId'
, forceAtlasState
, hyperdataGraph: hyperdataGraph' , hyperdataGraph: hyperdataGraph'
, reloadForest
, session: session , session: session
, sigmaRef: sigmaRef , sigmaRef: sigmaRef
, reloadForest
} }
] ]
, ,
...@@ -197,7 +198,8 @@ controlsCpt = R.memo' $ here.component "controls" cpt where ...@@ -197,7 +198,8 @@ controlsCpt = R.memo' $ here.component "controls" cpt where
, titleSlot: H.text "View settings" , titleSlot: H.text "View settings"
} }
[ [
centerButton sigmaRef centerButton { forceAtlasState
, sigmaRef }
, ,
gap gap
, ,
...@@ -208,7 +210,8 @@ controlsCpt = R.memo' $ here.component "controls" cpt where ...@@ -208,7 +210,8 @@ controlsCpt = R.memo' $ here.component "controls" cpt where
, ,
gap gap
, ,
louvainToggleButton { state: showLouvain } louvainToggleButton { forceAtlasState
, state: showLouvain }
] ]
] ]
, ,
...@@ -222,13 +225,16 @@ controlsCpt = R.memo' $ here.component "controls" cpt where ...@@ -222,13 +225,16 @@ controlsCpt = R.memo' $ here.component "controls" cpt where
} }
[ [
-- zoom: 0 -100 - calculate ratio -- zoom: 0 -100 - calculate ratio
multiSelectEnabledButton { state: multiSelectEnabled } multiSelectEnabledButton { forceAtlasState
, state: multiSelectEnabled }
, ,
gap gap
, ,
-- toggle multi node selection -- toggle multi node selection
-- save button -- save button
mouseSelectorSizeButton sigmaRef mouseSelectorSize mouseSelectorSizeSlider { forceAtlasState
, sigmaRef
, state: mouseSelectorSize }
] ]
] ]
, ,
...@@ -262,7 +268,9 @@ controlsCpt = R.memo' $ here.component "controls" cpt where ...@@ -262,7 +268,9 @@ controlsCpt = R.memo' $ here.component "controls" cpt where
-- run demo -- run demo
-- search button -- search button
-- search topics -- search topics
labelSizeButton sigmaRef labelSize labelSizeButton { forceAtlasState
, sigmaRef
, state: labelSize }
, ,
-- labels size: 1-4 -- labels size: 1-4
nodeSizeControl nodeSizeControl
...@@ -279,7 +287,9 @@ controlsCpt = R.memo' $ here.component "controls" cpt where ...@@ -279,7 +287,9 @@ controlsCpt = R.memo' $ here.component "controls" cpt where
-- run demo -- run demo
-- search button -- search button
-- search topics -- search topics
labelRenderedSizeThresholdButton sigmaRef labelRenderedSizeThreshold labelRenderedSizeThresholdButton { forceAtlasState
, sigmaRef
, state: labelRenderedSizeThreshold }
-- , -- ,
-- -- labels size: 1-4 -- -- labels size: 1-4
-- nodeSizeControl -- nodeSizeControl
......
...@@ -3,7 +3,7 @@ module Gargantext.Components.GraphExplorer.Toolbar.SlideButton ...@@ -3,7 +3,7 @@ module Gargantext.Components.GraphExplorer.Toolbar.SlideButton
, sizeButton , sizeButton
, labelSizeButton , labelSizeButton
, labelRenderedSizeThresholdButton , labelRenderedSizeThresholdButton
, mouseSelectorSizeButton , mouseSelectorSizeSlider
) where ) where
import Data.Maybe (Maybe(..)) import Data.Maybe (Maybe(..))
...@@ -14,27 +14,33 @@ import Reactix as R ...@@ -14,27 +14,33 @@ import Reactix as R
import Reactix.DOM.HTML as H import Reactix.DOM.HTML as H
import Toestand as T import Toestand as T
import Gargantext.Components.Bootstrap.Types (ComponentStatus(Disabled))
import Gargantext.Hooks.Sigmax as Sigmax import Gargantext.Hooks.Sigmax as Sigmax
import Gargantext.Hooks.Sigmax.Sigma as Sigma import Gargantext.Hooks.Sigmax.Sigma as Sigma
import Gargantext.Hooks.Sigmax.Types as SigmaxTypes
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
here :: R2.Here here :: R2.Here
here = R2.here "Gargantext.Components.GraphExplorer.Toolbar.SlideButton" here = R2.here "Gargantext.Components.GraphExplorer.Toolbar.SlideButton"
type Props = type Props =
( caption :: String ( caption :: String
, min :: Number , forceAtlasState :: T.Box SigmaxTypes.ForceAtlasState
, max :: Number , min :: Number
, onChange :: forall e. e -> Effect Unit , max :: Number
, state :: T.Box Number , onChange :: forall e. e -> Effect Unit
, state :: T.Box Number
) )
sizeButton :: Record Props -> R.Element sizeButton :: Record Props -> R.Element
sizeButton props = R.createElement sizeButtonCpt props [] sizeButton props = R.createElement sizeButtonCpt props []
sizeButtonCpt :: R.Component Props sizeButtonCpt :: R.Component Props
sizeButtonCpt = here.component "sizeButton" cpt where sizeButtonCpt = here.component "sizeButton" cpt where
cpt { state, caption, min, max, onChange } _ = do cpt { state, caption, forceAtlasState, min, max, onChange } _ = do
defaultValue <- T.useLive T.unequal state defaultValue <- T.useLive T.unequal state
forceAtlasState' <- R2.useLive' forceAtlasState
let status = SigmaxTypes.forceAtlasComponentStatus forceAtlasState'
pure $ pure $
...@@ -55,70 +61,101 @@ sizeButtonCpt = here.component "sizeButton" cpt where ...@@ -55,70 +61,101 @@ sizeButtonCpt = here.component "sizeButton" cpt where
, defaultValue , defaultValue
, on: { input: onChange } , on: { input: onChange }
, className: "range-simple__input" , className: "range-simple__input"
, disabled: status == Disabled
} }
] ]
] ]
labelSizeButton :: R.Ref Sigmax.Sigma -> T.Box Number -> R.Element type LabelSizeButtonProps =
labelSizeButton sigmaRef state = ( forceAtlasState :: T.Box SigmaxTypes.ForceAtlasState
sizeButton { , sigmaRef :: R.Ref Sigmax.Sigma
state , state :: T.Box Number)
, caption: "Label size"
, min: 1.0 labelSizeButton :: R2.Leaf LabelSizeButtonProps
, max: 30.0 labelSizeButton = R2.leaf labelSizeButtonCpt
, onChange: \e -> do labelSizeButtonCpt :: R.Component LabelSizeButtonProps
let sigma = R.readRef sigmaRef labelSizeButtonCpt = here.component "labelSizeButton" cpt
let newValue' = DN.fromString $ R.unsafeEventValue e where
case newValue' of cpt { forceAtlasState, sigmaRef, state} _ = do
Nothing -> pure unit pure $ sizeButton {
Just newValue -> state
Sigmax.dependOnSigma sigma "[labelSizeButton] sigma: Nothing" $ \s -> do , caption: "Label size"
Sigma.setSettings s { , forceAtlasState
defaultLabelSize: newValue , min: 1.0
, drawLabels: true , max: 30.0
, labelSize: newValue , onChange: \e -> do
, maxNodeSize: newValue / 2.5 let sigma = R.readRef sigmaRef
--, labelSizeRatio: newValue / 2.5 let newValue' = DN.fromString $ R.unsafeEventValue e
} case newValue' of
T.write_ newValue state Nothing -> pure unit
} Just newValue ->
Sigmax.dependOnSigma sigma "[labelSizeButton] sigma: Nothing" $ \s -> do
Sigma.setSettings s {
defaultLabelSize: newValue
, drawLabels: true
, labelSize: newValue
, maxNodeSize: newValue / 2.5
--, labelSizeRatio: newValue / 2.5
}
T.write_ newValue state
}
type LabelRenderedSizeThresholdButtonProps =
( forceAtlasState :: T.Box SigmaxTypes.ForceAtlasState
, sigmaRef :: R.Ref Sigmax.Sigma
, state :: T.Box Number)
labelRenderedSizeThresholdButton :: R2.Leaf LabelRenderedSizeThresholdButtonProps
labelRenderedSizeThresholdButton = R2.leaf labelRenderedSizeThresholdButtonCpt
labelRenderedSizeThresholdButtonCpt :: R.Component LabelRenderedSizeThresholdButtonProps
labelRenderedSizeThresholdButtonCpt = here.component "labelRenderedSizeThresholdButton" cpt
where
cpt { forceAtlasState, sigmaRef, state} _ = do
pure $ sizeButton {
state
, caption: "Label rendered size threshold"
, forceAtlasState
, min: 0.0
, max: 10.0
, onChange: \e -> do
let sigma = R.readRef sigmaRef
let newValue' = DN.fromString $ R.unsafeEventValue e
case newValue' of
Nothing -> pure unit
Just newValue ->
Sigmax.dependOnSigma sigma "[labelRenderdSizeThresholdButton] sigma: Nothing" $ \s -> do
Sigma.setSettings s {
labelRenderedSizeThreshold: newValue
}
T.write_ newValue state
}
labelRenderedSizeThresholdButton :: R.Ref Sigmax.Sigma -> T.Box Number -> R.Element type MouseSelectorSizeSliderProps =
labelRenderedSizeThresholdButton sigmaRef state = ( forceAtlasState :: T.Box SigmaxTypes.ForceAtlasState
sizeButton { , sigmaRef :: R.Ref Sigmax.Sigma
state , state :: T.Box Number)
, caption: "Label rendered size threshold"
, min: 0.0
, max: 10.0
, onChange: \e -> do
let sigma = R.readRef sigmaRef
let newValue' = DN.fromString $ R.unsafeEventValue e
case newValue' of
Nothing -> pure unit
Just newValue ->
Sigmax.dependOnSigma sigma "[labelRenderdSizeThresholdButton] sigma: Nothing" $ \s -> do
Sigma.setSettings s {
labelRenderedSizeThreshold: newValue
}
T.write_ newValue state
}
mouseSelectorSizeButton :: R.Ref Sigmax.Sigma -> T.Box Number -> R.Element mouseSelectorSizeSlider :: R2.Leaf MouseSelectorSizeSliderProps
mouseSelectorSizeButton sigmaRef state = mouseSelectorSizeSlider = R2.leaf mouseSelectorSizeSliderCpt
sizeButton { mouseSelectorSizeSliderCpt :: R.Component MouseSelectorSizeSliderProps
state mouseSelectorSizeSliderCpt = here.component "mouseSelectorSizeSlider" cpt
, caption: "Selector size (Shift + wheel)" where
, min: 1.0 cpt { forceAtlasState, sigmaRef, state } _ = do
, max: 50.0 pure $ sizeButton {
, onChange: \e -> do caption: "Selector size (Shift + wheel)"
let sigma = R.readRef sigmaRef , forceAtlasState
let newValue' = DN.fromString $ R.unsafeEventValue e , min: 1.0
case newValue' of , max: 50.0
Nothing -> pure unit , onChange: \e -> do
Just newValue -> let sigma = R.readRef sigmaRef
Sigmax.dependOnSigma sigma "[mouseSelectorSizeButton] sigma: Nothing" $ \s -> do let newValue' = DN.fromString $ R.unsafeEventValue e
Sigma.setSettings s { case newValue' of
mouseSelectorSize: newValue Nothing -> pure unit
} Just newValue ->
T.write_ newValue state Sigmax.dependOnSigma sigma "[mouseSelectorSizeButton] sigma: Nothing" $ \s -> do
} Sigma.setSettings s {
mouseSelectorSize: newValue
}
T.write_ newValue state
, state
}
...@@ -13,6 +13,7 @@ import Data.Tuple (Tuple(..)) ...@@ -13,6 +13,7 @@ import Data.Tuple (Tuple(..))
import Partial.Unsafe (unsafePartial) import Partial.Unsafe (unsafePartial)
import Prelude (class Eq, class Show, map, ($), (&&), (==), (||), (<$>), (<), mod, not) import Prelude (class Eq, class Show, map, ($), (&&), (==), (||), (<$>), (<), mod, not)
import Gargantext.Components.Bootstrap.Types (ComponentStatus(..))
import Gargantext.Components.GraphExplorer.GraphTypes as GEGT import Gargantext.Components.GraphExplorer.GraphTypes as GEGT
import Gargantext.Data.Louvain as Louvain import Gargantext.Data.Louvain as Louvain
import Gargantext.Types as GT import Gargantext.Types as GT
...@@ -172,6 +173,15 @@ toggleForceAtlasState Running = Paused ...@@ -172,6 +173,15 @@ toggleForceAtlasState Running = Paused
toggleForceAtlasState Paused = Running toggleForceAtlasState Paused = Running
toggleForceAtlasState Killed = InitialRunning toggleForceAtlasState Killed = InitialRunning
forceAtlasComponentStatus :: ForceAtlasState -> ComponentStatus
forceAtlasComponentStatus InitialRunning = Disabled
forceAtlasComponentStatus InitialStopped = Enabled
forceAtlasComponentStatus Running = Disabled
forceAtlasComponentStatus Paused = Enabled
forceAtlasComponentStatus Killed = Enabled
-- | Custom state for show edges. Normally it is EShow or EHide (show/hide -- | Custom state for show edges. Normally it is EShow or EHide (show/hide
-- | edges). However, edges are temporarily turned off when forceAtlas is -- | edges). However, edges are temporarily turned off when forceAtlas is
-- | running. -- | running.
...@@ -219,10 +229,8 @@ forceAtlasEdgeState Killed es = es ...@@ -219,10 +229,8 @@ forceAtlasEdgeState Killed es = es
-- | Return state in which labels should be depending on forceAtlasState -- | Return state in which labels should be depending on forceAtlasState
forceAtlasLabelState :: ForceAtlasState -> Boolean forceAtlasLabelState :: ForceAtlasState -> Boolean
forceAtlasLabelState InitialRunning = false forceAtlasLabelState InitialRunning = false
forceAtlasLabelState InitialStopped = true forceAtlasLabelState Running = false
forceAtlasLabelState Running = false forceAtlasLabelState _ = true
forceAtlasLabelState Paused = true
forceAtlasLabelState Killed = true
......
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