Commit 1f522286 authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[Annuaire] add annuaire user page

parent 6fe73e39
...@@ -17,7 +17,7 @@ import Gargantext.Components.Login (login) ...@@ -17,7 +17,7 @@ import Gargantext.Components.Login (login)
import Gargantext.Config (defaultFrontends, defaultBackends) import Gargantext.Config (defaultFrontends, defaultBackends)
import Gargantext.Components.Folder (folder) import Gargantext.Components.Folder (folder)
import Gargantext.Components.Nodes.Annuaire (annuaireLayout) import Gargantext.Components.Nodes.Annuaire (annuaireLayout)
import Gargantext.Components.Nodes.Annuaire.User.Contacts (userLayout) import Gargantext.Components.Nodes.Annuaire.User.Contacts (annuaireUserLayout, userLayout)
import Gargantext.Components.Nodes.Corpus (corpusLayout) import Gargantext.Components.Nodes.Corpus (corpusLayout)
import Gargantext.Components.Nodes.Corpus.Document (documentLayout) import Gargantext.Components.Nodes.Corpus.Document (documentLayout)
import Gargantext.Components.Nodes.Corpus.Dashboard (dashboardLayout) import Gargantext.Components.Nodes.Corpus.Dashboard (dashboardLayout)
...@@ -65,7 +65,7 @@ appCpt = R.hooksComponent "G.C.App.app" cpt where ...@@ -65,7 +65,7 @@ appCpt = R.hooksComponent "G.C.App.app" cpt where
Dashboard sid _nodeId -> withSession sid $ \session -> forested $ dashboardLayout {} Dashboard sid _nodeId -> withSession sid $ \session -> forested $ dashboardLayout {}
Annuaire sid nodeId -> withSession sid $ \session -> forested $ annuaireLayout { frontends, nodeId, session } Annuaire sid nodeId -> withSession sid $ \session -> forested $ annuaireLayout { frontends, nodeId, session }
UserPage sid nodeId -> withSession sid $ \session -> forested $ userLayout { frontends, nodeId, session } UserPage sid nodeId -> withSession sid $ \session -> forested $ userLayout { frontends, nodeId, session }
ContactPage sid _aId nodeId -> withSession sid $ \session -> forested $ userLayout { frontends, nodeId, session } ContactPage sid aId nodeId -> withSession sid $ \session -> forested $ annuaireUserLayout { annuaireId: aId, frontends, nodeId, session }
CorpusDocument sid corpusId listId nodeId -> CorpusDocument sid corpusId listId nodeId ->
withSession sid $ \session -> forested $ documentLayout { nodeId, listId, session, corpusId: Just corpusId } withSession sid $ \session -> forested $ documentLayout { nodeId, listId, session, corpusId: Just corpusId }
Document sid listId nodeId -> Document sid listId nodeId ->
......
module Gargantext.Components.Nodes.Annuaire.User.Contacts module Gargantext.Components.Nodes.Annuaire.User.Contacts
( module Gargantext.Components.Nodes.Annuaire.User.Contacts.Types ( module Gargantext.Components.Nodes.Annuaire.User.Contacts.Types
, annuaireUserLayout
, userLayout ) , userLayout )
where where
import Prelude (bind, pure, ($), (<<<), (<>), (<$>)) import Prelude (bind, pure, ($), (<<<), (<>), (<$>), show, discard)
import Data.Array (head) import Data.Array (head)
import Data.Maybe (Maybe(..), fromMaybe, maybe) import Data.Maybe (Maybe(..), fromMaybe, maybe)
import Data.Tuple (Tuple(..)) import Data.Tuple (Tuple(..))
import Data.Tuple.Nested ((/\)) import Data.Tuple.Nested ((/\))
import Data.Newtype (unwrap) import Data.Newtype (unwrap)
import Data.String (joinWith) import Data.String (joinWith)
import DOM.Simple.Console (log2)
import Effect.Aff (Aff) import Effect.Aff (Aff)
import Reactix as R import Reactix as R
import Reactix.DOM.HTML as H import Reactix.DOM.HTML as H
...@@ -18,6 +20,7 @@ import Gargantext.Components.Nodes.Annuaire.User.Contacts.Types ...@@ -18,6 +20,7 @@ import Gargantext.Components.Nodes.Annuaire.User.Contacts.Types
( Contact(..), ContactData, ContactTouch(..), ContactWhere(..) ( Contact(..), ContactData, ContactTouch(..), ContactWhere(..)
, ContactWho(..), HyperData(..), HyperdataContact(..) ) , ContactWho(..), HyperData(..), HyperdataContact(..) )
import Gargantext.Components.Nodes.Annuaire.User.Contacts.Tabs as Tabs import Gargantext.Components.Nodes.Annuaire.User.Contacts.Tabs as Tabs
import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Routes import Gargantext.Routes
import Gargantext.Ends (Frontends) import Gargantext.Ends (Frontends)
import Gargantext.Sessions (Session, get) import Gargantext.Sessions (Session, get)
...@@ -151,3 +154,37 @@ getContact session id = do ...@@ -151,3 +154,37 @@ getContact session id = do
-- throwError $ error "Missing default list" -- throwError $ error "Missing default list"
pure {contactNode, defaultListId: 424242} pure {contactNode, defaultListId: 424242}
type AnnuaireLayoutProps =
( annuaireId :: Int
| LayoutProps )
annuaireUserLayout :: Record AnnuaireLayoutProps -> R.Element
annuaireUserLayout props = R.createElement annuaireUserLayoutCpt props []
annuaireUserLayoutCpt :: R.Component AnnuaireLayoutProps
annuaireUserLayoutCpt = R.hooksComponent "G.C.Nodes.Annuaire.User.Contacts.annuaireUserLayout" cpt
where
cpt {annuaireId, frontends, nodeId, session} _ = do
R.useEffect' $ do
log2 "[annuaireUserLayoutCpt] annuaireId" annuaireId
log2 "[annuaireUserLayoutCpt] nodeId" nodeId
useLoader nodeId (getAnnuaireContact session annuaireId) $
\contactData@{contactNode: Contact {name, hyperdata}} ->
H.ul { className: "col-md-12 list-group" }
[ display (fromMaybe "no name" name) (contactInfos hyperdata)
, Tabs.tabs {frontends, nodeId, contactData, session} ]
getAnnuaireContact :: Session -> Int -> Int -> Aff ContactData
getAnnuaireContact session annuaireId id = do
contactNode <- get session $ NodeAPI Annuaire (Just annuaireId) $ "/contact" <> (show id)
-- TODO: we need a default list for the pairings
--defaultListIds <- get $ toUrl endConfigStateful Back (Children NodeList 0 1 Nothing) $ Just id
--case (head defaultListIds :: Maybe (NodePoly HyperdataList)) of
-- Just (NodePoly { id: defaultListId }) ->
-- pure {contactNode, defaultListId}
-- Nothing ->
-- throwError $ error "Missing default list"
pure {contactNode, defaultListId: 424242}
...@@ -21,7 +21,7 @@ router = oneOf ...@@ -21,7 +21,7 @@ router = oneOf
, PGraphExplorer <$> (route "graph" *> sid) <*> int , PGraphExplorer <$> (route "graph" *> sid) <*> int
, Texts <$> (route "texts" *> sid) <*> int , Texts <$> (route "texts" *> sid) <*> int
, Lists <$> (route "lists" *> sid) <*> int , Lists <$> (route "lists" *> sid) <*> int
, ContactPage <$> (route "annuaire" *> sid) <*> int , ContactPage <$> (route "annuaire" *> sid) <*> int
<*> (lit "contact" *> int) <*> (lit "contact" *> int)
, Annuaire <$> (route "annuaire" *> sid) <*> int , Annuaire <$> (route "annuaire" *> sid) <*> int
, UserPage <$> (route "user" *> sid) <*> int , UserPage <$> (route "user" *> sid) <*> int
......
...@@ -17,7 +17,7 @@ data AppRoute ...@@ -17,7 +17,7 @@ data AppRoute
| Lists SessionId Int | Lists SessionId Int
| Annuaire SessionId Int | Annuaire SessionId Int
| UserPage SessionId Int | UserPage SessionId Int
| ContactPage SessionId AnnuaireId ContactId | ContactPage SessionId Int Int
type AnnuaireId = Int type AnnuaireId = Int
type ContactId = Int type ContactId = Int
...@@ -47,7 +47,7 @@ instance showAppRoute :: Show AppRoute where ...@@ -47,7 +47,7 @@ instance showAppRoute :: Show AppRoute where
show (Lists s i) = "lists" <> show i <> " (" <> show s <> ")" show (Lists s i) = "lists" <> show i <> " (" <> show s <> ")"
show (Annuaire s i) = "Annuaire" <> show i <> " (" <> show s <> ")" show (Annuaire s i) = "Annuaire" <> show i <> " (" <> show s <> ")"
show (UserPage s i) = "User" <> show i <> " (" <> show s <> ")" show (UserPage s i) = "User" <> show i <> " (" <> show s <> ")"
show (ContactPage s _a i) = "Contact" <> show i <> " (" <> show s <> ")" show (ContactPage s a i) = "Contact" <> show a <> "::" <> show i <> " (" <> show s <> ")"
appPath :: AppRoute -> String appPath :: AppRoute -> String
appPath Home = "" appPath Home = ""
......
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