Commit ce88d2c0 authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[graph] implement disabling of camera based on FA2

parent 3f3693fb
Pipeline #3314 failed with stage
in 0 seconds
...@@ -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
......
...@@ -60,11 +60,12 @@ centerButton sigmaRef = B.button ...@@ -60,11 +60,12 @@ centerButton sigmaRef = B.button
------------------------------------------------------ ------------------------------------------------------
type CameraButtonProps = type CameraButtonProps =
( id :: Int ( id :: Int
, hyperdataGraph :: GET.HyperdataGraph , hyperdataGraph :: GET.HyperdataGraph
, reloadForest :: T2.ReloadS , forceAtlasState :: SigmaxTypes.ForceAtlasState
, session :: Session , reloadForest :: T2.ReloadS
, sigmaRef :: R.Ref Sigmax.Sigma , session :: Session
, sigmaRef :: R.Ref Sigmax.Sigma
) )
screenshotFilename :: Effect String screenshotFilename :: Effect String
...@@ -80,21 +81,21 @@ cameraButtonCpt :: R.Component CameraButtonProps ...@@ -80,21 +81,21 @@ cameraButtonCpt :: R.Component CameraButtonProps
cameraButtonCpt = here.component "cameraButton" cpt cameraButtonCpt = here.component "cameraButton" cpt
where where
cpt { id cpt { id
, hyperdataGraph: GET.HyperdataGraph { graph: GET.GraphData hyperdataGraph } , forceAtlasState
, hyperdataGraph: GET.HyperdataGraph { graph: GET.GraphData graphData' }
, reloadForest , reloadForest
, session , session
, sigmaRef } _ = do , sigmaRef } _ = do
pure $ B.button pure $ B.button
{ callback: \_ -> do { callback: \_ -> do
filename <- screenshotFilename filename <- screenshotFilename
let sigma = R.readRef sigmaRef Sigmax.dependOnSigma (R.readRef sigmaRef) "[cameraButton] sigma: Nothing" $ \s -> do
Sigmax.dependOnSigma sigma "[cameraButton] sigma: Nothing" $ \s -> do
screen <- Sigma.takeScreenshot s screen <- Sigma.takeScreenshot s
let graph = Sigma.graph s let graph = Sigma.graph s
edges = Graphology.edges graph edges = Graphology.edges graph
nodes = Graphology.nodes graph nodes = Graphology.nodes graph
graphData = GET.GraphData $ hyperdataGraph { edges = A.fromFoldable $ Seq.map GEU.stEdgeToGET edges graphData = GET.GraphData $ graphData' { edges = A.fromFoldable $ Seq.map GEU.stEdgeToGET edges
, nodes = A.fromFoldable $ GEU.normalizeNodes $ Seq.map GEU.stNodeToGET nodes } , nodes = A.fromFoldable $ GEU.normalizeNodes $ Seq.map GEU.stNodeToGET nodes }
let camera = Camera.toCamera $ Camera.camera s let camera = Camera.toCamera $ Camera.camera s
let hyperdataGraph' = GET.HyperdataGraph { graph: graphData, mCamera: Just camera } let hyperdataGraph' = GET.HyperdataGraph { graph: graphData, mCamera: Just camera }
launchAff_ $ do launchAff_ $ do
...@@ -107,6 +108,7 @@ cameraButtonCpt = here.component "cameraButton" cpt ...@@ -107,6 +108,7 @@ cameraButtonCpt = here.component "cameraButton" cpt
Left err -> liftEffect $ log2 "[cameraButton] RESTError" err Left err -> liftEffect $ log2 "[cameraButton] RESTError" err
Right _ret -> do Right _ret -> do
liftEffect $ T2.reload reloadForest liftEffect $ T2.reload reloadForest
, status: SigmaxTypes.forceAtlasComponentStatus forceAtlasState
, variant: OutlinedButtonVariant Secondary , variant: OutlinedButtonVariant Secondary
} [ H.text "Screenshot" ] } [ H.text "Screenshot" ]
......
...@@ -184,6 +184,7 @@ controlsCpt = R.memo' $ here.component "controls" cpt where ...@@ -184,6 +184,7 @@ controlsCpt = R.memo' $ here.component "controls" cpt where
, ,
cameraButton cameraButton
{ id: graphId' { id: graphId'
, forceAtlasState: forceAtlasState'
, hyperdataGraph: hyperdataGraph' , hyperdataGraph: hyperdataGraph'
, reloadForest , reloadForest
, session: session , session: session
......
...@@ -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.
......
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