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

[API] Graph Sidebar : search Data | Community ok

parent e51a41bb
......@@ -40,7 +40,7 @@ type Props =
, frontends :: Frontends
, listId :: Int
, nodeId :: Int
, query :: TextQuery
, query :: SearchQuery
, session :: Session
, totalRecords :: Int
)
......@@ -171,12 +171,12 @@ docViewGraphCpt = R.hooksComponent "FacetsDocViewGraph" cpt
type PagePath = { nodeId :: Int
, listId :: Int
, query :: TextQuery
, query :: SearchQuery
, params :: T.Params
, session :: Session
}
initialPagePath :: {session :: Session, nodeId :: Int, listId :: Int, query :: TextQuery} -> PagePath
initialPagePath :: {session :: Session, nodeId :: Int, listId :: Int, query :: SearchQuery} -> PagePath
initialPagePath {session, nodeId, listId, query} = {session, nodeId, listId, query, params: T.initialParams}
loadPage :: PagePath -> Aff (Array DocumentsView)
......@@ -193,7 +193,8 @@ loadPage {session, nodeId, listId, query, params: {limit, offset, orderBy, searc
p = Search { listId, offset, limit, orderBy: convOrderBy <$> orderBy } (Just nodeId)
--SearchResult {result} <- post session p $ SearchQuery {query: concat query, expected:searchType}
SearchResult {result} <- post session p $ SearchQuery {query: concat query, expected:SearchContact}
SearchResult {result} <- post session p query
-- $ SearchQuery {query: concat query, expected: SearchDoc}
pure $ case result of
SearchResultDoc {docs} -> docs2view docs
SearchResultContact {contacts} -> contacts2view contacts
......
......@@ -3,7 +3,7 @@ module Gargantext.Components.GraphExplorer.Sidebar
where
import Control.Parallel (parTraverse)
import Data.Array (head, last)
import Data.Array (head, last, concat)
import Data.Int (fromString)
import Data.Map as Map
import Data.Maybe (Maybe(..), fromJust)
......@@ -14,6 +14,7 @@ import Data.Tuple.Nested ((/\))
import Effect (Effect)
import Effect.Aff (Aff, launchAff_)
import Effect.Class (liftEffect)
import Gargantext.Components.Search (SearchType(..), SearchQuery(..))
import Gargantext.Components.GraphExplorer.Types as GET
import Gargantext.Components.GraphExplorer.Types (SidePanelState(..), SideTab(..))
import Gargantext.Components.GraphExplorer.Legend as Legend
......@@ -102,7 +103,8 @@ sideTab (Opened SideTabData) props =
]
, RH.div { className: "col-md-12", id: "query" }
[ query props.frontends
[ query SearchDoc
props.frontends
props.metaData
props.session
nodesMap
......@@ -151,7 +153,8 @@ sideTab (Opened SideTabData) props =
sideTab (Opened SideTabCommunity) props =
RH.div { className: "col-md-12", id: "query" }
[ query props.frontends
[ query SearchContact
props.frontends
props.metaData
props.session
(SigmaxT.nodesGraphMap props.graph)
......@@ -233,22 +236,26 @@ deleteNode termList session (GET.MetaData metaData) node = NTC.putNgramsPatches
patch_list :: NTC.Replace TermList
patch_list = NTC.Replace { new: termList, old: MapTerm }
query :: Frontends
query :: SearchType
-> Frontends
-> GET.MetaData
-> Session
-> SigmaxT.NodesMap
-> R.State SigmaxT.NodeIds
-> R.Element
query _ _ _ _ (selectedNodeIds /\ _) | Set.isEmpty selectedNodeIds = RH.div {} []
query frontends (GET.MetaData metaData) session nodesMap (selectedNodeIds /\ _) =
query _ _ _ _ _ (selectedNodeIds /\ _) | Set.isEmpty selectedNodeIds = RH.div {} []
query searchType frontends (GET.MetaData metaData) session nodesMap (selectedNodeIds /\ _) =
query' (head metaData.corpusId)
where
query' Nothing = RH.div {} []
query' (Just corpusId) = CGT.tabs { frontends
, session
, query: toQuery <$> Set.toUnfoldable selectedNodeIds
, sides: [side corpusId]
}
query' (Just corpusId) =
CGT.tabs { frontends
, session
, query: SearchQuery { query : concat $ toQuery <$> Set.toUnfoldable selectedNodeIds
, expected: searchType
}
, sides: [side corpusId]
}
toQuery id = case Map.lookup id nodesMap of
Nothing -> []
......
......@@ -6,7 +6,7 @@ import Data.Tuple (Tuple(..), fst)
import Reactix as R
import Gargantext.Components.GraphExplorer.Types (GraphSideCorpus(..))
import Gargantext.Components.FacetsTable (docView)
import Gargantext.Components.Search (TextQuery)
import Gargantext.Components.Search (SearchQuery)
import Gargantext.Components.Table as T
import Gargantext.Components.Tab as Tab
import Gargantext.Ends (Frontends)
......@@ -14,7 +14,7 @@ import Gargantext.Sessions (Session)
type Props =
( frontends :: Frontends
, query :: TextQuery
, query :: SearchQuery
, session :: Session
, sides :: Array GraphSideCorpus
)
......@@ -32,7 +32,7 @@ tabsCpt = R.hooksComponent "G.P.Corpus.Graph.Tabs.tabs" cpt
where
tabs' = fromFoldable $ tab frontends session query <$> sides
tab :: Frontends -> Session -> TextQuery -> GraphSideCorpus -> Tuple String R.Element
tab :: Frontends -> Session -> SearchQuery -> GraphSideCorpus -> Tuple String R.Element
tab frontends session query (GraphSideCorpus {corpusId: nodeId, corpusLabel, listId}) =
Tuple corpusLabel (docView dvProps)
where
......
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