This commit is contained in:
Čarodej
2022-02-15 16:08:12 +01:00
parent 820f0b3890
commit 421388b360
3 changed files with 30 additions and 24 deletions

View File

@@ -10,7 +10,7 @@
{{ title }}
<input v-if="type === 'file'" @change="emmitFiles" v-show="false" id="file" type="file" name="files[]" multiple />
<input v-if="type === 'folder'" @change="emmitFiles" v-show="false" id="folder" type="file" name="folders[]" webkitdirectory mozdirectory />
<input v-if="type === 'folder'" @change="emmitFolder" v-show="false" id="folder" type="file" name="folders[]" webkitdirectory mozdirectory />
</div>
</label>
</template>
@@ -30,6 +30,11 @@ export default {
emmitFiles(e) {
this.$uploadFiles(e.target.files)
},
emmitFolder(e) {
this.$store.commit('UPDATE_UPLOADING_FOLDER_STATE', true)
this.$uploadFiles(e.target.files)
},
},
}
</script>

View File

@@ -103,13 +103,9 @@ const actions = {
getFolderTree: ({ commit, getters }) => {
return new Promise((resolve, reject) => {
// Get route
let route = undefined
if (getters.sharedDetail) {
route = `/api/browse/navigation/${router.currentRoute.params.token}`
} else {
route = '/api/browse/navigation'
}
let route = getters.sharedDetail
? `/api/browse/navigation/${router.currentRoute.params.token}`
: '/api/browse/navigation'
axios
.get(route + getters.sorting.URI)

View File

@@ -6,6 +6,7 @@ import Vue from 'vue'
const defaultState = {
processingPopup: undefined,
isUploadingFolder: false,
isProcessingFile: false,
filesInQueueUploaded: 0,
filesInQueueTotal: 0,
@@ -107,8 +108,8 @@ const actions = {
}
}, 10)
if (Vue.prototype.$isThisRoute(router.currentRoute, ['Public'])) dispatch('getFolderTree')
else dispatch('getAppData')
// Refresh folder tree navigation
dispatch('getFolderTree')
})
.catch((error) => {
events.$emit('alert:open', {
@@ -200,11 +201,17 @@ const actions = {
if (!getters.fileQueue.length) {
commit('CLEAR_UPLOAD_PROGRESS')
// Reload folder tree
dispatch('getFolderTree')
// Reload File data after folder uploading is finished
if (getters.isUploadingFolder) {
// Reload files after upload is done
Vue.prototype.$getDataByLocation()
// Reload files after upload is done
Vue.prototype.$getDataByLocation()
// Reload folder tree
dispatch('getFolderTree')
commit('UPDATE_UPLOADING_FOLDER_STATE', false)
}
}
}
})
@@ -323,19 +330,13 @@ const actions = {
.then(() => {
itemsToDelete.forEach((data) => {
// If is folder, update app data
if (data.type === 'folder') {
if (data.id === getters.currentFolder.data.id) {
if (Vue.prototype.$isThisRoute(router.currentRoute, ['Public'])) {
dispatch('browseShared')
} else {
dispatch('getFolder')
}
}
if (data.type === 'folder' && (getters.currentFolder && data.id === getters.currentFolder.data.id)) {
router.back()
}
})
if (Vue.prototype.$isThisRoute(router.currentRoute, ['Public'])) dispatch('getFolderTree')
else dispatch('getAppData')
// Refresh folder tree navigation
dispatch('getFolderTree')
})
//.catch(() => Vue.prototype.$isSomethingWrong())
},
@@ -375,6 +376,9 @@ const actions = {
}
const mutations = {
UPDATE_UPLOADING_FOLDER_STATE(state, status) {
state.isUploadingFolder = status
},
PROCESSING_POPUP(state, status) {
state.processingPopup = status
},
@@ -407,6 +411,7 @@ const getters = {
filesInQueueUploaded: (state) => state.filesInQueueUploaded,
filesInQueueTotal: (state) => state.filesInQueueTotal,
uploadingProgress: (state) => state.uploadingProgress,
isUploadingFolder: (state) => state.isUploadingFolder,
isProcessingFile: (state) => state.isProcessingFile,
processingPopup: (state) => state.processingPopup,
fileQueue: (state) => state.fileQueue,