diff --git a/src/Gargantext/Pages/Annuaire.purs b/src/Gargantext/Pages/Annuaire.purs index 3dbd292fb043597d5fce9421e57af4d528fa76bb..2a0488d3cf089762be93a858a585c460f682ac71 100644 --- a/src/Gargantext/Pages/Annuaire.purs +++ b/src/Gargantext/Pages/Annuaire.purs @@ -15,7 +15,7 @@ import Thermite (Render, Spec import Gargantext.Prelude import Gargantext.Config (toUrl, NodeType(..), TabType(..), End(..)) import Gargantext.Config.REST (get) -import Gargantext.Pages.Annuaire.User.Users.Types.Types (User(..), HyperData(..)) +import Gargantext.Pages.Annuaire.User.Users.Types (User(..), HyperData(..)) import Data.Argonaut (class DecodeJson, decodeJson, (.?)) ------------------------------------------------------------------------------ type State = { info :: Maybe AnnuaireInfo diff --git a/src/Gargantext/Pages/Annuaire/User/Users/Specs.purs b/src/Gargantext/Pages/Annuaire/User/Users/Specs.purs index 4b1678916e28771e347ba2549596a20d8dd2c4c4..42cf1ef2ff5eab99bdf2b03a73f9d901e7c9afd5 100644 --- a/src/Gargantext/Pages/Annuaire/User/Users/Specs.purs +++ b/src/Gargantext/Pages/Annuaire/User/Users/Specs.purs @@ -1,12 +1,20 @@ module Gargantext.Pages.Annuaire.User.Users.Specs (module Gargantext.Pages.Annuaire.User.Users.Specs.Renders, + brevetSpec, + projectSpec, + facets, layoutUser) where -import Thermite (PerformAction, Spec, simpleSpec) +import Data.List (fromFoldable) +import Data.Tuple (Tuple(..)) +import Thermite (Render, PerformAction, Spec, focus, noState, defaultPerformAction, simpleSpec) import Gargantext.Prelude -import Gargantext.Pages.Annuaire.User.Users.Types (Action(..), State) +import Gargantext.Components.Tab as Tab +import Gargantext.Pages.Annuaire.User.Brevets as B +import Gargantext.Pages.Annuaire.User.Users.Specs.Documents as P +import Gargantext.Pages.Annuaire.User.Users.Types (Action(..), State, _tablens, _tabAction) import Gargantext.Pages.Annuaire.User.Users.API (fetchUser) import Gargantext.Pages.Annuaire.User.Users.Specs.Renders (render) @@ -16,3 +24,26 @@ layoutUser = simpleSpec performAction render performAction :: PerformAction State {} Action performAction (FetchUser userId) _ _ = fetchUser userId performAction (TabA _) _ _ = pure unit + +brevetSpec :: Spec State {} Action +brevetSpec = noState B.brevetsSpec + +projets :: Spec {} {} Void +projets = simpleSpec defaultPerformAction render + where + render :: Render {} {} Void + render dispatch _ state _ = + [] + +projectSpec :: Spec State {} Action +projectSpec = noState projets + +publicationSpec :: Spec State {} Action +publicationSpec = noState P.publicationSpec + +facets :: Spec State {} Action +facets = Tab.tabs _tablens _tabAction $ fromFoldable + [ Tuple "Publications (12)" publicationSpec + , Tuple "Brevets (2)" brevetSpec + , Tuple "Projets IMT (5)" projectSpec + ] diff --git a/src/Gargantext/Pages/Annuaire/User/Users/Types.purs b/src/Gargantext/Pages/Annuaire/User/Users/Types.purs index 62c99b264ed25fa5c1b9f96237d792d6f66c7508..f2e20f6099daa3f1b5a4f5064d91b3ec53f98262 100644 --- a/src/Gargantext/Pages/Annuaire/User/Users/Types.purs +++ b/src/Gargantext/Pages/Annuaire/User/Users/Types.purs @@ -1,40 +1,122 @@ -module Gargantext.Pages.Annuaire.User.Users.Types - (module Gargantext.Pages.Annuaire.User.Users.Types.Types, - module Gargantext.Pages.Annuaire.User.Users.Types.Lens, - module Gargantext.Pages.Annuaire.User.Users.Types.States, - brevetSpec, - projectSpec, - facets - ) - where +module Gargantext.Pages.Annuaire.User.Users.Types where import Prelude -import Gargantext.Pages.Annuaire.User.Users.Types.Lens -import Gargantext.Pages.Annuaire.User.Users.Types.Types -import Gargantext.Pages.Annuaire.User.Users.Types.States -import Gargantext.Pages.Annuaire.User.Brevets as B -import Data.List (fromFoldable) -import Data.Tuple (Tuple(..)) -import Gargantext.Components.Tab (tabs) -import Thermite (Render, Spec, focus, noState, defaultPerformAction, simpleSpec) - -brevetSpec :: Spec State {} Action -brevetSpec = noState B.brevetsSpec - -projets :: Spec {} {} Void -projets = simpleSpec defaultPerformAction render - where - render :: Render {} {} Void - render dispatch _ state _ = - [] - -projectSpec :: Spec State {} Action -projectSpec = noState projets - -facets :: Spec State {} Action -facets = tabs _tablens _tabAction $ fromFoldable - [ Tuple "Publications (12)" publicationSpec - , Tuple "Brevets (2)" brevetSpec - , Tuple "Projets IMT (5)" projectSpec - ] +import Data.Argonaut (class DecodeJson, decodeJson, (.?)) +import Data.Either (Either(..)) +import Data.Lens (Lens', Prism', lens, prism) +import Data.Maybe (Maybe(..)) + +import Gargantext.Components.Tab as Tab +import Gargantext.Utils.DecodeMaybe ((.?|)) + +newtype User = + User { id :: Int + , typename :: Maybe Int + , userId :: Int + , parentId :: Int + , name :: String + , date :: Maybe String + , hyperdata :: HyperData + } + +newtype HyperData = + HyperData + { bureau :: Maybe String + , atel :: Maybe String + , fax :: Maybe String + , aprecision :: Maybe String + , service :: Maybe String + , service2 :: Maybe String + , groupe :: Maybe String + , lieu :: Maybe String + , pservice :: Maybe String + , date_modification :: Maybe String + , fonction :: Maybe String + , pfonction :: Maybe String + , url :: Maybe String + , prenom :: Maybe String + , nom :: Maybe String + , idutilentite :: Maybe String + , afonction :: Maybe String + , grprech :: Maybe String + , entite :: Maybe String + , entite2 :: Maybe String + , mail :: Maybe String + } + +instance decodeUserHyperData :: DecodeJson HyperData where + decodeJson json = do + obj <- decodeJson json + bureau <- obj .?| "bureau" + atel <- obj .?| "atel" + fax <- obj .?| "fax" + aprecision <- obj .?| "aprecision" + service <- obj .?| "service" + service2 <- obj .?| "service2" + groupe <- obj .?| "groupe" + lieu <- obj .?| "lieu" + pservice <- obj .?| "pservice" + date_modification <- obj .?| "date_modification" + fonction <- obj .?| "fonction" + pfonction <- obj .?| "pfonction" + url <- obj .?| "url" + prenom <- obj .?| "prenom" + nom <- obj .?| "nom" + idutilentite <- obj .?| "idutilentite" + afonction <- obj .?| "afonction" + grprech <- obj .?| "grprech" + entite <- obj .?| "entite" + entite2 <- obj .?| "entite2" + mail <- obj .?| "mail" + pure $ HyperData { bureau, atel, fax + , aprecision, service + , service2, groupe, lieu + , pservice, date_modification + , fonction, pfonction, url + , prenom, nom, idutilentite + , afonction, grprech, entite + , entite2, mail + } + +instance decodeUser :: DecodeJson User where + decodeJson json = do + obj <- decodeJson json + id <- obj .? "id" + typename <- obj .?| "typename" + userId <- obj .? "userId" + parentId <- obj .? "parentId" + name <- obj .? "name" + date <- obj .?| "date" + hyperdata <- obj .? "hyperdata" + pure $ User { id, typename, userId + , parentId, name, date + , hyperdata + } + +data Action + = TabA Tab.Action + | FetchUser Int + +type State = + { activeTab :: Int + , user :: Maybe User + } + +initialState :: State +initialState = + { activeTab : 0 + , user: Nothing + } + +_user :: Lens' State (Maybe User) +_user = lens (\s -> s.user) (\s ss -> s{user = ss}) + +_tablens :: Lens' State Tab.State +_tablens = lens (\s -> s.activeTab) (\s ss -> s {activeTab = ss}) + +_tabAction :: Prism' Action Tab.Action +_tabAction = prism TabA \ action -> + case action of + TabA laction -> Right laction + _-> Left action diff --git a/src/Gargantext/Pages/Annuaire/User/Users/Types/Lens.purs b/src/Gargantext/Pages/Annuaire/User/Users/Types/Lens.purs deleted file mode 100644 index c8e9c68b98a8ad40d559cd9aae79ad93b2a24cbd..0000000000000000000000000000000000000000 --- a/src/Gargantext/Pages/Annuaire/User/Users/Types/Lens.purs +++ /dev/null @@ -1,26 +0,0 @@ -module Gargantext.Pages.Annuaire.User.Users.Types.Lens where - -import Gargantext.Pages.Annuaire.User.Brevets as B -import Data.Either (Either(..)) -import Data.Lens (Lens', Prism', lens, prism) -import Data.Maybe (Maybe) -import Gargantext.Pages.Annuaire.User.Users.Types.States (Action(..), State) -import Gargantext.Pages.Annuaire.User.Users.Types.Types (User) -import Gargantext.Pages.Annuaire.User.Users.Specs.Documents as P -import Gargantext.Components.Tab as Tab -import Thermite (Spec, noState) - -_user :: Lens' State (Maybe User) -_user = lens (\s -> s.user) (\s ss -> s{user = ss}) - -_tablens :: Lens' State Tab.State -_tablens = lens (\s -> s.activeTab) (\s ss -> s {activeTab = ss}) - -_tabAction :: Prism' Action Tab.Action -_tabAction = prism TabA \ action -> - case action of - TabA laction -> Right laction - _-> Left action - -publicationSpec :: Spec State {} Action -publicationSpec = noState P.publicationSpec diff --git a/src/Gargantext/Pages/Annuaire/User/Users/Types/States.purs b/src/Gargantext/Pages/Annuaire/User/Users/Types/States.purs deleted file mode 100644 index 1f9ba2de3087d7ee8d729225b84ed0c0efc2be5f..0000000000000000000000000000000000000000 --- a/src/Gargantext/Pages/Annuaire/User/Users/Types/States.purs +++ /dev/null @@ -1,21 +0,0 @@ -module Gargantext.Pages.Annuaire.User.Users.Types.States where - -import Data.Maybe (Maybe(..)) -import Gargantext.Pages.Annuaire.User.Users.Types.Types (User) -import Gargantext.Pages.Annuaire.User.Users.Specs.Documents as P -import Gargantext.Components.Tab as Tab - -data Action - = TabA Tab.Action - | FetchUser Int - -type State = - { activeTab :: Int - , user :: Maybe User - } - -initialState :: State -initialState = - { activeTab : 0 - , user: Nothing - } diff --git a/src/Gargantext/Pages/Annuaire/User/Users/Types/Types.purs b/src/Gargantext/Pages/Annuaire/User/Users/Types/Types.purs deleted file mode 100644 index bb19d8a0f0b7109769ac2a9d7631a450eec4a9de..0000000000000000000000000000000000000000 --- a/src/Gargantext/Pages/Annuaire/User/Users/Types/Types.purs +++ /dev/null @@ -1,91 +0,0 @@ -module Gargantext.Pages.Annuaire.User.Users.Types.Types where - -import Prelude - -import Data.Argonaut (class DecodeJson, decodeJson, (.?)) -import Data.Maybe (Maybe) -import Gargantext.Utils.DecodeMaybe ((.?|)) - -newtype User = - User { id :: Int - , typename :: Maybe Int - , userId :: Int - , parentId :: Int - , name :: String - , date :: Maybe String - , hyperdata :: HyperData - } - -newtype HyperData = - HyperData - { bureau :: Maybe String - , atel :: Maybe String - , fax :: Maybe String - , aprecision :: Maybe String - , service :: Maybe String - , service2 :: Maybe String - , groupe :: Maybe String - , lieu :: Maybe String - , pservice :: Maybe String - , date_modification :: Maybe String - , fonction :: Maybe String - , pfonction :: Maybe String - , url :: Maybe String - , prenom :: Maybe String - , nom :: Maybe String - , idutilentite :: Maybe String - , afonction :: Maybe String - , grprech :: Maybe String - , entite :: Maybe String - , entite2 :: Maybe String - , mail :: Maybe String - } - -instance decodeUserHyperData :: DecodeJson HyperData where - decodeJson json = do - obj <- decodeJson json - bureau <- obj .?| "bureau" - atel <- obj .?| "atel" - fax <- obj .?| "fax" - aprecision <- obj .?| "aprecision" - service <- obj .?| "service" - service2 <- obj .?| "service2" - groupe <- obj .?| "groupe" - lieu <- obj .?| "lieu" - pservice <- obj .?| "pservice" - date_modification <- obj .?| "date_modification" - fonction <- obj .?| "fonction" - pfonction <- obj .?| "pfonction" - url <- obj .?| "url" - prenom <- obj .?| "prenom" - nom <- obj .?| "nom" - idutilentite <- obj .?| "idutilentite" - afonction <- obj .?| "afonction" - grprech <- obj .?| "grprech" - entite <- obj .?| "entite" - entite2 <- obj .?| "entite2" - mail <- obj .?| "mail" - pure $ HyperData { bureau, atel, fax - , aprecision, service - , service2, groupe, lieu - , pservice, date_modification - , fonction, pfonction, url - , prenom, nom, idutilentite - , afonction, grprech, entite - , entite2, mail - } - -instance decodeUser :: DecodeJson User where - decodeJson json = do - obj <- decodeJson json - id <- obj .? "id" - typename <- obj .?| "typename" - userId <- obj .? "userId" - parentId <- obj .? "parentId" - name <- obj .? "name" - date <- obj .?| "date" - hyperdata <- obj .? "hyperdata" - pure $ User { id, typename, userId - , parentId, name, date - , hyperdata - }