Commit 7213662d authored by James Laver's avatar James Laver

Take 2 of docstable urls

parent 68dd9873
......@@ -60,12 +60,12 @@ appCpt = R.hooksComponent "G.C.App.app" cpt where
Login -> login { sessions, backends, visible: showLogin }
Folder sid _ -> withSession sid $ \_ -> forested (folder {})
Corpus sid nodeId -> withSession sid $ \_ -> forested $ corpusLayout { nodeId }
Texts sid nodeId -> withSession sid $ \session -> forested $ textsLayout { nodeId, session, route }
Texts sid nodeId -> withSession sid $ \session -> forested $ textsLayout { nodeId, session, frontends }
Lists sid nodeId -> withSession sid $ \session -> forested $ listsLayout { nodeId, session }
Dashboard sid _nodeId -> withSession sid $ \session -> forested $ dashboardLayout {}
Annuaire sid nodeId -> withSession sid $ \session -> forested $ annuaireLayout { nodeId, session }
UserPage sid nodeId -> withSession sid $ \session -> forested $ userLayout { route, nodeId, session }
ContactPage sid nodeId -> withSession sid $ \session -> forested $ userLayout { route, nodeId, session }
UserPage sid nodeId -> withSession sid $ \session -> forested $ userLayout { frontends, nodeId, session }
ContactPage sid nodeId -> withSession sid $ \session -> forested $ userLayout { frontends, nodeId, session }
CorpusDocument sid corpusId listId nodeId ->
withSession sid $ \session -> forested $ documentLayout { nodeId, listId, session, corpusId: Just corpusId }
Document sid listId nodeId ->
......
......@@ -26,11 +26,10 @@ import Reactix.DOM.HTML as H
------------------------------------------------------------------------
import Gargantext.Components.Search.Types (Category(..), CategoryQuery(..), favCategory, trashCategory, decodeCategory, putCategories)
import Gargantext.Components.Table as T
import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Components.Loader (loader)
import Gargantext.Components.Search.Types (Category(..), CategoryQuery(..), favCategory, trashCategory, decodeCategory, putCategories)
import Gargantext.Components.Table as T
import Gargantext.Ends (url)
import Gargantext.Ends (Frontends, url)
import Gargantext.Utils.Reactix as R2
import Gargantext.Routes as Routes
import Gargantext.Routes (AppRoute, SessionRoute(NodeAPI))
......@@ -49,7 +48,7 @@ type LayoutProps =
, listId :: Int
, corpusId :: Maybe Int
, showSearch :: Boolean
, route :: R.State AppRoute
, frontends :: Frontends
, session :: Session )
-- ^ tabType is not ideal here since it is too much entangled with tabs and
-- ngramtable. Let's see how this evolves. )
......@@ -62,7 +61,7 @@ type PageLayoutProps =
, corpusId :: Maybe Int
, query :: Query
, session :: Session
, route :: R.State AppRoute
, frontends :: Frontends
, params :: R.State T.Params )
type LocalCategories = Map Int Category
......@@ -148,14 +147,14 @@ docView props = R.createElement docViewCpt props []
docViewCpt :: R.Component Props
docViewCpt = R.hooksComponent "G.C.DocsTable.docView" cpt where
cpt { query, params
, layout: { route, session, nodeId, tabType, listId
, layout: { frontends, session, nodeId, tabType, listId
, corpusId, totalRecords, chart, showSearch } } _ = do
pure $ H.div {className: "container1"}
[ H.div {className: "row"}
[ chart
, if showSearch then searchBar query else H.div {} []
, H.div {className: "col-md-12"}
[ pageLayout {route, session, nodeId, totalRecords, tabType, listId, corpusId, query: fst query, params} ] ] ]
[ pageLayout {frontends, session, nodeId, totalRecords, tabType, listId, corpusId, query: fst query, params} ] ] ]
-- onClickTrashAll nodeId _ = do
-- launchAff $ deleteAllDocuments p.session nodeId
......@@ -265,7 +264,7 @@ pageLayout props = R.createElement pageLayoutCpt props []
pageLayoutCpt :: R.Memo PageLayoutProps
pageLayoutCpt = R.memo' $ R.staticComponent "G.C.DocsTable.pageLayout" cpt where
cpt props@{route, session, nodeId, listId, corpusId, tabType, query, params} _ =
cpt props@{frontends, session, nodeId, listId, corpusId, tabType, query, params} _ =
loader path (loadPage session) paint
where
path = {nodeId, listId, corpusId, tabType, query, params: fst params}
......@@ -281,7 +280,7 @@ page params layout documents = R.createElement pageCpt {params, layout, document
pageCpt :: R.Memo PageProps
pageCpt = R.memo' $ R.hooksComponent "G.C.DocsTable.pageCpt" cpt where
cpt { layout: {route, session, nodeId, corpusId, listId, totalRecords}, documents, params } _ = do
cpt { layout: {frontends, session, nodeId, corpusId, listId, totalRecords}, documents, params } _ = do
localCategories <- R.useState' (mempty :: LocalCategories)
pure $ T.table
{ rows: rows localCategories
......@@ -307,7 +306,7 @@ pageCpt = R.memo' $ R.hooksComponent "G.C.DocsTable.pageCpt" cpt where
-- TODO show date: Year-Month-Day only
, H.div { style } [ R2.showText r.date ]
, H.div { style }
[ H.a { on: {click: \_ -> (snd route) (const $ corpusDocument r._id) } } [ H.text r.title ] ]
[ H.a { href: url frontends $ corpusDocument r._id } [ H.text r.title ] ]
, H.div { style } [ H.text r.source ]
]
, delete: true }
......
......@@ -13,12 +13,13 @@ import Data.String (joinWith)
import Effect.Aff (Aff)
import Reactix as R
import Reactix.DOM.HTML as H
import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Components.Loader (loader)
import Gargantext.Components.Nodes.Annuaire.User.Contacts.Types
( Contact(..), ContactData, ContactTouch(..), ContactWhere(..)
, ContactWho(..), HyperData(..), HyperdataContact(..) )
import Gargantext.Components.Nodes.Annuaire.User.Contacts.Tabs as Tabs
import Gargantext.Routes (AppRoute, SessionRoute(..))
import Gargantext.Routes
import Gargantext.Ends (Frontends)
import Gargantext.Sessions (Session, get)
import Gargantext.Types (NodeType(..))
......@@ -122,20 +123,20 @@ infoRender (Tuple title content) =
[ H.span { className: "badge badge-default badge-pill"} [ H.text title ]
, H.span {} [H.text content] ]
type LayoutProps = ( route :: R.State AppRoute, nodeId :: Int, session :: Session )
type LayoutProps = ( frontends :: Frontends, nodeId :: Int, session :: Session )
userLayout :: Record LayoutProps -> R.Element
userLayout props = R.createElement userLayoutCpt props []
userLayoutCpt :: R.Component LayoutProps
userLayoutCpt = R.hooksComponent "G.P.Annuaire.UserLayout" cpt
userLayoutCpt = R.staticComponent "G.C.Nodes.Annuaire.User.Contacts.userLayout" cpt
where
cpt {route, nodeId, session} _ =
useLoader nodeId (getContact session) $
cpt {frontends, nodeId, session} _ =
loader nodeId (getContact session) $
\contactData@{contactNode: Contact {name, hyperdata}} ->
H.ul { className: "col-md-12 list-group" }
[ display (fromMaybe "no name" name) (contactInfos hyperdata)
, Tabs.tabs {route, nodeId, contactData, session} ]
, Tabs.tabs {frontends, nodeId, contactData, session} ]
-- | toUrl to get data
getContact :: Session -> Int -> Aff ContactData
......
......@@ -12,6 +12,7 @@ import Gargantext.Components.DocsTable as DT
import Gargantext.Components.NgramsTable as NT
import Gargantext.Components.Tab as Tab
import Gargantext.Components.Nodes.Annuaire.User.Contacts.Types (ContactData)
import Gargantext.Ends (Frontends)
import Gargantext.Routes (AppRoute)
import Gargantext.Sessions (Session)
import Gargantext.Types (TabType(..), TabSubType(..), CTabNgramType(..), PTabNgramType(..))
......@@ -40,7 +41,7 @@ modeTabType' Communication = CTabAuthors
type TabsProps =
( nodeId :: Int
, contactData :: ContactData
, route :: R.State AppRoute
, frontends :: Frontends
, session :: Session )
tabs :: Record TabsProps -> R.Element
......@@ -49,7 +50,7 @@ tabs props = R.createElement tabsCpt props []
tabsCpt :: R.Component TabsProps
tabsCpt = R.hooksComponent "G.P.Annuaire.User.Contacts.Tabs.tabs" cpt
where
cpt {route, nodeId, contactData: {defaultListId}, session} _ = do
cpt {frontends, nodeId, contactData: {defaultListId}, session} _ = do
active <- R.useState' 0
pure $
Tab.tabs { tabs: tabs', selected: fst active }
......@@ -68,7 +69,7 @@ tabsCpt = R.hooksComponent "G.P.Annuaire.User.Contacts.Tabs.tabs" cpt
chart = mempty
totalRecords = 4736 -- TODO
docs = DT.docViewLayout
{ route, session, nodeId, chart, totalRecords
{ frontends, session, nodeId, chart, totalRecords
, tabType: TabPairing TabDocs
, listId: defaultListId
, corpusId: Nothing
......
......@@ -16,11 +16,12 @@ import Gargantext.Components.Nodes.Corpus (CorpusData, CorpusInfo(..), loadCorpu
import Gargantext.Components.Nodes.Corpus.Chart.Histo (histo)
import Gargantext.Components.Tab as Tab
import Gargantext.Components.Table as Table
import Gargantext.Ends (Frontends)
import Gargantext.Routes (AppRoute)
import Gargantext.Sessions (Session)
import Gargantext.Types (CTabNgramType(..), TabSubType(..), TabType(..))
type Props = ( route :: R.State AppRoute, session :: Session, nodeId :: Int )
type Props = ( frontends :: Frontends, session :: Session, nodeId :: Int )
textsLayout :: Record Props -> R.Element
textsLayout props = R.createElement textsLayoutCpt props []
......@@ -28,7 +29,7 @@ textsLayout props = R.createElement textsLayoutCpt props []
------------------------------------------------------------------------
textsLayoutCpt :: R.Component Props
textsLayoutCpt = R.hooksComponent "G.C.Nodes.Texts.textsLayout" cpt where
cpt {session,nodeId,route} _ = do
cpt {session,nodeId,frontends} _ = do
pure $ loader {session, nodeId} loadCorpus paint
where
paint corpusData@{corpusId, corpusNode, defaultListId} =
......@@ -36,7 +37,7 @@ textsLayoutCpt = R.hooksComponent "G.C.Nodes.Texts.textsLayout" cpt where
where
NodePoly { name, date, hyperdata: CorpusInfo corpus } = corpusNode
{desc, query, authors: user} = corpus
tabs' = tabs {session, corpusId, corpusData, route}
tabs' = tabs {session, corpusId, corpusData, frontends}
title = "Corpus " <> name
headerProps = { title, desc, query, date, user }
......@@ -53,7 +54,7 @@ modeTabType :: Mode -> CTabNgramType
modeTabType MoreLikeFav = CTabAuthors -- TODO
modeTabType MoreLikeTrash = CTabSources -- TODO
type TabsProps = ( route :: R.State AppRoute, session :: Session, corpusId :: Int, corpusData :: CorpusData )
type TabsProps = ( frontends :: Frontends, session :: Session, corpusId :: Int, corpusData :: CorpusData )
tabs :: Record TabsProps -> R.Element
tabs props = R.createElement tabsCpt props []
......@@ -61,13 +62,13 @@ tabs props = R.createElement tabsCpt props []
tabsCpt :: R.Component TabsProps
tabsCpt = R.hooksComponent "G.C.Nodes.Texts.tabs" cpt
where
cpt {route, session, corpusId, corpusData} _ = do
cpt {frontends, session, corpusId, corpusData} _ = do
(selected /\ setSelected) <- R.useState' 0
pure $ Tab.tabs { tabs: tabs', selected }
where
tabs' = [ "Documents" /\ docs, "Trash" /\ trash
, "More like fav" /\ moreLikeFav, "More like trash" /\ moreLikeTrash ]
docView' tabType = docView { route, session, corpusId, corpusData, tabType }
docView' tabType = docView { frontends, session, corpusId, corpusData, tabType }
docs = R.fragment [ docsHisto, docView' TabDocs ]
docsHisto = histo { path, session }
where path = { corpusId, tabType: TabCorpus TabDocs }
......@@ -75,7 +76,12 @@ tabsCpt = R.hooksComponent "G.C.Nodes.Texts.tabs" cpt
moreLikeTrash = docView' TabMoreLikeTrash
trash = docView' TabTrash
type DocViewProps a = ( route :: R.State AppRoute, session :: Session, corpusId :: Int, corpusData :: CorpusData, tabType :: TabSubType a )
type DocViewProps a =
( frontends :: Frontends
, session :: Session
, corpusId :: Int
, corpusData :: CorpusData
, tabType :: TabSubType a )
docView :: forall a. Record (DocViewProps a) -> R.Element
docView props = R.createElement docViewCpt props []
......@@ -83,7 +89,7 @@ docView props = R.createElement docViewCpt props []
docViewCpt :: forall a. R.Component (DocViewProps a)
docViewCpt = R.hooksComponent "G.C.Nodes.Texts.docView" cpt
where
cpt {route, session, corpusId, corpusData: {defaultListId}, tabType} _children = do
cpt {frontends, session, corpusId, corpusData: {defaultListId}, tabType} _children = do
pure $ DT.docViewLayout $ params tabType
where
params :: forall b. TabSubType b -> Record DT.LayoutProps
......@@ -96,7 +102,7 @@ docViewCpt = R.hooksComponent "G.C.Nodes.Texts.docView" cpt
, listId: defaultListId
, corpusId: Just corpusId
, showSearch: true
, route, session }
, frontends, session }
params TabMoreLikeFav =
{ nodeId: corpusId
-- ^ TODO merge nodeId and corpusId in DT
......@@ -106,7 +112,7 @@ docViewCpt = R.hooksComponent "G.C.Nodes.Texts.docView" cpt
, listId: defaultListId
, corpusId: Just corpusId
, showSearch: false
, route, session }
, frontends, session }
params TabMoreLikeTrash =
{ nodeId: corpusId
-- ^ TODO merge nodeId and corpusId in DT
......@@ -116,7 +122,7 @@ docViewCpt = R.hooksComponent "G.C.Nodes.Texts.docView" cpt
, listId: defaultListId
, corpusId: Just corpusId
, showSearch: false
, route, session }
, frontends, session }
params TabTrash =
{ nodeId: corpusId
-- ^ TODO merge nodeId and corpusId in DT
......@@ -126,7 +132,7 @@ docViewCpt = R.hooksComponent "G.C.Nodes.Texts.docView" cpt
, listId: defaultListId
, corpusId: Nothing
, showSearch: true
, route, session }
, frontends, session }
-- DUMMY
params _ =
{ nodeId: corpusId
......@@ -137,4 +143,4 @@ docViewCpt = R.hooksComponent "G.C.Nodes.Texts.docView" cpt
, listId: defaultListId
, corpusId: Nothing
, showSearch: true
, route, session }
, frontends, session }
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