Commit e87b4662 authored by Alexandre Delanoë's avatar Alexandre Delanoë

[FEAT] Move node API

parent eec3bc97
...@@ -55,6 +55,7 @@ import Gargantext.Database.Action.Flow.Pairing (pairing) ...@@ -55,6 +55,7 @@ import Gargantext.Database.Action.Flow.Pairing (pairing)
import Gargantext.Database.Query.Facet (FacetDoc, OrderBy(..)) import Gargantext.Database.Query.Facet (FacetDoc, OrderBy(..))
import Gargantext.Core.Types.Individu (User(..)) import Gargantext.Core.Types.Individu (User(..))
import Gargantext.Database.Query.Table.Node import Gargantext.Database.Query.Table.Node
import Gargantext.Database.Query.Table.Node.Update (Update(..), update)
import Gargantext.Database.Query.Table.Node.Children (getChildren) import Gargantext.Database.Query.Table.Node.Children (getChildren)
import Gargantext.Database.Query.Table.Node.UpdateOpaleye (updateHyperdata) import Gargantext.Database.Query.Table.Node.UpdateOpaleye (updateHyperdata)
import Gargantext.Database.Query.Table.Node.User import Gargantext.Database.Query.Table.Node.User
...@@ -144,6 +145,7 @@ type NodeAPI a = Get '[JSON] (Node a) ...@@ -144,6 +145,7 @@ type NodeAPI a = Get '[JSON] (Node a)
:<|> "tree" :> TreeApi :<|> "tree" :> TreeApi
:<|> "phylo" :> PhyloAPI :<|> "phylo" :> PhyloAPI
-- :<|> "add" :> NodeAddAPI -- :<|> "add" :> NodeAddAPI
:<|> MoveAPI
-- TODO-ACCESS: check userId CanRenameNode nodeId -- TODO-ACCESS: check userId CanRenameNode nodeId
-- TODO-EVENTS: NodeRenamed RenameNode or re-use some more general NodeEdited... -- TODO-EVENTS: NodeRenamed RenameNode or re-use some more general NodeEdited...
...@@ -216,6 +218,7 @@ nodeAPI p uId id' = withAccess (Proxy :: Proxy (NodeAPI a)) Proxy uId (PathNode ...@@ -216,6 +218,7 @@ nodeAPI p uId id' = withAccess (Proxy :: Proxy (NodeAPI a)) Proxy uId (PathNode
:<|> pieApi id' :<|> pieApi id'
:<|> treeApi id' :<|> treeApi id'
:<|> phyloAPI id' uId :<|> phyloAPI id' uId
:<|> moveNode (RootId $ NodeId uId) id'
-- :<|> nodeAddAPI id' -- :<|> nodeAddAPI id'
-- :<|> postUpload id' -- :<|> postUpload id'
...@@ -271,12 +274,12 @@ catApi = putCat ...@@ -271,12 +274,12 @@ catApi = putCat
-- TODO adapt FacetDoc -> ListDoc (and add type of document as column) -- TODO adapt FacetDoc -> ListDoc (and add type of document as column)
-- Pairing utilities to move elsewhere -- Pairing utilities to move elsewhere
type PairingApi = Summary " Pairing API" type PairingApi = Summary " Pairing API"
:> QueryParam "view" TabType :> QueryParam "view" TabType
-- TODO change TabType -> DocType (CorpusId for pairing) -- TODO change TabType -> DocType (CorpusId for pairing)
:> QueryParam "offset" Int :> QueryParam "offset" Int
:> QueryParam "limit" Int :> QueryParam "limit" Int
:> QueryParam "order" OrderBy :> QueryParam "order" OrderBy
:> Get '[JSON] [FacetDoc] :> Get '[JSON] [FacetDoc]
---------- ----------
type Pairs = Summary "List of Pairs" type Pairs = Summary "List of Pairs"
...@@ -306,7 +309,7 @@ treeAPI :: NodeId -> GargServer TreeAPI ...@@ -306,7 +309,7 @@ treeAPI :: NodeId -> GargServer TreeAPI
treeAPI = tree Advanced treeAPI = tree Advanced
------------------------------------------------------------------------ ------------------------------------------------------------------------
-- | Check if the name is less than 255 char -- | TODO Check if the name is less than 255 char
rename :: NodeId -> RenameNode -> Cmd err [Int] rename :: NodeId -> RenameNode -> Cmd err [Int]
rename nId (RenameNode name') = U.update (U.Rename nId name') rename nId (RenameNode name') = U.update (U.Rename nId name')
...@@ -315,4 +318,16 @@ putNode :: forall err a. (HasNodeError err, JSONB a, ToJSON a) ...@@ -315,4 +318,16 @@ putNode :: forall err a. (HasNodeError err, JSONB a, ToJSON a)
-> a -> a
-> Cmd err Int -> Cmd err Int
putNode n h = fromIntegral <$> updateHyperdata n h putNode n h = fromIntegral <$> updateHyperdata n h
-------------------------------------------------------------
type MoveAPI = Summary "Move Node endpoint"
:> Capture "parent_id" ParentId
:> Put '[JSON] [Int]
moveNode :: User
-> NodeId
-> ParentId
-> Cmd err [Int]
moveNode _u n p = update (Move n p)
------------------------------------------------------------- -------------------------------------------------------------
...@@ -170,8 +170,8 @@ simuTask :: MonadBase IO m ...@@ -170,8 +170,8 @@ simuTask :: MonadBase IO m
-> Int -> Int
-> m () -> m ()
simuTask logStatus cur total = do simuTask logStatus cur total = do
let m = (10 :: Int) ^ (6 :: Int)
_ <- liftBase $ threadDelay (m*5) _ <- liftBase $ threadDelay (m*5)
where m = (10 :: Int) ^ (6 :: Int)
let status = JobLog { _scst_succeeded = Just cur let status = JobLog { _scst_succeeded = Just cur
, _scst_failed = Just 0 , _scst_failed = Just 0
......
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