Commit 20a7cbb9 authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[forest] more work on graph explorer, tree hiding works

But controls doesn't and sidebar throws exception...
parent 12910a76
...@@ -10,7 +10,6 @@ module Gargantext.Components.Forest ...@@ -10,7 +10,6 @@ module Gargantext.Components.Forest
import Data.Array as A import Data.Array as A
import Data.Maybe (Maybe(..), fromMaybe) import Data.Maybe (Maybe(..), fromMaybe)
import Data.Tuple (fst)
import Data.Tuple.Nested ((/\)) import Data.Tuple.Nested ((/\))
import Reactix as R import Reactix as R
import Reactix.DOM.HTML as H import Reactix.DOM.HTML as H
...@@ -45,6 +44,7 @@ type Props = ...@@ -45,6 +44,7 @@ type Props =
, reloadForest :: T.Box T2.Reload , reloadForest :: T.Box T2.Reload
, sessions :: T.Box Sessions , sessions :: T.Box Sessions
, showLogin :: T.Box Boolean , showLogin :: T.Box Boolean
, showTree :: T.Box Boolean
, tasks :: T.Box GAT.Storage , tasks :: T.Box GAT.Storage
| Common | Common
) )
...@@ -68,6 +68,7 @@ forestCpt = here.component "forest" cpt where ...@@ -68,6 +68,7 @@ forestCpt = here.component "forest" cpt where
, route , route
, sessions , sessions
, showLogin , showLogin
, showTree
, tasks } _ = do , tasks } _ = do
-- TODO Fix this. I think tasks shouldn't be a Box but only a Reductor -- TODO Fix this. I think tasks shouldn't be a Box but only a Reductor
-- tasks' <- GAT.useTasks reloadRoot reloadForest -- tasks' <- GAT.useTasks reloadRoot reloadForest
...@@ -80,17 +81,21 @@ forestCpt = here.component "forest" cpt where ...@@ -80,17 +81,21 @@ forestCpt = here.component "forest" cpt where
forestOpen' <- T.useLive T.unequal forestOpen forestOpen' <- T.useLive T.unequal forestOpen
sessions' <- T.useLive T.unequal sessions sessions' <- T.useLive T.unequal sessions
showTree' <- T.useLive T.unequal showTree
-- TODO If `reloadForest` is set, `reload` state should be updated -- TODO If `reloadForest` is set, `reload` state should be updated
-- TODO fix tasks ref -- TODO fix tasks ref
-- R.useEffect' $ do -- R.useEffect' $ do
-- R.setRef tasks $ Just tasks' -- R.setRef tasks $ Just tasks'
R2.useCache R2.useCache
( frontends /\ sessions' /\ handed' /\ forestOpen' /\ reloadForest' ) ( forestOpen' /\ frontends /\ handed' /\ reloadForest' /\ sessions' /\ showTree' )
(cp handed' sessions') (cp handed' sessions' showTree')
where where
common = RX.pick props :: Record Common common = RX.pick props :: Record Common
cp handed' sessions' _ = cp handed' sessions' showTree' _ = do
pure $ H.div { className: "forest" } let className = "forest " <> if showTree' then "" else "d-none"
pure $ H.div { className }
(A.cons (plus handed' showLogin) (trees handed' sessions')) (A.cons (plus handed' showLogin) (trees handed' sessions'))
trees handed' sessions' = (tree handed') <$> unSessions sessions' trees handed' sessions' = (tree handed') <$> unSessions sessions'
tree handed' s@(Session {treeId}) = tree handed' s@(Session {treeId}) =
...@@ -169,6 +174,7 @@ forestLayoutRawCpt = here.component "forestLayoutRaw" cpt where ...@@ -169,6 +174,7 @@ forestLayoutRawCpt = here.component "forestLayoutRaw" cpt where
, reloadRoot , reloadRoot
, route , route
, sessions , sessions
, showTree
, showLogin , showLogin
, tasks } children = do , tasks } children = do
handed' <- T.useLive T.unequal p.handed handed' <- T.useLive T.unequal p.handed
...@@ -187,6 +193,7 @@ forestLayoutRawCpt = here.component "forestLayoutRaw" cpt where ...@@ -187,6 +193,7 @@ forestLayoutRawCpt = here.component "forestLayoutRaw" cpt where
, reloadRoot , reloadRoot
, route , route
, sessions , sessions
, showTree
, showLogin , showLogin
, tasks } [] , tasks } []
......
...@@ -14,6 +14,14 @@ import Data.Set as Set ...@@ -14,6 +14,14 @@ import Data.Set as Set
import Data.Tuple (Tuple(..)) import Data.Tuple (Tuple(..))
import Data.Tuple.Nested ((/\)) import Data.Tuple.Nested ((/\))
import Effect.Aff (Aff) import Effect.Aff (Aff)
import Math (log)
import Partial.Unsafe (unsafePartial)
import Reactix as R
import Reactix.DOM.HTML as RH
import Record as Record
import Record.Extra as RX
import Toestand as T
import Gargantext.AsyncTasks as GAT import Gargantext.AsyncTasks as GAT
import Gargantext.Components.App.Data (Boxes) import Gargantext.Components.App.Data (Boxes)
import Gargantext.Components.Forest (forest) import Gargantext.Components.Forest (forest)
...@@ -35,13 +43,6 @@ import Gargantext.Types as Types ...@@ -35,13 +43,6 @@ import Gargantext.Types as Types
import Gargantext.Utils.Range as Range import Gargantext.Utils.Range as Range
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Toestand as T2 import Gargantext.Utils.Toestand as T2
import Math (log)
import Partial.Unsafe (unsafePartial)
import Reactix as R
import Reactix.DOM.HTML as RH
import Record as Record
import Record.Extra as RX
import Toestand as T
here :: R2.Here here :: R2.Here
here = R2.here "Gargantext.Components.GraphExplorer" here = R2.here "Gargantext.Components.GraphExplorer"
...@@ -108,7 +109,7 @@ explorerCpt :: R.Component Props ...@@ -108,7 +109,7 @@ explorerCpt :: R.Component Props
explorerCpt = here.component "explorer" cpt explorerCpt = here.component "explorer" cpt
where where
cpt props@{ backend cpt props@{ backend
, boxes: boxes@{ graphVersion, sidePanelGraph } , boxes: boxes@{ graphVersion, showTree, sidePanelGraph }
, frontends , frontends
, graph , graph
, graphId , graphId
...@@ -141,21 +142,22 @@ explorerCpt = here.component "explorer" cpt ...@@ -141,21 +142,22 @@ explorerCpt = here.component "explorer" cpt
, graph , graph
, graphId , graphId
, hyperdataGraph , hyperdataGraph
, reloadForest: \_ -> T2.reload reloadForest , reloadForest
, session , session
, showTree
, sidePanel: sidePanelGraph , sidePanel: sidePanelGraph
, sidePanelState , sidePanelState
} }
multiSelectEnabled' <- T.useLive T.unequal controls.multiSelectEnabled multiSelectEnabled' <- T.useLive T.unequal controls.multiSelectEnabled
showTree' <- T.useLive T.unequal controls.showTree showTree' <- T.useLive T.unequal controls.showTree
multiSelectEnabledRef <- R.useRef multiSelectEnabled' multiSelectEnabledRef <- R.useRef multiSelectEnabled'
sidePanel@{ mGraph, mMetaData, sideTab } <- GEST.focusedSidePanel sidePanelGraph { mGraph, mMetaData, sideTab } <- GEST.focusedSidePanel sidePanelGraph
R.useEffectOnce' $ do R.useEffectOnce' $ do
T.write_ (Just graph) mGraph T.write_ (Just graph) mGraph
T.write_ mMetaData' mMetaData T.write_ mMetaData' mMetaData
forestOpen <- T.useBox $ Set.empty forestOpen <- T.useBox $ (Set.empty :: OpenNodes)
R.useEffectOnce' $ do R.useEffectOnce' $ do
R2.loadLocalStorageState R2.openNodesKey forestOpen R2.loadLocalStorageState R2.openNodesKey forestOpen
T.listen (R2.listenLocalStorageState R2.openNodesKey) forestOpen T.listen (R2.listenLocalStorageState R2.openNodesKey) forestOpen
...@@ -180,30 +182,13 @@ explorerCpt = here.component "explorer" cpt ...@@ -180,30 +182,13 @@ explorerCpt = here.component "explorer" cpt
T.write_ Types.InitialClosed controls.sidePanelState T.write_ Types.InitialClosed controls.sidePanelState
pure $ pure $
RH.div { className: "graph-meta-container" } [ RH.div { className: "graph-meta-container" }
-- RH.div { className: "fixed-top navbar navbar-expand-lg" [ RH.div { className: "graph-container" }
-- , id: "graph-explorer" } [ inner handed'
-- [ topBar { controls, graph } [] ] [ RH.div { id: "controls-container" } [ Controls.controls controls [] ]
RH.div { className: "graph-container" } [ , RH.div { className: "row graph-row" }
inner handed' [ [ RH.div { ref: graphRef, id: "graph-view", className: "col-md-12" } []
rowControls [ Controls.controls controls ] , graphView { controls
, RH.div { className: "row graph-row" } $ mainLayout handed' $
tree { backend
, forestOpen
, frontends
, handed
, reload: reloadForest
, route
, reloadForest
, sessions
, show: showTree'
, showLogin: showLogin
, tasks
}
/\
RH.div { ref: graphRef, id: "graph-view", className: "col-md-12" } []
/\
graphView { controls
, elRef: graphRef , elRef: graphRef
, graphId , graphId
, graph , graph
...@@ -211,72 +196,16 @@ explorerCpt = here.component "explorer" cpt ...@@ -211,72 +196,16 @@ explorerCpt = here.component "explorer" cpt
, mMetaData , mMetaData
, multiSelectEnabledRef , multiSelectEnabledRef
} [] } []
/\ ]
mSidebar (Record.merge sidePanel { frontends
, graph
, graphId
, graphVersion
, reloadForest
, removedNodeIds : controls.removedNodeIds
, session
, sideTab
}) []
] ]
] ]
] ]
mainLayout Types.RightHanded (tree' /\ gc /\ gv /\ sdb) = [tree', gc, gv, sdb]
mainLayout Types.LeftHanded (tree' /\ gc /\ gv /\ sdb) = [sdb, gc, gv, tree']
outer = RH.div { className: "col-md-12" }
inner h = RH.div { className: "container-fluid " <> hClass } inner h = RH.div { className: "container-fluid " <> hClass }
where where
hClass = case h of hClass = case h of
Types.LeftHanded -> "lefthanded" Types.LeftHanded -> "lefthanded"
Types.RightHanded -> "righthanded" Types.RightHanded -> "righthanded"
rowControls = RH.div { id: "controls-container" }
pullLeft = RH.div { className: "pull-left" }
pullRight = RH.div { className: "pull-right" }
tree :: Record TreeProps -> R.Element
tree { show: false } = RH.div { id: "tree" } []
tree { backend, forestOpen, frontends, handed, reload, route, sessions, showLogin, reloadForest, tasks } =
RH.div {className: "col-md-2 graph-tree"} [
forest { backend
, forestOpen
, frontends
, handed
, reloadForest
, reloadRoot: reload
, route
, sessions
, showLogin
, tasks } []
]
type MSideBar =
(
mGraph :: T.Box (Maybe SigmaxT.SGraph)
, mMetaData :: T.Box (Maybe GET.MetaData)
, multiSelectEnabled :: T.Box Boolean
-- , selectedNodeIds :: T.Box SigmaxT.NodeIds
, showControls :: T.Box Boolean
| MSidebarProps
)
mSidebar :: R2.Component MSideBar
mSidebar = R.createElement mSidebarCpt
mSidebarCpt :: R.Component MSideBar
mSidebarCpt = here.component "mSidebar" cpt where
cpt props@{ mMetaData } _ = do
mMetaData' <- T.useLive T.unequal mMetaData
case mMetaData' of
Nothing -> pure $ RH.div {} []
Just metaData -> do
pure $ Sidebar.sidebar (Record.merge (RX.pick props :: Record MSidebarProps) { metaData }) []
type TopBar = type TopBar =
( (
...@@ -316,32 +245,6 @@ topBarCpt = here.component "topBar" cpt where ...@@ -316,32 +245,6 @@ topBarCpt = here.component "topBar" cpt where
-- spaces = RH.div { className: "flex-space-between" } -- spaces = RH.div { className: "flex-space-between" }
spaces = RH.a { className: "nav-link" } spaces = RH.a { className: "nav-link" }
type TreeProps = (
backend :: T.Box (Maybe Backend)
, forestOpen :: T.Box OpenNodes
, frontends :: Frontends
, handed :: T.Box Types.Handed
, reload :: T.Box T2.Reload
, reloadForest :: T.Box T2.Reload
, route :: T.Box AppRoute
, sessions :: T.Box Sessions
, show :: Boolean
, showLogin :: T.Box Boolean
, tasks :: T.Box GAT.Storage
)
type MSidebarProps =
( frontends :: Frontends
, graph :: SigmaxT.SGraph
, graphId :: GET.GraphId
, graphVersion :: T2.ReloadS
, reloadForest :: T.Box T2.Reload
, removedNodeIds :: T.Box SigmaxT.NodeIds
, selectedNodeIds :: T.Box SigmaxT.NodeIds
, session :: Session
, sideTab :: T.Box GET.SideTab
)
type GraphProps = ( type GraphProps = (
controls :: Record Controls.Controls controls :: Record Controls.Controls
, elRef :: R.Ref (Nullable Element) , elRef :: R.Ref (Nullable Element)
......
...@@ -23,6 +23,7 @@ import Gargantext.Hooks.Sigmax as Sigmax ...@@ -23,6 +23,7 @@ import Gargantext.Hooks.Sigmax as Sigmax
import Gargantext.Hooks.Sigmax.Sigma as Sigma import Gargantext.Hooks.Sigmax.Sigma as Sigma
import Gargantext.Sessions (Session) import Gargantext.Sessions (Session)
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Toestand as T2
here :: R2.Here here :: R2.Here
here = R2.here "Gargantext.Components.GraphExplorer.Button" here = R2.here "Gargantext.Components.GraphExplorer.Button"
...@@ -53,12 +54,12 @@ centerButton sigmaRef = simpleButton { ...@@ -53,12 +54,12 @@ centerButton sigmaRef = simpleButton {
} }
type CameraButtonProps = ( type CameraButtonProps =
id :: Int ( id :: Int
, hyperdataGraph :: GET.HyperdataGraph , hyperdataGraph :: GET.HyperdataGraph
, session :: Session , session :: Session
, sigmaRef :: R.Ref Sigmax.Sigma , sigmaRef :: R.Ref Sigmax.Sigma
, reloadForest :: Unit -> Effect Unit , reloadForest :: T2.ReloadS
) )
...@@ -94,7 +95,7 @@ cameraButton { id ...@@ -94,7 +95,7 @@ cameraButton { id
launchAff_ $ do launchAff_ $ do
clonedGraphId <- cloneGraph { id, hyperdataGraph: hyperdataGraph', session } clonedGraphId <- cloneGraph { id, hyperdataGraph: hyperdataGraph', session }
ret <- uploadArbitraryDataURL session clonedGraphId (Just $ nowStr <> "-" <> "screenshot.png") screen ret <- uploadArbitraryDataURL session clonedGraphId (Just $ nowStr <> "-" <> "screenshot.png") screen
liftEffect $ reloadForest unit liftEffect $ T2.reload reloadForest
pure ret pure ret
, text: "Screenshot" , text: "Screenshot"
} }
...@@ -3,8 +3,6 @@ module Gargantext.Components.GraphExplorer.Controls ...@@ -3,8 +3,6 @@ module Gargantext.Components.GraphExplorer.Controls
, useGraphControls , useGraphControls
, controls , controls
, controlsCpt , controlsCpt
, setShowTree
, setShowControls
) where ) where
import Data.Array as A import Data.Array as A
...@@ -32,6 +30,7 @@ import Gargantext.Sessions (Session) ...@@ -32,6 +30,7 @@ import Gargantext.Sessions (Session)
import Gargantext.Types as GT import Gargantext.Types as GT
import Gargantext.Utils.Range as Range import Gargantext.Utils.Range as Range
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Toestand as T2
here :: R2.Here here :: R2.Here
here = R2.here "Gargantext.Components.GraphExplorer.Controls" here = R2.here "Gargantext.Components.GraphExplorer.Controls"
...@@ -46,7 +45,7 @@ type Controls = ...@@ -46,7 +45,7 @@ type Controls =
, hyperdataGraph :: GET.HyperdataGraph , hyperdataGraph :: GET.HyperdataGraph
, multiSelectEnabled :: T.Box Boolean , multiSelectEnabled :: T.Box Boolean
, nodeSize :: T.Box Range.NumberRange , nodeSize :: T.Box Range.NumberRange
, reloadForest :: Unit -> Effect Unit , reloadForest :: T2.ReloadS
, removedNodeIds :: T.Box SigmaxT.NodeIds , removedNodeIds :: T.Box SigmaxT.NodeIds
, selectedNodeIds :: T.Box SigmaxT.NodeIds , selectedNodeIds :: T.Box SigmaxT.NodeIds
, session :: Session , session :: Session
...@@ -66,8 +65,8 @@ initialLocalControls = do ...@@ -66,8 +65,8 @@ initialLocalControls = do
mouseSelectorSize <- T.useBox 15.0 mouseSelectorSize <- T.useBox 15.0
pure $ { labelSize, mouseSelectorSize } pure $ { labelSize, mouseSelectorSize }
controls :: Record Controls -> R.Element controls :: R2.Component Controls
controls props = R.createElement controlsCpt props [] controls = R.createElement controlsCpt
controlsCpt :: R.Component Controls controlsCpt :: R.Component Controls
controlsCpt = here.component "controls" cpt controlsCpt = here.component "controls" cpt
...@@ -96,6 +95,9 @@ controlsCpt = here.component "controls" cpt ...@@ -96,6 +95,9 @@ controlsCpt = here.component "controls" cpt
showControls' <- T.useLive T.unequal showControls showControls' <- T.useLive T.unequal showControls
sidePanelState' <- T.useLive T.unequal sidePanelState sidePanelState' <- T.useLive T.unequal sidePanelState
R.useEffect' $ do
here.log2 "showControls" showControls'
localControls <- initialLocalControls localControls <- initialLocalControls
-- ref to track automatic FA pausing -- ref to track automatic FA pausing
-- If user pauses FA before auto is triggered, clear the timeoutId -- If user pauses FA before auto is triggered, clear the timeoutId
...@@ -160,36 +162,37 @@ controlsCpt = here.component "controls" cpt ...@@ -160,36 +162,37 @@ controlsCpt = here.component "controls" cpt
false -> RH.div {} [] false -> RH.div {} []
-- true -> R2.menu { id: "toolbar" } [ -- true -> R2.menu { id: "toolbar" } [
true -> RH.nav { className: "navbar navbar-expand-lg" } true -> RH.nav { className: "navbar navbar-expand-lg" }
[ RH.ul { className: "navbar-nav mx-auto" } [ -- change type button (?) [ RH.ul { className: "navbar-nav mx-auto" }
RH.li { className: "nav-item" } [ centerButton sigmaRef ] [ -- change type button (?)
, RH.li { className: "nav-item" } [ pauseForceAtlasButton { state: forceAtlasState } [] ] navItem [ centerButton sigmaRef ]
, RH.li { className: "nav-item" } [ edgesToggleButton { state: showEdges } [] ] , navItem [ pauseForceAtlasButton { state: forceAtlasState } [] ]
, RH.li { className: "nav-item" } [ louvainToggleButton { state: showLouvain } [] ] , navItem [ edgesToggleButton { state: showEdges } [] ]
, RH.li { className: "nav-item" } [ edgeConfluenceControl { range: edgeConfluenceRange , navItem [ louvainToggleButton { state: showLouvain } [] ]
, navItem [ edgeConfluenceControl { range: edgeConfluenceRange
, state: edgeConfluence } [] ] , state: edgeConfluence } [] ]
, RH.li { className: "nav-item" } [ edgeWeightControl { range: edgeWeightRange , navItem [ edgeWeightControl { range: edgeWeightRange
, state: edgeWeight } [] ] , state: edgeWeight } [] ]
-- change level -- change level
-- file upload -- file upload
-- run demo -- run demo
-- search button -- search button
-- search topics -- search topics
, RH.li { className: "nav-item" } [ labelSizeButton sigmaRef localControls.labelSize ] -- labels size: 1-4 , navItem [ labelSizeButton sigmaRef localControls.labelSize ] -- labels size: 1-4
, RH.li { className: "nav-item" } [ nodeSizeControl { range: nodeSizeRange , navItem [ nodeSizeControl { range: nodeSizeRange
, state: nodeSize } [] ] , state: nodeSize } [] ]
-- zoom: 0 -100 - calculate ratio -- zoom: 0 -100 - calculate ratio
, RH.li { className: "nav-item" } [ multiSelectEnabledButton { state: multiSelectEnabled } [] ] -- toggle multi node selection , navItem [ multiSelectEnabledButton { state: multiSelectEnabled } [] ] -- toggle multi node selection
-- save button -- save button
, RH.li { className: "nav-item" } , navItem [ mouseSelectorSizeButton sigmaRef localControls.mouseSelectorSize ]
[ mouseSelectorSizeButton sigmaRef localControls.mouseSelectorSize ] , navItem [ cameraButton { id: graphId
, RH.li { className: "nav-item" }
[ cameraButton { id: graphId
, hyperdataGraph: hyperdataGraph , hyperdataGraph: hyperdataGraph
, session: session , session: session
, sigmaRef: sigmaRef , sigmaRef: sigmaRef
, reloadForest: reloadForest } ] , reloadForest } ]
] ]
] ]
where
navItem = RH.li { className: "nav-item" }
-- RH.ul {} [ -- change type button (?) -- RH.ul {} [ -- change type button (?)
-- RH.li {} [ centerButton sigmaRef ] -- RH.li {} [ centerButton sigmaRef ]
-- , RH.li {} [ pauseForceAtlasButton {state: forceAtlasState} ] -- , RH.li {} [ pauseForceAtlasButton {state: forceAtlasState} ]
...@@ -223,8 +226,9 @@ useGraphControls :: { forceAtlasS :: SigmaxT.ForceAtlasState ...@@ -223,8 +226,9 @@ useGraphControls :: { forceAtlasS :: SigmaxT.ForceAtlasState
, graph :: SigmaxT.SGraph , graph :: SigmaxT.SGraph
, graphId :: GET.GraphId , graphId :: GET.GraphId
, hyperdataGraph :: GET.HyperdataGraph , hyperdataGraph :: GET.HyperdataGraph
, reloadForest :: Unit -> Effect Unit , reloadForest :: T2.ReloadS
, session :: Session , session :: Session
, showTree :: T.Box Boolean
, sidePanel :: T.Box (Maybe (Record GEST.SidePanel)) , sidePanel :: T.Box (Maybe (Record GEST.SidePanel))
, sidePanelState :: T.Box GT.SidePanelState } , sidePanelState :: T.Box GT.SidePanelState }
-> R.Hooks (Record Controls) -> R.Hooks (Record Controls)
...@@ -234,6 +238,7 @@ useGraphControls { forceAtlasS ...@@ -234,6 +238,7 @@ useGraphControls { forceAtlasS
, hyperdataGraph , hyperdataGraph
, reloadForest , reloadForest
, session , session
, showTree
, sidePanel , sidePanel
, sidePanelState } = do , sidePanelState } = do
edgeConfluence <- T.useBox $ Range.Closed { min: 0.0, max: 1.0 } edgeConfluence <- T.useBox $ Range.Closed { min: 0.0, max: 1.0 }
...@@ -251,7 +256,6 @@ useGraphControls { forceAtlasS ...@@ -251,7 +256,6 @@ useGraphControls { forceAtlasS
showEdges <- T.useBox SigmaxT.EShow showEdges <- T.useBox SigmaxT.EShow
showLouvain <- T.useBox false showLouvain <- T.useBox false
-- sidePanelState <- T.useBox GT.InitialClosed -- sidePanelState <- T.useBox GT.InitialClosed
showTree <- T.useBox false
sigma <- Sigmax.initSigma sigma <- Sigmax.initSigma
sigmaRef <- R.useRef sigma sigmaRef <- R.useRef sigma
...@@ -277,9 +281,3 @@ useGraphControls { forceAtlasS ...@@ -277,9 +281,3 @@ useGraphControls { forceAtlasS
, sigmaRef , sigmaRef
, reloadForest , reloadForest
} }
setShowControls :: Record Controls -> Boolean -> Effect Unit
setShowControls { showControls } v = T.write_ v showControls
setShowTree :: Record Controls -> Boolean -> Effect Unit
setShowTree { showTree } v = T.write_ (not v) showTree
...@@ -35,26 +35,27 @@ focusedSidePanel :: T.Box (Maybe (Record SidePanel)) ...@@ -35,26 +35,27 @@ focusedSidePanel :: T.Box (Maybe (Record SidePanel))
, sideTab :: T.Box GET.SideTab } , sideTab :: T.Box GET.SideTab }
focusedSidePanel sidePanel = do focusedSidePanel sidePanel = do
mGraph <- T.useFocused mGraph <- T.useFocused
(maybe Nothing (_.mGraph)) (maybe Nothing _.mGraph)
(\val -> maybe Nothing (\sp -> Just $ sp { mGraph = val })) sidePanel (\val -> maybe Nothing (\sp -> Just $ sp { mGraph = val })) sidePanel
mMetaData <- T.useFocused mMetaData <- T.useFocused
(maybe Nothing (_.mMetaData)) (maybe Nothing _.mMetaData)
(\val -> maybe Nothing (\sp -> Just $ sp { mMetaData = val })) sidePanel (\val -> maybe Nothing (\sp -> Just $ sp { mMetaData = val })) sidePanel
multiSelectEnabled <- T.useFocused multiSelectEnabled <- T.useFocused
(maybe false (_.multiSelectEnabled)) (maybe false _.multiSelectEnabled)
(\val -> maybe Nothing (\sp -> Just $ sp { multiSelectEnabled = val })) sidePanel (\val -> maybe Nothing (\sp -> Just $ sp { multiSelectEnabled = val })) sidePanel
removedNodeIds <- T.useFocused removedNodeIds <- T.useFocused
(maybe Set.empty (_.removedNodeIds)) (maybe Set.empty _.removedNodeIds)
(\val -> maybe Nothing (\sp -> Just $ sp { removedNodeIds = val })) sidePanel (\val -> maybe Nothing (\sp -> Just $ sp { removedNodeIds = val })) sidePanel
selectedNodeIds <- T.useFocused selectedNodeIds <- T.useFocused
(maybe Set.empty (_.selectedNodeIds)) (maybe Set.empty _.selectedNodeIds)
(\val -> maybe Nothing (\sp -> Just $ sp { selectedNodeIds = val })) sidePanel (\val -> maybe Nothing (\sp -> Just $ sp { selectedNodeIds = val })) sidePanel
showControls <- T.useFocused showControls <- T.useFocused
(maybe false (_.showControls)) (maybe false _.showControls)
(\val -> maybe Nothing (\sp -> Just $ sp { showControls = val })) sidePanel (\val -> maybe Nothing (\sp -> Just $ sp { showControls = val })) sidePanel
sideTab <- T.useFocused sideTab <- T.useFocused
(maybe GET.SideTabLegend (_.sideTab)) (maybe GET.SideTabLegend _.sideTab)
(\val -> maybe Nothing (\sp -> Just $ sp { sideTab = val })) sidePanel (\val -> maybe Nothing (\sp -> Just $ sp { sideTab = val })) sidePanel
pure $ { pure $ {
mGraph mGraph
, mMetaData , mMetaData
......
...@@ -47,7 +47,7 @@ toggleButtonCpt = here.component "toggleButton" cpt ...@@ -47,7 +47,7 @@ toggleButtonCpt = here.component "toggleButton" cpt
state' <- T.useLive T.unequal state state' <- T.useLive T.unequal state
pure $ H.button { className: "btn btn-outline-" <> style <> " " <> cls state' pure $ H.button { className: "btn btn-outline-" <> style <> " " <> cls state'
, on: {click: onClick} , on: { click: onClick }
} [ R2.small {} [ H.text (text onMessage offMessage state') ] ] } [ R2.small {} [ H.text (text onMessage offMessage state') ] ]
cls true = "active" cls true = "active"
......
...@@ -30,11 +30,8 @@ import Gargantext.Components.Nodes.File (fileLayout) ...@@ -30,11 +30,8 @@ import Gargantext.Components.Nodes.File (fileLayout)
import Gargantext.Components.Nodes.Frame (frameLayout) import Gargantext.Components.Nodes.Frame (frameLayout)
import Gargantext.Components.Nodes.Home (homeLayout) import Gargantext.Components.Nodes.Home (homeLayout)
import Gargantext.Components.Nodes.Lists as Lists import Gargantext.Components.Nodes.Lists as Lists
import Gargantext.Components.Nodes.Lists.Types as ListsTypes
import Gargantext.Components.Nodes.Texts as Texts import Gargantext.Components.Nodes.Texts as Texts
import Gargantext.Components.SessionLoader (sessionWrapper) import Gargantext.Components.SessionLoader (sessionWrapper)
import Gargantext.Components.SimpleLayout (simpleLayout)
import Gargantext.Components.TopBar (handedChooser)
import Gargantext.Components.TopBar as TopBar import Gargantext.Components.TopBar as TopBar
import Gargantext.Config (defaultFrontends, defaultBackends) import Gargantext.Config (defaultFrontends, defaultBackends)
import Gargantext.Ends (Backend) import Gargantext.Ends (Backend)
...@@ -43,7 +40,6 @@ import Gargantext.Routes as GR ...@@ -43,7 +40,6 @@ import Gargantext.Routes as GR
import Gargantext.Sessions (Session, WithSessionContext) import Gargantext.Sessions (Session, WithSessionContext)
import Gargantext.Types (CorpusId, ListId, NodeID, NodeType(..), SessionId, SidePanelState(..)) import Gargantext.Types (CorpusId, ListId, NodeID, NodeType(..), SessionId, SidePanelState(..))
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Toestand as T2
here :: R2.Here here :: R2.Here
here = R2.here "Gargantext.Components.Router" here = R2.here "Gargantext.Components.Router"
...@@ -156,6 +152,7 @@ forestCpt = here.component "forest" cpt where ...@@ -156,6 +152,7 @@ forestCpt = here.component "forest" cpt where
, route , route
, sessions , sessions
, showLogin , showLogin
, showTree
, tasks } , tasks }
, session } _ = do , session } _ = do
session' <- R.useContext session session' <- R.useContext session
...@@ -169,6 +166,7 @@ forestCpt = here.component "forest" cpt where ...@@ -169,6 +166,7 @@ forestCpt = here.component "forest" cpt where
, route , route
, sessions , sessions
, showLogin , showLogin
, showTree
, tasks } [ renderRoute (Record.merge { session } props) [] ] , tasks } [ renderRoute (Record.merge { session } props) [] ]
sidePanel :: R2.Component (WithSessionContext Props) sidePanel :: R2.Component (WithSessionContext Props)
...@@ -187,11 +185,14 @@ sidePanelCpt = here.component "sidePanel" cpt where ...@@ -187,11 +185,14 @@ sidePanelCpt = here.component "sidePanel" cpt where
session' <- R.useContext session session' <- R.useContext session
sidePanelState' <- T.useLive T.unequal sidePanelState sidePanelState' <- T.useLive T.unequal sidePanelState
let className = "side-panel"
case sidePanelState' of case sidePanelState' of
Opened -> Opened ->
case route' of case route' of
GR.Lists s n -> do GR.Lists s n -> do
pure $ H.div { className: "side-panel" } [ Lists.sidePanel { session: session' pure $ H.div { className }
[ Lists.sidePanel { session: session'
, sidePanel: sidePanelLists , sidePanel: sidePanelLists
, sidePanelState } [] ] , sidePanelState } [] ]
GR.PGraphExplorer s g -> do GR.PGraphExplorer s g -> do
...@@ -203,7 +204,7 @@ sidePanelCpt = here.component "sidePanel" cpt where ...@@ -203,7 +204,7 @@ sidePanelCpt = here.component "sidePanel" cpt where
(Nothing /\ _) -> pure $ H.div {} [] (Nothing /\ _) -> pure $ H.div {} []
(_ /\ Nothing) -> pure $ H.div {} [] (_ /\ Nothing) -> pure $ H.div {} []
(Just graph /\ Just metaData) -> do (Just graph /\ Just metaData) -> do
pure $ H.div { className: "side-panel" } pure $ H.div { className }
[ GES.sidebar { frontends: defaultFrontends [ GES.sidebar { frontends: defaultFrontends
, graph , graph
, graphId: g , graphId: g
...@@ -216,7 +217,8 @@ sidePanelCpt = here.component "sidePanel" cpt where ...@@ -216,7 +217,8 @@ sidePanelCpt = here.component "sidePanel" cpt where
, sideTab , sideTab
} [] ] } [] ]
GR.Texts s n -> do GR.Texts s n -> do
pure $ H.div { className: "side-panel" } [ Texts.sidePanel { session: session' pure $ H.div { className }
[ Texts.sidePanel { session: session'
, sidePanel: sidePanelTexts , sidePanel: sidePanelTexts
, sidePanelState } [] ] , sidePanelState } [] ]
_ -> pure $ H.div {} [] _ -> pure $ H.div {} []
......
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