Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
haskell-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
haskell-gargantext
Commits
7649e70b
Commit
7649e70b
authored
Aug 19, 2024
by
Karen Konou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Graph api] Legend update endpoint
parent
d6c03dc3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
41 additions
and
10 deletions
+41
-10
Viz.hs
src/Gargantext/API/Routes/Named/Viz.hs
+6
-5
Viz.hs
src/Gargantext/API/Server/Named/Viz.hs
+6
-5
API.hs
src/Gargantext/Core/Viz/Graph/API.hs
+15
-0
Types.hs
src/Gargantext/Core/Viz/Graph/Types.hs
+14
-0
No files found.
src/Gargantext/API/Routes/Named/Viz.hs
View file @
7649e70b
...
...
@@ -53,11 +53,12 @@ newtype PostPhylo mode = PostPhylo
-- | There is no Delete specific API for Graph since it can be deleted
-- as simple Node.
data
GraphAPI
mode
=
GraphAPI
{
getGraphEp
::
mode
:-
Get
'[
J
SON
]
HyperdataGraphAPI
,
getGraphAsyncEp
::
mode
:-
"async"
:>
NamedRoutes
GraphAsyncAPI
,
cloneGraphEp
::
mode
:-
"clone"
:>
ReqBody
'[
J
SON
]
HyperdataGraphAPI
:>
Post
'[
J
SON
]
NodeId
,
gexfEp
::
mode
:-
"gexf"
:>
Get
'[
X
ML
]
(
Headers
'[
S
ervant
.
Header
"Content-Disposition"
Text
]
Graph
)
,
graphVersionsAPI
::
mode
:-
"versions"
:>
NamedRoutes
GraphVersionsAPI
{
getGraphEp
::
mode
:-
Get
'[
J
SON
]
HyperdataGraphAPI
,
getGraphAsyncEp
::
mode
:-
"async"
:>
NamedRoutes
GraphAsyncAPI
,
cloneGraphEp
::
mode
:-
"clone"
:>
ReqBody
'[
J
SON
]
HyperdataGraphAPI
:>
Post
'[
J
SON
]
NodeId
,
gexfEp
::
mode
:-
"gexf"
:>
Get
'[
X
ML
]
(
Headers
'[
S
ervant
.
Header
"Content-Disposition"
Text
]
Graph
)
,
graphVersionsAPI
::
mode
:-
"versions"
:>
NamedRoutes
GraphVersionsAPI
,
updateGraphLegendEp
::
mode
:-
"legend"
:>
ReqBody
'[
J
SON
]
GraphLegendAPI
:>
Post
'[
J
SON
]
NodeId
}
deriving
Generic
...
...
src/Gargantext/API/Server/Named/Viz.hs
View file @
7649e70b
...
...
@@ -19,11 +19,12 @@ import Servant.Server.Generic (AsServerT)
graphAPI
::
AuthenticatedUser
->
UserId
->
NodeId
->
Named
.
GraphAPI
(
AsServerT
(
GargM
Env
BackendInternalError
))
graphAPI
authenticatedUser
userId
n
=
withNamedAccess
authenticatedUser
(
PathNode
n
)
$
Named
.
GraphAPI
{
getGraphEp
=
getGraph
n
,
getGraphAsyncEp
=
graphAsync
n
,
cloneGraphEp
=
graphClone
userId
n
,
gexfEp
=
getGraphGexf
n
,
graphVersionsAPI
=
graphVersionsAPI
userId
n
{
getGraphEp
=
getGraph
n
,
getGraphAsyncEp
=
graphAsync
n
,
cloneGraphEp
=
graphClone
userId
n
,
gexfEp
=
getGraphGexf
n
,
graphVersionsAPI
=
graphVersionsAPI
userId
n
,
updateGraphLegendEp
=
updateGraphLegend
n
}
...
...
src/Gargantext/Core/Viz/Graph/API.hs
View file @
7649e70b
...
...
@@ -297,3 +297,18 @@ getGraphGexf :: HasNodeStory env err m
getGraphGexf
nId
=
do
HyperdataGraphAPI
{
_hyperdataAPIGraph
=
graph
}
<-
getGraph
nId
pure
$
addHeader
"attachment; filename=graph.gexf"
graph
------------------------------------------------------------
updateGraphLegend
::
HasNodeError
err
=>
NodeId
->
GraphLegendAPI
->
DBCmd
err
NodeId
updateGraphLegend
nId
(
GraphLegendAPI
{
_graphAPILegend
=
lg
})
=
do
nodeGraph
<-
getNodeWith
nId
(
Proxy
::
Proxy
HyperdataGraph
)
let
graph
=
nodeGraph
^.
node_hyperdata
.
hyperdataGraph
case
graph
of
Nothing
->
pure
nId
Just
g
->
do
let
graph'
=
set
(
graph_metadata
.
_Just
.
gm_legend
)
lg
g
_
<-
updateHyperdata
nId
(
HyperdataGraph
(
Just
graph'
)
(
nodeGraph
^.
node_hyperdata
.
hyperdataCamera
))
pure
nId
src/Gargantext/Core/Viz/Graph/Types.hs
View file @
7649e70b
...
...
@@ -241,6 +241,20 @@ instance FromField HyperdataGraphAPI
fromField
=
fromField'
-----------------------------------------------------------
data
GraphLegendAPI
=
GraphLegendAPI
{
_graphAPILegend
::
[
LegendField
]
}
deriving
(
Show
,
Generic
)
$
(
deriveJSON
(
unPrefix
"_graphAPI"
)
''
G
raphLegendAPI
)
instance
ToSchema
GraphLegendAPI
where
declareNamedSchema
=
genericDeclareNamedSchema
(
unPrefixSwagger
"_graphAPI"
)
makeLenses
''
G
raphLegendAPI
instance
FromField
GraphLegendAPI
where
fromField
=
fromField'
---------------------- defaults
...
...
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