Henrique Dias 5a992f1785 Download centralized on api.js
Former-commit-id: 58fd027bfbc32198c39d87fe7e575229d33a65c8 [formerly 17779d3221cb765d4ce3a5aeccb551ddbfc56f19] [formerly 2f28a4e0bb119490a69968e3c6df29aa3779cc11 [formerly c6348931e0dcbc77e6cfea3d393a5a9c4c5bb1c7]]
Former-commit-id: 70b4148b16b7c8ac43dc6cb3f38fe5e7062c2af8 [formerly fa369137715c436e5f110b931386f4f6556e9733]
Former-commit-id: 760257fd5ce7b37f48c3848042fe33a4fdd7a905
2017-07-03 21:33:21 +01:00

42 lines
1.0 KiB
Vue

<template>
<div class="prompt" id="download">
<h3>Download files</h3>
<p>Choose the format you want to download.</p>
<button @click="download('zip')" autofocus>zip</button>
<button @click="download('tar')" autofocus>tar</button>
<button @click="download('targz')" autofocus>tar.gz</button>
<button @click="download('tarbz2')" autofocus>tar.bz2</button>
<button @click="download('tarxz')" autofocus>tar.xz</button>
</div>
</template>
<script>
import {mapGetters, mapState} from 'vuex'
import api from '@/utils/api'
export default {
name: 'download',
computed: {
...mapState(['selected', 'req']),
...mapGetters(['selectedCount'])
},
methods: {
download: function (format) {
if (this.selectedCount === 0) {
api.download(format, this.$route.path)
} else {
let files = []
for (let i of this.selected) {
files.push(this.req.items[i].url)
}
api.download(format, ...files)
}
this.$store.commit('closePrompts')
}
}
}
</script>