Download zip button from scan tab
This commit is contained in:
parent
07b1d3bb7c
commit
361130eea6
1 changed files with 28 additions and 3 deletions
|
|
@ -97,19 +97,30 @@
|
||||||
<button
|
<button
|
||||||
v-if="cancellable"
|
v-if="cancellable"
|
||||||
type="button"
|
type="button"
|
||||||
class="uk-button uk-button-danger uk-margin-remove uk-float-right uk-width-1-1"
|
class="uk-button uk-button-danger uk-width-1-1"
|
||||||
@click="$refs.smartScanTaskSubmitter.terminateTask()"
|
@click="$refs.smartScanTaskSubmitter.terminateTask()"
|
||||||
>
|
>
|
||||||
Cancel
|
Cancel
|
||||||
</button>
|
</button>
|
||||||
|
<div class="uk-margin uk-grid-small uk-child-width-expand" v-if="!cancellable" uk-grid>
|
||||||
<button
|
<button
|
||||||
v-if="!cancellable"
|
|
||||||
type="button"
|
type="button"
|
||||||
class="uk-button uk-button-danger uk-margin-remove uk-float-right uk-width-1-1"
|
class="uk-button"
|
||||||
@click="scanning = false; lastStitchedImage=null;"
|
@click="scanning = false; lastStitchedImage=null;"
|
||||||
>
|
>
|
||||||
Close
|
Close
|
||||||
</button>
|
</button>
|
||||||
|
<task-submitter
|
||||||
|
class="uk-button"
|
||||||
|
submit-label="Download ZIP"
|
||||||
|
:can-terminate="false"
|
||||||
|
:submit-data="{'scan_name': lastScanName}"
|
||||||
|
:button-primary="true"
|
||||||
|
:submit-url="createZipOfScanUri"
|
||||||
|
@response="downloadZipFile"
|
||||||
|
@error="modalError"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<h3 v-if="scanning">
|
<h3 v-if="scanning">
|
||||||
Scan ID: {{ lastScanName }}
|
Scan ID: {{ lastScanName }}
|
||||||
|
|
@ -157,6 +168,9 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
|
createZipOfScanUri() {
|
||||||
|
return this.thingActionUrl("smart_scan", "create_zip_of_scan");
|
||||||
|
},
|
||||||
backendOK() {
|
backendOK() {
|
||||||
return this.thingAvailable("smart_scan");
|
return this.thingAvailable("smart_scan");
|
||||||
},
|
},
|
||||||
|
|
@ -193,6 +207,17 @@ export default {
|
||||||
this.lastScanName = await this.readThingProperty("smart_scan", "latest_scan_name");
|
this.lastScanName = await this.readThingProperty("smart_scan", "latest_scan_name");
|
||||||
setTimeout(this.pollScan, 1000); // keep rescheduling until it's stopped
|
setTimeout(this.pollScan, 1000); // keep rescheduling until it's stopped
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
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