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
Christian Merten
purescript-gargantext
Commits
7763e559
Verified
Commit
7763e559
authored
Jan 11, 2023
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[contexts] add GraphQL endpoint for node contexts
Also, implement rating on Document view.
parent
bc0abe91
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
161 additions
and
30 deletions
+161
-30
Category.purs
src/Gargantext/Components/Category.purs
+87
-20
Layout.purs
src/Gargantext/Components/Document/Layout.purs
+9
-1
Sidebar.purs
src/Gargantext/Components/GraphExplorer/Sidebar.purs
+0
-1
GraphQL.purs
src/Gargantext/Components/GraphQL.purs
+3
-1
Contact.purs
src/Gargantext/Components/GraphQL/Contact.purs
+1
-1
Context.purs
src/Gargantext/Components/GraphQL/Context.purs
+49
-0
Endpoints.purs
src/Gargantext/Components/GraphQL/Endpoints.purs
+10
-1
Node.purs
src/Gargantext/Components/Node.purs
+1
-1
Contact.purs
src/Gargantext/Components/Nodes/Annuaire/User/Contact.purs
+1
-1
Texts.purs
src/Gargantext/Components/Nodes/Texts.purs
+0
-1
Noverlap.js
src/Gargantext/Hooks/Sigmax/Noverlap.js
+0
-2
No files found.
src/Gargantext/Components/Category.purs
View file @
7763e559
...
@@ -7,13 +7,17 @@ import Data.Array as A
...
@@ -7,13 +7,17 @@ import Data.Array as A
import Data.Generic.Rep (class Generic)
import Data.Generic.Rep (class Generic)
import Data.Map as Map
import Data.Map as Map
import Data.Maybe (Maybe(..))
import Data.Maybe (Maybe(..))
import Data.Tuple.Nested ((/\))
import Effect.Aff (launchAff_)
import Effect.Aff (launchAff_)
import Effect.Class (liftEffect)
import Effect.Class (liftEffect)
import Gargantext.Components.Bootstrap as B
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, 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.Config.REST (AffRESTError)
import Gargantext.Components.GraphQL.Context (NodeContext, NodeContext')
import Gargantext.Components.GraphQL.Endpoints (getNodeContext)
import Gargantext.Config.REST (AffRESTError, RESTError(..))
import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Routes (SessionRoute(NodeAPI))
import Gargantext.Routes (SessionRoute(NodeAPI))
import Gargantext.Sessions (Session, put)
import Gargantext.Sessions (Session, put)
import Gargantext.Types (NodeID, NodeType(..))
import Gargantext.Types (NodeID, NodeType(..))
...
@@ -47,21 +51,6 @@ ratingCpt = here.component "rating" cpt where
...
@@ -47,21 +51,6 @@ ratingCpt = here.component "rating" cpt where
, session
, session
, setLocalCategories
, setLocalCategories
} _ = do
} _ = do
-- | Computed
-- |
let
icon' Star_0 Star_0 = "times-circle"
icon' _ Star_0 = "times"
icon' c s = star2score c < star2score s ? "star-o" $ "star"
variant' Star_0 Star_0 = Dark
variant' _ Star_0 = Dark
variant' _ _ = Dark
className' Star_0 Star_0 = "rating-group__action"
className' _ Star_0 = "rating-group__action"
className' _ _ = "rating-group__star"
-- | Behaviors
-- | Behaviors
-- |
-- |
let
let
...
@@ -84,11 +73,89 @@ ratingCpt = here.component "rating" cpt where
...
@@ -84,11 +73,89 @@ ratingCpt = here.component "rating" cpt where
{ className: "rating-group" } $
{ className: "rating-group" } $
stars <#> \s ->
stars <#> \s ->
B.iconButton
B.iconButton
{ name:
icon'
score s
{ name:
ratingIcon
score s
, callback: onClick s
, callback: onClick s
, overlay: false
, overlay: false
, variant: variant' score s
, variant: ratingVariant score s
, className: className' score s
, className: ratingClassName score s
}
ratingIcon Star_0 Star_0 = "times-circle"
ratingIcon _ Star_0 = "times"
ratingIcon c s = star2score c < star2score s ? "star-o" $ "star"
ratingVariant Star_0 Star_0 = Dark
ratingVariant _ Star_0 = Dark
ratingVariant _ _ = Dark
ratingClassName Star_0 Star_0 = "rating-group__action"
ratingClassName _ Star_0 = "rating-group__action"
ratingClassName _ _ = "rating-group__star"
------------------------------------------------
type RatingSimpleLoaderProps =
( docId :: NodeID
, corpusId :: NodeID
, session :: Session
)
ratingSimpleLoader :: R2.Component RatingSimpleLoaderProps
ratingSimpleLoader = R.createElement ratingSimpleLoaderCpt
ratingSimpleLoaderCpt :: R.Component RatingSimpleLoaderProps
ratingSimpleLoaderCpt = here.component "ratingSimpleLoader" cpt where
cpt { docId
, corpusId
, session
} _ = do
useLoader { errorHandler
, loader: loadDocumentContext session
, path: { docId, corpusId }
, render: \nc -> renderRatingSimple nc [] }
where
errorHandler err = do
here.warn2 "[pageLayout] RESTError" err
case err of
ReadJSONError err' -> here.warn2 "[pageLayout] ReadJSONError" $ show err'
_ -> pure unit
type ContextParams =
( docId :: NodeID
, corpusId :: NodeID )
loadDocumentContext :: Session -> Record ContextParams -> AffRESTError NodeContext
loadDocumentContext session { docId, corpusId } = getNodeContext session docId corpusId
renderRatingSimple :: R2.Component NodeContext'
renderRatingSimple = R.createElement renderRatingSimpleCpt
renderRatingSimpleCpt :: R.Component NodeContext'
renderRatingSimpleCpt = here.component "renderRatingSimple" cpt where
cpt { nc_category
} _ = do
pure $ case nc_category of
Nothing -> H.div {} []
Just category -> ratingSimple { score: decodeStar category } []
type RatingSimpleProps =
( score :: Star )
ratingSimple :: R2.Component RatingSimpleProps
ratingSimple = R.createElement ratingSimpleCpt
ratingSimpleCpt :: R.Component RatingSimpleProps
ratingSimpleCpt = here.component "ratingSimple" cpt where
cpt { score
} _ = do
pure $
H.div
{ className: "rating-group" } $
stars <#> \s ->
B.iconButton
{ name: ratingIcon score s
, callback: \_ -> pure unit -- onClick s
, overlay: false
, variant: ratingVariant score s
, className: ratingClassName score s
}
}
...
...
src/Gargantext/Components/Document/Layout.purs
View file @
7763e559
...
@@ -4,6 +4,7 @@ module Gargantext.Components.Document.Layout
...
@@ -4,6 +4,7 @@ module Gargantext.Components.Document.Layout
import Gargantext.Prelude
import Gargantext.Prelude
import Data.Array as A
import Data.Maybe (Maybe(..), fromMaybe, isJust, maybe)
import Data.Maybe (Maybe(..), fromMaybe, isJust, maybe)
import Data.Ord (greaterThan)
import Data.Ord (greaterThan)
import Data.String (length)
import Data.String (length)
...
@@ -14,6 +15,8 @@ import Gargantext.Components.Annotation.Types as AFT
...
@@ -14,6 +15,8 @@ import Gargantext.Components.Annotation.Types as AFT
import Gargantext.Components.AutoUpdate (autoUpdate)
import Gargantext.Components.AutoUpdate (autoUpdate)
import Gargantext.Components.Bootstrap as B
import Gargantext.Components.Bootstrap as B
import Gargantext.Components.Bootstrap.Types (ComponentStatus(..), SpinnerTheme(..))
import Gargantext.Components.Bootstrap.Types (ComponentStatus(..), SpinnerTheme(..))
import Gargantext.Components.Category (ratingSimpleLoader)
import Gargantext.Components.Category.Types (decodeStar)
import Gargantext.Components.Document.Types (DocPath, Document(..), LoadedData, initialState)
import Gargantext.Components.Document.Types (DocPath, Document(..), LoadedData, initialState)
import Gargantext.Components.NgramsTable.AutoSync (useAutoSync)
import Gargantext.Components.NgramsTable.AutoSync (useAutoSync)
import Gargantext.Components.Node (NodePoly(..))
import Gargantext.Components.Node (NodePoly(..))
...
@@ -48,7 +51,7 @@ here = R2.here "Gargantext.Components.Document.Layout"
...
@@ -48,7 +51,7 @@ here = R2.here "Gargantext.Components.Document.Layout"
layout :: forall r. R2.OptLeaf Options Props r
layout :: forall r. R2.OptLeaf Options Props r
layout = R2.optLeaf layoutCpt options
layout = R2.optLeaf layoutCpt options
layoutCpt :: R.Component Props
layoutCpt :: R.Component Props
layoutCpt = here.component "
main
" cpt where
layoutCpt = here.component "
layout
" cpt where
-- Component
-- Component
cpt { path
cpt { path
, loaded:
, loaded:
...
@@ -273,6 +276,11 @@ layoutCpt = here.component "main" cpt where
...
@@ -273,6 +276,11 @@ layoutCpt = here.component "main" cpt where
{ className: "document-layout__date__content" }
{ className: "document-layout__date__content" }
(publicationDate $ Document doc)
(publicationDate $ Document doc)
]
]
, case path.mCorpusId of
Nothing -> H.div {} []
Just corpusId -> ratingSimpleLoader { docId: path.nodeId
, corpusId
, session: path.session } []
,
,
R2.when hasAbstract $
R2.when hasAbstract $
...
...
src/Gargantext/Components/GraphExplorer/Sidebar.purs
View file @
7763e559
...
@@ -60,7 +60,6 @@ type Props =
...
@@ -60,7 +60,6 @@ type Props =
sidebar :: R2.Leaf Props
sidebar :: R2.Leaf Props
sidebar = R2.leaf sidebarCpt
sidebar = R2.leaf sidebarCpt
sidebarCpt :: R.Component Props
sidebarCpt :: R.Component Props
sidebarCpt = here.component "sidebar" cpt where
sidebarCpt = here.component "sidebar" cpt where
cpt props _ = do
cpt props _ = do
...
...
src/Gargantext/Components/GraphQL.purs
View file @
7763e559
...
@@ -10,6 +10,8 @@ import Effect (Effect)
...
@@ -10,6 +10,8 @@ import Effect (Effect)
import Effect.Aff (Aff)
import Effect.Aff (Aff)
import Effect.Class (liftEffect)
import Effect.Class (liftEffect)
import Foreign (unsafeToForeign, ForeignError)
import Foreign (unsafeToForeign, ForeignError)
import Gargantext.Components.GraphQL.Contact (AnnuaireContact)
import Gargantext.Components.GraphQL.Context as GQLCTX
import Gargantext.Components.GraphQL.IMT as GQLIMT
import Gargantext.Components.GraphQL.IMT as GQLIMT
import Gargantext.Components.GraphQL.Node (Node)
import Gargantext.Components.GraphQL.Node (Node)
import Gargantext.Components.GraphQL.Tree (TreeFirstLevel)
import Gargantext.Components.GraphQL.Tree (TreeFirstLevel)
...
@@ -18,7 +20,6 @@ import Gargantext.Components.GraphQL.Team (Team, TeamDeleteM)
...
@@ -18,7 +20,6 @@ import Gargantext.Components.GraphQL.Team (Team, TeamDeleteM)
import Gargantext.Ends (Backend(..))
import Gargantext.Ends (Backend(..))
import Gargantext.Sessions (Session(..))
import Gargantext.Sessions (Session(..))
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Reactix as R2
import Gargnatext.Components.GraphQL.Contact (AnnuaireContact)
import GraphQL.Client.Args (type (==>))
import GraphQL.Client.Args (type (==>))
import GraphQL.Client.BaseClients.Urql (UrqlClient, createClient)
import GraphQL.Client.BaseClients.Urql (UrqlClient, createClient)
import GraphQL.Client.Query (queryWithDecoder)
import GraphQL.Client.Query (queryWithDecoder)
...
@@ -72,6 +73,7 @@ queryGql session name q = do
...
@@ -72,6 +73,7 @@ queryGql session name q = do
-- Schema
-- Schema
type Schema
type Schema
= { imt_schools :: {} ==> Array GQLIMT.School
= { imt_schools :: {} ==> Array GQLIMT.School
, contexts :: { context_id :: Int, node_id :: Int } ==> Array GQLCTX.NodeContext
, nodes :: { node_id :: Int } ==> Array Node
, nodes :: { node_id :: Int } ==> Array Node
, node_parent :: { node_id :: Int, parent_type :: String } ==> Array Node -- TODO: parent_type :: NodeType
, node_parent :: { node_id :: Int, parent_type :: String } ==> Array Node -- TODO: parent_type :: NodeType
, user_infos :: { user_id :: Int } ==> Array UserInfo
, user_infos :: { user_id :: Int } ==> Array UserInfo
...
...
src/Gargantext/Components/GraphQL/Contact.purs
View file @
7763e559
module Garg
na
text.Components.GraphQL.Contact
module Garg
an
text.Components.GraphQL.Contact
( AnnuaireContact
( AnnuaireContact
, annuaireContactQuery
, annuaireContactQuery
-- Lenses
-- Lenses
...
...
src/Gargantext/Components/GraphQL/Context.purs
0 → 100644
View file @
7763e559
module Gargantext.Components.GraphQL.Context
( NodeContext
, NodeContext'
, nodeContextQuery
) where
import Gargantext.Prelude
import Data.Lens (Lens', lens)
import Data.Maybe (Maybe(..), fromMaybe)
import GraphQL.Client.Args (Args, (=>>))
import GraphQL.Client.Variable (Var(..))
import Data.Array as A
type NodeContext'
= ( nc_id :: Maybe Int
, nc_node_id :: Int
, nc_context_id :: Int
, nc_score :: Maybe Number
, nc_category :: Maybe Int
)
type NodeContext = Record NodeContext'
type NodeContextQuery
= { contexts :: Args
{ context_id :: Var "context_id" Int
, node_id :: Var "node_id" Int }
{ nc_id :: Unit
, nc_node_id :: Unit
, nc_context_id :: Unit
, nc_score :: Unit
, nc_category :: Unit
}
}
nodeContextQuery :: NodeContextQuery
nodeContextQuery
= { contexts:
{ context_id: Var :: _ "context_id" Int
, node_id: Var :: _ "node_id" Int } =>>
{ nc_id: unit
, nc_node_id: unit
, nc_context_id: unit
, nc_score: unit
, nc_category: unit
}
}
------------------------------------------------------------------------
src/Gargantext/Components/GraphQL/Endpoints.purs
View file @
7763e559
...
@@ -8,6 +8,8 @@ import Data.Maybe (Maybe(..))
...
@@ -8,6 +8,8 @@ import Data.Maybe (Maybe(..))
import Effect.Aff (Aff)
import Effect.Aff (Aff)
import Effect.Class (liftEffect)
import Effect.Class (liftEffect)
import Gargantext.Components.GraphQL (getClient, queryGql)
import Gargantext.Components.GraphQL (getClient, queryGql)
import Gargantext.Components.GraphQL.Contact (AnnuaireContact, annuaireContactQuery)
import Gargantext.Components.GraphQL.Context as GQLCTX
import Gargantext.Components.GraphQL.IMT as GQLIMT
import Gargantext.Components.GraphQL.IMT as GQLIMT
import Gargantext.Components.GraphQL.Node (Node, nodeParentQuery, nodesQuery)
import Gargantext.Components.GraphQL.Node (Node, nodeParentQuery, nodesQuery)
import Gargantext.Components.GraphQL.Team (Team, teamQuery)
import Gargantext.Components.GraphQL.Team (Team, teamQuery)
...
@@ -17,7 +19,6 @@ import Gargantext.Config.REST (RESTError(..), AffRESTError)
...
@@ -17,7 +19,6 @@ import Gargantext.Config.REST (RESTError(..), AffRESTError)
import Gargantext.Sessions (Session(..))
import Gargantext.Sessions (Session(..))
import Gargantext.Types (NodeType)
import Gargantext.Types (NodeType)
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Reactix as R2
import Gargnatext.Components.GraphQL.Contact (AnnuaireContact, annuaireContactQuery)
import GraphQL.Client.Args (onlyArgs)
import GraphQL.Client.Args (onlyArgs)
import GraphQL.Client.Query (mutation)
import GraphQL.Client.Query (mutation)
import GraphQL.Client.Variables (withVars)
import GraphQL.Client.Variables (withVars)
...
@@ -97,3 +98,11 @@ deleteTeamMembership session sharedFolderId teamNodeId = do
...
@@ -97,3 +98,11 @@ deleteTeamMembership session sharedFolderId teamNodeId = do
Just _ -> Right sharedFolderId
Just _ -> Right sharedFolderId
where
where
getToken (Session { token }) = token
getToken (Session { token }) = token
getNodeContext :: Session -> Int -> Int -> AffRESTError GQLCTX.NodeContext
getNodeContext session context_id node_id = do
{ contexts } <- queryGql session "get node context" $ GQLCTX.nodeContextQuery `withVars` { context_id, node_id }
liftEffect $ here.log2 "[getNodeContext] node context" contexts
case A.head contexts of
Nothing -> pure $ Left $ CustomError "no node context found"
Just context -> pure $ Right context -- TODO: error handling
src/Gargantext/Components/Node.purs
View file @
7763e559
module Gargantext.Components.Node
module Gargantext.Components.Node
where
where
import Gargantext.Prelude
import Gargantext.Prelude
...
...
src/Gargantext/Components/Nodes/Annuaire/User/Contact.purs
View file @
7763e559
...
@@ -16,7 +16,7 @@ import Gargantext.Hooks.Session (useSession)
...
@@ -16,7 +16,7 @@ import Gargantext.Hooks.Session (useSession)
import Gargantext.Types (NodeID)
import Gargantext.Types (NodeID)
import Gargantext.Utils (nbsp)
import Gargantext.Utils (nbsp)
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Reactix as R2
import Garg
na
text.Components.GraphQL.Contact (AnnuaireContact, _ac_city, _ac_country, _ac_firstName, _ac_labTeamDeptsFirst, _ac_lastName, _ac_office, _ac_organizationFirst, _ac_role, _ac_touchMail, _ac_touchPhone, _ac_touchUrl)
import Garg
an
text.Components.GraphQL.Contact (AnnuaireContact, _ac_city, _ac_country, _ac_firstName, _ac_labTeamDeptsFirst, _ac_lastName, _ac_office, _ac_organizationFirst, _ac_role, _ac_touchMail, _ac_touchPhone, _ac_touchUrl)
import Reactix as R
import Reactix as R
import Reactix.DOM.HTML as H
import Reactix.DOM.HTML as H
...
...
src/Gargantext/Components/Nodes/Texts.purs
View file @
7763e559
...
@@ -541,7 +541,6 @@ type SideText =
...
@@ -541,7 +541,6 @@ type SideText =
sideText :: R2.Leaf ( key :: String | SideText )
sideText :: R2.Leaf ( key :: String | SideText )
sideText = R2.leaf sideTextCpt
sideText = R2.leaf sideTextCpt
sideTextCpt :: R.Component ( key :: String | SideText )
sideTextCpt :: R.Component ( key :: String | SideText )
sideTextCpt = here.component "sideText" cpt where
sideTextCpt = here.component "sideText" cpt where
cpt { sidePanelText: { corpusId, listId, nodeId }
cpt { sidePanelText: { corpusId, listId, nodeId }
...
...
src/Gargantext/Hooks/Sigmax/Noverlap.js
View file @
7763e559
...
@@ -17,12 +17,10 @@ export function _init(graph, options) {
...
@@ -17,12 +17,10 @@ export function _init(graph, options) {
}
}
export
function
_start
(
layout
)
{
export
function
_start
(
layout
)
{
console
.
log
(
'[noverlap] _start'
,
layout
);
return
layout
.
start
();
return
layout
.
start
();
}
}
export
function
_stop
(
layout
)
{
export
function
_stop
(
layout
)
{
console
.
log
(
'[noverlap] _stop'
,
layout
);
return
layout
.
stop
();
return
layout
.
stop
();
}
}
...
...
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