Commit c3e4b105 authored by Sudhir Kumar's avatar Sudhir Kumar

partial user profile

parent 113500f8
...@@ -25,7 +25,7 @@ endConfig = endConfig' V10 ...@@ -25,7 +25,7 @@ endConfig = endConfig' V10
endConfig' :: ApiVersion -> EndConfig endConfig' :: ApiVersion -> EndConfig
endConfig' v = { front : frontRelative endConfig' v = { front : frontRelative
, back : backLocal v } , back : backDev v }
------------------------------------------------------------------------ ------------------------------------------------------------------------
frontRelative :: Config frontRelative :: Config
......
...@@ -5,7 +5,7 @@ import Gargantext.Pages.Annuaire.User.Contacts.Types ...@@ -5,7 +5,7 @@ import Gargantext.Pages.Annuaire.User.Contacts.Types
import Data.List (List, zipWith, catMaybes, toUnfoldable) import Data.List (List, zipWith, catMaybes, toUnfoldable)
import Data.Map (Map, empty, keys, values, lookup) import Data.Map (Map, empty, keys, values, lookup)
import Data.Maybe (Maybe(..), maybe) import Data.Maybe (Maybe(..), fromMaybe)
import Data.Set (toUnfoldable) as S import Data.Set (toUnfoldable) as S
import Data.Tuple (Tuple(..), uncurry) import Data.Tuple (Tuple(..), uncurry)
import Data.Unfoldable (class Unfoldable) import Data.Unfoldable (class Unfoldable)
...@@ -15,14 +15,15 @@ import React (ReactElement) ...@@ -15,14 +15,15 @@ import React (ReactElement)
import React.DOM (div, h3, img, li, span, text, ul, text) import React.DOM (div, h3, img, li, span, text, ul, text)
import React.DOM.Props (_id, className, src) import React.DOM.Props (_id, className, src)
import Thermite (Render) import Thermite (Render)
import Data.Newtype (unwrap)
import Data.String
render :: Render State {} Action render :: Render State {} Action
render dispatch _ state _ = render dispatch _ state _ =
[ [
div [className "col-md-12"] div [className "col-md-12"]
$ case state.contact of $ case state.contact of
(Just (Contact contact)) -> display (maybe "no name" identity contact.name) (contactInfos contact.hyperdata) (Just (Contact contact)) -> display (fromMaybe "no name" contact.name) (contactInfos contact.hyperdata)
Nothing -> display "Contact not found" [] Nothing -> display "Contact not found" []
] ]
...@@ -41,7 +42,7 @@ display title elems = ...@@ -41,7 +42,7 @@ display title elems =
--[ ] --[ ]
[ img [src "/images/Gargantextuel-212x300.jpg"] ] [ img [src "/images/Gargantextuel-212x300.jpg"] ]
, div [className "col-md-1"] [] , div [className "col-md-1"] []
, div [className "col-mdData.Unfoldable-8"] elems , div [className "col-md-8"] elems
] ]
] ]
] ]
...@@ -56,10 +57,36 @@ mapMyMap f m = toUnfoldable ...@@ -56,10 +57,36 @@ mapMyMap f m = toUnfoldable
infixl 4 mapMyMap as <.~$> infixl 4 mapMyMap as <.~$>
getFirstName obj = fromMaybe "no title" $ getFirstName' <$> obj
getFirstName' = fromMaybe "no first name" <<< _.firstName <<< unwrap
getLastName obj = fromMaybe "no title" $ getLastName' <$> obj
getLastName' = fromMaybe "no last name" <<< _.lastName <<< unwrap
getRole obj = joinWith ", " $ getRole' <$> (fromMaybe [] obj)
getRole' = fromMaybe "no role" <<< _.role <<< unwrap
-- getTouch :: Maybe (Array ContactWhere) -> Array ContactTouch
-- getTouch obj = (_.touch <<< unwrap) <$>
-- where
-- ary = fromMaybe [] obj
-- getPhone :: Maybe (Array ContactWhere) -> String
-- getPhone obj = fromMaybe "" $ getPhone' <$> (getTouch obj)
-- getPhone' :: ContactTouch -> String
-- getPhone' = fromMaybe "no phone" <<< _.phone <<< unwrap
-- getMail obj = fromMaybe "" $ getMail' <$> (getTouch obj)
-- getMail' = fromMaybe "no mail" <<< _.mail <<< unwrap
contactInfos :: HyperdataContact -> Array ReactElement contactInfos :: HyperdataContact -> Array ReactElement
contactInfos (HyperdataContact {who:who,ou:ou}) = contactInfos (HyperdataContact {who:who, ou:ou}) =
[ ul [className "list-group"] (infoRender (Tuple "Last Name" $ maybe "no title" (\(ContactWho {lastName:lastName}) -> maybe "no lastName" identity lastName) who)) [ ul [className "list-group"] (infoRender (Tuple "Last Name" $ getLastName who))
, ul [className "list-group"] (infoRender (Tuple "First name" $ maybe "no title" (\(ContactWho {firstName:firstName}) -> maybe "no firstName" identity firstName) who)) , ul [className "list-group"] (infoRender (Tuple "First name" $ getFirstName who))
, ul [className "list-group"] (infoRender (Tuple "Role" $ getRole ou))
-- , ul [className "list-group"] (infoRender (Tuple "Phone" $ getPhone "Phone" ou))
-- , ul [className "list-group"] (infoRender (Tuple "Mail" $ getMail "Mail"))
] ]
......
...@@ -13,8 +13,9 @@ import React.DOM (div) ...@@ -13,8 +13,9 @@ import React.DOM (div)
import Gargantext.Components.Tab as Tab import Gargantext.Components.Tab as Tab
import Gargantext.Utils.DecodeMaybe ((.?|)) import Gargantext.Utils.DecodeMaybe ((.?|))
import Data.Newtype
data Contact = Contact { newtype Contact = Contact {
id :: Int id :: Int
, typename :: Maybe Int , typename :: Maybe Int
, userId :: Maybe Int , userId :: Maybe Int
...@@ -24,7 +25,9 @@ data Contact = Contact { ...@@ -24,7 +25,9 @@ data Contact = Contact {
, hyperdata :: HyperdataContact , hyperdata :: HyperdataContact
} }
data ContactWho = derive instance newtypeContact :: Newtype Contact _
newtype ContactWho =
ContactWho { idWho :: Maybe String ContactWho { idWho :: Maybe String
, firstName :: Maybe String , firstName :: Maybe String
, lastName :: Maybe String , lastName :: Maybe String
...@@ -32,6 +35,8 @@ data ContactWho = ...@@ -32,6 +35,8 @@ data ContactWho =
, freetags :: Maybe (Array String) , freetags :: Maybe (Array String)
} }
derive instance newtypeContactWho :: Newtype ContactWho _
instance decodeContactWho :: DecodeJson ContactWho instance decodeContactWho :: DecodeJson ContactWho
where where
decodeJson json = do decodeJson json = do
...@@ -43,7 +48,7 @@ instance decodeContactWho :: DecodeJson ContactWho ...@@ -43,7 +48,7 @@ instance decodeContactWho :: DecodeJson ContactWho
freetags <- obj .?? "freetags" freetags <- obj .?? "freetags"
pure $ ContactWho {idWho, firstName, lastName, keywords, freetags} pure $ ContactWho {idWho, firstName, lastName, keywords, freetags}
data ContactWhere = newtype ContactWhere =
ContactWhere { organization :: Maybe (Array String) ContactWhere { organization :: Maybe (Array String)
, labTeamDepts :: Maybe (Array String) , labTeamDepts :: Maybe (Array String)
...@@ -58,7 +63,7 @@ data ContactWhere = ...@@ -58,7 +63,7 @@ data ContactWhere =
, entry :: Maybe String , entry :: Maybe String
, exit :: Maybe String , exit :: Maybe String
} }
derive instance newtypeContactWhere :: Newtype ContactWhere _
instance decodeContactWhere :: DecodeJson ContactWhere instance decodeContactWhere :: DecodeJson ContactWhere
where where
...@@ -75,11 +80,12 @@ instance decodeContactWhere :: DecodeJson ContactWhere ...@@ -75,11 +80,12 @@ instance decodeContactWhere :: DecodeJson ContactWhere
exit <- obj .?? "exit" exit <- obj .?? "exit"
pure $ ContactWhere {organization, labTeamDepts, role, office, country, city, touch, entry, exit} pure $ ContactWhere {organization, labTeamDepts, role, office, country, city, touch, entry, exit}
data ContactTouch = newtype ContactTouch =
ContactTouch { mail :: Maybe String ContactTouch { mail :: Maybe String
, phone :: Maybe String , phone :: Maybe String
, url :: Maybe String , url :: Maybe String
} }
derive instance newtypeContactTouch :: Newtype ContactTouch _
instance decodeContactTouch :: DecodeJson ContactTouch instance decodeContactTouch :: DecodeJson ContactTouch
where where
...@@ -91,7 +97,7 @@ instance decodeContactTouch :: DecodeJson ContactTouch ...@@ -91,7 +97,7 @@ instance decodeContactTouch :: DecodeJson ContactTouch
pure $ ContactTouch {mail, phone, url} pure $ ContactTouch {mail, phone, url}
data HyperdataContact = newtype HyperdataContact =
HyperdataContact { bdd :: Maybe String HyperdataContact { bdd :: Maybe String
, who :: Maybe ContactWho , who :: Maybe ContactWho
, ou :: Maybe (Array ContactWhere) , ou :: Maybe (Array ContactWhere)
...@@ -101,6 +107,7 @@ data HyperdataContact = ...@@ -101,6 +107,7 @@ data HyperdataContact =
, uniqId :: Maybe String , uniqId :: Maybe String
, uniqIdBdd :: Maybe String , uniqIdBdd :: Maybe String
} }
derive instance newtypeHyperdataContact :: Newtype HyperdataContact _
instance decodeHyperdataContact :: DecodeJson HyperdataContact instance decodeHyperdataContact :: DecodeJson HyperdataContact
where where
...@@ -114,10 +121,11 @@ instance decodeHyperdataContact :: DecodeJson HyperdataContact ...@@ -114,10 +121,11 @@ instance decodeHyperdataContact :: DecodeJson HyperdataContact
lastValidation <- obj .?? "lastValidation" lastValidation <- obj .?? "lastValidation"
uniqId <- obj .?? "uniqId" uniqId <- obj .?? "uniqId"
uniqIdBdd <- obj .?? "uniqIdBdd" uniqIdBdd <- obj .?? "uniqIdBdd"
pure $ HyperdataContact {bdd, who, ou, title, source, lastValidation, uniqId, uniqIdBdd} pure $ HyperdataContact {bdd, who, ou, title, source, lastValidation, uniqId, uniqIdBdd}
data HyperData c s = newtype HyperData c s =
HyperData HyperData
{ common :: c { common :: c
, shared :: s , shared :: s
......
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