Commit 027ae537 authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

tree: create new corpus button

- some Tree.purs code cleanup (imports)
- file upload via drop onto tree node
parent f8fa5702
...@@ -570,6 +570,16 @@ ...@@ -570,6 +570,16 @@
"repo": "https://github.com/purescript/purescript-distributive.git", "repo": "https://github.com/purescript/purescript-distributive.git",
"version": "v4.0.0" "version": "v4.0.0"
}, },
"dom-filereader": {
"dependencies": [
"aff",
"arraybuffer-types",
"web-file",
"web-html"
],
"repo": "https://github.com/nwolverson/purescript-dom-filereader",
"version": "v5.0.0"
},
"dom-indexed": { "dom-indexed": {
"dependencies": [ "dependencies": [
"media-types", "media-types",
......
...@@ -173,6 +173,15 @@ let additions = ...@@ -173,6 +173,15 @@ let additions =
] ]
"https://github.com/irresponsible/purescript-dom-simple" "https://github.com/irresponsible/purescript-dom-simple"
"v0.2.4" "v0.2.4"
, dom-filereader =
mkPackage
[ "aff"
, "arraybuffer-types"
, "web-file"
, "web-html"
]
"https://github.com/nwolverson/purescript-dom-filereader"
"v5.0.0"
, reactix = , reactix =
mkPackage mkPackage
[ "console" [ "console"
......
...@@ -3,30 +3,31 @@ ...@@ -3,30 +3,31 @@
"set": "local", "set": "local",
"source": ".psc-package", "source": ".psc-package",
"depends": [ "depends": [
"numbers", "affjax",
"spec-quickcheck",
"spec-discovery",
"uint",
"js-timers",
"psci-support",
"css",
"generics-rep",
"maybe",
"routing",
"foreign-object",
"argonaut", "argonaut",
"console",
"css",
"dom-filereader",
"dom-simple",
"effect", "effect",
"web-html", "foreign-object",
"thermite", "generics-rep",
"integers", "integers",
"random", "js-timers",
"affjax", "maybe",
"console", "numbers",
"strings",
"string-parsers",
"prelude", "prelude",
"dom-simple", "psci-support",
"random",
"reactix", "reactix",
"uri" "routing",
"spec-discovery",
"spec-quickcheck",
"string-parsers",
"strings",
"thermite",
"uint",
"uri",
"web-html"
] ]
} }
This diff is collapsed.
module Gargantext.Config.REST where module Gargantext.Config.REST where
import Gargantext.Prelude
import Affjax (defaultRequest, printResponseFormatError, request) import Affjax (defaultRequest, printResponseFormatError, request)
import Affjax.RequestBody (RequestBody(..)) import Affjax.RequestBody (RequestBody(..), string)
import Affjax.RequestHeader (RequestHeader(..)) import Affjax.RequestHeader (RequestHeader(..))
import Affjax.ResponseFormat as ResponseFormat import Affjax.ResponseFormat as ResponseFormat
import Data.Argonaut (class DecodeJson, decodeJson, class EncodeJson, encodeJson) import Data.Argonaut (class DecodeJson, decodeJson, class EncodeJson, encodeJson)
import Data.Either (Either(..)) import Data.Either (Either(..))
import Data.HTTP.Method (Method(..)) import Data.HTTP.Method (Method(..))
import Data.Maybe (Maybe(..)) import Data.Maybe (Maybe(..))
import Data.MediaType.Common (applicationJSON) import Data.MediaType.Common (applicationFormURLEncoded, applicationJSON)
import Effect.Aff (Aff, throwError) import Effect.Aff (Aff, throwError)
import Effect.Exception (error) import Effect.Exception (error)
import Gargantext.Prelude
send :: forall a b. EncodeJson a => DecodeJson b => send :: forall a b. EncodeJson a => DecodeJson b =>
Method -> String -> Maybe a -> Aff b Method -> String -> Maybe a -> Aff b
send m url reqbody = do send m url reqbody = do
...@@ -58,3 +58,26 @@ deleteWithBody url = send DELETE url <<< Just ...@@ -58,3 +58,26 @@ deleteWithBody url = send DELETE url <<< Just
post :: forall a b. EncodeJson a => DecodeJson b => String -> a -> Aff b post :: forall a b. EncodeJson a => DecodeJson b => String -> a -> Aff b
post url = send POST url <<< Just post url = send POST url <<< Just
postWwwUrlencoded :: forall b. DecodeJson b => String -> String -> Aff b
postWwwUrlencoded url body = do
affResp <- request $ defaultRequest
{ url = url
, responseFormat = ResponseFormat.json
, method = Left POST
, headers = [ ContentType applicationFormURLEncoded
, Accept applicationJSON
]
, content = Just $ string body
}
case affResp.body of
Left err -> do
_ <- logs $ printResponseFormatError err
throwError $ error $ printResponseFormatError err
Right json -> do
--_ <- logs $ show json.status
--_ <- logs $ show json.headers
--_ <- logs $ show json.body
case decodeJson json of
Left err -> throwError $ error $ "decodeJson affResp.body: " <> err
Right b -> pure b
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