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
efb4c8a0
Commit
efb4c8a0
authored
Oct 05, 2021
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[upload] implement zip file upload
parent
41ecf1e2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
21 deletions
+20
-21
Upload.purs
...Gargantext/Components/Forest/Tree/Node/Action/Upload.purs
+14
-16
Types.purs
...text/Components/Forest/Tree/Node/Action/Upload/Types.purs
+4
-5
Types.purs
src/Gargantext/Types.purs
+2
-0
No files found.
src/Gargantext/Components/Forest/Tree/Node/Action/Upload.purs
View file @
efb4c8a0
...
...
@@ -123,6 +123,7 @@ uploadFileViewCpt = here.component "uploadFileView" cpt
, WOS
, PresseRIS
, Arbitrary
, ZIP
] CSV setFileType' show
]
]
...
...
@@ -334,31 +335,28 @@ uploadFile session NodeList id JSON { mName, contents } = do
task <- post session url body
pure $ GT.AsyncTaskWithType { task, typ: GT.Form }
-}
uploadFile { contents, fileType: CSV, id, nodeType: NodeList, mName, session } = do
let url = GR.NodeAPI NodeList (Just id) $ GT.asyncTaskTypePath GT.ListCSVUpload
let body = [ Tuple "_wtf_data" (Just contents)
, Tuple "_wtf_filetype" (Just $ show NodeList)
, Tuple "_wtf_name" mName ]
eTask <- postWwwUrlencoded session url body
pure $ (\task -> GT.AsyncTaskWithType { task, typ: GT.ListCSVUpload }) <$> eTask
uploadFile { contents, fileType, id, nodeType, mName, session } = do
-- contents <- readAsText blob
eTask :: Either RESTError GT.AsyncTask <- postWwwUrlencoded session p body
Params
eTask :: Either RESTError GT.AsyncTask <- postWwwUrlencoded session p body
pure $ (\task -> GT.AsyncTaskWithType { task, typ }) <$> eTask
--postMultipartFormData session p fileContents
where
Tuple typ p = case nodeType of
Corpus -> Tuple GT.CorpusFormUpload (GR.NodeAPI nodeType (Just id) $ GT.asyncTaskTypePath GT.CorpusFormUpload)
Annuaire -> Tuple GT.UploadFile (GR.NodeAPI nodeType (Just id) "annuaire")
NodeList -> case fileType of
JSON -> Tuple GT.ListUpload (GR.NodeAPI nodeType (Just id) $ GT.asyncTaskTypePath GT.ListUpload)
_ -> Tuple GT.UploadFile (GR.NodeAPI nodeType (Just id) "")
_ -> Tuple GT.UploadFile (GR.NodeAPI nodeType (Just id) "")
bodyParams = [ Tuple "_wf_data" (Just contents)
, Tuple "_wf_filetype" (Just $ show fileType)
, Tuple "_wf_name" mName
]
csvBodyParams = [ Tuple "_wtf_data" (Just contents)
, Tuple "_wtf_filetype" (Just $ show NodeList)
, Tuple "_wtf_name" mName ]
(typ /\ p /\ body) = case nodeType of
Corpus -> GT.CorpusFormUpload /\ (GR.NodeAPI nodeType (Just id) $ GT.asyncTaskTypePath GT.CorpusFormUpload) /\ bodyParams
Annuaire -> GT.UploadFile /\ (GR.NodeAPI nodeType (Just id) "annuaire") /\ bodyParams
NodeList -> case fileType of
JSON -> GT.ListUpload /\ (GR.NodeAPI nodeType (Just id) $ GT.asyncTaskTypePath GT.ListUpload) /\ bodyParams
CSV -> GT.ListCSVUpload /\ (GR.NodeAPI NodeList (Just id) $ GT.asyncTaskTypePath GT.ListCSVUpload) /\ csvBodyParams
_ -> GT.UploadFile /\ (GR.NodeAPI nodeType (Just id) "") /\ bodyParams
_ -> GT.UploadFile /\ (GR.NodeAPI nodeType (Just id) "") /\ bodyParams
uploadArbitraryFile :: Session
...
...
src/Gargantext/Components/Forest/Tree/Node/Action/Upload/Types.purs
View file @
efb4c8a0
...
...
@@ -11,13 +11,11 @@ import Web.File.FileReader.Aff (readAsText)
import Gargantext.Prelude
data FileType = CSV | CSV_HAL | WOS | PresseRIS | Arbitrary | JSON
data FileType = CSV | CSV_HAL | WOS | PresseRIS | Arbitrary | JSON
| ZIP
derive instance Generic FileType _
instance Eq FileType where
eq = genericEq
instance Show FileType where
show = genericShow
instance Eq FileType where eq = genericEq
instance Show FileType where show = genericShow
instance Read FileType where
read :: String -> Maybe FileType
read "Arbitrary" = Just Arbitrary
...
...
@@ -26,6 +24,7 @@ instance Read FileType where
read "PresseRIS" = Just PresseRIS
read "WOS" = Just WOS
read "JSON" = Just JSON
read "ZIP" = Just ZIP
read _ = Nothing
...
...
src/Gargantext/Types.purs
View file @
efb4c8a0
...
...
@@ -659,6 +659,7 @@ data AsyncTaskType = AddNode
| GraphRecompute
| ListUpload
| ListCSVUpload -- legacy v3 CSV upload for lists
| ListZIPUpload
| Query
| UpdateNgramsCharts
| UpdateNode
...
...
@@ -679,6 +680,7 @@ asyncTaskTypePath CorpusFormUpload = "add/form/async/"
asyncTaskTypePath GraphRecompute = "async/recompute/"
asyncTaskTypePath ListUpload = "add/form/async/"
asyncTaskTypePath ListCSVUpload = "csv/add/form/async/"
asyncTaskTypePath ListZIPUpload = "zip/add/form/async/"
asyncTaskTypePath Query = "query/"
asyncTaskTypePath UpdateNgramsCharts = "ngrams/async/charts/update/"
asyncTaskTypePath UpdateNode = "update/"
...
...
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