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
import Affjax (defaultRequest, request)
......
This diff is collapsed.
......@@ -51,8 +51,11 @@ instance decodeJsonGraphData :: DecodeJson GraphData where
nodes <- obj .? "nodes"
edges <- obj .? "edges"
-- TODO: sides
-- sides <- obj .? "corpusId"
pure $ GraphData { nodes, edges, sides: [GraphSideCorpus { corpusId: 1004223, corpusLabel: "Patents" }, GraphSideCorpus { corpusId: 998770, corpusLabel: "Books" }] }
metadata <- obj .? "metadata"
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
decodeJson json = do
......
......@@ -108,6 +108,9 @@ limitUrl l = "&limit=" <> show l
offsetUrl :: Offset -> UrlPath
offsetUrl o = "&offset=" <> show o
orderUrl :: forall a. Show a => Maybe a -> UrlPath
orderUrl = maybe "" (\x -> "&order=" <> show x)
tabTypeNgrams :: TabType -> UrlPath
tabTypeNgrams (TabCorpus t) = "listGet?ngramsType=" <> show t
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 c (Tab t o l s) i =
pathUrl c (NodeAPI Node) i <>
"/" <> tabTypeDocs t <> offsetUrl o <> limitUrl l <> os
where
os = maybe "" (\x -> "&order=" <> show x) s
"/" <> tabTypeDocs t <> offsetUrl o <> limitUrl l <> orderUrl s
pathUrl c (Children n o l s) i =
pathUrl c (NodeAPI Node) i <>
"/" <> "children?type=" <> show n <> offsetUrl o <> limitUrl l <> os
where
os = maybe "" (\x -> "&order=" <> show x) s
"/" <> "children?type=" <> show n <> offsetUrl o <> limitUrl l <> orderUrl s
pathUrl c (Ngrams t o l listid) i =
pathUrl c (NodeAPI Node) i <> "/" <> tabTypeNgrams t
<> offsetUrl o <> limitUrl l <> listid'
......@@ -131,7 +130,9 @@ pathUrl c (Ngrams t o l listid) i =
pathUrl c Auth Nothing = c.prePath <> "auth"
pathUrl c Auth (Just _) = "impossible" -- TODO better types
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
| Children NodeType Offset Limit (Maybe OrderBy)
| Ngrams TabType Offset Limit (Maybe TermList)
| NodeAPI NodeType
| Search { {-id :: Int
, query :: Array String
,-} limit :: Limit
, offset :: Offset
, orderBy :: Maybe OrderBy
}
data End = Back | Front
type Id = Int
......
......@@ -23,6 +23,7 @@ import Effect.Aff (Aff, attempt)
import Effect.Aff.Class (liftAff)
import Effect.Class (liftEffect)
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.Types (Cluster(..), Edge(..), GraphData(..), Legend(..), Node(..), getLegendData)
import Gargantext.Components.Login.Types (AuthData(..), TreeId)
......@@ -561,7 +562,10 @@ specOld = fold [treespec treeSpec, graphspec $ simpleSpec performAction render']
, div []
[ p [] []
, div [className "col-md-12"]
[ GT.tabsElt {sides}
[ case st.selectedNode of
Just (SelectedNode {label}) ->
GT.tabsElt {query: words label, sides}
Nothing -> p [] []
, p [] []
]
]
......
......@@ -6,37 +6,38 @@ import Data.List (fromFoldable)
import Data.Tuple (Tuple(..))
import Gargantext.Config (TabType(..), TabSubType(..))
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 React (ReactElement, ReactClass, Children, createElement)
import Thermite ( Spec, PerformAction, Render, _performAction, _render
, hideState, noState, cmapProps, simpleSpec, createClass
)
type Props = { sides :: Array GraphSideCorpus }
type Props = { query :: Array String, sides :: Array GraphSideCorpus }
tabsElt :: Props -> ReactElement
tabsElt props = createElement tabsClass props []
-- 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 {})
pureTabs :: Spec {} Props Void
pureTabs = hideState (const {activeTab: 0}) statefulTabs
tab :: forall props state. GraphSideCorpus -> Tuple String (Spec state props Tab.Action)
tab (GraphSideCorpus {corpusId: nodeId, corpusLabel}) =
tab :: forall props state. Array String -> GraphSideCorpus -> Tuple String (Spec state props Tab.Action)
tab query (GraphSideCorpus {corpusId: nodeId, corpusLabel}) =
Tuple corpusLabel $
cmapProps (const {nodeId, chart, tabType: TabCorpus TabDocs, totalRecords: 4736}) $
noState DT.docViewSpec
cmapProps (const {nodeId, query, chart, totalRecords: 4736}) $
noState FT.docViewSpec
where
-- TODO totalRecords: probably need to insert a corpusLoader.
chart = mempty
statefulTabs :: Spec Tab.State Props Tab.Action
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
-- | 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