Commit ebcacb43 authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[graphql] remove ethercalc endpoint, use previous frame calc upload

parent 6bae5166
Pipeline #2196 failed with stage
...@@ -6,13 +6,11 @@ import Affjax.RequestHeader as ARH ...@@ -6,13 +6,11 @@ import Affjax.RequestHeader as ARH
import Data.Argonaut.Decode (JsonDecodeError) import Data.Argonaut.Decode (JsonDecodeError)
import Data.Bifunctor (lmap) import Data.Bifunctor (lmap)
import Data.List.Types (NonEmptyList) import Data.List.Types (NonEmptyList)
import Data.Maybe (Maybe)
import Effect (Effect) import Effect (Effect)
import Effect.Aff (Aff) import Effect.Aff (Aff)
import Effect.Class (liftEffect) import Effect.Class (liftEffect)
import Foreign (unsafeToForeign, ForeignError) import Foreign (unsafeToForeign, ForeignError)
import Gargantext.Components.GraphQL.Node (Node, EthercalcCSVDownloadM) import Gargantext.Components.GraphQL.Node (Node)
import Gargantext.Components.GraphQL.Task as GQT
import Gargantext.Components.GraphQL.User (User, UserInfo, UserInfoM) import Gargantext.Components.GraphQL.User (User, UserInfo, UserInfoM)
import Gargantext.Sessions (Session(..)) import Gargantext.Sessions (Session(..))
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
...@@ -74,6 +72,4 @@ type Schema ...@@ -74,6 +72,4 @@ type Schema
} }
type Mutation type Mutation
= { ethercalc_csv_download :: EthercalcCSVDownloadM ==> { a :: Int } --Maybe GQT.AsyncTaskWithType = { update_user_info :: UserInfoM ==> Int }
-- ethercalc_csv_download :: EthercalcCSVDownloadM ==> Int
, update_user_info :: UserInfoM ==> Int }
...@@ -16,7 +16,7 @@ import Gargantext.Config.REST (AffRESTError, RESTError(..)) ...@@ -16,7 +16,7 @@ import Gargantext.Config.REST (AffRESTError, RESTError(..))
import Gargantext.Sessions (Session) import Gargantext.Sessions (Session)
import Gargantext.Types (AsyncTaskWithType(..), AsyncTask(..), AsyncTaskType(..), NodeType) import Gargantext.Types (AsyncTaskWithType(..), AsyncTask(..), AsyncTaskType(..), NodeType)
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
import GraphQL.Client.Args (onlyArgs) import GraphQL.Client.Args (onlyArgs, (=>>))
import GraphQL.Client.Query (mutation) import GraphQL.Client.Query (mutation)
import GraphQL.Client.Variables (withVars) import GraphQL.Client.Variables (withVars)
import Simple.JSON as JSON import Simple.JSON as JSON
...@@ -41,24 +41,3 @@ getUserInfo session id = do ...@@ -41,24 +41,3 @@ getUserInfo session id = do
-- NOTE Contact is at G.C.N.A.U.C.Types -- NOTE Contact is at G.C.N.A.U.C.Types
Just ui -> Right ui Just ui -> Right ui
triggerEthercalcCSVDownload :: Session -> Int -> Int -> Aff (Maybe AsyncTaskWithType)
triggerEthercalcCSVDownload session corpusId nodeId = do
client <- liftEffect $ getClient session
res <- mutation
client
"trigger ethercalc CSV download"
{ ethercalc_csv_download: onlyArgs { corpusId
, nodeId } }
pure Nothing
-- pure $ case res.ethercalc_csv_download of
-- Nothing -> Nothing
-- Just { task: { id, status }, typ } ->
-- case JSON.readJSON typ of
-- Left _ -> Nothing
-- Right typ_ ->
-- case JSON.readJSON status of
-- Left _ -> Nothing
-- Right status_ ->
-- Just $ AsyncTaskWithType { task: AsyncTask { id, status: status_ }
-- , typ: typ_ }
...@@ -26,7 +26,3 @@ nodeParentQuery = { node_parent: { node_id: Var :: _ "id" Int ...@@ -26,7 +26,3 @@ nodeParentQuery = { node_parent: { node_id: Var :: _ "id" Int
, parent_id: unit , parent_id: unit
, type_id: unit } , type_id: unit }
} }
type EthercalcCSVDownloadM
= { corpusId :: Int
, nodeId :: Int }
...@@ -3,29 +3,19 @@ module Gargantext.Components.Nodes.Frame where ...@@ -3,29 +3,19 @@ module Gargantext.Components.Nodes.Frame where
import Gargantext.Prelude import Gargantext.Prelude
import DOM.Simple as DOM import DOM.Simple as DOM
import Data.Array as A
import Data.Either (Either(..))
import Data.Eq.Generic (genericEq) import Data.Eq.Generic (genericEq)
import Data.Generic.Rep (class Generic) import Data.Generic.Rep (class Generic)
import Data.Maybe (Maybe(..)) import Data.Maybe (Maybe(..))
import Data.Newtype (class Newtype) import Data.Newtype (class Newtype)
import Data.Nullable (Nullable, null, toMaybe) import Data.Nullable (Nullable, null, toMaybe)
import Data.Show.Generic (genericShow) import Data.Show.Generic (genericShow)
import Data.Tuple (Tuple(..))
import Effect.Aff (launchAff_)
import Effect.Class (liftEffect)
import Gargantext.Components.FolderView as FV import Gargantext.Components.FolderView as FV
import Gargantext.Components.Forest.Tree.Node.Action.Upload.Types (FileType(..))
import Gargantext.Components.GraphQL.Endpoints (getNodeParent, triggerEthercalcCSVDownload)
import Gargantext.Components.Node (NodePoly(..)) import Gargantext.Components.Node (NodePoly(..))
import Gargantext.Config.REST (RESTError, AffRESTError, logRESTError) import Gargantext.Config.REST (AffRESTError, logRESTError)
import Gargantext.Hooks.Loader (useLoader) import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Routes (SessionRoute(NodeAPI)) import Gargantext.Routes (SessionRoute(NodeAPI))
import Gargantext.Routes as GR import Gargantext.Sessions (Session, get, sessionId)
import Gargantext.Sessions (Session, get, postWwwUrlencoded, sessionId)
import Gargantext.Types (NodeType(..)) import Gargantext.Types (NodeType(..))
import Gargantext.Types as GT
import Gargantext.Utils.EtherCalc as EC
import Gargantext.Utils.JitsiMeet as JM import Gargantext.Utils.JitsiMeet as JM
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Toestand as T2 import Gargantext.Utils.Toestand as T2
...@@ -116,7 +106,6 @@ frameLayoutViewCpt = here.component "frameLayoutView" cpt ...@@ -116,7 +106,6 @@ frameLayoutViewCpt = here.component "frameLayoutView" cpt
_ -> _ ->
pure $ H.div{} pure $ H.div{}
[ FV.backButton {} [] [ FV.backButton {} []
, importIntoListButton { hyperdata: h, nodeId, session } []
, H.div { className : "frame" , H.div { className : "frame"
, rows: "100%,*" } , rows: "100%,*" }
[ -- H.script { src: "https://visio.gargantext.org/external_api.js"} [], [ -- H.script { src: "https://visio.gargantext.org/external_api.js"} [],
...@@ -127,46 +116,6 @@ frameLayoutViewCpt = here.component "frameLayoutView" cpt ...@@ -127,46 +116,6 @@ frameLayoutViewCpt = here.component "frameLayoutView" cpt
] ]
] ]
type ImportIntoListButtonProps =
( hyperdata :: Hyperdata
, nodeId :: Int
, session :: Session )
importIntoListButton :: R2.Component ImportIntoListButtonProps
importIntoListButton = R.createElement importIntoListButtonCpt
importIntoListButtonCpt :: R.Component ImportIntoListButtonProps
importIntoListButtonCpt = here.component "importIntoListButton" cpt where
cpt { hyperdata: Hyperdata { base, frame_id }
, nodeId
, session } _ = do
pure $ H.div { className: "btn btn-default"
, on: { click: onClick } }
[ H.text $ "Import into list" ]
where
onClick _ = do
let url = base <> "/" <> frame_id
--task = GT.AsyncTaskWithType { task, typ: GT.ListCSVUpload }
launchAff_ $ do
-- Get corpus_id
corpusNodes <- getNodeParent session nodeId Corpus
case A.uncons corpusNodes of
Nothing -> liftEffect $ here.log2 "[importIntoListButton] corpusNodes empty" corpusNodes
Just { head: corpusNode } -> do
-- Use that corpus id
_ <- triggerEthercalcCSVDownload session corpusNode.id nodeId
-- eCsv <- EC.downloadCSV base frame_id
-- case eCsv of
-- Left err -> liftEffect $ here.log2 "[importIntoListButton] error with csv" err
-- Right csv -> do
-- let uploadPath = GR.NodeAPI NodeList (Just corpusNode.id) $ GT.asyncTaskTypePath GT.ListCSVUpload
-- eTask :: Either RESTError GT.AsyncTaskWithType <- postWwwUrlencoded
-- session
-- uploadPath
-- [ Tuple "_wf_data" (Just csv.body)
-- , Tuple "_wf_filetype" (Just $ show CSV)
-- , Tuple "_wf_name" (Just frame_id) ]
pure unit
type NodeFrameVisioProps = type NodeFrameVisioProps =
( frame_id :: String ( frame_id :: String
, reload :: T2.ReloadS , reload :: T2.ReloadS
......
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