Commit 210b31cf authored by mzheng's avatar mzheng

commenting DOT export for now

parent d05e9762
...@@ -14,12 +14,16 @@ module Gargantext.API.Node.Phylo.Export ...@@ -14,12 +14,16 @@ module Gargantext.API.Node.Phylo.Export
-- import Control.Lens (view) -- import Control.Lens (view)
-- import Data.ByteString.Lazy.Char8 qualified as BSC -- import Data.ByteString.Lazy.Char8 qualified as BSC
-- import Data.Csv (encodeDefaultOrderedByName) -- import Data.Csv (encodeDefaultOrderedByName)
import Data.Aeson
-- import Debug.Trace qualified as DT
import Data.Text qualified as T import Data.Text qualified as T
-- import Data.Text.Encoding qualified as TE -- import Data.Text.Encoding qualified as TE
-- import Data.Version (showVersion) -- import Data.Version (showVersion)
import Gargantext.API.Node.Phylo.Export.Types import Gargantext.API.Node.Phylo.Export.Types
import Gargantext.API.Prelude (GargNoServer, GargServer) import Gargantext.API.Prelude (GargNoServer, GargServer)
-- import Gargantext.Core (toDBid) -- import Gargantext.Core (toDBid)
import Gargantext.Core.Viz.Phylo.API.Tools
import Gargantext.Core.Viz.Phylo.Example (phyloCleopatre)
import Gargantext.Database.Admin.Types.Node (PhyloId, NodeId,) -- NodeType(..)) import Gargantext.Database.Admin.Types.Node (PhyloId, NodeId,) -- NodeType(..))
-- import Gargantext.Database.Query.Facet (runViewDocuments, Facet(..)) -- import Gargantext.Database.Query.Facet (runViewDocuments, Facet(..))
-- import Gargantext.Database.Query.Table.Node (getClosestParentIdByType) -- import Gargantext.Database.Query.Table.Node (getClosestParentIdByType)
...@@ -33,22 +37,36 @@ api :: NodeId ...@@ -33,22 +37,36 @@ api :: NodeId
-- ^ The ID of the target user -- ^ The ID of the target user
-> PhyloId -> PhyloId
-> GargServer API -> GargServer API
api userNodeId dId = getTest userNodeId dId api userNodeId dId = getPhylo userNodeId dId
:<|> getTest2 userNodeId dId -- :<|> getTest2 userNodeId dId
getTest :: NodeId getPhylo :: NodeId
-- ^ The ID of the target user -- ^ The ID of the target user
-> PhyloId -> PhyloId
-> GargNoServer (Headers '[Header "Content-Disposition" T.Text] User) -> GargNoServer (Headers '[Header "Content-Disposition" T.Text] Value)
getTest _ pId = pure $ addHeader (T.concat [ "attachment; filename=" getPhylo _ pId = do
maybePhyloData <- getPhyloData pId
let phyloData = fromMaybe phyloCleopatre maybePhyloData
phyloJson <- liftBase $ phylo2dot2json phyloData
pure $ addHeader (T.concat [ "attachment; filename="
, "GarganText_Phylo-" , "GarganText_Phylo-"
, T.pack (show pId) , T.pack (show pId)
, ".json" ]) , ".json" ])
User { phyloJson
_us_name = "test"
, _us_age = 80 -- getTest :: NodeId
, _us_email = "mail" -- -- ^ The ID of the target user
} -- -> PhyloId
-- -> GargNoServer (Headers '[Header "Content-Disposition" T.Text] User)
-- getTest _ pId = pure $ addHeader (T.concat [ "attachment; filename="
-- , "GarganText_Phylo-"
-- , T.pack (show pId)
-- , ".json" ])
-- User {
-- _us_name = "test"
-- , _us_age = 80
-- , _us_email = "mail"
-- }
getTest2 :: NodeId getTest2 :: NodeId
-- ^ The ID of the target user -- ^ The ID of the target user
......
...@@ -13,7 +13,7 @@ Portability : POSIX ...@@ -13,7 +13,7 @@ Portability : POSIX
module Gargantext.API.Node.Phylo.Export.Types where module Gargantext.API.Node.Phylo.Export.Types where
import Data.Aeson (ToJSON, encode) import Data.Aeson (ToJSON, Value, encode)
import Data.Aeson.TH (deriveJSON) import Data.Aeson.TH (deriveJSON)
-- import Data.Csv (DefaultOrdered(..), ToNamedRecord(..), (.=), header, namedRecord) -- import Data.Csv (DefaultOrdered(..), ToNamedRecord(..), (.=), header, namedRecord)
import Data.Swagger ( genericDeclareNamedSchema, ToParamSchema(..), ToSchema(..) ) import Data.Swagger ( genericDeclareNamedSchema, ToParamSchema(..), ToSchema(..) )
...@@ -98,14 +98,21 @@ instance ToParamSchema Phylo where ...@@ -98,14 +98,21 @@ instance ToParamSchema Phylo where
toParamSchema _ = toParamSchema (Proxy :: Proxy TODO) toParamSchema _ = toParamSchema (Proxy :: Proxy TODO)
-------------------------------------------------- --------------------------------------------------
type API = Summary "Phylo Export" type APITest = Summary "Phylo Export"
:> "export" :> "export"
:> ( "json" :> ( "json"
:> Get '[JSON] (Headers '[Servant.Header "Content-Disposition" Text] User) :> Get '[JSON] (Headers '[Servant.Header "Content-Disposition" Text] Value)
:<|> "dot" :<|> "dot"
:> Get '[JSON] (Headers '[Servant.Header "Content-Disposition" Text] User) :> Get '[JSON] (Headers '[Servant.Header "Content-Disposition" Text] User)
) )
type API = Summary "Phylo Export"
:> "export"
:> ( "json"
:> Get '[JSON] (Headers '[Servant.Header "Content-Disposition" Text] Value)
)
data User = User data User = User
{ _us_name :: Text { _us_name :: Text
, _us_age :: Int , _us_age :: Int
......
...@@ -183,17 +183,9 @@ type GargPrivateAPI' = ...@@ -183,17 +183,9 @@ type GargPrivateAPI' =
:<|> "texts" :> Capture "node_id" DocId :<|> "texts" :> Capture "node_id" DocId
:> DocumentExport.API :> DocumentExport.API
-- :<|> "phylo" :> Capture "node_id" DocId
-- :> DocumentExport.API
:<|> "phylo" :> Capture "node_id" DocId :<|> "phylo" :> Capture "node_id" DocId
:> PhyloExport.API :> PhyloExport.API
-- :<|> "phylo" :> Capture "phylo_id" PhyloId
-- :> Capture "action" Text
-- :> Capture "format" Text
-- :> Raw
-- :<|> "counts" :> Stream GET NewLineFraming '[JSON] Count :> CountAPI -- :<|> "counts" :> Stream GET NewLineFraming '[JSON] Count :> CountAPI
-- TODO-SECURITY -- TODO-SECURITY
:<|> "count" :> Summary "Count endpoint" :<|> "count" :> Summary "Count endpoint"
...@@ -209,6 +201,10 @@ type GargPrivateAPI' = ...@@ -209,6 +201,10 @@ type GargPrivateAPI' =
:> Capture "graph_id" NodeId :> Capture "graph_id" NodeId
:> GraphAPI :> GraphAPI
-- :<|> "phylo" :> Summary "Phylo endpoint"
-- :> Capture "pylo_id" NodeId
-- :>
-- TODO move to NodeAPI? -- TODO move to NodeAPI?
-- Tree endpoint -- Tree endpoint
:<|> "tree" :> Summary "Tree endpoint" :<|> "tree" :> Summary "Tree endpoint"
......
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