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
142
Issues
142
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
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
gargantext
purescript-gargantext
Commits
260a2fd1
Commit
260a2fd1
authored
Oct 18, 2021
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[graphql] some user work
parent
a554c2bd
Pipeline
#1984
failed with stage
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
89 additions
and
54 deletions
+89
-54
GraphQL.purs
src/Gargantext/Components/GraphQL.purs
+22
-38
User.purs
src/Gargantext/Components/GraphQL/User.purs
+28
-0
User.purs
src/Gargantext/Components/Nodes/Annuaire/User.purs
+39
-13
Home.purs
src/Gargantext/Components/Nodes/Home.purs
+0
-3
No files found.
src/Gargantext/Components/GraphQL.purs
View file @
260a2fd1
module Gargantext.Components.GraphQL where
import Gargantext.Prelude
import Affjax.RequestBody (RequestBody(..))
import Data.Argonaut.Decode (class DecodeJson)
import Data.
Maybe (Maybe(..), maybe)
import
Effect (Effect
)
import Data.
Array as A
import
Data.Maybe (Maybe(..)
)
import Effect.Aff (Aff, launchAff_)
import Effect.Class (liftEffect)
import Gargantext.Components.GraphQL.User
import Gargantext.Prelude
import Gargantext.Utils.Reactix as R2
import GraphQL.Client.Args (type (==>), (=>>))
import GraphQL.Client.Query (query_)
import GraphQL.Client.Types (class GqlQuery)
import GraphQL.Client.BaseClients.Urql
import GraphQL.Client.Query (query, query_)
import GraphQL.Client.Types (class GqlQuery, Client)
import Reactix as R
import Reactix.DOM.HTML as H
import Toestand as T
...
...
@@ -32,14 +32,17 @@ graphQLTestCpt = here.component "graphQLTest" cpt where
user' <- T.useLive T.unequal userBox
R.useEffect' do
launchAff_ $ do
{ user } <-
{ user
s
} <-
queryGql "get user"
{ user: { user_id: 1 } =>> { userLight_id
, userLight_username
, userLight_password
, userLight_email } }
liftEffect $ here.log2 "[graphQLTest] user" user
liftEffect $ T.write_ (Just user) userBox
{ users: { user_id: 1 } =>> { userLight_id
, userLight_username
, userLight_password
, userLight_email } }
liftEffect $ do
here.log2 "[graphQLTest] users" users
case A.head users of
Nothing -> here.log2 "[graphQLTest] user not found with id" 1
Just u -> T.write_ (Just u) userBox
pure $ R2.row
--[ H.div { className: "col-12 d-flex justify-content-center" }
...
...
@@ -62,31 +65,12 @@ queryGql ::
GqlQuery Schema query returns =>
DecodeJson returns =>
String -> query -> Aff returns
queryGql = query_ "http://localhost:8008/gql" (Proxy :: Proxy Schema)
queryGql name q = do
client <- liftEffect $ createClient { headers: [], url: "http://localhost:8008/gql" }
query (client :: Client UrqlClient Schema _ _) name q
--query_ "http://localhost:8008/gql" (Proxy :: Proxy Schema)
-- Schema
type Schema
= { user
:: { user_id :: Int } ==>
User
= { user
s :: { user_id :: Int } ==> Array
User
}
type User
= { userLight_id :: Int
, userLight_username :: String
, userLight_password :: String
, userLight_email :: String
}
showUser { userLight_id
, userLight_username
, userLight_password
, userLight_email } = "[" <> show userLight_id <> "] " <> userLight_username <> " :: " <> userLight_email
showMUser u = maybe "" showUser u
-- Symbols
userLight_id :: Proxy "userLight_id"
userLight_id = Proxy
userLight_username :: Proxy "userLight_username"
userLight_username = Proxy
userLight_password :: Proxy "userLight_password"
userLight_password = Proxy
userLight_email :: Proxy "userLight_email"
userLight_email = Proxy
src/Gargantext/Components/GraphQL/User.purs
0 → 100644
View file @
260a2fd1
module Gargantext.Components.GraphQL.User where
import Data.Maybe (Maybe(..), maybe)
import Gargantext.Prelude
import Type.Proxy (Proxy(..))
type User
= { userLight_id :: Int
, userLight_username :: String
, userLight_password :: String
, userLight_email :: String
}
showUser { userLight_id
, userLight_username
, userLight_password
, userLight_email } = "[" <> show userLight_id <> "] " <> userLight_username <> " :: " <> userLight_email
showMUser u = maybe "" showUser u
-- Symbols
userLight_id :: Proxy "userLight_id"
userLight_id = Proxy
userLight_username :: Proxy "userLight_username"
userLight_username = Proxy
userLight_password :: Proxy "userLight_password"
userLight_password = Proxy
userLight_email :: Proxy "userLight_email"
userLight_email = Proxy
src/Gargantext/Components/Nodes/Annuaire/User.purs
View file @
260a2fd1
...
...
@@ -6,18 +6,21 @@ module Gargantext.Components.Nodes.Annuaire.User
import Gargantext.Prelude
import Data.Either (Either)
import Data.Array as A
import Data.Either (Either(..))
import Data.Lens as L
import Data.Maybe (Maybe(..), fromMaybe)
import Effect (Effect)
import Effect.Aff (Aff, launchAff_)
import Effect.Class (liftEffect)
import Gargantext.Components.App.Data (Boxes)
import Gargantext.Components.GraphQL (queryGql)
import Gargantext.Components.GraphQL.User
import Gargantext.Components.InputWithEnter (inputWithEnter)
import Gargantext.Components.Nodes.Annuaire.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)
import Gargantext.Components.Nodes.Lists.Types as LT
import Gargantext.Config.REST (RESTError, logRESTError)
import Gargantext.Config.REST (RESTError
(..)
, logRESTError)
import Gargantext.Ends (Frontends)
import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Routes as Routes
...
...
@@ -25,6 +28,9 @@ import Gargantext.Sessions (WithSession, WithSessionContext, Session, get, put,
import Gargantext.Types (NodeType(..))
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Toestand as T2
import GraphQL.Client.Args (type (==>), (=>>))
import GraphQL.Client.Query (query_)
import GraphQL.Client.Types (class GqlQuery)
import Reactix as R
import Reactix.DOM.HTML as H
import Record as Record
...
...
@@ -102,16 +108,16 @@ contactInfoItemCpt = here.component "contactInfoItem" cpt
let value = (L.view cLens hyperdata) :: String
valueRef <- R.useRef value
pure $ H.div { className: "form-group row" }
[
H.span { className: "col-sm-2 col-form-label" } [ H.text label ]
, item isEditing' isEditing valueRef
]
pure $ H.div { className: "form-group row" }
[
H.span { className: "col-sm-2 col-form-label" } [ H.text label ]
, item isEditing' isEditing valueRef
]
where
cLens = L.cloneLens lens
item false isEditing valueRef =
H.div { className: "input-group col-sm-6" }
[
H.input { className: "form-control"
H.div { className: "input-group col-sm-6" }
[
H.input { className: "form-control"
, defaultValue: placeholder'
, disabled: 1
, type: "text" }
...
...
@@ -124,8 +130,8 @@ contactInfoItemCpt = here.component "contactInfoItem" cpt
placeholder' = R.readRef valueRef
onClick _ = T.write_ true isEditing
item true isEditing valueRef =
H.div { className: "input-group col-sm-6" }
[
inputWithEnter {
H.div { className: "input-group col-sm-6" }
[
inputWithEnter {
autoFocus: true
, className: "form-control"
, defaultValue: R.readRef valueRef
...
...
@@ -136,8 +142,8 @@ contactInfoItemCpt = here.component "contactInfoItem" cpt
, type: "text"
}
, H.div { className: "btn input-group-append"
, on: { click: onClick } }
[
H.div { className: "input-group-text fa fa-floppy-o" } []
, on: { click: onClick } }
[
H.div { className: "input-group-text fa fa-floppy-o" } []
]
]
where
...
...
@@ -232,7 +238,27 @@ getContact session id = do
getUserWithReload :: { nodeId :: Int
, reload :: T2.Reload
, session :: Session} -> Aff (Either RESTError ContactData)
getUserWithReload {nodeId, session} = getContact session nodeId
getUserWithReload {nodeId, session} = getUser session nodeId -- getContact session nodeId
getUser :: Session -> Int -> Aff (Either RESTError ContactData)
getUser session id = do
{ users } <- queryGql "get user"
{ users: { user_id: id } =>> { userLight_id
, userLight_username
, userLight_password
, userLight_email } }
liftEffect $ here.log2 "[getUser] users" users
pure $ case A.head users of
Nothing -> Left (CustomError $ "user with id " <> show id <> " not found")
Just u -> Right $ { contactNode: Contact
{ id: u.userLight_id
, date: Nothing
, hyperdata: HyperdataUser { shared: Nothing }
, name: Just u.userLight_username
, parentId: Nothing
, typename: Nothing
, userId: Just u.userLight_id }
, defaultListId: 424242 }
saveContactHyperdata :: Session -> Int -> HyperdataUser -> Aff (Either RESTError Int)
saveContactHyperdata session id h = do
...
...
src/Gargantext/Components/Nodes/Home.purs
View file @
260a2fd1
...
...
@@ -8,7 +8,6 @@ import Effect (Effect)
import Gargantext.Components.App.Data (Boxes)
import Gargantext.Components.Data.Landing (BlockText(..), BlockTexts(..), Button(..), LandingData(..))
import Gargantext.Components.FolderView as FV
import Gargantext.Components.GraphQL (graphQLTest)
import Gargantext.Components.Lang (LandingLang(..))
import Gargantext.Components.Lang.Landing.EnUS as En
import Gargantext.Components.Lang.Landing.FrFR as Fr
...
...
@@ -82,8 +81,6 @@ homeLayoutCpt = here.component "homeLayout" cpt
, H.div { className: "home-landing-data container1" }
[ blocksRandomText' landingData ]
, license
, graphQLTest {} []
]
] where
click mBackend _ =
...
...
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