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
Julien Moutinho
haskell-gargantext
Commits
7aa33462
Unverified
Commit
7aa33462
authored
Jan 24, 2019
by
Nicolas Pouillard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Small refactoring of the calls which creates a node
parent
930b75fc
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
25 deletions
+19
-25
API.hs
src/Gargantext/API.hs
+5
-3
Node.hs
src/Gargantext/API/Node.hs
+7
-6
Node.hs
src/Gargantext/Database/Schema/Node.hs
+7
-16
No files found.
src/Gargantext/API.hs
View file @
7aa33462
...
...
@@ -285,15 +285,17 @@ serverGargAPI :: GargServer GargAPI
serverGargAPI
-- orchestrator
=
auth
:<|>
roots
:<|>
nodeAPI
(
Proxy
::
Proxy
HyperdataAny
)
:<|>
nodeAPI
(
Proxy
::
Proxy
HyperdataCorpus
)
:<|>
nodeAPI
(
Proxy
::
Proxy
HyperdataAnnuaire
)
:<|>
nodeAPI
(
Proxy
::
Proxy
HyperdataAny
)
fakeUserId
:<|>
nodeAPI
(
Proxy
::
Proxy
HyperdataCorpus
)
fakeUserId
:<|>
nodeAPI
(
Proxy
::
Proxy
HyperdataAnnuaire
)
fakeUserId
:<|>
nodesAPI
:<|>
count
-- TODO: undefined
:<|>
search
:<|>
graphAPI
-- TODO: mock
:<|>
treeAPI
-- :<|> orchestrator
where
fakeUserId
=
1
-- TODO
serverIndex
::
Server
(
Get
'[
H
TML
]
Html
)
serverIndex
=
$
(
do
(
Just
s
)
<-
liftIO
(
fileTypeToFileTree
(
FileTypeFile
"purescript-gargantext/dist/index.html"
))
...
...
src/Gargantext/API/Node.hs
View file @
7aa33462
...
...
@@ -50,7 +50,7 @@ import Gargantext.API.Ngrams (TabType(..), TableNgramsApi, TableNgramsApiGet, ta
import
Gargantext.Prelude
import
Gargantext.Database.Types.Node
import
Gargantext.Database.Utils
-- (Cmd, CmdM)
import
Gargantext.Database.Schema.Node
(
getNodesWithParentId
,
getNode
,
deleteNode
,
deleteNodes
,
mk
,
JSONB
,
NodeError
(
..
),
HasNodeError
(
..
))
import
Gargantext.Database.Schema.Node
(
getNodesWithParentId
,
getNode
,
deleteNode
,
deleteNodes
,
mk
NodeWithParent
,
JSONB
,
NodeError
(
..
),
HasNodeError
(
..
))
import
Gargantext.Database.Node.Children
(
getChildren
)
import
qualified
Gargantext.Database.Node.Update
as
U
(
update
,
Update
(
..
))
import
Gargantext.Database.Facet
(
FacetDoc
,
runViewDocuments
,
OrderBy
(
..
),
FacetChart
,
runViewAuthorsDoc
)
...
...
@@ -136,10 +136,11 @@ type ChildrenApi a = Summary " Summary children"
:>
Get
'[
J
SON
]
[
Node
a
]
------------------------------------------------------------------------
-- TODO: make the NodeId type indexed by `a`, then we no longer need the proxy.
nodeAPI
::
JSONB
a
=>
proxy
a
->
NodeId
->
GargServer
(
NodeAPI
a
)
nodeAPI
p
id
=
getNode
id
p
nodeAPI
::
JSONB
a
=>
proxy
a
->
UserId
->
NodeId
->
GargServer
(
NodeAPI
a
)
nodeAPI
p
uId
id
=
getNode
id
p
:<|>
rename
id
:<|>
postNode
id
:<|>
postNode
uId
id
:<|>
putNode
id
:<|>
deleteNode
id
:<|>
getChildren
id
p
...
...
@@ -330,8 +331,8 @@ getChart :: NodeId -> Maybe UTCTime -> Maybe UTCTime
->
Cmd
err
[
FacetChart
]
getChart
_
_
_
=
undefined
-- TODO
postNode
::
NodeId
->
PostNode
->
Cmd
err
[
NodeId
]
postNode
pId
(
PostNode
name
nt
)
=
mk
nt
(
Just
pId
)
name
postNode
::
HasNodeError
err
=>
UserId
->
NodeId
->
PostNode
->
Cmd
err
[
NodeId
]
postNode
uId
pId
(
PostNode
name
nt
)
=
mkNodeWithParent
nt
(
Just
pId
)
uId
name
putNode
::
NodeId
->
Cmd
err
Int
putNode
=
undefined
-- TODO
...
...
src/Gargantext/Database/Schema/Node.hs
View file @
7aa33462
...
...
@@ -500,29 +500,20 @@ childWith uId pId (Node' NodeContact txt v []) = node2table uId (Just pId) (Nod
childWith
_
_
(
Node'
_
_
_
_
)
=
panic
"This NodeType can not be a child"
-- | TODO Use right userId
mk
::
NodeType
->
Maybe
ParentId
->
Text
->
Cmd
err
[
NodeId
]
mk
nt
pId
name
=
mk'
nt
userId
pId
name
where
userId
=
1
type
Name
=
Text
mk'
::
NodeType
->
UserId
->
Maybe
ParentId
->
Text
->
Cmd
err
[
NodeId
]
mk'
nt
uId
pId
name
=
insertNodesWithParentR
pId
[
node
nt
name
hd
pId
uId
]
mkNodeWithParent
::
HasNodeError
err
=>
NodeType
->
Maybe
ParentId
->
UserId
->
Name
->
Cmd
err
[
NodeId
]
mkNodeWithParent
NodeUser
(
Just
_
)
_
_
=
nodeError
UserNoParent
mkNodeWithParent
_
Nothing
_
_
=
nodeError
HasParent
mkNodeWithParent
nt
pId
uId
name
=
insertNodesWithParentR
pId
[
node
nt
name
hd
pId
uId
]
where
hd
=
HyperdataUser
.
Just
.
pack
$
show
EN
type
Name
=
Text
mk''
::
HasNodeError
err
=>
NodeType
->
Maybe
ParentId
->
UserId
->
Name
->
Cmd
err
[
NodeId
]
mk''
NodeUser
Nothing
uId
name
=
mk'
NodeUser
uId
Nothing
name
mk''
NodeUser
_
_
_
=
nodeError
UserNoParent
mk''
_
Nothing
_
_
=
nodeError
HasParent
mk''
nt
pId
uId
name
=
mk'
nt
uId
pId
name
mkRoot
::
HasNodeError
err
=>
Username
->
UserId
->
Cmd
err
[
RootId
]
mkRoot
uname
uId
=
case
uId
>
0
of
False
->
nodeError
NegativeId
True
->
mk
''
NodeUser
Nothing
uId
uname
True
->
mk
NodeWithParent
NodeUser
Nothing
uId
uname
mkCorpus
::
Maybe
Name
->
Maybe
HyperdataCorpus
->
ParentId
->
UserId
->
Cmd
err
[
CorpusId
]
mkCorpus
n
h
p
u
=
insertNodesR
[
nodeCorpusW
n
h
p
u
]
...
...
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