Commit c03222b2 authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[graph explorer] refresh tree when screenshot is made

parent 69038bce
......@@ -120,7 +120,8 @@ explorerCpt = R.hooksComponentWithModule thisModule "explorer" cpt
graphVersionRef <- R.useRef (GUR.value graphVersion)
treeReload <- GUR.new
treeReloadRef <- GUR.newIInitialized treeReload
controls <- Controls.useGraphControls { forceAtlasS
controls <- Controls.useGraphControls { asyncTasksRef
, forceAtlasS
, graph
, graphId
, hyperdataGraph
......
......@@ -7,11 +7,12 @@ module Gargantext.Components.GraphExplorer.Button
import Prelude
import Data.Enum (fromEnum)
import Data.Maybe (Maybe(..))
import Data.DateTime as DDT
import Data.DateTime.Instant as DDI
import Data.Enum (fromEnum)
import Data.Maybe (Maybe(..))
import Data.String as DS
import Data.Tuple (snd)
import DOM.Simple.Console (log2)
import Effect (Effect)
import Effect.Aff (launchAff_)
......@@ -20,6 +21,7 @@ import Effect.Now as EN
import Reactix as R
import Reactix.DOM.HTML as H
import Gargantext.AsyncTasks as GAT
import Gargantext.Components.Forest.Tree.Node.Action.Upload (uploadArbitraryDataURL)
import Gargantext.Components.GraphExplorer.API (cloneGraph)
import Gargantext.Components.GraphExplorer.Types as GET
......@@ -29,6 +31,7 @@ import Gargantext.Hooks.Sigmax.Sigma as Sigma
import Gargantext.Sessions (Session)
import Gargantext.Utils.Reactix as R2
thisModule :: String
thisModule = "Gargantext.Components.GraphExplorer.Button"
type Props = (
......@@ -58,7 +61,8 @@ centerButton sigmaRef = simpleButton {
type CameraButtonProps = (
id :: Int
asyncTasksRef :: R.Ref (Maybe GAT.Reductor)
, id :: Int
, hyperdataGraph :: GET.HyperdataGraph
, session :: Session
, sigmaRef :: R.Ref Sigmax.Sigma
......@@ -67,7 +71,8 @@ type CameraButtonProps = (
cameraButton :: Record CameraButtonProps -> R.Element
cameraButton { id
cameraButton { asyncTasksRef
, id
, hyperdataGraph: GET.HyperdataGraph { graph: GET.GraphData hyperdataGraph }
, session
, sigmaRef
......@@ -102,8 +107,12 @@ cameraButton { id
, mCamera: Just camera }
launchAff_ $ do
clonedGraphId <- cloneGraph { id, hyperdataGraph, session }
ret <- uploadArbitraryDataURL session clonedGraphId (Just $ nowStr <> "-" <> "screenshot.png") screen
liftEffect $ treeReload unit
pure ret
task <- uploadArbitraryDataURL session clonedGraphId (Just $ nowStr <> "-" <> "screenshot.png") screen
case R.readRef asyncTasksRef of
Nothing -> pure unit
Just asyncTasks -> liftEffect $ do
snd asyncTasks $ GAT.Insert id task
treeReload unit
pure task
, text: "Screenshot"
}
......@@ -20,6 +20,7 @@ import Prelude
import Reactix as R
import Reactix.DOM.HTML as RH
import Gargantext.AsyncTasks as GAT
import Gargantext.Components.Graph as Graph
import Gargantext.Components.GraphExplorer.Button (centerButton, cameraButton)
import Gargantext.Components.GraphExplorer.RangeControl (edgeConfluenceControl, edgeWeightControl, nodeSizeControl)
......@@ -35,7 +36,8 @@ thisModule :: String
thisModule = "Gargantext.Components.GraphExplorer.Controls"
type Controls =
( edgeConfluence :: R.State Range.NumberRange
( asyncTasksRef :: R.Ref (Maybe GAT.Reductor)
, edgeConfluence :: R.State Range.NumberRange
, edgeWeight :: R.State Range.NumberRange
, forceAtlasState :: R.State SigmaxT.ForceAtlasState
, graph :: SigmaxT.SGraph
......@@ -160,11 +162,12 @@ controlsCpt = R.hooksComponentWithModule thisModule "controls" cpt
, RH.li { className: "nav-item" } [ multiSelectEnabledButton props.multiSelectEnabled ] -- toggle multi node selection
-- save button
, RH.li { className: "nav-item" } [ mouseSelectorSizeButton props.sigmaRef localControls.mouseSelectorSize ]
, RH.li { className: "nav-item" } [ cameraButton { id: props.graphId
, hyperdataGraph: props.hyperdataGraph
, session: props.session
, sigmaRef: props.sigmaRef
, treeReload: props.treeReload } ]
, RH.li { className: "nav-item" } [ cameraButton { asyncTasksRef: props.asyncTasksRef
, id: props.graphId
, hyperdataGraph: props.hyperdataGraph
, session: props.session
, sigmaRef: props.sigmaRef
, treeReload: props.treeReload } ]
]
]
-- RH.ul {} [ -- change type button (?)
......@@ -196,14 +199,16 @@ controlsCpt = R.hooksComponentWithModule thisModule "controls" cpt
-- ]
-- ]
useGraphControls :: { forceAtlasS :: SigmaxT.ForceAtlasState
useGraphControls :: { asyncTasksRef :: R.Ref (Maybe GAT.Reductor)
, forceAtlasS :: SigmaxT.ForceAtlasState
, graph :: SigmaxT.SGraph
, graphId :: GET.GraphId
, hyperdataGraph :: GET.HyperdataGraph
, session :: Session
, treeReload :: Unit -> Effect Unit }
-> R.Hooks (Record Controls)
useGraphControls { forceAtlasS
useGraphControls { asyncTasksRef
, forceAtlasS
, graph
, graphId
, hyperdataGraph
......@@ -228,7 +233,8 @@ useGraphControls { forceAtlasS
sigma <- Sigmax.initSigma
sigmaRef <- R.useRef sigma
pure { edgeConfluence
pure { asyncTasksRef
, edgeConfluence
, edgeWeight
, forceAtlasState
, graph
......
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