Commit 61bed3f7 authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[Graph] graph is loaded once, settings updated directly to sigma

parent 837ba3f4
...@@ -55,6 +55,7 @@ type GraphId = Int ...@@ -55,6 +55,7 @@ type GraphId = Int
type Props = ( type Props = (
graphId :: GraphId graphId :: GraphId
, graph :: Maybe Graph.Graph
, mCurrentRoute :: Maybe Routes , mCurrentRoute :: Maybe Routes
, treeId :: Maybe Int , treeId :: Maybe Int
) )
...@@ -76,12 +77,22 @@ specCpt d stateGlue p = R.createElement el p [] ...@@ -76,12 +77,22 @@ specCpt d stateGlue p = R.createElement el p []
pure $ explorer state props pure $ explorer state props
explorer :: Record GET.State -> Record Props -> R.Element explorer :: Record GET.State -> Record Props -> R.Element
explorer state props = R.createElement (explorerCpt state) props [] explorer state props = R.createElement (explorerLoader state) props []
explorerLoader :: Record GET.State -> R.Component Props
explorerLoader state = R.hooksComponent "GraphExplorerLoader" cpt
where
cpt props _ = do
Loader.useLoader props.graphId getNodes $ \{loaded} ->
explorerEl state $ props {graph = Just $ convert loaded}
explorerEl :: Record GET.State -> Record Props -> R.Element
explorerEl state props = R.createElement (explorerCpt state) props []
explorerCpt :: Record GET.State -> R.Component Props explorerCpt :: Record GET.State -> R.Component Props
explorerCpt state = R.hooksComponent "GraphExplorer" cpt explorerCpt state = R.hooksComponent "GraphExplorer" cpt
where where
cpt {graphId, mCurrentRoute, treeId} _ = do cpt {graphId, mCurrentRoute, treeId, graph} _ = do
controls <- Controls.useGraphControls controls <- Controls.useGraphControls
pure $ pure $
RH.div RH.div
...@@ -97,7 +108,7 @@ explorerCpt state = R.hooksComponent "GraphExplorer" cpt ...@@ -97,7 +108,7 @@ explorerCpt state = R.hooksComponent "GraphExplorer" cpt
, col [ pullRight [ Toggle.sidebarToggleButton controls.showSidePanel ] ] , col [ pullRight [ Toggle.sidebarToggleButton controls.showSidePanel ] ]
] ]
, row [ Controls.controls controls ] , row [ Controls.controls controls ]
, row [ tree {mCurrentRoute, treeId} controls, graphLoader graphId controls, Sidebar.sidebar controls ] , row [ tree {mCurrentRoute, treeId} controls, mGraph {graphId, graph} controls, Sidebar.sidebar controls ]
, row [ ] , row [ ]
] ]
] ]
...@@ -116,21 +127,17 @@ explorerCpt state = R.hooksComponent "GraphExplorer" cpt ...@@ -116,21 +127,17 @@ explorerCpt state = R.hooksComponent "GraphExplorer" cpt
tree {mCurrentRoute, treeId: Just treeId} _ = tree {mCurrentRoute, treeId: Just treeId} _ =
RH.div { className: "col-md-2" } [ Tree.elTreeview {mCurrentRoute, root: treeId} ] RH.div { className: "col-md-2" } [ Tree.elTreeview {mCurrentRoute, root: treeId} ]
graphLoader :: GraphId -> Record Controls.Controls -> R.Element mGraph :: {graphId :: GraphId, graph :: Maybe Graph.Graph} -> Record Controls.Controls -> R.Element
graphLoader graphId controls = R.createElement el {} [] mGraph {graph: Nothing} _ = RH.div {} []
where mGraph {graphId, graph: Just graph} controls = graphView controls {graphId, graph}
el = R.hooksComponent "GraphLoader" cpt
cpt {} _children = do
Loader.useLoader graphId getNodes $ \{loaded} ->
loadedGraphView controls {graphId, graph: convert loaded}
type GraphProps = ( type GraphProps = (
graphId :: GraphId graphId :: GraphId
, graph :: Graph.Graph , graph :: Graph.Graph
) )
loadedGraphView :: Record Controls.Controls -> Record GraphProps -> R.Element graphView :: Record Controls.Controls -> Record GraphProps -> R.Element
loadedGraphView controls props = R.createElement el props [] graphView controls props = R.createElement el props []
where where
el = R.hooksComponent "GraphView" cpt el = R.hooksComponent "GraphView" cpt
cpt {graphId, graph} _children = do cpt {graphId, graph} _children = do
......
...@@ -71,6 +71,7 @@ pagesComponent s = case s.currentRoute of ...@@ -71,6 +71,7 @@ pagesComponent s = case s.currentRoute of
graphSpec i = layout1 $ withState \st -> graphSpec i = layout1 $ withState \st ->
cmapProps (const { cmapProps (const {
graphId: i graphId: i
, graph: Nothing
, mCurrentRoute: st.currentRoute , mCurrentRoute: st.currentRoute
, treeId: case st.loginState.authData of , treeId: case st.loginState.authData of
Nothing -> Nothing Nothing -> Nothing
......
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