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
8d73c0c4
Verified
Commit
8d73c0c4
authored
Jan 12, 2023
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[graphql] some refactoring to make for less typing
parent
e6ae3530
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
148 additions
and
87 deletions
+148
-87
spago.dhall
spago.dhall
+1
-0
Category.purs
src/Gargantext/Components/Category.purs
+46
-44
Contact.purs
src/Gargantext/Components/GraphQL/Contact.purs
+3
-15
Context.purs
src/Gargantext/Components/GraphQL/Context.purs
+6
-9
IMT.purs
src/Gargantext/Components/GraphQL/IMT.purs
+10
-4
Node.purs
src/Gargantext/Components/GraphQL/Node.purs
+14
-9
Team.purs
src/Gargantext/Components/GraphQL/Team.purs
+14
-6
GraphQL.purs
src/Gargantext/Utils/GraphQL.purs
+54
-0
No files found.
spago.dhall
View file @
8d73c0c4
...
@@ -44,6 +44,7 @@ to generate this file without the comments in this block.
...
@@ -44,6 +44,7 @@ to generate this file without the comments in this block.
, "formula"
, "formula"
, "functions"
, "functions"
, "graphql-client"
, "graphql-client"
, "heterogeneous"
, "http-methods"
, "http-methods"
, "integers"
, "integers"
, "js-timers"
, "js-timers"
...
...
src/Gargantext/Components/Category.purs
View file @
8d73c0c4
...
@@ -14,7 +14,7 @@ import Gargantext.Components.Bootstrap as B
...
@@ -14,7 +14,7 @@ import Gargantext.Components.Bootstrap as B
import Gargantext.Components.Bootstrap.Types (Variant(..))
import Gargantext.Components.Bootstrap.Types (Variant(..))
import Gargantext.Components.Category.Types (Category(..), Star(..), cat2score, categories, clickAgain, decodeStar, star2score, stars)
import Gargantext.Components.Category.Types (Category(..), Star(..), cat2score, categories, clickAgain, decodeStar, star2score, stars)
import Gargantext.Components.DocsTable.Types (DocumentsView(..), LocalCategories, LocalUserScore)
import Gargantext.Components.DocsTable.Types (DocumentsView(..), LocalCategories, LocalUserScore)
import Gargantext.Components.GraphQL.Context (NodeContext
, NodeContext'
)
import Gargantext.Components.GraphQL.Context (NodeContext)
import Gargantext.Components.GraphQL.Endpoints (getNodeContext, updateNodeContextCategory)
import Gargantext.Components.GraphQL.Endpoints (getNodeContext, updateNodeContextCategory)
import Gargantext.Config.REST (AffRESTError, RESTError(..))
import Gargantext.Config.REST (AffRESTError, RESTError(..))
import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Hooks.Loader (useLoader)
...
@@ -52,34 +52,39 @@ ratingCpt = here.component "rating" cpt where
...
@@ -52,34 +52,39 @@ ratingCpt = here.component "rating" cpt where
, session
, session
, setLocalCategories
, setLocalCategories
} _ = do
} _ = do
-- | Behaviors
pure $ renderRatingSimple { docId: nodeId
-- |
, corpusId: r._id
let
, category: star2score score
onClick c _ = do
, session } []
let c' = score == c ? clickAgain c $ c
-- -- | Behaviors
setLocalCategories $ Map.insert r._id c'
-- -- |
launchAff_ do
-- let
_ <- putRating session nodeId $ RatingQuery
-- onClick c _ = do
{ nodeIds: [r._id]
-- let c' = score == c ? clickAgain c $ c
, rating: c'
}
-- setLocalCategories $ Map.insert r._id c'
liftEffect $ T2.reload chartReload
-- launchAff_ do
-- _ <- putRating session nodeId $ RatingQuery
-- | Render
-- { nodeIds: [r._id]
-- |
-- , rating: c'
pure $
-- }
-- liftEffect $ T2.reload chartReload
H.div
{ className: "rating-group" } $
-- -- | Render
stars <#> \s ->
-- -- |
B.iconButton
-- pure $
{ name: ratingIcon score s
, callback: onClick s
-- H.div
, overlay: false
-- { className: "rating-group" } $
, variant: ratingVariant score s
-- stars <#> \s ->
, className: ratingClassName score s
-- B.iconButton
}
-- { name: ratingIcon score s
-- , callback: onClick s
-- , overlay: false
-- , variant: ratingVariant score s
-- , className: ratingClassName score s
-- }
ratingIcon Star_0 Star_0 = "times-circle"
ratingIcon Star_0 Star_0 = "times-circle"
ratingIcon _ Star_0 = "times"
ratingIcon _ Star_0 = "times"
...
@@ -113,10 +118,10 @@ ratingSimpleLoaderCpt = here.component "ratingSimpleLoader" cpt where
...
@@ -113,10 +118,10 @@ ratingSimpleLoaderCpt = here.component "ratingSimpleLoader" cpt where
useLoader { errorHandler
useLoader { errorHandler
, loader: loadDocumentContext session
, loader: loadDocumentContext session
, path: { docId, corpusId }
, path: { docId, corpusId }
, render: \
nc
-> renderRatingSimple { docId
, render: \
{ nc_category }
-> renderRatingSimple { docId
, corpusId
, corpusId
, context: nc
, category: fromMaybe 0 nc_category
, session } [] }
, session } [] }
where
where
errorHandler err = do
errorHandler err = do
here.warn2 "[pageLayout] RESTError" err
here.warn2 "[pageLayout] RESTError" err
...
@@ -134,7 +139,7 @@ loadDocumentContext session { docId, corpusId } = getNodeContext session docId c
...
@@ -134,7 +139,7 @@ loadDocumentContext session { docId, corpusId } = getNodeContext session docId c
type RenderRatingSimpleProps =
type RenderRatingSimpleProps =
( docId :: NodeID
( docId :: NodeID
, corpusId :: NodeID
, corpusId :: NodeID
, c
ontext :: NodeContex
t
, c
ategory :: In
t
, session :: Session )
, session :: Session )
renderRatingSimple :: R2.Component RenderRatingSimpleProps
renderRatingSimple :: R2.Component RenderRatingSimpleProps
...
@@ -143,18 +148,15 @@ renderRatingSimpleCpt :: R.Component RenderRatingSimpleProps
...
@@ -143,18 +148,15 @@ renderRatingSimpleCpt :: R.Component RenderRatingSimpleProps
renderRatingSimpleCpt = here.component "renderRatingSimple" cpt where
renderRatingSimpleCpt = here.component "renderRatingSimple" cpt where
cpt { docId
cpt { docId
, corpusId
, corpusId
, c
ontext: { nc_category }
, c
ategory
, session
, session
} _ = do
} _ = do
score <- T.useBox $ decodeStar $ fromMaybe 0 nc_category
score <- T.useBox $ decodeStar category
pure $ case nc_category of
pure $ ratingSimple { docId
Nothing -> H.div {} []
, corpusId
Just category -> do
, score
ratingSimple { docId
, session } []
, corpusId
, score
, session } []
type RatingSimpleProps =
type RatingSimpleProps =
( docId :: NodeID
( docId :: NodeID
...
...
src/Gargantext/Components/GraphQL/Contact.purs
View file @
8d73c0c4
...
@@ -25,6 +25,8 @@ import Data.Lens (Lens', lens)
...
@@ -25,6 +25,8 @@ import Data.Lens (Lens', lens)
import Data.Maybe (Maybe(..), fromMaybe)
import Data.Maybe (Maybe(..), fromMaybe)
import GraphQL.Client.Args (Args, (=>>))
import GraphQL.Client.Args (Args, (=>>))
import GraphQL.Client.Variable (Var(..))
import GraphQL.Client.Variable (Var(..))
import Gargantext.Utils.GraphQL as GGQL
import Type.Proxy (Proxy(..))
import Data.Array as A
import Data.Array as A
...
@@ -68,21 +70,7 @@ annuaireContactQuery :: AnnuaireContactQuery
...
@@ -68,21 +70,7 @@ annuaireContactQuery :: AnnuaireContactQuery
annuaireContactQuery
annuaireContactQuery
= { annuaire_contacts:
= { annuaire_contacts:
{ contact_id: Var :: _ "id" Int } =>>
{ contact_id: Var :: _ "id" Int } =>>
{ ac_title: unit
GGQL.getFieldsStandard (Proxy :: _ AnnuaireContact)
, ac_source: unit
, ac_id: unit
, ac_firstName: unit
, ac_lastName: unit
, ac_labTeamDepts: unit
, ac_organization: unit
, ac_role: unit
, ac_office: unit
, ac_country: unit
, ac_city: unit
, ac_touchMail: unit
, ac_touchPhone: unit
, ac_touchUrl: unit
}
}
}
------------------------------------------------------------------------
------------------------------------------------------------------------
...
...
src/Gargantext/Components/GraphQL/Context.purs
View file @
8d73c0c4
module Gargantext.Components.GraphQL.Context
module Gargantext.Components.GraphQL.Context
( NodeContext
( NodeContext
, NodeContext
'
, NodeContext
_
, nodeContextQuery
, nodeContextQuery
, NodeContextCategoryM
, NodeContextCategoryM
) where
) where
...
@@ -11,17 +11,19 @@ import Data.Lens (Lens', lens)
...
@@ -11,17 +11,19 @@ import Data.Lens (Lens', lens)
import Data.Maybe (Maybe(..), fromMaybe)
import Data.Maybe (Maybe(..), fromMaybe)
import GraphQL.Client.Args (Args, NotNull, (=>>))
import GraphQL.Client.Args (Args, NotNull, (=>>))
import GraphQL.Client.Variable (Var(..))
import GraphQL.Client.Variable (Var(..))
import Gargantext.Utils.GraphQL as GGQL
import Type.Proxy (Proxy(..))
import Data.Array as A
import Data.Array as A
type NodeContext
'
type NodeContext
_
= ( nc_id :: Maybe Int
= ( nc_id :: Maybe Int
, nc_node_id :: Int
, nc_node_id :: Int
, nc_context_id :: Int
, nc_context_id :: Int
, nc_score :: Maybe Number
, nc_score :: Maybe Number
, nc_category :: Maybe Int
, nc_category :: Maybe Int
)
)
type NodeContext = Record NodeContext
'
type NodeContext = Record NodeContext
_
type NodeContextQuery
type NodeContextQuery
= { contexts :: Args
= { contexts :: Args
...
@@ -39,12 +41,7 @@ nodeContextQuery
...
@@ -39,12 +41,7 @@ nodeContextQuery
= { contexts:
= { contexts:
{ context_id: Var :: _ "context_id" Int
{ context_id: Var :: _ "context_id" Int
, node_id: Var :: _ "node_id" Int } =>>
, node_id: Var :: _ "node_id" Int } =>>
{ nc_id: unit
GGQL.getFieldsStandard (Proxy :: _ NodeContext)
, nc_node_id: unit
, nc_context_id: unit
, nc_score: unit
, nc_category: unit
}
}
}
------------------------------------------------------------------------
------------------------------------------------------------------------
...
...
src/Gargantext/Components/GraphQL/IMT.purs
View file @
8d73c0c4
...
@@ -8,6 +8,8 @@ import Data.Lens (Lens', lens)
...
@@ -8,6 +8,8 @@ import Data.Lens (Lens', lens)
import Data.Maybe (Maybe(..), fromMaybe, maybe)
import Data.Maybe (Maybe(..), fromMaybe, maybe)
import GraphQL.Client.Args (NotNull, (=>>))
import GraphQL.Client.Args (NotNull, (=>>))
import GraphQL.Client.Variable (Var(..))
import GraphQL.Client.Variable (Var(..))
import Gargantext.Utils.GraphQL as GGQL
import Type.Proxy (Proxy(..))
type School
type School
...
@@ -16,9 +18,13 @@ type School
...
@@ -16,9 +18,13 @@ type School
, school_shortName :: String
, school_shortName :: String
}
}
type SchoolsQuery
= { imt_schools ::
{ school_id :: Unit
, school_longName :: Unit
, school_shortName :: Unit } }
schoolsQuery :: SchoolsQuery
schoolsQuery = { imt_schools:
schoolsQuery = { imt_schools:
{ school_id: unit
GGQL.getFieldsStandard (Proxy :: _ School)
, school_longName: unit
, school_shortName: unit}
}
}
src/Gargantext/Components/GraphQL/Node.purs
View file @
8d73c0c4
...
@@ -2,8 +2,10 @@ module Gargantext.Components.GraphQL.Node where
...
@@ -2,8 +2,10 @@ module Gargantext.Components.GraphQL.Node where
import Gargantext.Prelude
import Gargantext.Prelude
import GraphQL.Client.Args ((=>>))
import GraphQL.Client.Args (
Args,
(=>>))
import GraphQL.Client.Variable (Var(..))
import GraphQL.Client.Variable (Var(..))
import Gargantext.Utils.GraphQL as GGQL
import Type.Proxy (Proxy(..))
type Node
type Node
...
@@ -12,17 +14,20 @@ type Node
...
@@ -12,17 +14,20 @@ type Node
, parent_id :: Int
, parent_id :: Int
, type_id :: Int }
, type_id :: Int }
type NodesQuery =
{ nodes :: Args
{ node_id :: Var "id" Int }
{ id :: Unit
, name :: Unit
, parent_id :: Unit
, type_id :: Unit } }
nodesQuery :: NodesQuery
nodesQuery = { nodes: { node_id: Var :: _ "id" Int } =>>
nodesQuery = { nodes: { node_id: Var :: _ "id" Int } =>>
{ id: unit
GGQL.getFieldsStandard (Proxy :: _ Node)
, name: unit
, parent_id: unit
, type_id: unit }
}
}
nodeParentQuery = { node_parent: { node_id: Var :: _ "id" Int
nodeParentQuery = { node_parent: { node_id: Var :: _ "id" Int
, parent_type: Var :: _ "parent_type" String } =>> -- TODO parent_type :: NodeType
, parent_type: Var :: _ "parent_type" String } =>> -- TODO parent_type :: NodeType
{ id: unit
GGQL.getFieldsStandard (Proxy :: _ Node)
, name: unit
, parent_id: unit
, type_id: unit }
}
}
src/Gargantext/Components/GraphQL/Team.purs
View file @
8d73c0c4
...
@@ -2,8 +2,10 @@ module Gargantext.Components.GraphQL.Team where
...
@@ -2,8 +2,10 @@ module Gargantext.Components.GraphQL.Team where
import Gargantext.Prelude
import Gargantext.Prelude
import GraphQL.Client.Args (NotNull, (=>>))
import GraphQL.Client.Args (
Args,
NotNull, (=>>))
import GraphQL.Client.Variable (Var(..))
import GraphQL.Client.Variable (Var(..))
import Gargantext.Utils.GraphQL as GGQL
import Type.Proxy (Proxy(..))
type Team
type Team
= { team_owner_username :: String
= { team_owner_username :: String
...
@@ -21,10 +23,16 @@ type TeamDeleteM
...
@@ -21,10 +23,16 @@ type TeamDeleteM
, team_node_id :: Int
, team_node_id :: Int
}
}
type TeamQuery =
{ team :: Args
{ team_node_id :: Var "id" Int}
{ team_owner_username :: Unit
, team_members ::
{ username :: Unit
, shared_folder_id :: Unit } }
}
teamQuery :: TeamQuery
teamQuery = { team: { team_node_id: Var :: _ "id" Int } =>>
teamQuery = { team: { team_node_id: Var :: _ "id" Int } =>>
{ team_owner_username: unit
GGQL.getFieldsStandard (Proxy :: _ Team)
, team_members: { username: unit
, shared_folder_id: unit
}
}
}
}
src/Gargantext/Utils/GraphQL.purs
0 → 100644
View file @
8d73c0c4
-- https://github.com/OxfordAbstracts/purescript-graphql-client/pull/68/files#diff-404493334c4108c2411bd1767059be2e94295df5742d14d58116667dc5e80dd7R16-R19
module Gargantext.Utils.GraphQL
-- | Get the graphql fields from a data type
(class GetFieldsStandard, PropGetFieldsStandard, getFieldsStandard) where
import Prelude
import Data.HeytingAlgebra (class HeytingAlgebraRecord, tt)
import Data.Maybe (Maybe)
import Heterogeneous.Mapping (class HMap, class Mapping, hmap)
import Prim.RowList (class RowToList)
import Type.Proxy (Proxy(..))
class GetFieldsStandard :: forall k. k -> Type -> Constraint
class GetFieldsStandard t fields | t -> fields where
getFieldsStandard :: Proxy t -> fields
data PropGetFieldsStandard
= PropGetFieldsStandard
data PropToProxy
= PropToProxy
instance getFieldsStandardRecord ::
( RowToList r t
, HeytingAlgebraRecord t r r
, HMap PropGetFieldsStandard { | r } fields
, HMap PropGetFieldsStandard { | input } { | r }
) =>
GetFieldsStandard { | input } fields where
getFieldsStandard _ = recordGetFieldsStandard (tt :: { | r })
else instance getFieldsStandardMaybe :: GetFieldsStandard a fields => GetFieldsStandard (Maybe a) fields where
getFieldsStandard _ = getFieldsStandard (Proxy :: _ a)
else instance getFieldsStandardArray :: GetFieldsStandard a fields => GetFieldsStandard (Array a) fields where
getFieldsStandard _ = getFieldsStandard (Proxy :: _ a)
else instance getFieldsStandardLeaf :: GetFieldsStandard a Unit where
getFieldsStandard _ = unit
instance propToProxy ::
Mapping PropToProxy t (Proxy t) where
mapping PropToProxy _ = Proxy
recordGetFieldsStandard ::
forall t fields.
HMap PropGetFieldsStandard ({ | t }) fields => { | t } -> fields
recordGetFieldsStandard = hmap PropGetFieldsStandard
instance propGetFieldsStandard ::
(GetFieldsStandard t fields) =>
Mapping PropGetFieldsStandard t fields where
mapping PropGetFieldsStandard _ = getFieldsStandard (Proxy :: _ t)
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