Commit 7fe038e4 authored by arturo's avatar arturo

>>> continue

parent f4c47bfd
module Gargantext.Components.GraphExplorer.ControlsToggleButton
( Props, controlsToggleButton, controlsToggleButtonCpt
) where
import Reactix as R
import Reactix.DOM.HTML as H
import Toestand as T
import Gargantext.Prelude
import Gargantext.Utils.Reactix as R2
here :: R2.Here
here = R2.here "Gargantext.Components.GraphExplorer.ControlsToggleButton"
type Props = ( state :: T.Box Boolean )
controlsToggleButton :: R2.Leaf Props
controlsToggleButton = R2.leafComponent controlsToggleButtonCpt
controlsToggleButtonCpt :: R.Component Props
controlsToggleButtonCpt = here.component "controlsToggleButton" cpt
where
cpt { state } _ = do
open' <- T.useLive T.unequal state
pure $
H.button
{ className: "btn btn-primary", on: {click: \_ -> T.modify_ not state } }
[ H.text (text open') ]
text true = "Hide Controls"
text false = "Show Controls"
...@@ -15,7 +15,7 @@ import Data.Tuple (Tuple(..)) ...@@ -15,7 +15,7 @@ import Data.Tuple (Tuple(..))
import Gargantext.Components.App.Data (Boxes) import Gargantext.Components.App.Data (Boxes)
import Gargantext.Components.Bootstrap as B import Gargantext.Components.Bootstrap as B
import Gargantext.Components.GraphExplorer.Resources as Graph import Gargantext.Components.GraphExplorer.Resources as Graph
import Gargantext.Components.GraphExplorer.Controls as Controls import Gargantext.Components.GraphExplorer.Toolbar.Controls as Controls
import Gargantext.Components.GraphExplorer.Sidebar as GES import Gargantext.Components.GraphExplorer.Sidebar as GES
import Gargantext.Components.GraphExplorer.Sidebar.Types as GEST import Gargantext.Components.GraphExplorer.Sidebar.Types as GEST
import Gargantext.Components.GraphExplorer.TopBar as GETB import Gargantext.Components.GraphExplorer.TopBar as GETB
......
module Gargantext.Components.GraphExplorer.Legend module Gargantext.Components.GraphExplorer.Sidebar.Legend
( Props, legend ( Props, legend
) where ) where
...@@ -13,7 +13,7 @@ import Gargantext.Components.GraphExplorer.Types (Legend(..), intColor) ...@@ -13,7 +13,7 @@ import Gargantext.Components.GraphExplorer.Types (Legend(..), intColor)
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
here :: R2.Here here :: R2.Here
here = R2.here "Gargantext.Components.GraphExplorer.Legend" here = R2.here "Gargantext.Components.GraphExplorer.Sidebar.Legend"
type Props = ( items :: Seq Legend ) type Props = ( items :: Seq Legend )
......
...@@ -23,7 +23,7 @@ import Effect.Class (liftEffect) ...@@ -23,7 +23,7 @@ import Effect.Class (liftEffect)
import Gargantext.Components.App.Data (Boxes) import Gargantext.Components.App.Data (Boxes)
import Gargantext.Components.Bootstrap as B import Gargantext.Components.Bootstrap as B
import Gargantext.Components.Bootstrap.Types (ButtonVariant(..), Variant(..)) import Gargantext.Components.Bootstrap.Types (ButtonVariant(..), Variant(..))
import Gargantext.Components.GraphExplorer.Legend as Legend import Gargantext.Components.GraphExplorer.Sidebar.Legend as Legend
import Gargantext.Components.GraphExplorer.Sidebar.Types as GEST import Gargantext.Components.GraphExplorer.Sidebar.Types as GEST
import Gargantext.Components.GraphExplorer.Types as GET import Gargantext.Components.GraphExplorer.Types as GET
import Gargantext.Components.Lang (Lang(..)) import Gargantext.Components.Lang (Lang(..))
...@@ -51,15 +51,15 @@ import Toestand as T ...@@ -51,15 +51,15 @@ import Toestand as T
here :: R2.Here here :: R2.Here
here = R2.here "Gargantext.Components.GraphExplorer.Sidebar" here = R2.here "Gargantext.Components.GraphExplorer.Sidebar"
type Common = ( type Common =
boxes :: Boxes ( boxes :: Boxes
, graphId :: NodeID , graphId :: NodeID
, metaData :: GET.MetaData , metaData :: GET.MetaData
, session :: Session , session :: Session
) )
type Props = ( type Props =
frontends :: Frontends ( frontends :: Frontends
, graph :: SigmaxT.SGraph , graph :: SigmaxT.SGraph
| Common | Common
) )
...@@ -612,50 +612,46 @@ type Query = ...@@ -612,50 +612,46 @@ type Query =
, nodesMap :: SigmaxT.NodesMap , nodesMap :: SigmaxT.NodesMap
, searchType :: SearchType , searchType :: SearchType
, selectedNodeIds :: SigmaxT.NodeIds , selectedNodeIds :: SigmaxT.NodeIds
, session :: Session ) , session :: Session
)
query :: R2.Leaf Query query :: R2.Leaf Query
query = R2.leaf queryCpt query = R2.leaf queryCpt
queryCpt :: R.Component Query queryCpt :: R.Component Query
queryCpt = here.component "query" cpt where queryCpt = here.component "query'" cpt where
cpt props@{ selectedNodeIds } _ = do
pure $ if Set.isEmpty selectedNodeIds
then H.div {} []
else query' props []
query' :: R2.Component Query
query' = R.createElement queryCpt'
queryCpt' :: R.Component Query
queryCpt' = here.component "query'" cpt where
cpt { frontends cpt { frontends
, metaData: GET.MetaData metaData , metaData: GET.MetaData metaData
, nodesMap , nodesMap
, searchType , searchType
, selectedNodeIds , selectedNodeIds
, session } _ = do , session } _ = do
pure $ case (head metaData.corpusId) of -- Computed
Nothing -> H.div {} [] let
Just corpusId ->
CGT.tabs { frontends
, query: SearchQuery { expected: searchType
, query : concat $ toQuery <$> Set.toUnfoldable selectedNodeIds
}
, session
, sides: [side corpusId]
}
where
toQuery id = case Map.lookup id nodesMap of toQuery id = case Map.lookup id nodesMap of
Nothing -> [] Nothing -> []
Just n -> words n.label Just n -> words n.label
side corpusId = GET.GraphSideCorpus { corpusId side corpusId = GET.GraphSideCorpus
, corpusLabel: metaData.title { corpusId
, listId : metaData.list.listId , corpusLabel: metaData.title
} , listId : metaData.list.listId
}
-- Render
pure $
R2.fromMaybe_ (head metaData.corpusId) \corpusId ->
CGT.tabs
{ frontends
, query: SearchQuery
{ expected: searchType
, query: concat $ toQuery <$> Set.toUnfoldable selectedNodeIds
}
, session
, sides: [side corpusId]
}
------------------------------------------------------------------------ ------------------------------------------------------------------------
......
module Gargantext.Components.GraphExplorer.ToggleButton
( Props
, toggleButton
, toggleButtonCpt
, controlsToggleButton
) where
import Prelude
import Effect (Effect)
import Gargantext.Utils.Reactix as R2
import Reactix as R
import Reactix.DOM.HTML as H
import Toestand as T
-- @WIP: used?
here :: R2.Here
here = R2.here "Gargantext.Components.GraphExplorer.ToggleButton"
type Props = (
state :: T.Box Boolean
, onMessage :: String
, offMessage :: String
, style :: String
, onClick :: forall e. e -> Effect Unit
)
toggleButton :: R2.Component Props
toggleButton = R.createElement toggleButtonCpt
toggleButtonCpt :: R.Component Props
toggleButtonCpt = here.component "toggleButton" cpt
where
cpt { state
, onMessage
, offMessage
, onClick
, style } _ = do
state' <- T.useLive T.unequal state
pure $ H.div { className: "btn btn-outline-" <> style <> " " <> cls state' <> " mx-2"
, on: { click: onClick }
} [ R2.small {} [ H.text (text onMessage offMessage state') ] ]
cls true = "active"
cls false = ""
text on _off true = on
text _on off false = off
----------------------------------------------------------------
type ControlsToggleButtonProps = (
state :: T.Box Boolean
)
controlsToggleButton :: R2.Component ControlsToggleButtonProps
controlsToggleButton = R.createElement controlsToggleButtonCpt
controlsToggleButtonCpt :: R.Component ControlsToggleButtonProps
controlsToggleButtonCpt = here.component "controlsToggleButton" cpt
where
cpt { state } _ = do
pure $ toggleButton {
state: state
, onMessage: "Hide Controls"
, offMessage: "Show Controls"
, onClick: \_ -> T.modify_ not state
, style: "light"
} []
module Gargantext.Components.GraphExplorer.Buttons module Gargantext.Components.GraphExplorer.Toolbar.Buttons
( Props ( centerButton
, centerButton
, simpleButton
, cameraButton , cameraButton
, edgesToggleButton , edgesToggleButton
, louvainToggleButton , louvainToggleButton
...@@ -19,7 +17,6 @@ import Data.Either (Either(..)) ...@@ -19,7 +17,6 @@ import Data.Either (Either(..))
import Data.Enum (fromEnum) import Data.Enum (fromEnum)
import Data.Maybe (Maybe(..)) import Data.Maybe (Maybe(..))
import Data.String as DS import Data.String as DS
import Effect (Effect)
import Effect.Aff (launchAff_) import Effect.Aff (launchAff_)
import Effect.Class (liftEffect) import Effect.Class (liftEffect)
import Effect.Now as EN import Effect.Now as EN
...@@ -43,27 +40,10 @@ import Reactix.DOM.HTML as H ...@@ -43,27 +40,10 @@ import Reactix.DOM.HTML as H
import Toestand as T import Toestand as T
here :: R2.Here here :: R2.Here
here = R2.here "Gargantext.Components.GraphExplorer.Button" here = R2.here "Gargantext.Components.GraphExplorer.Toolbar.Button"
type Props = (
onClick :: forall e. e -> Effect Unit
, text :: String
)
-- @WIP
simpleButton :: Record Props -> R.Element
simpleButton props = R.createElement simpleButtonCpt props []
------------------------------------------------------ ------------------------------------------------------
simpleButtonCpt :: R.Component Props
simpleButtonCpt = here.component "simpleButton" cpt
where
cpt {onClick, text} _ = do
pure $ H.button { className: "btn btn-outline-secondary"
, on: {click: onClick}
} [ R2.small {} [ H.text text ] ]
centerButton :: R.Ref Sigmax.Sigma -> R.Element centerButton :: R.Ref Sigmax.Sigma -> R.Element
centerButton sigmaRef = B.button centerButton sigmaRef = B.button
{ variant: OutlinedButtonVariant Secondary { variant: OutlinedButtonVariant Secondary
......
module Gargantext.Components.GraphExplorer.Controls module Gargantext.Components.GraphExplorer.Toolbar.Controls
( Controls ( Controls
, useGraphControls , useGraphControls
, controls , controls
...@@ -15,11 +15,11 @@ import Data.Sequence as Seq ...@@ -15,11 +15,11 @@ import Data.Sequence as Seq
import Data.Set as Set import Data.Set as Set
import Effect.Timer (setTimeout) import Effect.Timer (setTimeout)
import Gargantext.Components.Bootstrap as B import Gargantext.Components.Bootstrap as B
import Gargantext.Components.GraphExplorer.Buttons (centerButton, cameraButton, edgesToggleButton, louvainToggleButton, pauseForceAtlasButton, multiSelectEnabledButton) import Gargantext.Components.GraphExplorer.Toolbar.Buttons (centerButton, cameraButton, edgesToggleButton, louvainToggleButton, pauseForceAtlasButton, multiSelectEnabledButton)
import Gargantext.Components.GraphExplorer.RangeControl (edgeConfluenceControl, edgeWeightControl, nodeSizeControl) import Gargantext.Components.GraphExplorer.Toolbar.RangeControl (edgeConfluenceControl, edgeWeightControl, nodeSizeControl)
import Gargantext.Components.GraphExplorer.Resources as Graph import Gargantext.Components.GraphExplorer.Resources as Graph
import Gargantext.Components.GraphExplorer.Sidebar.Types as GEST import Gargantext.Components.GraphExplorer.Sidebar.Types as GEST
import Gargantext.Components.GraphExplorer.SlideButton (labelSizeButton, mouseSelectorSizeButton) import Gargantext.Components.GraphExplorer.Toolbar.SlideButton (labelSizeButton, mouseSelectorSizeButton)
import Gargantext.Components.GraphExplorer.Types as GET import Gargantext.Components.GraphExplorer.Types as GET
import Gargantext.Hooks.Sigmax as Sigmax import Gargantext.Hooks.Sigmax as Sigmax
import Gargantext.Hooks.Sigmax.Types as SigmaxT import Gargantext.Hooks.Sigmax.Types as SigmaxT
...@@ -33,7 +33,7 @@ import Reactix.DOM.HTML as H ...@@ -33,7 +33,7 @@ import Reactix.DOM.HTML as H
import Toestand as T import Toestand as T
here :: R2.Here here :: R2.Here
here = R2.here "Gargantext.Components.GraphExplorer.Controls" here = R2.here "Gargantext.Components.GraphExplorer.Toolbar.Controls"
type Controls = type Controls =
( edgeConfluence :: T.Box Range.NumberRange ( edgeConfluence :: T.Box Range.NumberRange
......
module Gargantext.Components.GraphExplorer.RangeControl module Gargantext.Components.GraphExplorer.Toolbar.RangeControl
( Props ( Props
, rangeControl , rangeControl
, edgeConfluenceControl , edgeConfluenceControl
...@@ -16,7 +16,7 @@ import Gargantext.Utils.Range as Range ...@@ -16,7 +16,7 @@ import Gargantext.Utils.Range as Range
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
here :: R2.Here here :: R2.Here
here = R2.here "Gargantext.Components.GraphExplorer.RangeControl" here = R2.here "Gargantext.Components.GraphExplorer.Toolbar.RangeControl"
type Props = type Props =
( caption :: String ( caption :: String
......
module Gargantext.Components.GraphExplorer.SlideButton module Gargantext.Components.GraphExplorer.Toolbar.SlideButton
( Props ( Props
, sizeButton , sizeButton
, labelSizeButton , labelSizeButton
...@@ -17,7 +17,7 @@ import Gargantext.Hooks.Sigmax.Sigma as Sigma ...@@ -17,7 +17,7 @@ import Gargantext.Hooks.Sigmax.Sigma as Sigma
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
here :: R2.Here here :: R2.Here
here = R2.here "Gargantext.Components.GraphExplorer.SlideButton" here = R2.here "Gargantext.Components.GraphExplorer.Toolbar.SlideButton"
type Props = type Props =
( caption :: String ( caption :: String
......
module Gargantext.Components.GraphExplorer.Search module Gargantext.Components.GraphExplorer.Topbar.Search
( Props, nodeSearchControl ) where ( Props, nodeSearchControl ) where
import Prelude import Prelude
...@@ -18,10 +18,10 @@ import Reactix.DOM.HTML as H ...@@ -18,10 +18,10 @@ import Reactix.DOM.HTML as H
import Toestand as T import Toestand as T
here :: R2.Here here :: R2.Here
here = R2.here "Gargantext.Components.GraphExplorer.Search" here = R2.here "Gargantext.Components.GraphExplorer.Topbar.Search"
type Props = ( type Props =
graph :: SigmaxT.SGraph ( graph :: SigmaxT.SGraph
, multiSelectEnabled :: T.Box Boolean , multiSelectEnabled :: T.Box Boolean
, selectedNodeIds :: T.Box SigmaxT.NodeIds , selectedNodeIds :: T.Box SigmaxT.NodeIds
, className :: String , className :: String
......
...@@ -5,7 +5,7 @@ import Gargantext.Prelude hiding (max, min) ...@@ -5,7 +5,7 @@ import Gargantext.Prelude hiding (max, min)
import Data.Maybe (Maybe) import Data.Maybe (Maybe)
import Gargantext.Components.Bootstrap as B import Gargantext.Components.Bootstrap as B
import Gargantext.Components.Bootstrap.Types (ButtonVariant(..), Variant(..)) import Gargantext.Components.Bootstrap.Types (ButtonVariant(..), Variant(..))
import Gargantext.Components.GraphExplorer.Search (nodeSearchControl) import Gargantext.Components.GraphExplorer.Topbar.Search (nodeSearchControl)
import Gargantext.Components.GraphExplorer.Sidebar.Types as GEST import Gargantext.Components.GraphExplorer.Sidebar.Types as GEST
import Gargantext.Types as GT import Gargantext.Types as GT
import Gargantext.Utils ((?)) import Gargantext.Utils ((?))
......
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