Commit d1e913f4 authored by Sudhir Kumar's avatar Sudhir Kumar

Graph frontend Integration is done

parent 942d054b
......@@ -39,18 +39,18 @@ derive instance newtypeGraphData :: Newtype GraphData _
instance decodeJsonGraphData :: DecodeJson GraphData where
decodeJson json = do
obj <- decodeJson json
nodes <- obj .? "graph_nodes"
edges <- obj .? "graph_edges"
nodes <- obj .? "nodes"
edges <- obj .? "edges"
pure $ GraphData { nodes, edges }
instance decodeJsonNode :: DecodeJson Node where
decodeJson json = do
obj <- decodeJson json
id_ <- obj .? "node_id"
type_ <- obj .? "node_type"
label <- obj .? "node_label"
size <- obj .? "node_size"
attributes <- obj .? "node_attributes"
id_ <- obj .? "id"
type_ <- obj .? "type"
label <- obj .? "label"
size <- obj .? "size"
attributes <- obj .? "attributes"
pure $ Node { id_, type_, size, label, attributes }
instance decodeJsonCluster :: DecodeJson Cluster where
......@@ -62,10 +62,10 @@ instance decodeJsonCluster :: DecodeJson Cluster where
instance decodeJsonEdge :: DecodeJson Edge where
decodeJson json = do
obj <- decodeJson json
id_ <- obj .? "edge_id"
source <- obj .? "edge_source"
target <- obj .? "edge_target"
weight <- obj .? "edge_weight"
id_ <- obj .? "id"
source <- obj .? "source"
target <- obj .? "target"
weight <- obj .? "weight"
pure $ Edge { id_, source, target, weight }
newtype Legend = Legend {id_ ::Int , label :: String}
......
......@@ -68,7 +68,7 @@ performAction (LoadGraph fp) _ _ = void do
-- graph.
case gd of
Left err -> do
_ <- liftEffect $ log err
_ <- liftEffect $ log err
modifyState identity
Right resp -> modifyState \(State s) -> State s {graphData = resp, sigmaGraphData = Just $ convert resp, legendData = getLegendData resp}
......@@ -95,18 +95,7 @@ convert (GraphData r) = SigmaGraphData { nodes, edges}
render :: Render State {} Action
render d p (State s) c =
[ select [ onChange $ \e -> d $ LoadGraph (unsafeCoerce e).target.value, value s.filePath]
[ option [value ""] [text ""]
, option [value "example_01_clean.json"] [text "example_01_clean.json"]
, option [value "example_01_conditional.json"] [text "example_01_conditional.json"]
, option [value "example_01_distributional.json"] [text "example_01_distributional.json"]
, option [value "example_02.json"] [text "example_02.json"]
, option [value "example_02_clean.json"] [text "example_02_clean.json"]
, option [value "example_03.json"] [text "example_03.json"]
, option [value "example_03_clean.json"] [text "example_03_clean.json"]
, option [value "imtNew.json"] [text "imtNew.json"]
-- , option [value "exemplePhyloBipartite.gexf"] [text "exemplePhyloBipartite.gexf"]
]
[
]
<>
case s.sigmaGraphData of
......@@ -279,7 +268,7 @@ specOld = simpleSpec performAction render'
render' :: Render State {} Action
render' d _ (State st) _ =
[ div [className "row"] [
div [className "col-md-12", style {marginTop : "21px", marginBottom : "21px"}]
div [className "col-md-12", style {marginTop : "34px", marginBottom : "21px"}]
[ menu [_id "toolbar"]
[ ul'
[
......@@ -349,20 +338,7 @@ specOld = simpleSpec performAction render'
, div [className "row"]
[ div [className "col-md-9"]
[ div [style {border : "1px black solid", height: "90%"}] $
[ select [ onChange $ \e -> d $ LoadGraph (unsafeCoerce e).target.value
, value st.filePath
]
[ option [value ""] [text ""]
, option [value "example_01_clean.json"] [text "example_01_clean.json"]
, option [value "example_01_conditional.json"] [text "example_01_conditional.json"]
, option [value "example_01_distributional.json"] [text "example_01_distributional.json"]
, option [value "example_02.json"] [text "example_02.json"]
, option [value "example_02_clean.json"] [text "example_02_clean.json"]
, option [value "example_03.json"] [text "example_03.json"]
, option [value "example_03_clean.json"] [text "example_03_clean.json"]
, option [value "imtNew.json"] [text "imtNew.json"]
-- , option [value "exemplePhyloBipartite.gexf"] [text "exemplePhyloBipartite.gexf"]
]
[
]
<>
case st.sigmaGraphData of
......
......@@ -55,9 +55,9 @@ dispatchAction dispatcher _ (Document n) = do
dispatcher $ SetRoute $ Document n
dispatcher $ DocumentViewA $ Document.Load n
dispatchAction dispatcher _ PGraphExplorer = do
dispatcher $ SetRoute PGraphExplorer
dispatcher $ GraphExplorerA $ GE.LoadGraph 2
dispatchAction dispatcher _ (PGraphExplorer nid) = do
dispatcher $ SetRoute $ PGraphExplorer nid
dispatcher $ GraphExplorerA $ GE.LoadGraph nid
--dispatcher $ GraphExplorerA $ GE.LoadGraph "imtNew.json"
dispatchAction dispatcher _ NGramsTable = do
......
......@@ -59,7 +59,7 @@ pagesComponent s = case s.currentRoute of
selectSpec AddCorpus = layout0 $ focus _addCorpusState _addCorpusAction AC.layoutAddcorpus
selectSpec SearchView = layout0 $ focus _searchState _searchAction S.searchSpec
selectSpec (Document i) = layout0 $ focus _documentViewState _documentViewAction Annotation.docview
selectSpec PGraphExplorer = focus _graphExplorerState _graphExplorerAction GE.specOld
selectSpec (PGraphExplorer i) = focus _graphExplorerState _graphExplorerAction GE.specOld
selectSpec Dashboard = layout0 $ noState Dsh.layoutDashboard
selectSpec (Annuaire i) = layout0 $ cmapProps (const {annuaireId: i}) $ noState A.layout
......
......@@ -20,7 +20,7 @@ data Routes
| Corpus Int
| AddCorpus
| Document Int
| PGraphExplorer
| PGraphExplorer Int
| NGramsTable
| Dashboard
| Annuaire Int
......@@ -36,7 +36,7 @@ routing =
<|> NGramsTable <$ route "ngrams"
<|> Document <$> (route "document" *> int)
<|> Dashboard <$ route "dashboard"
<|> PGraphExplorer <$ route "graph"
<|> PGraphExplorer <$> (route "graph" *> int )
<|> Annuaire <$> (route "annuaire" *> int)
<|> UserPage <$> (route "user" *> int)
<|> Home <$ lit ""
......@@ -58,7 +58,7 @@ instance showRoutes :: Show Routes where
show (Annuaire i) = "Annuaire" <> show i
show (Folder i) = "Folder" <> show i
show Dashboard = "Dashboard"
show PGraphExplorer = "graphExplorer"
show (PGraphExplorer i) = "graphExplorer" <> show i
show Home = "Home"
......
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