Mercurial > gemma
changeset 4337:086640dc0fba
stretches: download etd
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Thu, 05 Sep 2019 16:50:00 +0200 |
parents | 45307cf4931a |
children | 08aef146f95a c03449c96437 |
files | client/src/components/stretches/Stretches.vue |
diffstat | 1 files changed, 24 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/client/src/components/stretches/Stretches.vue Thu Sep 05 15:52:43 2019 +0200 +++ b/client/src/components/stretches/Stretches.vue Thu Sep 05 16:50:00 2019 +0200 @@ -48,6 +48,12 @@ /> </button> <button + class="btn btn-xs btn-dark mr-2" + @click="download(stretch)" + > + <font-awesome-icon icon="download" fixed-width /> + </button> + <button class="btn btn-xs btn-dark" @click="deleteStretch(stretch)" > @@ -99,6 +105,7 @@ import { displayError, displayInfo } from "@/lib/errors"; import { HTTP } from "@/lib/http"; import { sortTable } from "@/lib/mixins"; +import { format } from "date-fns"; export default { mixins: [sortTable], @@ -134,6 +141,23 @@ } }, methods: { + download(stretch) { + const { name } = stretch.properties; + HTTP.get(`/data/stretch/shape/${name}`, { + responseType: "blob", + headers: { + "X-Gemma-Auth": localStorage.getItem("token") + } + }).then(response => { + const link = document.createElement("a"); + const now = new Date(); + link.href = window.URL.createObjectURL(response.data); + link.download = `${name}-${format(now, "YYYY-mm-DD")}.zip`; + document.body.appendChild(link); + link.click(); + document.body.removeChild(link); + }); + }, filteredStretches() { return this.stretches.filter(s => { return (s.properties.name + s.properties.source_organization)