Commit 9f0a0a6a authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[graph] reload tree after graph cloning

parent 2b22fc81
...@@ -104,7 +104,8 @@ appCpt = R.hooksComponent "G.C.App.app" cpt where ...@@ -104,7 +104,8 @@ appCpt = R.hooksComponent "G.C.App.app" cpt where
, session , session
, sessions: (fst sessions) , sessions: (fst sessions)
, showLogin , showLogin
, treeReload } --, treeReload
}
type ForestLayoutProps = type ForestLayoutProps =
( child :: R.Element ( child :: R.Element
......
...@@ -45,7 +45,7 @@ type LayoutProps = ...@@ -45,7 +45,7 @@ type LayoutProps =
, session :: Session , session :: Session
, sessions :: Sessions , sessions :: Sessions
, showLogin :: R.State Boolean , showLogin :: R.State Boolean
, treeReload :: R.State Int --, treeReload :: R.State Int
) )
type Props = ( type Props = (
...@@ -99,7 +99,8 @@ explorerCpt = R.hooksComponent "G.C.GraphExplorer.explorer" cpt ...@@ -99,7 +99,8 @@ explorerCpt = R.hooksComponent "G.C.GraphExplorer.explorer" cpt
, session , session
, sessions , sessions
, showLogin , showLogin
, treeReload } _ = do --, treeReload
} _ = do
let startForceAtlas = maybe true (\(GET.MetaData { startForceAtlas }) -> startForceAtlas) mMetaData let startForceAtlas = maybe true (\(GET.MetaData { startForceAtlas }) -> startForceAtlas) mMetaData
let forceAtlasS = if startForceAtlas then SigmaxT.InitialRunning else SigmaxT.InitialStopped let forceAtlasS = if startForceAtlas then SigmaxT.InitialRunning else SigmaxT.InitialStopped
...@@ -107,7 +108,14 @@ explorerCpt = R.hooksComponent "G.C.GraphExplorer.explorer" cpt ...@@ -107,7 +108,14 @@ explorerCpt = R.hooksComponent "G.C.GraphExplorer.explorer" cpt
dataRef <- R.useRef graph dataRef <- R.useRef graph
graphRef <- R.useRef null graphRef <- R.useRef null
graphVersionRef <- R.useRef (fst graphVersion) graphVersionRef <- R.useRef (fst graphVersion)
controls <- Controls.useGraphControls graph graphId hyperdataGraph session forceAtlasS treeReload <- R.useState' 0
controls <- Controls.useGraphControls { forceAtlasS
, graph
, graphId
, hyperdataGraph
, session
, treeReload: \_ -> (snd treeReload) $ (+) 1
}
multiSelectEnabledRef <- R.useRef $ fst controls.multiSelectEnabled multiSelectEnabledRef <- R.useRef $ fst controls.multiSelectEnabled
R.useEffect' $ do R.useEffect' $ do
...@@ -144,7 +152,7 @@ explorerCpt = R.hooksComponent "G.C.GraphExplorer.explorer" cpt ...@@ -144,7 +152,7 @@ explorerCpt = R.hooksComponent "G.C.GraphExplorer.explorer" cpt
tree { frontends tree { frontends
, handed , handed
, mCurrentRoute , mCurrentRoute
, reload: props.treeReload , reload: treeReload
, sessions , sessions
, show: fst controls.showTree , show: fst controls.showTree
, showLogin: snd showLogin } , showLogin: snd showLogin }
......
...@@ -15,6 +15,7 @@ import Data.String as DS ...@@ -15,6 +15,7 @@ import Data.String as DS
import DOM.Simple.Console (log2) import DOM.Simple.Console (log2)
import Effect (Effect) import Effect (Effect)
import Effect.Aff (launchAff_) import Effect.Aff (launchAff_)
import Effect.Class (liftEffect)
import Effect.Now as EN import Effect.Now as EN
import Reactix as R import Reactix as R
import Reactix.DOM.HTML as H import Reactix.DOM.HTML as H
...@@ -62,6 +63,7 @@ type CameraButtonProps = ( ...@@ -62,6 +63,7 @@ type CameraButtonProps = (
, hyperdataGraph :: GET.HyperdataGraph , hyperdataGraph :: GET.HyperdataGraph
, session :: Session , session :: Session
, sigmaRef :: R.Ref Sigmax.Sigma , sigmaRef :: R.Ref Sigmax.Sigma
, treeReload :: Unit -> Effect Unit
) )
...@@ -69,7 +71,8 @@ cameraButton :: Record CameraButtonProps -> R.Element ...@@ -69,7 +71,8 @@ cameraButton :: Record CameraButtonProps -> R.Element
cameraButton { id cameraButton { id
, hyperdataGraph: GET.HyperdataGraph { graph: GET.GraphData hyperdataGraph } , hyperdataGraph: GET.HyperdataGraph { graph: GET.GraphData hyperdataGraph }
, session , session
, sigmaRef } = simpleButton { , sigmaRef
, treeReload } = simpleButton {
onClick: \_ -> do onClick: \_ -> do
let sigma = R.readRef sigmaRef let sigma = R.readRef sigmaRef
Sigmax.dependOnSigma sigma "[cameraButton] sigma: Nothing" $ \s -> do Sigmax.dependOnSigma sigma "[cameraButton] sigma: Nothing" $ \s -> do
...@@ -100,6 +103,8 @@ cameraButton { id ...@@ -100,6 +103,8 @@ cameraButton { id
, mCamera: Just camera } , mCamera: Just camera }
launchAff_ $ do launchAff_ $ do
clonedGraphId <- cloneGraph { id, hyperdataGraph, session } clonedGraphId <- cloneGraph { id, hyperdataGraph, session }
uploadArbitraryDataURL session clonedGraphId (Just $ nowStr <> "-" <> "screenshot.png") screen ret <- uploadArbitraryDataURL session clonedGraphId (Just $ nowStr <> "-" <> "screenshot.png") screen
liftEffect $ treeReload unit
pure ret
, text: "Screenshot" , text: "Screenshot"
} }
...@@ -52,6 +52,7 @@ type Controls = ...@@ -52,6 +52,7 @@ type Controls =
, showSidePanel :: R.State GET.SidePanelState , showSidePanel :: R.State GET.SidePanelState
, showTree :: R.State Boolean , showTree :: R.State Boolean
, sigmaRef :: R.Ref Sigmax.Sigma , sigmaRef :: R.Ref Sigmax.Sigma
, treeReload :: Unit -> Effect Unit
) )
type LocalControls = type LocalControls =
...@@ -165,18 +166,25 @@ controlsCpt = R.hooksComponent "GraphControls" cpt ...@@ -165,18 +166,25 @@ controlsCpt = R.hooksComponent "GraphControls" cpt
, RH.li {} [ cameraButton { id: props.graphId , RH.li {} [ cameraButton { id: props.graphId
, hyperdataGraph: props.hyperdataGraph , hyperdataGraph: props.hyperdataGraph
, session: props.session , session: props.session
, sigmaRef: props.sigmaRef } ] , sigmaRef: props.sigmaRef
, treeReload: props.treeReload } ]
] ]
] ]
] ]
useGraphControls :: SigmaxT.SGraph useGraphControls :: { forceAtlasS :: SigmaxT.ForceAtlasState
-> GET.GraphId , graph :: SigmaxT.SGraph
-> GET.HyperdataGraph , graphId :: GET.GraphId
-> Session , hyperdataGraph :: GET.HyperdataGraph
-> SigmaxT.ForceAtlasState , session :: Session
, treeReload :: Unit -> Effect Unit }
-> R.Hooks (Record Controls) -> R.Hooks (Record Controls)
useGraphControls graph graphId hyperdataGraph session forceAtlasS = do useGraphControls { forceAtlasS
, graph
, graphId
, hyperdataGraph
, session
, treeReload } = do
edgeConfluence <- R.useState' $ Range.Closed { min: 0.0, max: 1.0 } edgeConfluence <- R.useState' $ Range.Closed { min: 0.0, max: 1.0 }
edgeWeight <- R.useState' $ Range.Closed { edgeWeight <- R.useState' $ Range.Closed {
min: 0.0 min: 0.0
...@@ -214,6 +222,7 @@ useGraphControls graph graphId hyperdataGraph session forceAtlasS = do ...@@ -214,6 +222,7 @@ useGraphControls graph graphId hyperdataGraph session forceAtlasS = do
, showSidePanel , showSidePanel
, showTree , showTree
, sigmaRef , sigmaRef
, treeReload
} }
getShowControls :: Record Controls -> Boolean getShowControls :: Record Controls -> Boolean
......
...@@ -4,13 +4,14 @@ import Data.Maybe (Maybe(..)) ...@@ -4,13 +4,14 @@ import Data.Maybe (Maybe(..))
import Data.Tuple.Nested ((/\)) import Data.Tuple.Nested ((/\))
import Effect.Aff (Aff, launchAff_) import Effect.Aff (Aff, launchAff_)
import Effect.Class (liftEffect) import Effect.Class (liftEffect)
import Prelude
import Reactix as R
import Reactix.DOM.HTML as H
import Gargantext.Config.REST as REST import Gargantext.Config.REST as REST
import Gargantext.Ends (toUrl) import Gargantext.Ends (toUrl)
import Gargantext.Sessions (Session(..)) import Gargantext.Sessions (Session(..))
import Gargantext.Sessions as Sessions import Gargantext.Sessions as Sessions
import Prelude
import Reactix as R
import Reactix.DOM.HTML as H
type Version = String type Version = String
......
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