Commit a097bd1a authored by Alexandre Delanoë's avatar Alexandre Delanoë

Merge branch 'side-docs' of...

Merge branch 'side-docs' of ssh://gitlab.iscpif.fr:20022/gargantext/purescript-gargantext into masterLocal
parents 51fc63a6 34d8fef7
-- TODO: this module should be replaced by FacetsTable
module Gargantext.Components.DocsTable where module Gargantext.Components.DocsTable where
import Affjax (defaultRequest, request) import Affjax (defaultRequest, request)
......
This diff is collapsed.
...@@ -51,8 +51,11 @@ instance decodeJsonGraphData :: DecodeJson GraphData where ...@@ -51,8 +51,11 @@ instance decodeJsonGraphData :: DecodeJson GraphData where
nodes <- obj .? "nodes" nodes <- obj .? "nodes"
edges <- obj .? "edges" edges <- obj .? "edges"
-- TODO: sides -- TODO: sides
-- sides <- obj .? "corpusId" metadata <- obj .? "metadata"
pure $ GraphData { nodes, edges, sides: [GraphSideCorpus { corpusId: 1004223, corpusLabel: "Patents" }, GraphSideCorpus { corpusId: 998770, corpusLabel: "Books" }] } corpusIds <- metadata .? "corpusId"
let side x = GraphSideCorpus { corpusId: x, corpusLabel: "Patents" }
let sides = side <$> corpusIds
pure $ GraphData { nodes, edges, sides }
instance decodeJsonNode :: DecodeJson Node where instance decodeJsonNode :: DecodeJson Node where
decodeJson json = do decodeJson json = do
......
...@@ -108,6 +108,9 @@ limitUrl l = "&limit=" <> show l ...@@ -108,6 +108,9 @@ limitUrl l = "&limit=" <> show l
offsetUrl :: Offset -> UrlPath offsetUrl :: Offset -> UrlPath
offsetUrl o = "&offset=" <> show o offsetUrl o = "&offset=" <> show o
orderUrl :: forall a. Show a => Maybe a -> UrlPath
orderUrl = maybe "" (\x -> "&order=" <> show x)
tabTypeNgrams :: TabType -> UrlPath tabTypeNgrams :: TabType -> UrlPath
tabTypeNgrams (TabCorpus t) = "listGet?ngramsType=" <> show t tabTypeNgrams (TabCorpus t) = "listGet?ngramsType=" <> show t
tabTypeNgrams (TabPairing t) = "listGet?ngramsType=" <> show t -- TODO tabTypeNgrams (TabPairing t) = "listGet?ngramsType=" <> show t -- TODO
...@@ -115,14 +118,10 @@ tabTypeNgrams (TabPairing t) = "listGet?ngramsType=" <> show t -- TODO ...@@ -115,14 +118,10 @@ tabTypeNgrams (TabPairing t) = "listGet?ngramsType=" <> show t -- TODO
pathUrl :: Config -> Path -> Maybe Id -> UrlPath pathUrl :: Config -> Path -> Maybe Id -> UrlPath
pathUrl c (Tab t o l s) i = pathUrl c (Tab t o l s) i =
pathUrl c (NodeAPI Node) i <> pathUrl c (NodeAPI Node) i <>
"/" <> tabTypeDocs t <> offsetUrl o <> limitUrl l <> os "/" <> tabTypeDocs t <> offsetUrl o <> limitUrl l <> orderUrl s
where
os = maybe "" (\x -> "&order=" <> show x) s
pathUrl c (Children n o l s) i = pathUrl c (Children n o l s) i =
pathUrl c (NodeAPI Node) i <> pathUrl c (NodeAPI Node) i <>
"/" <> "children?type=" <> show n <> offsetUrl o <> limitUrl l <> os "/" <> "children?type=" <> show n <> offsetUrl o <> limitUrl l <> orderUrl s
where
os = maybe "" (\x -> "&order=" <> show x) s
pathUrl c (Ngrams t o l listid) i = pathUrl c (Ngrams t o l listid) i =
pathUrl c (NodeAPI Node) i <> "/" <> tabTypeNgrams t pathUrl c (NodeAPI Node) i <> "/" <> tabTypeNgrams t
<> offsetUrl o <> limitUrl l <> listid' <> offsetUrl o <> limitUrl l <> listid'
...@@ -131,7 +130,9 @@ pathUrl c (Ngrams t o l listid) i = ...@@ -131,7 +130,9 @@ pathUrl c (Ngrams t o l listid) i =
pathUrl c Auth Nothing = c.prePath <> "auth" pathUrl c Auth Nothing = c.prePath <> "auth"
pathUrl c Auth (Just _) = "impossible" -- TODO better types pathUrl c Auth (Just _) = "impossible" -- TODO better types
pathUrl c (NodeAPI nt) i = c.prePath <> nodeTypeUrl nt <> (maybe "" (\i' -> "/" <> show i') i) pathUrl c (NodeAPI nt) i = c.prePath <> nodeTypeUrl nt <> (maybe "" (\i' -> "/" <> show i') i)
pathUrl c (Search {limit,offset,orderBy}) _TODO =
c.prePath <> "search/?dummy=dummy"
<> offsetUrl offset <> limitUrl limit <> orderUrl orderBy
------------------------------------------------------------ ------------------------------------------------------------
...@@ -190,6 +191,12 @@ data Path ...@@ -190,6 +191,12 @@ data Path
| Children NodeType Offset Limit (Maybe OrderBy) | Children NodeType Offset Limit (Maybe OrderBy)
| Ngrams TabType Offset Limit (Maybe TermList) | Ngrams TabType Offset Limit (Maybe TermList)
| NodeAPI NodeType | NodeAPI NodeType
| Search { {-id :: Int
, query :: Array String
,-} limit :: Limit
, offset :: Offset
, orderBy :: Maybe OrderBy
}
data End = Back | Front data End = Back | Front
type Id = Int type Id = Int
......
...@@ -23,6 +23,7 @@ import Effect.Aff (Aff, attempt) ...@@ -23,6 +23,7 @@ import Effect.Aff (Aff, attempt)
import Effect.Aff.Class (liftAff) import Effect.Aff.Class (liftAff)
import Effect.Class (liftEffect) import Effect.Class (liftEffect)
import Effect.Console (log) import Effect.Console (log)
import Gargantext.Components.RandomText (words)
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 (AuthData(..), TreeId) import Gargantext.Components.Login.Types (AuthData(..), TreeId)
...@@ -561,7 +562,10 @@ specOld = fold [treespec treeSpec, graphspec $ simpleSpec performAction render'] ...@@ -561,7 +562,10 @@ specOld = fold [treespec treeSpec, graphspec $ simpleSpec performAction render']
, div [] , div []
[ p [] [] [ p [] []
, div [className "col-md-12"] , div [className "col-md-12"]
[ GT.tabsElt {sides} [ case st.selectedNode of
Just (SelectedNode {label}) ->
GT.tabsElt {query: words label, sides}
Nothing -> p [] []
, p [] [] , p [] []
] ]
] ]
......
...@@ -6,37 +6,38 @@ import Data.List (fromFoldable) ...@@ -6,37 +6,38 @@ import Data.List (fromFoldable)
import Data.Tuple (Tuple(..)) import Data.Tuple (Tuple(..))
import Gargantext.Config (TabType(..), TabSubType(..)) import Gargantext.Config (TabType(..), TabSubType(..))
import Gargantext.Components.GraphExplorer.Types (GraphSideCorpus(..)) import Gargantext.Components.GraphExplorer.Types (GraphSideCorpus(..))
import Gargantext.Components.DocsTable as DT import Gargantext.Components.FacetsTable as FT
import Gargantext.Components.Tab as Tab import Gargantext.Components.Tab as Tab
import React (ReactElement, ReactClass, Children, createElement) import React (ReactElement, ReactClass, Children, createElement)
import Thermite ( Spec, PerformAction, Render, _performAction, _render import Thermite ( Spec, PerformAction, Render, _performAction, _render
, hideState, noState, cmapProps, simpleSpec, createClass , hideState, noState, cmapProps, simpleSpec, createClass
) )
type Props = { sides :: Array GraphSideCorpus } type Props = { query :: Array String, sides :: Array GraphSideCorpus }
tabsElt :: Props -> ReactElement tabsElt :: Props -> ReactElement
tabsElt props = createElement tabsClass props [] tabsElt props = createElement tabsClass props []
-- TODO no need for Children here -- TODO no need for Children here
tabsClass :: ReactClass { sides :: Array GraphSideCorpus, children :: Children } tabsClass :: ReactClass { query :: Array String, sides :: Array GraphSideCorpus, children :: Children }
tabsClass = createClass "GraphTabs" pureTabs (const {}) tabsClass = createClass "GraphTabs" pureTabs (const {})
pureTabs :: Spec {} Props Void pureTabs :: Spec {} Props Void
pureTabs = hideState (const {activeTab: 0}) statefulTabs pureTabs = hideState (const {activeTab: 0}) statefulTabs
tab :: forall props state. GraphSideCorpus -> Tuple String (Spec state props Tab.Action) tab :: forall props state. Array String -> GraphSideCorpus -> Tuple String (Spec state props Tab.Action)
tab (GraphSideCorpus {corpusId: nodeId, corpusLabel}) = tab query (GraphSideCorpus {corpusId: nodeId, corpusLabel}) =
Tuple corpusLabel $ Tuple corpusLabel $
cmapProps (const {nodeId, chart, tabType: TabCorpus TabDocs, totalRecords: 4736}) $ cmapProps (const {nodeId, query, chart, totalRecords: 4736}) $
noState DT.docViewSpec noState FT.docViewSpec
where where
-- TODO totalRecords: probably need to insert a corpusLoader. -- TODO totalRecords: probably need to insert a corpusLoader.
chart = mempty chart = mempty
statefulTabs :: Spec Tab.State Props Tab.Action statefulTabs :: Spec Tab.State Props Tab.Action
statefulTabs = statefulTabs =
withProps (\{sides} -> Tab.tabs identity identity $ fromFoldable $ tab <$> sides) withProps (\{query, sides} ->
Tab.tabs identity identity $ fromFoldable $ tab query <$> sides)
-- TODO move to Thermite -- TODO move to Thermite
-- | This function captures the props of the `Spec` as a function argument. -- | This function captures the props of the `Spec` as a function argument.
......
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