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
98e9a0f0
Commit
98e9a0f0
authored
Sep 26, 2018
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[REST] Rename node (put).
parent
88585c12
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
6 deletions
+30
-6
Node.hs
src/Gargantext/API/Node.hs
+30
-6
No files found.
src/Gargantext/API/Node.hs
View file @
98e9a0f0
...
...
@@ -12,11 +12,12 @@ Node API
{-# OPTIONS_GHC -fno-warn-name-shadowing #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE OverloadedStrings #-}
-------------------------------------------------------------------
module
Gargantext.API.Node
...
...
@@ -27,13 +28,15 @@ import Control.Monad.IO.Class (liftIO)
import
Control.Monad
((
>>
))
--import System.IO (putStrLn, readFile)
import
Data.Aeson
(
Value
())
import
Data.Aeson
(
FromJSON
,
ToJSON
,
Value
())
--import Data.Text (Text(), pack)
import
Data.Text
(
Text
())
import
Data.Swagger
import
Data.Time
(
UTCTime
)
import
Database.PostgreSQL.Simple
(
Connection
)
import
GHC.Generics
(
Generic
)
import
Servant
-- import Servant.Multipart
...
...
@@ -51,7 +54,9 @@ import Gargantext.Viz.Graph (Graph)
import
Gargantext.Core
(
Lang
(
..
))
import
Gargantext.Core.Types.Main
(
Tree
,
NodeTree
)
import
Gargantext.Text.Terms
(
TermType
(
..
))
-------------------------------------------------------------------
import
Test.QuickCheck
(
elements
)
import
Test.QuickCheck.Arbitrary
(
Arbitrary
,
arbitrary
)
-------------------------------------------------------------------
-- | Node API Types management
type
Roots
=
Get
'[
J
SON
]
[
Node
Value
]
...
...
@@ -61,7 +66,21 @@ type Roots = Get '[JSON] [Node Value]
type
NodesAPI
=
Delete
'[
J
SON
]
Int
data
Rename
=
Rename
{
name
::
Text
}
deriving
(
Generic
)
instance
FromJSON
Rename
instance
ToJSON
Rename
instance
ToSchema
Rename
instance
Arbitrary
Rename
where
arbitrary
=
elements
[
Rename
"test"
]
type
NodeAPI
=
Get
'[
J
SON
]
(
Node
Value
)
:<|>
"rename"
:>
Summary
" Rename Node"
:>
ReqBody
'[
J
SON
]
Rename
:>
Get
'[
J
SON
]
Int
:<|>
Post
'[
J
SON
]
Int
:<|>
Put
'[
J
SON
]
Int
:<|>
Delete
'[
J
SON
]
Int
...
...
@@ -121,14 +140,19 @@ treeAPI _ _ = undefined
nodeAPI
::
Connection
->
NodeId
->
Server
NodeAPI
nodeAPI
conn
id
=
liftIO
(
putStrLn
(
"/node"
::
Text
)
>>
getNode
conn
id
)
:<|>
postNode
conn
id
:<|>
putNode
conn
id
:<|>
rename
conn
id
:<|>
postNode
conn
id
:<|>
putNode
conn
id
:<|>
deleteNode'
conn
id
:<|>
getNodesWith'
conn
id
:<|>
getFacet
conn
id
:<|>
getChart
conn
id
-- :<|> upload
-- :<|> query
-- | Check if the name is less than 255 char
--rename :: Connection -> NodeId -> Rename -> Server NodeAPI
rename
::
Connection
->
NodeId
->
Rename
->
Handler
Int
rename
=
undefined
nodesAPI
::
Connection
->
[
NodeId
]
->
Server
NodesAPI
nodesAPI
conn
ids
=
deleteNodes'
conn
ids
...
...
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