diff --git a/src/Gargantext/Components/FacetsTable.purs b/src/Gargantext/Components/FacetsTable.purs index d9bef3d912fad956d501e2f9ec33d66a3b1fcd22..d482eaa01d7d67f7c96d5a06dde1da55bc939430 100644 --- a/src/Gargantext/Components/FacetsTable.purs +++ b/src/Gargantext/Components/FacetsTable.purs @@ -20,11 +20,12 @@ import Effect.Aff (Aff, launchAff_) import Reactix as R import Reactix.DOM.HTML as H ------------------------------------------------------------------------ -import Gargantext.Ends (url) +import Gargantext.Ends (url, Frontends) import Gargantext.Hooks.Loader (useLoader) import Gargantext.Components.Search.Types (Category(..), CategoryQuery(..), favCategory, decodeCategory, putCategories) import Gargantext.Components.Table as T -import Gargantext.Routes (SessionRoute(Search,NodeAPI)) +import Gargantext.Routes (SessionRoute(Search, NodeAPI), AppRoute(CorpusDocument)) +import Gargantext.Routes as Routes import Gargantext.Sessions (Session, sessionId, post, deleteWithBody) import Gargantext.Types (NodeType(..), OrderBy(..), NodePath(..)) import Gargantext.Utils (toggleSet) @@ -55,13 +56,14 @@ instance decodeSearchResults :: DecodeJson SearchResults where pure $ SearchResults {results} type Props = - ( nodeId :: Int + ( chart :: R.Element + , container :: Record T.TableContainerProps -> R.Element + , frontends :: Frontends , listId :: Int + , nodeId :: Int , query :: TextQuery - , totalRecords :: Int - , chart :: R.Element - , container :: Record T.TableContainerProps -> R.Element , session :: Session + , totalRecords :: Int ) -- | Tracks the ids of documents to delete and that have been deleted @@ -165,14 +167,14 @@ docView props = R.createElement docViewCpt props [] docViewCpt :: R.Component Props docViewCpt = R.hooksComponent "G.C.FacetsTable.DocView" cpt where - cpt {session, nodeId, listId, query, totalRecords, chart, container} _ = do + cpt {frontends, session, nodeId, listId, query, totalRecords, chart, container} _ = do deletions <- R.useState' initialDeletions path <- R.useState' $ initialPagePath {nodeId, listId, query, session} pure $ H.div { className: "container1" } [ H.div { className: "row" } [ chart , H.div { className: "col-md-12" } - [ pageLayout { deletions, totalRecords, container, session, path } ] + [ pageLayout { deletions, frontends, totalRecords, container, session, path } ] , H.div { className: "col-md-12" } [ H.button { style: buttonStyle, on: { click: trashClick deletions } } [ H.i { className: "glyphitem glyphicon glyphicon-trash" @@ -208,7 +210,7 @@ docViewGraph props = R.createElement docViewCpt props [] docViewGraphCpt :: R.Component Props docViewGraphCpt = R.hooksComponent "FacetsDocViewGraph" cpt where - cpt {session, nodeId, listId, query, totalRecords, chart, container} _ = do + cpt {frontends, session, nodeId, listId, query, totalRecords, chart, container} _ = do deletions <- R.useState' initialDeletions let buttonStyle = { backgroundColor: "peru", padding : "9px" , color : "white", border : "white", float: "right"} @@ -222,7 +224,7 @@ docViewGraphCpt = R.hooksComponent "FacetsDocViewGraph" cpt [ H.div { className: "row" } [ chart , H.div { className: "col-md-12" } - [ pageLayout { totalRecords, deletions, container, session, path } + [ pageLayout { frontends, totalRecords, deletions, container, session, path } , H.button { style: buttonStyle, on: { click: performClick } } [ H.i { className: "glyphitem glyphicon glyphicon-trash" , style: { marginRight : "9px" } } [] @@ -253,7 +255,8 @@ loadPage {session, nodeId, listId, query, params: {limit, offset, orderBy}} = do convOrderBy _ = DateAsc -- TODO type PageLayoutProps = - ( totalRecords :: Int + ( frontends :: Frontends + , totalRecords :: Int , deletions :: R.State Deletions , container :: Record T.TableContainerProps -> R.Element , session :: Session @@ -269,9 +272,9 @@ pageLayout props = R.createElement pageLayoutCpt props [] pageLayoutCpt :: R.Component PageLayoutProps pageLayoutCpt = R.hooksComponent "G.C.FacetsTable.PageLayout" cpt where - cpt {totalRecords, deletions, container, session, path} _ = do + cpt {frontends, totalRecords, deletions, container, session, path} _ = do useLoader (fst path) loadPage $ \documents -> - page {totalRecords, deletions, container, session, path, documents} + page {frontends, totalRecords, deletions, container, session, path, documents} page :: Record PageProps -> R.Element page props = R.createElement pageCpt props [] @@ -279,7 +282,7 @@ page props = R.createElement pageCpt props [] pageCpt :: R.Component PageProps pageCpt = R.staticComponent "G.C.FacetsTable.Page" cpt where - cpt {totalRecords, container, deletions, documents, session, path: path@({nodeId, listId, query} /\ setPath)} _ = do + cpt {frontends, totalRecords, container, deletions, documents, session, path: path@({nodeId, listId, query} /\ setPath)} _ = do T.table { rows, container, colNames, totalRecords, params } where setParams f = setPath $ \p@{params: ps} -> p {params = f ps} @@ -294,14 +297,16 @@ pageCpt = R.staticComponent "G.C.FacetsTable.Page" cpt | id > 1 = H.a { href, target: "blank" } [ H.text label ] where href = url session $ NodePath (sessionId session) NodeContact (Just id) | otherwise = H.text label + documentUrl id = + url frontends $ Routes.CorpusDocument (sessionId session) nodeId listId id comma = H.span {} [ H.text ", " ] rows = row <$> filter (not <<< isDeleted) documents row dv@(DocumentsView {id,score,title,source,date, authors,pairs,delete,category}) = { row: - [ H.a { className: gi category, on: {click: markClick} } [] + [ H.div {} [ H.a { className: gi category, on: {click: markClick} } [] ] -- TODO show date: Year-Month-Day only , maybeStricken delete [ H.text date ] - , maybeStricken delete [ H.text title ] + , maybeStricken delete [ H.a {target: "_blank", href: documentUrl id} [ H.text title ] ] , maybeStricken delete [ H.text source ] , maybeStricken delete [ H.text authors ] -- , maybeStricken $ intercalate [comma] (pairUrl <$> pairs) diff --git a/src/Gargantext/Components/GraphExplorer.purs b/src/Gargantext/Components/GraphExplorer.purs index 7f668d1d51e849ffbd71ed3987bfa66f0bb8463e..38113e151b9ca24b70a0d03452783d9f61b3b56c 100644 --- a/src/Gargantext/Components/GraphExplorer.purs +++ b/src/Gargantext/Components/GraphExplorer.purs @@ -97,7 +97,7 @@ explorerCpt = R.hooksComponent "G.C.GraphExplorer.explorer" cpt , row [ tree {mCurrentRoute, treeId} controls showLogin , RH.div { ref: graphRef, id: "graph-view", className: "col-md-12", style: {height: "95%"} } [] -- graph container , mGraph graphRef controls.sigmaRef {graphId, graph, selectedNodeIds} - , mSidebar graph mMetaData {session, selectedNodeIds, showSidePanel: fst controls.showSidePanel} + , mSidebar graph mMetaData {frontends, session, selectedNodeIds, showSidePanel: fst controls.showSidePanel} ] , row [ ] @@ -131,14 +131,16 @@ explorerCpt = R.hooksComponent "G.C.GraphExplorer.explorer" cpt mSidebar :: Maybe Graph.Graph -> Maybe GET.MetaData - -> { showSidePanel :: GET.SidePanelState + -> { frontends :: Frontends + , showSidePanel :: GET.SidePanelState , selectedNodeIds :: R.State SigmaxTypes.SelectedNodeIds , session :: Session } -> R.Element mSidebar Nothing _ _ = RH.div {} [] mSidebar _ Nothing _ = RH.div {} [] - mSidebar (Just graph) (Just metaData) {session, selectedNodeIds, showSidePanel} = - Sidebar.sidebar { graph + mSidebar (Just graph) (Just metaData) {frontends, session, selectedNodeIds, showSidePanel} = + Sidebar.sidebar { frontends + , graph , metaData , session , selectedNodeIds diff --git a/src/Gargantext/Components/GraphExplorer/Sidebar.purs b/src/Gargantext/Components/GraphExplorer/Sidebar.purs index d1a967c5f992b57e52e171b393aacdcfd9a136a1..cb637434716106f1797007c507740da0610da3b8 100644 --- a/src/Gargantext/Components/GraphExplorer/Sidebar.purs +++ b/src/Gargantext/Components/GraphExplorer/Sidebar.purs @@ -15,11 +15,13 @@ import Gargantext.Components.RandomText (words) import Gargantext.Components.Nodes.Corpus.Graph.Tabs as GT import Gargantext.Components.Graph as Graph import Gargantext.Components.GraphExplorer.Types as GET +import Gargantext.Ends (Frontends) import Gargantext.Hooks.Sigmax.Types as SigmaxTypes import Gargantext.Sessions (Session) type Props = - ( graph :: Graph.Graph + ( frontends :: Frontends + , graph :: Graph.Graph , metaData :: GET.MetaData , selectedNodeIds :: R.State SigmaxTypes.SelectedNodeIds , session :: Session @@ -66,7 +68,7 @@ sidebarCpt = R.hooksComponent "Sidebar" cpt ] , RH.div { className: "col-md-12", id: "query" } [ - query props.metaData props.session nodesMap props.selectedNodeIds + query props.frontends props.metaData props.session nodesMap props.selectedNodeIds ] ] ] @@ -91,13 +93,13 @@ sidebarCpt = R.hooksComponent "Sidebar" cpt , "complex systems" , "wireless communications" ] - query _ _ _ (selectedNodeIds /\ _) | Set.isEmpty selectedNodeIds = RH.div {} [] - query (GET.MetaData metaData) session nodesMap (selectedNodeIds /\ _) = + query _ _ _ _ (selectedNodeIds /\ _) | Set.isEmpty selectedNodeIds = RH.div {} [] + query frontends (GET.MetaData metaData) session nodesMap (selectedNodeIds /\ _) = query' (head metaData.corpusId) where query' Nothing = RH.div {} [] query' (Just corpusId) = - GT.tabs {session, query: q <$> Set.toUnfoldable selectedNodeIds, sides: [side corpusId]} + GT.tabs {frontends, session, query: q <$> Set.toUnfoldable selectedNodeIds, sides: [side corpusId]} q id = case Map.lookup id nodesMap of Nothing -> [] Just n -> words n.label diff --git a/src/Gargantext/Components/Nodes/Corpus/Graph/Tabs.purs b/src/Gargantext/Components/Nodes/Corpus/Graph/Tabs.purs index 3670fc90b028e0918b5588b84fc113f29e501f44..4ed3aeb949e246539c9af108589468c24b42c338 100644 --- a/src/Gargantext/Components/Nodes/Corpus/Graph/Tabs.purs +++ b/src/Gargantext/Components/Nodes/Corpus/Graph/Tabs.purs @@ -8,9 +8,15 @@ import Gargantext.Components.GraphExplorer.Types (GraphSideCorpus(..)) import Gargantext.Components.FacetsTable (TextQuery, docView) import Gargantext.Components.Table as T import Gargantext.Components.Tab as Tab +import Gargantext.Ends (Frontends) import Gargantext.Sessions (Session) -type Props = ( session :: Session, query :: TextQuery, sides :: Array GraphSideCorpus ) +type Props = ( + frontends :: Frontends + , query :: TextQuery + , session :: Session + , sides :: Array GraphSideCorpus + ) tabs :: Record Props -> R.Element tabs props = R.createElement tabsCpt props [] @@ -19,17 +25,17 @@ tabs props = R.createElement tabsCpt props [] tabsCpt :: R.Component Props tabsCpt = R.hooksComponent "G.P.Corpus.Graph.Tabs.tabs" cpt where - cpt {session, query, sides} _ = do + cpt {frontends, query, session, sides} _ = do active <- R.useState' 0 pure $ Tab.tabs {tabs: tabs', selected: fst active} where - tabs' = fromFoldable $ tab session query <$> sides + tabs' = fromFoldable $ tab frontends session query <$> sides -tab :: Session -> TextQuery -> GraphSideCorpus -> Tuple String R.Element -tab session query (GraphSideCorpus {corpusId: nodeId, corpusLabel, listId}) = +tab :: Frontends -> Session -> TextQuery -> GraphSideCorpus -> Tuple String R.Element +tab frontends session query (GraphSideCorpus {corpusId: nodeId, corpusLabel, listId}) = Tuple corpusLabel (docView dvProps) where - dvProps = {session, nodeId, listId, query, chart, totalRecords: 4736, container} + dvProps = {frontends, session, nodeId, listId, query, chart, totalRecords: 4736, container} -- TODO totalRecords: probably need to insert a corpusLoader. chart = mempty container = T.graphContainer {title: corpusLabel}