Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
purescript-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Grégoire Locqueville
purescript-gargantext
Commits
ba24537c
Commit
ba24537c
authored
Nov 04, 2021
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[graphql] user query/mutate works now
parent
7b91b0fd
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
72 additions
and
58 deletions
+72
-58
GraphQL.purs
src/Gargantext/Components/GraphQL.purs
+1
-1
User.purs
src/Gargantext/Components/GraphQL/User.purs
+33
-32
User.purs
src/Gargantext/Components/Nodes/Annuaire/User.purs
+15
-14
Contact.purs
src/Gargantext/Components/Nodes/Annuaire/User/Contact.purs
+23
-11
No files found.
src/Gargantext/Components/GraphQL.purs
View file @
ba24537c
...
...
@@ -62,4 +62,4 @@ type Schema
}
type Mutation
= { update_user_info :: UserInfoM
} ==> UserInfo
= { update_user_info :: UserInfoM
==> Int }
src/Gargantext/Components/GraphQL/User.purs
View file @
ba24537c
...
...
@@ -5,6 +5,7 @@ import Gargantext.Prelude
import Data.Array as A
import Data.Lens (Lens', lens)
import Data.Maybe (Maybe(..), fromMaybe, maybe)
import GraphQL.Client.Args (NotNull(..))
import Type.Proxy (Proxy(..))
...
...
@@ -25,38 +26,38 @@ type UserInfo
, ui_cwTouchPhone :: Maybe String
, ui_cwTouchMail :: Maybe String }
type UserInfoM
= { ui_id :: Int
, ui_username ::
Maybe
String
, ui_email ::
Maybe
String
, ui_title ::
Maybe
String
, ui_source ::
Maybe
String
, ui_cwFirstName ::
Maybe
String
, ui_cwLastName ::
Maybe
String
, ui_cwOrganization ::
Maybe
(Array String)
, ui_cwLabTeamDepts ::
Maybe
(Array String)
, ui_cwOffice ::
Maybe
String
, ui_cwCity ::
Maybe
String
, ui_cwCountry ::
Maybe
String
, ui_cwRole ::
Maybe
String
, ui_cwTouchPhone ::
Maybe
String
, ui_cwTouchMail ::
Maybe
String }
defaultUserInfoM :: UserInfoM
defaultUserInfoM =
{ ui_id:
0
, ui_username: Nothing
, ui_email: Nothing
, ui_title: Nothing
, ui_source: Nothing
, ui_cwFirstName: Nothing
, ui_cwLastName: Nothing
, ui_cwOrganization: Nothing
, ui_cwLabTeamDepts: Nothing
, ui_cwOffice: Nothing
, ui_cwCity: Nothing
, ui_cwCountry: Nothing
, ui_cwRole: Nothing
, ui_cwTouchPhone: Nothing
, ui_cwTouchMail: Nothing }
= { ui_id ::
NotNull
Int
, ui_username :: String
, ui_email :: String
, ui_title :: String
, ui_source :: String
, ui_cwFirstName :: String
, ui_cwLastName :: String
, ui_cwOrganization :: (Array String)
, ui_cwLabTeamDepts :: (Array String)
, ui_cwOffice :: String
, ui_cwCity :: String
, ui_cwCountry :: String
, ui_cwRole :: String
, ui_cwTouchPhone :: String
, ui_cwTouchMail :: String }
--
defaultUserInfoM :: UserInfoM
--
defaultUserInfoM =
-- { ui_id: NotNull
0
--
, ui_username: Nothing
--
, ui_email: Nothing
--
, ui_title: Nothing
--
, ui_source: Nothing
--
, ui_cwFirstName: Nothing
--
, ui_cwLastName: Nothing
--
, ui_cwOrganization: Nothing
--
, ui_cwLabTeamDepts: Nothing
--
, ui_cwOffice: Nothing
--
, ui_cwCity: Nothing
--
, ui_cwCountry: Nothing
--
, ui_cwRole: Nothing
--
, ui_cwTouchPhone: Nothing
--
, ui_cwTouchMail: Nothing }
_ui_cwFirstName :: Lens' UserInfo String
_ui_cwFirstName = lens getter setter
...
...
src/Gargantext/Components/Nodes/Annuaire/User.purs
View file @
ba24537c
...
...
@@ -5,7 +5,6 @@ module Gargantext.Components.Nodes.Annuaire.User
where
import Gargantext.Components.GraphQL.User
import Gargantext.Prelude
import Data.Either (Either)
...
...
@@ -14,6 +13,7 @@ import Effect (Effect)
import Effect.Aff (Aff, launchAff_)
import Effect.Class (liftEffect)
import Gargantext.Components.App.Data (Boxes)
import Gargantext.Components.GraphQL.User (UserInfo)
import Gargantext.Components.Nodes.Annuaire.Tabs as Tabs
import Gargantext.Components.Nodes.Annuaire.User.Contact (getUserInfoWithReload, saveUserInfo, contactInfos)
import Gargantext.Components.Nodes.Annuaire.User.Contacts.Types (Contact(..), ContactData, ContactTouch(..), ContactWhere(..), ContactWho(..), HyperdataContact(..), HyperdataUser(..), _city, _country, _firstName, _labTeamDeptsJoinComma, _lastName, _mail, _office, _organizationJoinComma, _ouFirst, _phone, _role, _shared, _touch, _who, defaultContactTouch, defaultContactWhere, defaultContactWho, defaultHyperdataContact, defaultHyperdataUser)
...
...
@@ -131,18 +131,19 @@ userLayoutWithKeyCpt = here.component "userLayoutWithKey" cpt where
handleRESTError errors res $ \_ ->
liftEffect $ T2.reload reload
saveContactHyperdata :: Session -> Int -> HyperdataUser -> Aff (Either RESTError Int)
saveContactHyperdata session id = put session (Routes.NodeAPI Node (Just id) "")
--
saveContactHyperdata :: Session -> Int -> HyperdataUser -> Aff (Either RESTError Int)
--
saveContactHyperdata session id = put session (Routes.NodeAPI Node (Just id) "")
-- | toUrl to get data XXX
getContact :: Session -> Int -> Aff (Either RESTError ContactData)
getContact session id = do
eContactNode <- get session $ Routes.NodeAPI Node (Just 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 -> { contactNode, defaultListId: 424242 }) <$> eContactNode
--getContact :: Session -> Int -> Aff (Either RESTError ContactData)
--getContact session id = do
-- eContactNode <- get session $ Routes.NodeAPI Node (Just 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 -> { contactNode, defaultListId: 424242 }) <$> eContactNode
--
src/Gargantext/Components/Nodes/Annuaire/User/Contact.purs
View file @
ba24537c
...
...
@@ -21,7 +21,6 @@ import Effect.Aff (Aff, launchAff_)
import Effect.Class (liftEffect)
import Gargantext.Components.App.Data (Boxes)
import Gargantext.Components.GraphQL (getClient, queryGql)
import Gargantext.Components.GraphQL.User (defaultUserInfoM)
import Gargantext.Components.InputWithEnter (inputWithEnter)
import Gargantext.Components.Nodes.Annuaire.User.Contacts.Tabs as Tabs
import Gargantext.Components.Nodes.Annuaire.User.Contacts.Types (Contact'(..), ContactData', ContactTouch(..), ContactWhere(..), ContactWho(..), HyperdataContact(..), HyperdataUser(..), _city, _country, _firstName, _labTeamDeptsJoinComma, _lastName, _mail, _office, _organizationJoinComma, _ouFirst, _phone, _role, _shared, _touch, _who, defaultContactTouch, defaultContactWhere, defaultContactWho, defaultHyperdataContact, defaultHyperdataUser)
...
...
@@ -34,7 +33,7 @@ import Gargantext.Sessions (Session, get, put, sessionId)
import Gargantext.Types (NodeType(..))
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Toestand as T2
import GraphQL.Client.Args (type (==>),
(=>>), onlyArgs
)
import GraphQL.Client.Args (type (==>),
IgnoreArg(..), OrArg(..), onlyArgs, (=>>)
)
import GraphQL.Client.Query (mutationOpts, mutation)
import Reactix as R
import Reactix.DOM.HTML as H
...
...
@@ -225,15 +224,28 @@ saveContactHyperdata session id = put session (Routes.NodeAPI Node (Just id) "")
saveUserInfo :: Session -> Int -> UserInfo -> Aff (Either RESTError Int)
saveUserInfo session id ui = do
-- TODO GraphQL
pure $ Left $ CustomError "TODO implement graphql for saveUserInfo"
-- client <- liftEffect $ getClient
-- res <- mutation
-- client
-- "update user_info"
-- { update_user_info: userInfo =>> { ui_id: unit } }
-- pure $ Right 0
-- where
-- userInfo = defaultUserInfoM { ui_id = id }
-- pure $ Left $ CustomError "TODO implement graphql for saveUserInfo"
client <- liftEffect $ getClient
res <- mutationOpts
(\m -> m)
client
"update user_info"
{ update_user_info: onlyArgs { ui_id: id
, ui_cwFirstName: ga ui.ui_cwFirstName
, ui_cwLastName: ga ui.ui_cwLastName
, ui_cwOrganization: ui.ui_cwOrganization
, ui_cwLabTeamDepts: ui.ui_cwLabTeamDepts
, ui_cwOffice: ga ui.ui_cwOffice
, ui_cwCity: ga ui.ui_cwCity
, ui_cwCountry: ga ui.ui_cwCountry
, ui_cwRole: ga ui.ui_cwRole
, ui_cwTouchPhone: ga ui.ui_cwTouchPhone
, ui_cwTouchMail: ga ui.ui_cwTouchMail } }
liftEffect $ here.log2 "[saveUserInfo] res" res
pure $ Right 0
where
ga Nothing = ArgL IgnoreArg
ga (Just val) = ArgR val
type AnnuaireLayoutProps = ( annuaireId :: Int, session :: Session | ReloadProps )
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment