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
This commit is contained in:
Henrique Dias
2017-07-03 21:33:21 +01:00
parent deef004513
commit 5a992f1785
5 changed files with 51 additions and 20 deletions

View File

@@ -8,20 +8,23 @@
<script>
import {mapGetters, mapState} from 'vuex'
import api from '@/utils/api'
export default {
name: 'download-button',
computed: {
...mapState(['req']),
...mapState(['req', 'selected']),
...mapGetters(['selectedCount'])
},
methods: {
download: function (event) {
if (this.req.kind !== 'listing') {
let url = this.$route.params[0]
url = this.$store.state.baseURL + '/api/download/' + url
url += '?token=' + this.$store.state.jwt
window.open(url)
api.download(null, this.$route.path)
return
}
if (this.selectedCount === 1) {
api.download(null, this.req.items[this.selected[0]].url)
return
}