- zip implementation for users

This commit is contained in:
Peter Papp
2020-12-13 17:49:44 +01:00
parent 874b4bb768
commit 11873d06ff
16 changed files with 335 additions and 129 deletions
@@ -11,7 +11,7 @@
{{ $t('context_menu.move') }}
</div>
</li>
<li class="menu-option" @click="shareItem" v-if="$checkPermission('master')">
<li class="menu-option" @click="shareItem" v-if="$checkPermission('master')">
<div class="icon">
<link-icon size="17"></link-icon>
</div>
@@ -131,12 +131,12 @@
}}
</div>
</li>
<li class="menu-option" @click="shareCancel" v-if="this.fileInfoDetail.length > 1 && !multiSelectContextMenu">
<li class="menu-option" @click="shareCancel" v-if="this.fileInfoDetail.length > 1 && !multiSelectContextMenu">
<div class="icon">
<link-icon size="17"></link-icon>
</div>
<div class="text-label">
{{$t('context_menu.share_cancel')}}
{{ $t('context_menu.share_cancel') }}
</div>
</li>
<li class="menu-option" @click="deleteItem">
@@ -365,18 +365,18 @@ export default {
TrashIcon,
LinkIcon,
StarIcon,
EyeIcon,
EyeIcon
},
computed: {
...mapGetters(['user', 'fileInfoDetail']),
multiSelectContextMenu() {
// If is context Menu open on multi selected items open just options for the multi selected items
if(this.fileInfoDetail.length > 1 && this.fileInfoDetail.includes(this.item)) {
if (this.fileInfoDetail.length > 1 && this.fileInfoDetail.includes(this.item)) {
return false
}
// If is context Menu open for the non selected item open options for the single item
if(this.fileInfoDetail.length < 2 || !this.fileInfoDetail.includes(this.item)) {
if (this.fileInfoDetail.length < 2 || !this.fileInfoDetail.includes(this.item)) {
return true
}
},
@@ -399,7 +399,7 @@ export default {
},
isInFavourites() {
return this.favourites.find((el) => el.unique_id == this.item.unique_id)
},
}
},
data() {
return {
@@ -436,41 +436,26 @@ export default {
this.favourites &&
!this.favourites.find((el) => el.unique_id == this.item.unique_id)
) {
//Add to favourite folder that is not selected
if(!this.fileInfoDetail.includes(this.item)){
this.$store.dispatch('addToFavourites', this.item)
// Add to favourite folder that is not selected
if (!this.fileInfoDetail.includes(this.item)) {
this.$store.dispatch('addToFavourites', this.item)
}
//Add to favourites all selected folders
if(this.fileInfoDetail.includes(this.item)) {
this.$store.dispatch('addToFavourites', null)
// Add to favourites all selected folders
if (this.fileInfoDetail.includes(this.item)) {
this.$store.dispatch('addToFavourites', null)
}
} else {
this.$store.dispatch('removeFromFavourites', this.item)
}
},
downloadItem() {
//Download no selected item
if(!this.fileInfoDetail.includes(this.item)) {
this.$downloadFile(
this.item.file_url,
this.item.name + '.' + this.item.mimetype
)
}
// Download all selected items
if(this.fileInfoDetail.includes(this.item)) {
var files = this.fileInfoDetail;
var interval = setInterval(() => {
let file = files.pop()
this.$downloadFile(file.file_url,file.name + '.' + file.mimetype)
if (files.length === 0)
clearInterval(interval)
}, 300)
// Zip and download multiple files
if (this.fileInfoDetail.length > 1)
this.$store.dispatch('downloadFiles')
else {
this.$downloadFile(this.item.file_url, this.item.name + '.' + this.item.mimetype)
}
},
ItemDetail() {
@@ -481,13 +466,12 @@ export default {
this.$store.dispatch('fileInfoToggle', true)
},
deleteItem() {
// Dispatch remove item
// If is context menu open on non selected item delete this single item
if(!this.fileInfoDetail.includes(this.item)){
if (!this.fileInfoDetail.includes(this.item)) {
this.$store.dispatch('deleteItem', this.item)
}
// If is context menu open to multi selected items dele this selected items
if(this.fileInfoDetail.includes(this.item)) {
if (this.fileInfoDetail.includes(this.item)) {
this.$store.dispatch('deleteItem')
}
},
@@ -549,7 +533,6 @@ export default {
this.positionY = container.offsetTop + 51
}
}
},
watch: {
item(newValue, oldValue) {
+27 -15
View File
@@ -1,11 +1,31 @@
import i18n from '@/i18n/index'
import router from '@/router'
import {events} from '@/bus'
import { Store } from 'vuex'
import {last} from 'lodash'
import axios from 'axios'
import { Store } from 'vuex'
import Vue from "vue"
const actions = {
downloadFiles: ({ getters }) => {
let files = []
// get unique_ids of selected files
getters.fileInfoDetail.forEach(file => files.push(file.unique_id))
let route = '/download'
axios.post(route, {
files: files
})
.then(response => {
Vue.prototype.$downloadFile(response.data.url, response.data.name)
})
.catch(() => {
Vue.prototype.$isSomethingWrong()
})
},
moveItem: ({commit, getters, dispatch}, {to_item ,noSelectedItem}) => {
let itemsToMove = []
@@ -49,7 +69,7 @@ const actions = {
dispatch('getAppData')
})
})
.catch(() => isSomethingWrong())
.catch(() => Vue.prototype.$isSomethingWrong())
},
createFolder: ({commit, getters, dispatch}, folderName) => {
@@ -74,7 +94,7 @@ const actions = {
dispatch('getFolderTree')
})
.catch(() => isSomethingWrong())
.catch(() => Vue.prototype.$isSomethingWrong())
},
renameItem: ({commit, getters, dispatch}, data) => {
@@ -101,7 +121,7 @@ const actions = {
if (data.type === 'folder' && getters.currentFolder.location === 'public')
dispatch('getFolderTree')
})
.catch(() => isSomethingWrong())
.catch(() => Vue.prototype.$isSomethingWrong())
},
uploadFiles: ({commit, getters}, {form, fileSize, totalUploadedSize}) => {
return new Promise((resolve, reject) => {
@@ -210,7 +230,7 @@ const actions = {
to_home: restoreToHome,
_method: 'patch'
})
.catch(() => isSomethingWrong())
.catch(() => Vue.prototype.$isSomethingWrong())
},
deleteItem: ({commit, getters, dispatch}, noSelectedItem) => {
@@ -290,7 +310,7 @@ const actions = {
dispatch('getFolderTree')
})
.catch(() => isSomethingWrong())
.catch(() => Vue.prototype.$isSomethingWrong())
},
emptyTrash: ({commit, getters}) => {
@@ -308,18 +328,10 @@ const actions = {
// Remove file preview
commit('CLEAR_FILEINFO_DETAIL')
})
.catch(() => isSomethingWrong())
.catch(() => Vue.prototype.$isSomethingWrong())
},
}
// Show error message
function isSomethingWrong() {
events.$emit('alert:open', {
title: i18n.t('popup_error.title'),
message: i18n.t('popup_error.message'),
})
}
export default {
actions,
}