Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
purescript-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Grégoire Locqueville
purescript-gargantext
Commits
e004b064
Commit
e004b064
authored
Nov 26, 2021
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[graphql] ethercalc csv download graphql frontend
parent
7ea0fe74
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
65 additions
and
23 deletions
+65
-23
GraphQL.purs
src/Gargantext/Components/GraphQL.purs
+6
-5
Endpoints.purs
src/Gargantext/Components/GraphQL/Endpoints.purs
+25
-2
Node.purs
src/Gargantext/Components/GraphQL/Node.purs
+4
-0
Task.purs
src/Gargantext/Components/GraphQL/Task.purs
+14
-0
Contact.purs
src/Gargantext/Components/Nodes/Annuaire/User/Contact.purs
+2
-3
Frame.purs
src/Gargantext/Components/Nodes/Frame.purs
+14
-13
No files found.
src/Gargantext/Components/GraphQL.purs
View file @
e004b064
module Gargantext.Components.GraphQL where
import Gargantext.Prelude
import Affjax.RequestHeader as ARH
import Data.Argonaut.Decode (JsonDecodeError)
import Data.Bifunctor (lmap)
import Data.List.Types (NonEmptyList)
import Data.Maybe (Maybe)
import Effect (Effect)
import Effect.Aff (Aff)
import Effect.Class (liftEffect)
import Foreign (unsafeToForeign, ForeignError)
import Gargantext.Components.GraphQL.Node (Node)
import Gargantext.Components.GraphQL.Node (
EthercalcCSVDownloadM,
Node)
import Gargantext.Components.GraphQL.User (User, UserInfo, UserInfoM)
import Gargantext.Components.GraphQL.Task (AsyncTaskWithType)
import Gargantext.Prelude
import Gargantext.Sessions (Session(..))
import Gargantext.Types (NodeType)
import Gargantext.Utils.Reactix as R2
import GraphQL.Client.Args (type (==>))
import GraphQL.Client.BaseClients.Urql (UrqlClient, createClient)
...
...
@@ -73,4 +73,5 @@ type Schema
}
type Mutation
= { update_user_info :: UserInfoM ==> Int }
= { ethercalc_csv_download :: EthercalcCSVDownloadM ==> Maybe AsyncTaskWithType
, update_user_info :: UserInfoM ==> Int }
src/Gargantext/Components/GraphQL/Endpoints.purs
View file @
e004b064
...
...
@@ -5,15 +5,18 @@ import Data.Either (Either(..))
import Data.Maybe (Maybe(..))
import Effect.Aff (Aff)
import Effect.Class (liftEffect)
import Gargantext.Components.GraphQL (queryGql)
import Gargantext.Components.GraphQL (
getClient,
queryGql)
import Gargantext.Components.GraphQL.Node
import Gargantext.Components.GraphQL.User
import Gargantext.Config.REST (AffRESTError, RESTError(..))
import Gargantext.Prelude
import Gargantext.Sessions (Session)
import Gargantext.Types (NodeType)
import Gargantext.Types (
AsyncTaskWithType(..), AsyncTask(..), AsyncTaskType(..),
NodeType)
import Gargantext.Utils.Reactix as R2
import GraphQL.Client.Args (onlyArgs)
import GraphQL.Client.Query (mutation)
import GraphQL.Client.Variables (withVars)
import Simple.JSON as JSON
here :: R2.Here
here = R2.here "Gargantext.Components.GraphQL.Endpoints"
...
...
@@ -34,3 +37,23 @@ getUserInfo session id = do
Nothing -> Left (CustomError $ "user with id " <> show id <> " not found")
-- NOTE Contact is at G.C.N.A.U.C.Types
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 $ 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_ }
src/Gargantext/Components/GraphQL/Node.purs
View file @
e004b064
...
...
@@ -27,3 +27,7 @@ nodeParentQuery = { node_parent: { node_id: Var :: _ "id" Int
, parent_id: unit
, type_id: unit }
}
type EthercalcCSVDownloadM
= { corpusId :: Int
, nodeId :: Int }
src/Gargantext/Components/GraphQL/Task.purs
0 → 100644
View file @
e004b064
module Gargantext.Components.GraphQL.Task where
import Gargantext.Types (AsyncTaskID)
type AsyncTaskStatus = String
type AsyncTaskType = String
type AsyncTask =
{ id :: AsyncTaskID
, status :: AsyncTaskStatus}
type AsyncTaskWithType =
{ task :: AsyncTask
, typ :: AsyncTaskType }
src/Gargantext/Components/Nodes/Annuaire/User/Contact.purs
View file @
e004b064
...
...
@@ -33,7 +33,7 @@ import Gargantext.Types (NodeType(..))
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Toestand as T2
import GraphQL.Client.Args (IgnoreArg(..), OrArg(..), onlyArgs)
import GraphQL.Client.Query (mutation
Opts
)
import GraphQL.Client.Query (mutation)
import Reactix as R
import Reactix.DOM.HTML as H
import Record as Record
...
...
@@ -198,8 +198,7 @@ saveContactHyperdata session id = put session (Routes.NodeAPI Node (Just id) "")
saveUserInfo :: Session -> Int -> UserInfo -> AffRESTError Int
saveUserInfo session id ui = do
client <- liftEffect $ getClient session
res <- mutationOpts
(\m -> m)
res <- mutation
client
"update user_info"
{ update_user_info: onlyArgs { ui_id: id
...
...
src/Gargantext/Components/Nodes/Frame.purs
View file @
e004b064
...
...
@@ -16,7 +16,7 @@ import Effect.Aff (launchAff_)
import Effect.Class (liftEffect)
import Gargantext.Components.FolderView as FV
import Gargantext.Components.Forest.Tree.Node.Action.Upload.Types (FileType(..))
import Gargantext.Components.GraphQL.Endpoints (getNodeParent)
import Gargantext.Components.GraphQL.Endpoints (getNodeParent
, triggerEthercalcCSVDownload
)
import Gargantext.Components.Node (NodePoly(..))
import Gargantext.Config.REST (RESTError, AffRESTError, logRESTError)
import Gargantext.Hooks.Loader (useLoader)
...
...
@@ -153,17 +153,18 @@ importIntoListButtonCpt = here.component "importIntoListButton" cpt where
Nothing -> liftEffect $ here.log2 "[importIntoListButton] corpusNodes empty" corpusNodes
Just { head: corpusNode } -> do
-- Use that corpus id
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) ]
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 =
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment