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
195
Issues
195
List
Board
Labels
Milestones
Merge Requests
12
Merge Requests
12
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
haskell-gargantext
Commits
a3cd87ad
Commit
a3cd87ad
authored
Jan 22, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[WIP] update hyperdata.
parent
13b3d633
Pipeline
#705
failed with stage
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
9 deletions
+21
-9
Node.hs
src/Gargantext/API/Node.hs
+21
-9
No files found.
src/Gargantext/API/Node.hs
View file @
a3cd87ad
...
@@ -61,6 +61,7 @@ import Gargantext.Database.Facet (FacetDoc, OrderBy(..))
...
@@ -61,6 +61,7 @@ import Gargantext.Database.Facet (FacetDoc, OrderBy(..))
import
Gargantext.Database.Node.Children
(
getChildren
)
import
Gargantext.Database.Node.Children
(
getChildren
)
import
Gargantext.Database.Schema.Node
(
getNodesWithParentId
,
getNodeWith
,
getNode
,
deleteNode
,
deleteNodes
,
mkNodeWithParent
,
JSONB
,
HasNodeError
(
..
))
import
Gargantext.Database.Schema.Node
(
getNodesWithParentId
,
getNodeWith
,
getNode
,
deleteNode
,
deleteNodes
,
mkNodeWithParent
,
JSONB
,
HasNodeError
(
..
))
import
Gargantext.Database.Schema.NodeNode
(
nodeNodesCategory
)
import
Gargantext.Database.Schema.NodeNode
(
nodeNodesCategory
)
import
Gargantext.Database.Node.UpdateOpaleye
(
updateHyperdata
)
import
Gargantext.Database.Tree
(
treeDB
)
import
Gargantext.Database.Tree
(
treeDB
)
import
Gargantext.Database.Types.Node
import
Gargantext.Database.Types.Node
import
Gargantext.Database.Utils
-- (Cmd, CmdM)
import
Gargantext.Database.Utils
-- (Cmd, CmdM)
...
@@ -160,14 +161,17 @@ type ChildrenApi a = Summary " Summary children"
...
@@ -160,14 +161,17 @@ type ChildrenApi a = Summary " Summary children"
------------------------------------------------------------------------
------------------------------------------------------------------------
type
NodeNodeAPI
a
=
Get
'[
J
SON
]
(
Node
a
)
type
NodeNodeAPI
a
=
Get
'[
J
SON
]
(
Node
a
)
nodeNodeAPI
::
forall
proxy
a
.
(
JSONB
a
,
ToJSON
a
)
=>
proxy
a
->
UserId
->
CorpusId
->
NodeId
->
GargServer
(
NodeNodeAPI
a
)
nodeNodeAPI
::
forall
proxy
a
.
(
JSONB
a
,
ToJSON
a
)
=>
proxy
a
->
UserId
->
CorpusId
->
NodeId
->
GargServer
(
NodeNodeAPI
a
)
nodeNodeAPI
p
uId
cId
nId
=
withAccess
(
Proxy
::
Proxy
(
NodeNodeAPI
a
))
Proxy
uId
(
PathNodeNode
cId
nId
)
nodeNodeAPI'
nodeNodeAPI
p
uId
cId
nId
=
withAccess
(
Proxy
::
Proxy
(
NodeNodeAPI
a
))
Proxy
uId
(
PathNodeNode
cId
nId
)
nodeNodeAPI'
where
where
nodeNodeAPI'
::
GargServer
(
NodeNodeAPI
a
)
nodeNodeAPI'
::
GargServer
(
NodeNodeAPI
a
)
nodeNodeAPI'
=
getNodeWith
nId
p
nodeNodeAPI'
=
getNodeWith
nId
p
------------------------------------------------------------------------
------------------------------------------------------------------------
-- TODO: make the NodeId type indexed by `a`, then we no longer need the proxy.
-- TODO: make the NodeId type indexed by `a`, then we no longer need the proxy.
nodeAPI
::
forall
proxy
a
.
(
JSONB
a
,
ToJSON
a
)
=>
proxy
a
->
UserId
->
NodeId
->
GargServer
(
NodeAPI
a
)
nodeAPI
::
forall
proxy
a
.
(
JSONB
a
,
ToJSON
a
)
=>
proxy
a
->
UserId
->
NodeId
->
GargServer
(
NodeAPI
a
)
...
@@ -177,7 +181,7 @@ nodeAPI p uId id = withAccess (Proxy :: Proxy (NodeAPI a)) Proxy uId (PathNode i
...
@@ -177,7 +181,7 @@ nodeAPI p uId id = withAccess (Proxy :: Proxy (NodeAPI a)) Proxy uId (PathNode i
nodeAPI'
=
getNodeWith
id
p
nodeAPI'
=
getNodeWith
id
p
:<|>
rename
id
:<|>
rename
id
:<|>
postNode
uId
id
:<|>
postNode
uId
id
:<|>
putNode
id
:<|>
putNode
id
p
:<|>
deleteNodeApi
id
:<|>
deleteNodeApi
id
:<|>
getChildren
id
p
:<|>
getChildren
id
p
...
@@ -323,13 +327,21 @@ treeAPI = treeDB
...
@@ -323,13 +327,21 @@ treeAPI = treeDB
rename
::
NodeId
->
RenameNode
->
Cmd
err
[
Int
]
rename
::
NodeId
->
RenameNode
->
Cmd
err
[
Int
]
rename
nId
(
RenameNode
name'
)
=
U
.
update
(
U
.
Rename
nId
name'
)
rename
nId
(
RenameNode
name'
)
=
U
.
update
(
U
.
Rename
nId
name'
)
postNode
::
HasNodeError
err
=>
UserId
->
NodeId
->
PostNode
->
Cmd
err
[
NodeId
]
postNode
::
HasNodeError
err
=>
UserId
->
NodeId
->
PostNode
->
Cmd
err
[
NodeId
]
postNode
uId
pId
(
PostNode
nodeName
nt
)
=
do
postNode
uId
pId
(
PostNode
nodeName
nt
)
=
do
nodeUser
<-
getNodeWith
(
NodeId
uId
)
HyperdataUser
nodeUser
<-
getNodeWith
(
NodeId
uId
)
HyperdataUser
let
uId'
=
nodeUser
^.
node_userId
let
uId'
=
nodeUser
^.
node_userId
mkNodeWithParent
nt
(
Just
pId
)
uId'
nodeName
mkNodeWithParent
nt
(
Just
pId
)
uId'
nodeName
putNode
::
NodeId
->
Cmd
err
Int
putNode
::
forall
err
proxy
a
.
(
HasNodeError
err
,
JSONB
a
,
ToJSON
a
)
putNode
=
undefined
-- TODO
=>
NodeId
->
proxy
a
->
Cmd
err
Int
putNode
n
h
=
do
n
<-
fromIntegral
<$>
updateHyperdata
n
h
pure
n
-------------------------------------------------------------
-------------------------------------------------------------
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