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
153
Issues
153
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
dc484896
Commit
dc484896
authored
Nov 25, 2019
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Annuanire][Contact] Route + script.
parent
229f0d44
Pipeline
#617
canceled with stage
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
50 additions
and
36 deletions
+50
-36
Main.hs
bin/gargantext-import/Main.hs
+18
-7
API.hs
src/Gargantext/API.hs
+12
-6
Auth.hs
src/Gargantext/API/Auth.hs
+7
-15
Node.hs
src/Gargantext/API/Node.hs
+6
-2
Flow.hs
src/Gargantext/Database/Flow.hs
+3
-2
Contact.hs
src/Gargantext/Database/Node/Contact.hs
+4
-4
No files found.
bin/gargantext-import/Main.hs
View file @
dc484896
...
...
@@ -23,7 +23,7 @@ import Data.Either
import
Prelude
(
read
)
import
Control.Exception
(
finally
)
import
Gargantext.Prelude
import
Gargantext.Database.Flow
(
FlowCmdM
,
flowCorpusFile
)
import
Gargantext.Database.Flow
(
FlowCmdM
,
flowCorpusFile
,
flowAnnuaire
)
import
Gargantext.Text.Corpus.Parsers
(
FileFormat
(
..
))
import
Gargantext.Database.Utils
(
Cmd
,
)
import
Gargantext.Database.Types.Node
(
CorpusId
,
toHyperdataDocument
)
...
...
@@ -41,9 +41,10 @@ import Control.Monad.IO.Class (liftIO)
main
::
IO
()
main
=
do
[
userCreate
,
user
,
name
,
iniPath
,
limit
,
corpusPath
]
<-
getArgs
[
fun
,
user
,
name
,
iniPath
,
limit
,
corpusPath
]
<-
getArgs
--{-
let
createUsers
::
Cmd
GargError
Int64
createUsers
=
insertUsersDemo
...
...
@@ -51,8 +52,13 @@ main = do
--tt = (Unsupervised EN 6 0 Nothing)
tt
=
(
Multi
EN
)
format
=
CsvGargV3
-- CsvHalFormat --WOS
cmd
::
forall
m
.
FlowCmdM
DevEnv
GargError
m
=>
m
CorpusId
cmd
=
flowCorpusFile
(
cs
user
)
(
Left
(
cs
name
::
Text
))
(
read
limit
::
Int
)
tt
format
corpusPath
corpus
::
forall
m
.
FlowCmdM
DevEnv
GargError
m
=>
m
CorpusId
corpus
=
flowCorpusFile
(
cs
user
)
(
Left
(
cs
name
::
Text
))
(
read
limit
::
Int
)
tt
format
corpusPath
annuaire
::
forall
m
.
FlowCmdM
DevEnv
GargError
m
=>
m
CorpusId
annuaire
=
flowAnnuaire
(
cs
user
)
(
Left
"Annuaire"
)
(
Multi
EN
)
corpusPath
{-
let debatCorpus :: forall m. FlowCmdM DevEnv GargError m => m CorpusId
debatCorpus = do
...
...
@@ -64,13 +70,18 @@ main = do
flowCorpus (Text.pack user) (Text.pack name) (Multi FR) (map (map toHyperdataDocument) docs)
--}
withDevEnv
iniPath
$
\
env
->
do
_
<-
if
userCreate
==
"true
"
_
<-
if
fun
==
"users
"
then
runCmdDev
env
createUsers
else
pure
0
--(cs "false")
_
<-
runCmdDev
env
cmd
_
<-
if
fun
==
"corpus"
then
runCmdDev
env
corpus
else
pure
0
--(cs "false")
_
<-
if
fun
==
"annuaire"
then
runCmdDev
env
annuaire
else
pure
0
{-
_ <- if corpusType == "csv"
then runCmdDev env csvCorpus
...
...
src/Gargantext/API.hs
View file @
dc484896
...
...
@@ -70,7 +70,7 @@ import Text.Blaze.Html (Html)
--import Gargantext.API.Swagger
--
import Gargantext.Database.Node.Contact (HyperdataContact)
import
Gargantext.Database.Node.Contact
(
HyperdataContact
)
import
Gargantext.API.Auth
(
AuthRequest
,
AuthResponse
,
AuthenticatedUser
(
..
),
AuthContext
,
auth
,
withAccess
,
PathId
(
..
))
import
Gargantext.API.Count
(
CountAPI
,
count
,
Query
)
import
Gargantext.API.FrontEnd
(
FrontEndAPI
,
frontEndServer
)
...
...
@@ -249,6 +249,11 @@ type GargPrivateAPI' =
:<|>
"annuaire"
:>
Summary
"Annuaire endpoint"
:>
Capture
"id"
AnnuaireId
:>
NodeAPI
HyperdataAnnuaire
:<|>
"annuaire"
:>
Summary
"Contact endpoint"
:>
Capture
"annuaire_id"
NodeId
:>
"contact"
:>
Capture
"contact_id"
NodeId
:>
NodeNodeAPI
HyperdataContact
-- Document endpoint
:<|>
"document"
:>
Summary
"Document endpoint"
:>
Capture
"id"
DocId
:>
"ngrams"
:>
TableNgramsApi
...
...
@@ -325,11 +330,12 @@ serverGargAdminAPI
serverPrivateGargAPI'
::
AuthenticatedUser
->
GargServer
GargPrivateAPI'
serverPrivateGargAPI'
(
AuthenticatedUser
(
NodeId
uid
))
=
serverGargAdminAPI
:<|>
nodeAPI
(
Proxy
::
Proxy
HyperdataAny
)
uid
:<|>
nodeAPI
(
Proxy
::
Proxy
HyperdataCorpus
)
uid
:<|>
nodeNodeAPI
(
Proxy
::
Proxy
HyperdataAny
)
uid
:<|>
nodeAPI
(
Proxy
::
Proxy
HyperdataAnnuaire
)
uid
:<|>
withAccess
(
Proxy
::
Proxy
TableNgramsApi
)
Proxy
uid
<$>
PathNode
<*>
apiNgramsTableDoc
:<|>
nodeAPI
(
Proxy
::
Proxy
HyperdataAny
)
uid
:<|>
nodeAPI
(
Proxy
::
Proxy
HyperdataCorpus
)
uid
:<|>
nodeNodeAPI
(
Proxy
::
Proxy
HyperdataAny
)
uid
:<|>
nodeAPI
(
Proxy
::
Proxy
HyperdataAnnuaire
)
uid
:<|>
nodeNodeAPI
(
Proxy
::
Proxy
HyperdataContact
)
uid
:<|>
withAccess
(
Proxy
::
Proxy
TableNgramsApi
)
Proxy
uid
<$>
PathNode
<*>
apiNgramsTableDoc
:<|>
count
-- TODO: undefined
:<|>
withAccess
(
Proxy
::
Proxy
SearchPairsAPI
)
Proxy
uid
<$>
PathNode
<*>
searchPairs
-- TODO: move elsewhere
:<|>
withAccess
(
Proxy
::
Proxy
GraphAPI
)
Proxy
uid
<$>
PathNode
<*>
graphAPI
-- TODO: mock
...
...
src/Gargantext/API/Auth.hs
View file @
dc484896
...
...
@@ -102,7 +102,7 @@ checkAuthRequest u p
|
not
(
u
`
elem
`
arbitraryUsername
)
=
pure
InvalidUser
|
u
/=
reverse
p
=
pure
InvalidPassword
|
otherwise
=
do
muId
<-
head
<$>
getRoot
"user1"
-- TODO user1 hard-coded
muId
<-
head
<$>
getRoot
u
case
_node_id
<$>
muId
of
Nothing
->
pure
InvalidUser
Just
uid
->
do
...
...
@@ -179,7 +179,7 @@ instance Arbitrary AuthValid where
,
tr
<-
[
1
..
3
]
]
data
PathId
=
PathNode
NodeId
|
Path
Doc
ListId
DocId
data
PathId
=
PathNode
NodeId
|
Path
NodeNode
ListId
DocId
withAccessM
::
(
CmdM
env
err
m
,
HasServerError
err
)
=>
UserId
...
...
@@ -190,13 +190,12 @@ withAccessM uId (PathNode id) m = do
d
<-
id
`
isDescendantOf
`
NodeId
uId
if
d
then
m
else
m
-- serverError err401
withAccessM
uId
(
Path
Doc
cId
docId
)
m
=
do
a
<-
isIn
cId
docId
-- TODO use one query for all ?
d
<-
cId
`
isDescendantOf
`
NodeId
uId
if
a
&&
d
withAccessM
uId
(
Path
NodeNode
cId
docId
)
m
=
do
_
a
<-
isIn
cId
docId
-- TODO use one query for all ?
_
d
<-
cId
`
isDescendantOf
`
NodeId
uId
if
True
--
a && d
then
m
else
m
-- serverError err401
else
m
withAccess
::
forall
env
err
m
api
.
(
GargServerC
env
err
m
,
HasServer
api
'[
]
)
=>
...
...
@@ -208,16 +207,9 @@ withAccess p _ uId id = hoistServer p f
f
::
forall
a
.
m
a
->
m
a
f
=
withAccessM
uId
id
{- | Collaborative Schema
User at his root can create Teams Folder
User can create Team in Teams Folder.
User can invite User in Team as NodeNode only if Team in his parents.
All users can access to the Team folder as if they were owner.
-}
src/Gargantext/API/Node.hs
View file @
dc484896
...
...
@@ -164,11 +164,13 @@ type ChildrenApi a = Summary " Summary children"
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
p
uId
cId
nId
=
withAccess
(
Proxy
::
Proxy
(
NodeNodeAPI
a
))
Proxy
uId
(
Path
Doc
cId
nId
)
nodeNodeAPI'
nodeNodeAPI
p
uId
cId
nId
=
withAccess
(
Proxy
::
Proxy
(
NodeNodeAPI
a
))
Proxy
uId
(
Path
NodeNode
cId
nId
)
nodeNodeAPI'
where
nodeNodeAPI'
::
GargServer
(
NodeNodeAPI
a
)
nodeNodeAPI'
=
getNode
nId
p
------------------------------------------------------------------------
-- 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
)
...
...
@@ -204,9 +206,11 @@ nodeAPI p uId id = withAccess (Proxy :: Proxy (NodeAPI a)) Proxy uId (PathNode i
if
_node_typename
node
==
nodeTypeId
NodeUser
then
panic
"not allowed"
-- TODO add proper Right Management Type
else
deleteNode
id'
-- Annuaire
-- :<|> query
------------------------------------------------------------------------
data
RenameNode
=
RenameNode
{
r_name
::
Text
}
deriving
(
Generic
)
...
...
src/Gargantext/Database/Flow.hs
View file @
dc484896
...
...
@@ -37,6 +37,7 @@ module Gargantext.Database.Flow -- (flowDatabase, ngrams2list)
,
flowCorpusSearchInDatabase
,
getOrMkRoot
,
getOrMkRootWithCorpus
,
flowAnnuaire
)
where
import
Prelude
(
String
)
...
...
@@ -120,9 +121,9 @@ _flowCorpusApi u n tt l q = do
------------------------------------------------------------------------
-- UNUSED
_
flowAnnuaire
::
FlowCmdM
env
err
m
flowAnnuaire
::
FlowCmdM
env
err
m
=>
Username
->
Either
CorpusName
[
CorpusId
]
->
(
TermType
Lang
)
->
FilePath
->
m
AnnuaireId
_
flowAnnuaire
u
n
l
filePath
=
do
flowAnnuaire
u
n
l
filePath
=
do
docs
<-
liftIO
$
((
splitEvery
500
<$>
deserialiseImtUsersFromFile
filePath
)
::
IO
[[
HyperdataContact
]])
flow
(
Nothing
::
Maybe
HyperdataAnnuaire
)
u
n
l
docs
...
...
src/Gargantext/Database/Node/Contact.hs
View file @
dc484896
...
...
@@ -76,15 +76,15 @@ data ContactWho =
data
ContactWhere
=
ContactWhere
{
_cw_organization
::
[
Text
]
,
_cw_labTeamDepts
::
[
Text
]
,
_cw_role
::
Maybe
Text
,
_cw_office
::
Maybe
Text
,
_cw_country
::
Maybe
Text
,
_cw_city
::
Maybe
Text
,
_cw_touch
::
Maybe
ContactTouch
,
_cw_entry
::
Maybe
UTCTime
,
_cw_exit
::
Maybe
UTCTime
}
deriving
(
Eq
,
Show
,
Generic
)
...
...
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