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