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

View File

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

View File

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