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