Commit ce88d2c0 authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[graph] implement disabling of camera based on FA2

parent 3f3693fb
......@@ -20,24 +20,24 @@ type Props =
)
type Options =
( status :: ComponentStatus
, size :: Sizing
, variant :: ButtonVariant
, type :: String
( block :: Boolean
, className :: String
, block :: Boolean
, size :: Sizing
, status :: ComponentStatus
, title :: String
, type :: String
, variant :: ButtonVariant
)
options :: Record Options
options =
{ status : Enabled
, size : MediumSize
, variant : ButtonVariant Primary
, type : "button"
{ block : false
, className : ""
, block : false
, status : Enabled
, size : MediumSize
, title : ""
, type : "button"
, variant : ButtonVariant Primary
}
-- | Structural Component for the Bootstrap button
......
......@@ -60,11 +60,12 @@ centerButton sigmaRef = B.button
------------------------------------------------------
type CameraButtonProps =
( id :: Int
, hyperdataGraph :: GET.HyperdataGraph
, reloadForest :: T2.ReloadS
, session :: Session
, sigmaRef :: R.Ref Sigmax.Sigma
( id :: Int
, hyperdataGraph :: GET.HyperdataGraph
, forceAtlasState :: SigmaxTypes.ForceAtlasState
, reloadForest :: T2.ReloadS
, session :: Session
, sigmaRef :: R.Ref Sigmax.Sigma
)
screenshotFilename :: Effect String
......@@ -80,21 +81,21 @@ cameraButtonCpt :: R.Component CameraButtonProps
cameraButtonCpt = here.component "cameraButton" cpt
where
cpt { id
, hyperdataGraph: GET.HyperdataGraph { graph: GET.GraphData hyperdataGraph }
, forceAtlasState
, hyperdataGraph: GET.HyperdataGraph { graph: GET.GraphData graphData' }
, reloadForest
, session
, sigmaRef } _ = do
pure $ B.button
{ callback: \_ -> do
filename <- screenshotFilename
let sigma = R.readRef sigmaRef
Sigmax.dependOnSigma sigma "[cameraButton] sigma: Nothing" $ \s -> do
Sigmax.dependOnSigma (R.readRef sigmaRef) "[cameraButton] sigma: Nothing" $ \s -> do
screen <- Sigma.takeScreenshot s
let graph = Sigma.graph s
edges = Graphology.edges graph
nodes = Graphology.nodes graph
graphData = GET.GraphData $ hyperdataGraph { edges = A.fromFoldable $ Seq.map GEU.stEdgeToGET edges
, nodes = A.fromFoldable $ GEU.normalizeNodes $ Seq.map GEU.stNodeToGET nodes }
graphData = GET.GraphData $ graphData' { edges = A.fromFoldable $ Seq.map GEU.stEdgeToGET edges
, nodes = A.fromFoldable $ GEU.normalizeNodes $ Seq.map GEU.stNodeToGET nodes }
let camera = Camera.toCamera $ Camera.camera s
let hyperdataGraph' = GET.HyperdataGraph { graph: graphData, mCamera: Just camera }
launchAff_ $ do
......@@ -107,6 +108,7 @@ cameraButtonCpt = here.component "cameraButton" cpt
Left err -> liftEffect $ log2 "[cameraButton] RESTError" err
Right _ret -> do
liftEffect $ T2.reload reloadForest
, status: SigmaxTypes.forceAtlasComponentStatus forceAtlasState
, variant: OutlinedButtonVariant Secondary
} [ H.text "Screenshot" ]
......
......@@ -184,6 +184,7 @@ controlsCpt = R.memo' $ here.component "controls" cpt where
,
cameraButton
{ id: graphId'
, forceAtlasState: forceAtlasState'
, hyperdataGraph: hyperdataGraph'
, reloadForest
, session: session
......
......@@ -13,6 +13,7 @@ import Data.Tuple (Tuple(..))
import Partial.Unsafe (unsafePartial)
import Prelude (class Eq, class Show, map, ($), (&&), (==), (||), (<$>), (<), mod, not)
import Gargantext.Components.Bootstrap.Types (ComponentStatus(..))
import Gargantext.Components.GraphExplorer.GraphTypes as GEGT
import Gargantext.Data.Louvain as Louvain
import Gargantext.Types as GT
......@@ -172,6 +173,15 @@ toggleForceAtlasState Running = Paused
toggleForceAtlasState Paused = Running
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
-- | edges). However, edges are temporarily turned off when forceAtlas is
-- | running.
......
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