Download centralized on api.js

Former-commit-id: 58fd027bfbc32198c39d87fe7e575229d33a65c8 [formerly 17779d3221cb765d4ce3a5aeccb551ddbfc56f19] [formerly 2f28a4e0bb119490a69968e3c6df29aa3779cc11 [formerly c6348931e0]]
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
+28 -1
View File
@@ -141,6 +141,32 @@ function search (url, search, onmessage, onclose) {
conn.onclose = onclose
}
function download (format, ...files) {
let url = `${store.state.baseURL}/api/download`
if (files.length === 1) {
url += removePrefix(files[0]) + '?'
} else {
let arg = ''
for (let file of files) {
arg += removePrefix(file) + ','
}
arg = arg.substring(0, arg.length - 1)
arg = encodeURIComponent(arg)
url += `/?files=${arg}&`
}
url += `token=${store.state.jwt}`
if (format !== null) {
url += `&format=${format}`
}
window.open(url)
}
export default {
delete: rm,
fetch,
@@ -148,5 +174,6 @@ export default {
move,
put,
command,
search
search,
download
}