Commit 4de7535c authored by Sudhir Kumar's avatar Sudhir Kumar

error types dont unify

parent 7ecae0f6
...@@ -7,9 +7,10 @@ import Affjax (defaultRequest, request) ...@@ -7,9 +7,10 @@ import Affjax (defaultRequest, request)
import Affjax.ResponseFormat (ResponseFormat(..), printResponseFormatError) import Affjax.ResponseFormat (ResponseFormat(..), printResponseFormatError)
import Affjax.ResponseFormat as ResponseFormat import Affjax.ResponseFormat as ResponseFormat
import Control.Monad.Cont.Trans (lift) import Control.Monad.Cont.Trans (lift)
import Control.Monad.State (withState)
import Data.Argonaut (class DecodeJson, class EncodeJson, decodeJson, jsonEmptyObject, (.?), (.??), (:=), (~>)) import Data.Argonaut (class DecodeJson, class EncodeJson, decodeJson, jsonEmptyObject, (.?), (.??), (:=), (~>))
import Data.Argonaut (decodeJson) import Data.Argonaut (decodeJson)
import Data.Array (length, mapWithIndex, (!!)) import Data.Array (fold, length, mapWithIndex, (!!))
import Data.Either (Either(..)) import Data.Either (Either(..))
import Data.HTTP.Method (Method(..)) import Data.HTTP.Method (Method(..))
import Data.Int (fromString, toNumber) import Data.Int (fromString, toNumber)
...@@ -22,6 +23,8 @@ import Effect.Class (liftEffect) ...@@ -22,6 +23,8 @@ import Effect.Class (liftEffect)
import Effect.Console (log) import Effect.Console (log)
import Gargantext.Components.GraphExplorer.Sigmajs (Color(Color), SigmaEasing, SigmaGraphData(SigmaGraphData), SigmaNode, SigmaSettings, canvas, edgeShape, edgeShapes, forceAtlas2, sStyle, sigma, sigmaEasing, sigmaEdge, sigmaEnableWebGL, sigmaNode, sigmaSettings) import Gargantext.Components.GraphExplorer.Sigmajs (Color(Color), SigmaEasing, SigmaGraphData(SigmaGraphData), SigmaNode, SigmaSettings, canvas, edgeShape, edgeShapes, forceAtlas2, sStyle, sigma, sigmaEasing, sigmaEdge, sigmaEnableWebGL, sigmaNode, sigmaSettings)
import Gargantext.Components.GraphExplorer.Types (Cluster(..), Edge(..), GraphData(..), Legend(..), Node(..), getLegendData) import Gargantext.Components.GraphExplorer.Types (Cluster(..), Edge(..), GraphData(..), Legend(..), Node(..), getLegendData)
import Gargantext.Components.Login.Types (TreeId)
import Gargantext.Components.Tree as Tree
import Gargantext.Config as Config import Gargantext.Config as Config
import Gargantext.Config.REST (get, post) import Gargantext.Config.REST (get, post)
import Gargantext.Utils (getter) import Gargantext.Utils (getter)
...@@ -30,7 +33,7 @@ import Partial.Unsafe (unsafePartial) ...@@ -30,7 +33,7 @@ import Partial.Unsafe (unsafePartial)
import React (ReactElement) import React (ReactElement)
import React.DOM (a, br', button, div, form', input, li, li', menu, option, p, select, span, text, ul, ul') import React.DOM (a, br', button, div, form', input, li, li', menu, option, p, select, span, text, ul, ul')
import React.DOM.Props (_id, _type, checked, className, href, name, onChange, onClick, placeholder, style, title, value) import React.DOM.Props (_id, _type, checked, className, href, name, onChange, onClick, placeholder, style, title, value)
import Thermite (PerformAction, Render, Spec, modifyState, simpleSpec) import Thermite (PerformAction, Render, Spec, cmapProps, defaultPerformAction, defaultRender, modifyState, noState, simpleSpec)
import Unsafe.Coerce (unsafeCoerce) import Unsafe.Coerce (unsafeCoerce)
...@@ -38,7 +41,8 @@ data Action ...@@ -38,7 +41,8 @@ data Action
= LoadGraph Int = LoadGraph Int
| SelectNode SelectedNode | SelectNode SelectedNode
| ShowSidePanel Boolean | ShowSidePanel Boolean
| ShowControls | ToggleControls
| ToggleTree
newtype SelectedNode = SelectedNode {id :: String, label :: String} newtype SelectedNode = SelectedNode {id :: String, label :: String}
...@@ -53,8 +57,10 @@ newtype State = State ...@@ -53,8 +57,10 @@ newtype State = State
, selectedNode :: Maybe SelectedNode , selectedNode :: Maybe SelectedNode
, showSidePanel :: Boolean , showSidePanel :: Boolean
, showControls :: Boolean , showControls :: Boolean
, showTree :: Boolean
, nodeResults :: Array NodeResults , nodeResults :: Array NodeResults
, corpusId :: Int , corpusId :: Int
, treeId :: Maybe TreeId
} }
newtype NodeQuery = NodeQuery newtype NodeQuery = NodeQuery
...@@ -78,8 +84,10 @@ initialState = State ...@@ -78,8 +84,10 @@ initialState = State
, selectedNode : Nothing , selectedNode : Nothing
, showSidePanel : false , showSidePanel : false
, showControls : false , showControls : false
, showTree : false
, nodeResults : [] , nodeResults : []
, corpusId : 0 , corpusId : 0
, treeId : Nothing
} }
graphSpec :: Spec State {} Action graphSpec :: Spec State {} Action
...@@ -108,9 +116,13 @@ performAction (ShowSidePanel b) _ (State state) = void do ...@@ -108,9 +116,13 @@ performAction (ShowSidePanel b) _ (State state) = void do
modifyState $ \(State s) -> State s {showSidePanel = b } modifyState $ \(State s) -> State s {showSidePanel = b }
performAction (ShowControls) _ (State state) = void do performAction (ToggleControls) _ (State state) = void do
modifyState $ \(State s) -> State s {showControls = not (state.showControls) } modifyState $ \(State s) -> State s {showControls = not (state.showControls) }
performAction (ToggleTree) _ (State state) = void do
modifyState $ \(State s) -> State s {showTree = not (state.showTree) }
convert :: GraphData -> SigmaGraphData convert :: GraphData -> SigmaGraphData
convert (GraphData r) = SigmaGraphData { nodes, edges} convert (GraphData r) = SigmaGraphData { nodes, edges}
where where
...@@ -131,9 +143,6 @@ convert (GraphData r) = SigmaGraphData { nodes, edges} ...@@ -131,9 +143,6 @@ convert (GraphData r) = SigmaGraphData { nodes, edges}
render :: Render State {} Action render :: Render State {} Action
render d p (State s) c = render d p (State s) c =
[
]
<>
case s.sigmaGraphData of case s.sigmaGraphData of
Nothing -> [] Nothing -> []
Just gData -> Just gData ->
...@@ -296,25 +305,46 @@ dispLegend ary = div [] $ map dl ary ...@@ -296,25 +305,46 @@ dispLegend ary = div [] $ map dl ary
specOld :: Spec State {} Action specOld :: Spec State {} Action
specOld = simpleSpec performAction render' specOld = fold [simpleSpec performAction render']
where where
treeSpec :: Spec State {} Action
treeSpec = withState \(State st) ->
case st.treeId of
Nothing ->
simpleSpec defaultPerformAction defaultRender
Just treeId ->
(cmapProps (const {root: treeId}) (noState Tree.treeview))
render' :: Render State {} Action render' :: Render State {} Action
render' d _ (State st) _ = render' d _ (State st) _ =
[ div [className "row"] [ div [className "container-fluid", style {"padding-top" : "100px"}]
[ div [className "row", style {"padding-bottom" : "10px"}]
[ [
div [className "col-md-12"] div [className "col-md-4"]
[ button [className "btn btn-primary" [ button [className "btn btn-primary"
, onClick \_ -> d ShowControls , onClick \_ -> d ToggleTree
,style {position:"relative",top:"-25px",left: "737px"}
] ]
[text "Show Controls"] [text $ if st.showTree then "Hide Tree" else "Show Tree"]
, button [className "btn btn-primary" ]
, style {position:"relative",top:"-25px",left: "1380px"} , div [className "col-md-4"]
[
button [className "btn btn-primary center-block"
, onClick \_ -> d ToggleControls
]
[text $ if st.showControls then "Hide Controls" else "Show Controls"]
]
, div [className "col-md-4"]
[ div [className "pull-right"]
[ button [className "btn btn-primary"
,onClick \_ -> d $ ShowSidePanel $ not st.showSidePanel ,onClick \_ -> d $ ShowSidePanel $ not st.showSidePanel
] [text "Show SidePanel"] ] [text $ if st.showSidePanel then "Hide Side Panel" else "Show Side Panel"]
] ]
, if (st.showControls) then ]
div [className "col-md-12", style {marginBottom : "21px"}] ],
div [className "row"]
[
if (st.showControls) then
div [className "col-md-12", style {"padding-bottom" : "10px"}]
[ menu [_id "toolbar"] [ menu [_id "toolbar"]
[ ul' [ ul'
[ [
...@@ -384,7 +414,7 @@ specOld = simpleSpec performAction render' ...@@ -384,7 +414,7 @@ specOld = simpleSpec performAction render'
else div [] [] else div [] []
] ]
, div [className "row"] , div [className "row"]
[ div [if (st.showSidePanel) then className "col-md-10" else className "col-md-11"] [ div [if (st.showSidePanel && st.showTree) then className "col-md-8" else if (st.showSidePanel || st.showTree) then className "col-md-10" else className "col-md-12"]
[ div [style {height: "90%"}] $ [ div [style {height: "90%"}] $
[ [
] ]
...@@ -414,7 +444,7 @@ specOld = simpleSpec performAction render' ...@@ -414,7 +444,7 @@ specOld = simpleSpec performAction render'
] ]
--, button [onClick \_ -> d ShowSidePanel, className "btn btn-primary", style {right:"39px",position : "relative",zIndex:"1000", top: "-59px"}] [text "Show SidePanel"] --, button [onClick \_ -> d ShowSidePanel, className "btn btn-primary", style {right:"39px",position : "relative",zIndex:"1000", top: "-59px"}] [text "Show SidePanel"]
, if (st.showSidePanel) then , if (st.showSidePanel) then
div [_id "sp-container",className "col-md-2", style {border : "1px black solid", backgroundColor : "beige", position:"absolute",right: "0px",top:"265px"}] div [_id "sp-container", className "col-md-2", style {border : "1px black solid", backgroundColor : "beige"}]
[ div [className "row"] [ div [className "row"]
[ div [_id "sidepanel" , style {borderBottom : "1px solid black"}] [ div [_id "sidepanel" , style {borderBottom : "1px solid black"}]
[ case st.selectedNode of [ case st.selectedNode of
...@@ -518,6 +548,7 @@ specOld = simpleSpec performAction render' ...@@ -518,6 +548,7 @@ specOld = simpleSpec performAction render'
div [] [] -- ends sidepanel column here div [] [] -- ends sidepanel column here
] ]
] ]
]
getTitle :: Array NodeResults -> Array String getTitle :: Array NodeResults -> Array String
getTitle ary = map (\(NodeResults s)-> s.title) ary getTitle ary = map (\(NodeResults s)-> s.title) ary
......
...@@ -35,7 +35,7 @@ data Action ...@@ -35,7 +35,7 @@ data Action
| ShowLogin | ShowLogin
| Logout | Logout
| ShowAddcorpus | ShowAddcorpus
| ShowTree | ToggleTree
performAction :: PerformAction AppState {} Action performAction :: PerformAction AppState {} Action
...@@ -44,7 +44,7 @@ performAction (SetRoute route) _ _ = void do ...@@ -44,7 +44,7 @@ performAction (SetRoute route) _ _ = void do
performAction (Search s) _ _ = void do performAction (Search s) _ _ = void do
modifyState $ _ {search = s} modifyState $ _ {search = s}
performAction (ShowTree) _ (state) = void do -- TODO performAction (ToggleTree) _ (state) = void do -- TODO
modifyState $ _ {showTree = not (state.showTree)} modifyState $ _ {showTree = not (state.showTree)}
performAction (ShowLogin) _ _ = void do performAction (ShowLogin) _ _ = void do
......
...@@ -117,7 +117,8 @@ layout1 :: Spec AppState {} Action ...@@ -117,7 +117,8 @@ layout1 :: Spec AppState {} Action
layout1 layout = layout1 layout =
fold fold
[ layoutSidebar divSearchBar [ layoutSidebar divSearchBar
, outerLayout , layout
-- , outerLayout
, layoutFooter , layoutFooter
] ]
where where
...@@ -135,7 +136,7 @@ layout1 layout = ...@@ -135,7 +136,7 @@ layout1 layout =
] ]
ls = over _render \render d p s c -> [ ls = over _render \render d p s c -> [
button [onClick $ \e -> d ShowTree, className "btn btn-primary",style {position:"relative", top: "99px",left:"-264px",zIndex : "1000"}] [text "ShowTree"] button [onClick $ \e -> d ToggleTree, className "btn btn-primary",style {position:"relative", top: "99px",left:"-264px",zIndex : "1000"}] [text "ShowTree"]
, div [if (s.showTree) then className "col-md-2" else className "col-md-2"] if (s.showTree) then (render d p s c) else [] , div [if (s.showTree) then className "col-md-2" else className "col-md-2"] if (s.showTree) then (render d p s c) else []
] ]
......
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