Commit 5f98197e authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[upload] more upload work

parent 6fc84226
......@@ -270,7 +270,7 @@ performAction = performAction' where
performAction' (SharePublic { params }) p = sharePublic params p
performAction' (AddContact params) p = addContact params p
performAction' (AddNode name nodeType) p = addNode' name nodeType p
performAction' (UploadFile nodeType fileType mName blob) p = uploadFile' nodeType fileType mName blob p
performAction' (UploadFile nodeType fileType mName contents) p = uploadFile' nodeType fileType mName contents p
performAction' (UploadArbitraryFile mName blob) p = uploadArbitraryFile' mName blob p
performAction' DownloadNode _ = liftEffect $ log "[performAction] DownloadNode"
performAction' (MoveNode {params}) p = moveNode params p
......@@ -316,8 +316,8 @@ performAction = performAction' where
addContact params p@{ nodeId: id } =
void $ Contact.contactReq p.session id params
uploadFile' nodeType fileType mName blob p@{ tasks, nodeId: id } = do
task <- uploadFile p.session nodeType id fileType {mName, blob}
uploadFile' nodeType fileType mName contents p@{ tasks, nodeId: id } = do
task <- uploadFile p.session nodeType id fileType {mName, contents}
liftEffect $ do
GAT.insert id task tasks
log2 "[performAction] UploadFile, uploaded, task:" task
......
......@@ -276,7 +276,7 @@ performAction (ShareTeam username) p = shareTeam username p
performAction (SharePublic { params }) p = sharePublic params p
performAction (AddContact params) p = addContact params p
performAction (AddNode name nodeType) p = addNode' name nodeType p
performAction (UploadFile nodeType fileType mName blob) p = uploadFile' nodeType fileType mName blob p
performAction (UploadFile nodeType fileType mName contents) p = uploadFile' nodeType fileType mName contents p
performAction (UploadArbitraryFile mName blob) p = uploadArbitraryFile' mName blob p
performAction DownloadNode _ = liftEffect $ log "[performAction] DownloadNode"
performAction (MoveNode {params}) p = moveNode params p
......
......@@ -28,7 +28,7 @@ data Action = AddNode String GT.NodeType
| RenameNode String
| UpdateNode UpdateNodeParams
| DoSearch GT.AsyncTaskWithType
| UploadFile GT.NodeType FileType (Maybe String) UploadFileBlob
| UploadFile GT.NodeType FileType (Maybe String) String
| UploadArbitraryFile (Maybe String) UploadFileBlob
| DownloadNode
| RefreshTree
......
......@@ -202,8 +202,9 @@ uploadButtonCpt = here.component "uploadButton" cpt
case fileType' of
Arbitrary ->
dispatch $ UploadArbitraryFile (Just name) blob
_ ->
dispatch $ UploadFile nodeType fileType' (Just name) blob
_ -> do
contents <- readAsText blob
dispatch $ UploadFile nodeType fileType' (Just name) contents
liftEffect $ do
T.write_ Nothing mFile
T.write_ CSV fileType
......@@ -313,10 +314,10 @@ uploadFile :: Session
-> GT.NodeType
-> ID
-> FileType
-> {blob :: UploadFileBlob, mName :: Maybe String}
-> {contents :: String, mName :: Maybe String}
-> Aff GT.AsyncTaskWithType
uploadFile session nodeType id fileType {mName, blob: UploadFileBlob blob} = do
contents <- readAsText blob
uploadFile session nodeType id fileType { mName, contents } = do
-- contents <- readAsText blob
task <- postWwwUrlencoded session p (bodyParams contents)
pure $ GT.AsyncTaskWithType {task, typ: GT.Form}
--postMultipartFormData session p fileContents
......@@ -453,6 +454,7 @@ uploadTermButtonCpt = here.component "uploadTermButton" cpt
onClick mFile' uploadType' e = do
let {name, blob} = unsafePartial $ fromJust mFile'
void $ launchAff do
_ <- dispatch $ UploadFile nodeType uploadType' (Just name) blob
contents <- readAsText blob
_ <- dispatch $ UploadFile nodeType uploadType' (Just name) contents
liftEffect $ do
T.write_ Nothing mFile
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