Skip to content
Snippets Groups Projects
Commit 231526ba authored by vkovtun's avatar vkovtun
Browse files

BIS-753: Fixed binary data processing for the new DSS widget. Added loading...

BIS-753: Fixed binary data processing for the new DSS widget. Added loading popup for file download.
parent c5724e57
No related branches found
No related tags found
1 merge request!40SSDM-13578 : 2PT : Database and V3 Implementation - include the new AFS "free"...
...@@ -59,18 +59,17 @@ _DataStoreServerInternal.prototype.sendHttpRequest = function(httpMethod, conten ...@@ -59,18 +59,17 @@ _DataStoreServerInternal.prototype.sendHttpRequest = function(httpMethod, conten
switch (contentType) { switch (contentType) {
case 'text/plain': case 'text/plain':
// Fall through.
case 'application/json':
response.text().then((blobResponse) => callback(blobResponse)) response.text().then((blobResponse) => callback(blobResponse))
.catch((error) => alert(error)); .catch((error) => alert(error));
break; break;
case 'application/octet-stream': case 'application/octet-stream':
callback(response); callback(response);
break; break;
case 'application/json': default:
response.text().then((blobResponse) => callback(blobResponse)) throw new Error("Client error HTTP response. Unsupported content-type received.");
.catch((error) => alert(error));
break;
} }
} else if(status >= 400 && status < 500) { } else if(status >= 400 && status < 500) {
let response = JSON.parse(xhr.responseText); let response = JSON.parse(xhr.responseText);
alert(response.error[1].message); alert(response.error[1].message);
......
...@@ -165,7 +165,8 @@ export default class DataBrowserController extends ComponentController { ...@@ -165,7 +165,8 @@ export default class DataBrowserController extends ComponentController {
const dataArray = [] const dataArray = []
while (offset < file.size) { while (offset < file.size) {
dataArray.push(await this._download(file, offset)) const blob = await this._download(file, offset)
dataArray.push(await blob.arrayBuffer())
offset += MAX_READ_SIZE_IN_BYTES offset += MAX_READ_SIZE_IN_BYTES
} }
......
...@@ -36,7 +36,7 @@ import Popover from '@material-ui/core/Popover' ...@@ -36,7 +36,7 @@ import Popover from '@material-ui/core/Popover'
import InputDialog from '@src/js/components/common/dialog/InputDialog.jsx' import InputDialog from '@src/js/components/common/dialog/InputDialog.jsx'
import ConfirmationDialog from '@src/js/components/common/dialog/ConfirmationDialog.jsx' import ConfirmationDialog from '@src/js/components/common/dialog/ConfirmationDialog.jsx'
import LocationDialog from '@src/js/components/database/data-browser/LocationDialog.jsx' import LocationDialog from '@src/js/components/database/data-browser/LocationDialog.jsx'
import LoadingDialog from "@src/js/components/common/loading/LoadingDialog.jsx"; import LoadingDialog from '@src/js/components/common/loading/LoadingDialog.jsx'
const color = 'default' const color = 'default'
const iconButtonSize = 'medium' const iconButtonSize = 'medium'
...@@ -187,13 +187,19 @@ class LeftToolbar extends React.Component { ...@@ -187,13 +187,19 @@ class LeftToolbar extends React.Component {
async handleDownload() { async handleDownload() {
const { multiselectedFiles } = this.props const { multiselectedFiles } = this.props
const file = multiselectedFiles.values().next().value; const file = multiselectedFiles.values().next().value;
const dataArray = await this.controller.download(file)
const blob = new Blob(dataArray, { type: "application/octet-stream" }) try {
const link = document.createElement('a') this.setState({ loading: true })
link.href = window.URL.createObjectURL(blob)
link.download = file.name const dataArray = await this.controller.download(file)
link.click() const blob = new Blob(dataArray, { type: "application/octet-stream" })
const link = document.createElement('a')
link.href = window.URL.createObjectURL(blob)
link.download = file.name
link.click()
} finally {
this.setState({ loading: false })
}
} }
renderNoSelectionContextToolbar() { renderNoSelectionContextToolbar() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment