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