Commit 677fed9b authored by Alexandre Delanoë's avatar Alexandre Delanoë

[API] PostNodeAsync funs, before refactoring

parent 00b915ee
Pipeline #841 failed with stage
......@@ -24,11 +24,12 @@ import Data.Maybe (Maybe(..))
import Gargantext.API.Admin.Settings (withDevEnv, runCmdDev)
import Gargantext.API.Admin.Types (GargError)
import Gargantext.API.Node () -- instances
import Gargantext.Core.Types.Individu (UserId, User(..))
import Gargantext.Core.Types.Individu (User(..))
import Gargantext.Database.Action.Flow (getOrMkRoot, getOrMk_RootWithCorpus)
import Gargantext.Database.Query.Table.Node (getOrMkList)
import Gargantext.Database.Query.Table.User (insertUsersDemo)
import Gargantext.Database.Admin.Config (userMaster, corpusMasterName)
import Gargantext.Database.Admin.Types.Node
import Gargantext.Database.Admin.Trigger.Init (initTriggers)
import Gargantext.Database.Admin.Types.Node (CorpusId, RootId, HyperdataCorpus, ListId)
import Gargantext.Database.Prelude (Cmd, )
......
......@@ -70,6 +70,7 @@ import Gargantext.API.Admin.Types
import Gargantext.API.Count ( CountAPI, count, Query)
import Gargantext.API.Ngrams (HasRepo(..), HasRepoSaver(..), saveRepo, TableNgramsApi, apiNgramsTableDoc)
import Gargantext.API.Node
import qualified Gargantext.API.Node.New as NodeNew
import Gargantext.API.Search (SearchPairsAPI, searchPairs)
import Gargantext.Core.Types.Individu (User(..))
import Gargantext.Database.Query.Table.Node.Contact (HyperdataContact)
......@@ -411,47 +412,6 @@ serverPrivateGargAPI' (AuthenticatedUser (NodeId uid))
:<|> waitAPI
addCorpusWithQuery :: User -> GargServer New.AddWithQuery
addCorpusWithQuery user cid =
serveJobsAPI $
JobFunction (\q log ->
let
log' x = do
printDebug "addToCorpusWithQuery" x
liftBase $ log x
in New.addToCorpusWithQuery user cid q log'
)
{-
addWithFile :: GargServer New.AddWithFile
addWithFile cid i f =
serveJobsAPI $
JobFunction (\_i log -> New.addToCorpusWithFile cid i f (liftBase . log))
-}
addCorpusWithForm :: User -> GargServer New.AddWithForm
addCorpusWithForm user cid =
serveJobsAPI $
JobFunction (\i log ->
let
log' x = do
printDebug "addToCorpusWithForm" x
liftBase $ log x
in New.addToCorpusWithForm user cid i log')
addAnnuaireWithForm :: GargServer Annuaire.AddWithForm
addAnnuaireWithForm cid =
serveJobsAPI $
JobFunction (\i log -> Annuaire.addToAnnuaireWithForm cid i (liftBase . log))
{-
serverStatic :: Server (Get '[HTML] Html)
serverStatic = $(do
let path = "purescript-gargantext/dist/index.html"
Just s <- liftBase (fileTypeToFileTree (FileTypeFile path))
fileTreeToServer s
)
-}
---------------------------------------------------------------------
--gargMock :: Server GargAPI
--gargMock = mock apiGarg Proxy
......@@ -537,4 +497,43 @@ startGargantextMock port = do
-}
----------------------------------------------------------------------
addCorpusWithQuery :: User -> GargServer New.AddWithQuery
addCorpusWithQuery user cid =
serveJobsAPI $
JobFunction (\q log ->
let
log' x = do
printDebug "addToCorpusWithQuery" x
liftBase $ log x
in New.addToCorpusWithQuery user cid q log'
)
{-
addWithFile :: GargServer New.AddWithFile
addWithFile cid i f =
serveJobsAPI $
JobFunction (\_i log -> New.addToCorpusWithFile cid i f (liftBase . log))
-}
addCorpusWithForm :: User -> GargServer New.AddWithForm
addCorpusWithForm user cid =
serveJobsAPI $
JobFunction (\i log ->
let
log' x = do
printDebug "addToCorpusWithForm" x
liftBase $ log x
in New.addToCorpusWithForm user cid i log')
addAnnuaireWithForm :: GargServer Annuaire.AddWithForm
addAnnuaireWithForm cid =
serveJobsAPI $
JobFunction (\i log -> Annuaire.addToAnnuaireWithForm cid i (liftBase . log))
postNodeAsync :: UserId -> NodeId -> GargServer NodeNew.PostNodeAsync
postNodeAsync uId nId =
serveJobsAPI $
JobFunction (\p log -> NodeNew.postNodeAsync uId nId p (liftBase . log))
......@@ -121,6 +121,7 @@ roots = getNodesWithParentId Nothing
type NodeAPI a = Get '[JSON] (Node a)
:<|> "rename" :> RenameApi
:<|> PostNodeApi -- TODO move to children POST
-- :<|> PostNodeAsync
:<|> ReqBody '[JSON] a :> Put '[JSON] Int
:<|> Delete '[JSON] Int
:<|> "children" :> ChildrenApi a
......@@ -193,6 +194,7 @@ nodeAPI p uId id' = withAccess (Proxy :: Proxy (NodeAPI a)) Proxy uId (PathNode
nodeAPI' = getNodeWith id' p
:<|> rename id'
:<|> postNode uId id'
-- :<|> postNodeAsync uId id'
:<|> putNode id'
:<|> deleteNodeApi id'
:<|> getChildren id' p
......
......@@ -202,6 +202,7 @@ type AddWithForm = Summary "Add with FormUrlEncoded to corpus endpoint"
:> "async"
:> AsyncJobs ScraperStatus '[FormUrlEncoded] WithForm ScraperStatus
------------------------------------------------------------------------
-- TODO WithQuery also has a corpus id
addToCorpusWithQuery :: FlowCmdM env err m
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment