Generate zip files before download
Previously, zip files were only downloaded if they already existed. Now, they are created with an action, then downloaded from the result. Chrome now insists on downloading the files as `output.zip`, I can't see why this has changed, but perhaps it's related to the security warning. This seems to be specific to zip files.
This commit is contained in:
parent
b35db02f34
commit
50cf8e6f78
1 changed files with 25 additions and 7 deletions
|
|
@ -42,13 +42,15 @@
|
|||
<div class="uk-card">
|
||||
<div class="uk-card-body">
|
||||
<h3 class="uk-card-title">{{ item.name }}</h3>
|
||||
<a
|
||||
:href="`${scansUri}/${item.name}/images.zip`"
|
||||
:download="`${item.name}_images.zip`"
|
||||
class="uk-button uk-button-default"
|
||||
>
|
||||
Download images
|
||||
</a>
|
||||
<task-submitter
|
||||
submit-label="Download ZIP"
|
||||
:can-terminate="false"
|
||||
:submit-data="{'scan_name': item.name}"
|
||||
:button-primary="true"
|
||||
:submit-url="createZipOfScanUri"
|
||||
@response="downloadZipFile"
|
||||
@error="modalError"
|
||||
/>
|
||||
<button class="uk-button" @click="deleteScan(item.name)">
|
||||
Delete
|
||||
</button>
|
||||
|
|
@ -73,9 +75,11 @@
|
|||
|
||||
<script>
|
||||
import axios from "axios";
|
||||
import taskSubmitter from '../genericComponents/taskSubmitter.vue';
|
||||
|
||||
// Export main app
|
||||
export default {
|
||||
components: { taskSubmitter },
|
||||
name: "ScanListContent",
|
||||
|
||||
data: function() {
|
||||
|
|
@ -92,6 +96,9 @@ export default {
|
|||
"readproperty",
|
||||
true
|
||||
);
|
||||
},
|
||||
createZipOfScanUri() {
|
||||
return this.thingActionUrl("smart_scan", "create_zip_of_scan");
|
||||
}
|
||||
},
|
||||
|
||||
|
|
@ -186,6 +193,17 @@ export default {
|
|||
// if the confirmation was cancelled, it's rejected with null error
|
||||
if (e) this.modalError(e);
|
||||
}
|
||||
},
|
||||
async downloadZipFile(response) {
|
||||
const scan_name = response.input.scan_name;
|
||||
const filename = `${scan_name}_images.zip`
|
||||
const url = response.output.href;
|
||||
const link = document.createElement("a");
|
||||
link.href = url;
|
||||
link.setAttribute("download", filename);
|
||||
console.log(link);
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue