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
158
Issues
158
List
Board
Labels
Milestones
Merge Requests
10
Merge Requests
10
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
bc39b467
Commit
bc39b467
authored
Oct 09, 2018
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'rest'
parents
cbe804f5
5e6e3575
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 @
bc39b467
...
...
@@ -12,11 +12,12 @@ Node API
{-# OPTIONS_GHC -fno-warn-name-shadowing -fno-warn-orphans #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE OverloadedStrings #-}
-------------------------------------------------------------------
module
Gargantext.API.Node
...
...
@@ -28,13 +29,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
...
...
@@ -54,7 +57,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
]
...
...
@@ -64,7 +69,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
:>
Put
'[
J
SON
]
Int
:<|>
Post
'[
J
SON
]
Int
:<|>
Put
'[
J
SON
]
Int
:<|>
Delete
'[
J
SON
]
Int
...
...
@@ -132,14 +151,19 @@ treeAPI = treeDB
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