fixed bulk action export action

This commit is contained in:
Cüneyt Şentürk 2021-05-23 18:45:33 +03:00
parent 4e924ab46d
commit e6e74a44b7

View File

@ -106,37 +106,43 @@ export default class BulkAction {
})); }));
download_promise.then((response) => { download_promise.then((response) => {
const blob = new Blob([response.data], {type: response.data.type}); if (response.data.type != 'application/json') {
const url = window.URL.createObjectURL(blob); const blob = new Blob([response.data], {type: response.data.type});
const link = document.createElement('a'); const url = window.URL.createObjectURL(blob);
const link = document.createElement('a');
link.href = url; link.href = url;
const contentDisposition = response.headers['content-disposition']; const contentDisposition = response.headers['content-disposition'];
let fileName = 'unknown'; let fileName = 'unknown';
if (contentDisposition) { if (contentDisposition) {
const fileNameMatch = contentDisposition.match(/filename=(.+)/); const fileNameMatch = contentDisposition.match(/filename=(.+)/);
if (fileNameMatch.length === 2) { if (fileNameMatch.length === 2) {
fileName = fileNameMatch[1]; fileName = fileNameMatch[1];
}
} }
link.setAttribute('download', fileName);
document.body.appendChild(link);
link.click();
link.remove();
window.URL.revokeObjectURL(url);
this.loading = false;
this.modal = false;
this.value = '*';
this.clear();
return;
} }
link.setAttribute('download', fileName); window.location.reload(false);
document.body.appendChild(link);
link.click();
link.remove();
window.URL.revokeObjectURL(url);
this.loading = false;
this.modal = false;
this.value = '*';
this.clear();
}); });
break; break;
default: default: