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:
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<nav>
|
||||
<nav :class="{active}">
|
||||
<router-link class="action" to="/files/" aria-label="My Files" title="My Files">
|
||||
<i class="material-icons">folder</i>
|
||||
<span>My Files</span>
|
||||
@@ -48,7 +48,8 @@ export default {
|
||||
name: 'sidebar',
|
||||
data: () => {
|
||||
return {
|
||||
plugins: []
|
||||
plugins: [],
|
||||
active: false
|
||||
}
|
||||
},
|
||||
computed: mapState(['user']),
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
<script>
|
||||
import {mapGetters, mapState} from 'vuex'
|
||||
import api from '@/utils/api'
|
||||
|
||||
export default {
|
||||
name: 'download',
|
||||
@@ -21,24 +22,18 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
download: function (format) {
|
||||
let uri = this.$route.params[0]
|
||||
uri = this.$store.state.baseURL + '/api/download/' + uri
|
||||
uri += `?token=${this.$store.state.jwt}`
|
||||
uri += `&format=${format}`
|
||||
|
||||
if (this.selectedCount > 0) {
|
||||
let files = ''
|
||||
if (this.selectedCount === 0) {
|
||||
api.download(format, this.$route.path)
|
||||
} else {
|
||||
let files = []
|
||||
|
||||
for (let i of this.selected) {
|
||||
files += this.req.items[i].url.replace(window.location.pathname, '') + ','
|
||||
files.push(this.req.items[i].url)
|
||||
}
|
||||
|
||||
files = files.substring(0, files.length - 1)
|
||||
files = encodeURIComponent(files)
|
||||
uri += `&files=${files}`
|
||||
api.download(format, ...files)
|
||||
}
|
||||
|
||||
window.open(uri)
|
||||
this.$store.commit('closePrompts')
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user