mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-05-21 20:44:42 +00:00
backend refactoring
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
>
|
||||
<!--ContextMenu for trash location-->
|
||||
<ul v-if="$isThisLocation(['trash', 'trash-root']) && $checkPermission('master')" class="menu-options" ref="list">
|
||||
<li class="menu-option" @click="removeItem" v-if="item">
|
||||
<li class="menu-option" @click="deleteItem" v-if="item">
|
||||
{{ $t('context_menu.delete') }}
|
||||
</li>
|
||||
<li class="menu-option" @click="$store.dispatch('restoreItem', item)" v-if="item">
|
||||
@@ -30,7 +30,7 @@
|
||||
<li class="menu-option" @click="addToFavourites" v-if="item && isFolder">
|
||||
{{ isInFavourites ? $t('context_menu.remove_from_favourites') : $t('context_menu.add_to_favourites') }}
|
||||
</li>
|
||||
<li class="menu-option" @click="removeItem" v-if="item">
|
||||
<li class="menu-option" @click="deleteItem" v-if="item">
|
||||
{{ $t('context_menu.delete') }}
|
||||
</li>
|
||||
<li class="menu-option" @click="shareItem" v-if="item">
|
||||
@@ -52,7 +52,7 @@
|
||||
<li class="menu-option" @click="createFolder">
|
||||
{{ $t('context_menu.create_folder') }}
|
||||
</li>
|
||||
<li class="menu-option" @click="removeItem" v-if="item">
|
||||
<li class="menu-option" @click="deleteItem" v-if="item">
|
||||
{{ $t('context_menu.delete') }}
|
||||
</li>
|
||||
<li class="menu-option" @click="moveItem" v-if="item">
|
||||
@@ -74,7 +74,7 @@
|
||||
<li class="menu-option" @click="createFolder">
|
||||
{{ $t('context_menu.create_folder') }}
|
||||
</li>
|
||||
<li class="menu-option" @click="removeItem" v-if="item">
|
||||
<li class="menu-option" @click="deleteItem" v-if="item">
|
||||
{{ $t('context_menu.delete') }}
|
||||
</li>
|
||||
<li class="menu-option" @click="moveItem" v-if="item">
|
||||
@@ -165,9 +165,9 @@
|
||||
// Show panel if is not open
|
||||
this.$store.dispatch('fileInfoToggle', true)
|
||||
},
|
||||
removeItem() {
|
||||
deleteItem() {
|
||||
// Dispatch remove item
|
||||
this.$store.dispatch('removeItem', this.item)
|
||||
this.$store.dispatch('deleteItem', this.item)
|
||||
},
|
||||
createFolder() {
|
||||
// Create folder
|
||||
|
||||
@@ -202,7 +202,7 @@
|
||||
|
||||
// On items delete
|
||||
events.$on('items:delete', () => {
|
||||
this.$store.dispatch('removeItem', this.fileInfoDetail)
|
||||
this.$store.dispatch('deleteItem', this.fileInfoDetail)
|
||||
|
||||
//let ids = []
|
||||
//let items = []
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
<li class="menu-option" @click="downloadItem" v-if="! isFolder">
|
||||
{{ $t('context_menu.download') }}
|
||||
</li>
|
||||
<li class="menu-option delete" @click="removeItem" v-if="fileInfoDetail">
|
||||
<li class="menu-option delete" @click="deleteItem" v-if="fileInfoDetail">
|
||||
{{ $t('context_menu.delete') }}
|
||||
</li>
|
||||
</ul>
|
||||
@@ -36,7 +36,7 @@
|
||||
<li class="menu-option" @click="downloadItem" v-if="! isFolder">
|
||||
{{ $t('context_menu.download') }}
|
||||
</li>
|
||||
<li class="menu-option delete" @click="removeItem" v-if="fileInfoDetail">
|
||||
<li class="menu-option delete" @click="deleteItem" v-if="fileInfoDetail">
|
||||
{{ $t('context_menu.delete') }}
|
||||
</li>
|
||||
</ul>
|
||||
@@ -58,7 +58,7 @@
|
||||
<li class="menu-option" @click="downloadItem" v-if="! isFolder">
|
||||
{{ $t('context_menu.download') }}
|
||||
</li>
|
||||
<li class="menu-option delete" @click="removeItem" v-if="fileInfoDetail">
|
||||
<li class="menu-option delete" @click="deleteItem" v-if="fileInfoDetail">
|
||||
{{ $t('context_menu.delete') }}
|
||||
</li>
|
||||
</ul>
|
||||
@@ -145,9 +145,9 @@
|
||||
this.fileInfoDetail.name + '.' + this.fileInfoDetail.mimetype
|
||||
)
|
||||
},
|
||||
removeItem() {
|
||||
deleteItem() {
|
||||
// Dispatch remove item
|
||||
this.$store.dispatch('removeItem', this.fileInfoDetail)
|
||||
this.$store.dispatch('deleteItem', this.fileInfoDetail)
|
||||
},
|
||||
renameItem() {
|
||||
let itemName = prompt(
|
||||
|
||||
@@ -142,16 +142,16 @@
|
||||
|
||||
// Send request to get share link
|
||||
axios
|
||||
.post('/api/share/generate', this.shareOptions)
|
||||
.post('/api/share', this.shareOptions)
|
||||
.then(response => {
|
||||
|
||||
// End loading
|
||||
this.isLoading = false
|
||||
|
||||
this.shareLink = response.data.link
|
||||
this.shareLink = response.data.data.attributes.link
|
||||
this.isGeneratedShared = true
|
||||
|
||||
this.$store.commit('UPDATE_SHARED_ITEM', response.data)
|
||||
this.$store.commit('UPDATE_SHARED_ITEM', response.data.data.attributes)
|
||||
})
|
||||
.catch(error => {
|
||||
|
||||
|
||||
@@ -142,11 +142,7 @@
|
||||
|
||||
// Send delete request
|
||||
axios
|
||||
.delete('/api/share/remove', {
|
||||
params: {
|
||||
token: this.pickedItem.shared.token
|
||||
}
|
||||
})
|
||||
.delete('/api/share/' + this.pickedItem.shared.token)
|
||||
.then(() => {
|
||||
|
||||
// Remove item from file browser
|
||||
@@ -187,14 +183,18 @@
|
||||
|
||||
// Send request to get share link
|
||||
axios
|
||||
.post('/api/share/update', this.shareOptions)
|
||||
.patch('/api/share/' + this.shareOptions.token, {
|
||||
permission: this.shareOptions.permission,
|
||||
protected: this.shareOptions.isProtected,
|
||||
password: this.shareOptions.password ? this.shareOptions.password : undefined,
|
||||
})
|
||||
.then(response => {
|
||||
|
||||
// End loading
|
||||
this.isLoading = false
|
||||
|
||||
// Update shared data
|
||||
this.$store.commit('UPDATE_SHARED_ITEM', response.data)
|
||||
this.$store.commit('UPDATE_SHARED_ITEM', response.data.data.attributes)
|
||||
|
||||
events.$emit('popup:close')
|
||||
})
|
||||
|
||||
Vendored
+1
-1
@@ -10,7 +10,7 @@ const Helpers = {
|
||||
|
||||
if (value === '') return
|
||||
|
||||
axios.put(this.$store.getters.api + route, {name, value})
|
||||
axios.patch(this.$store.getters.api + route, {name, value})
|
||||
.catch(error => {
|
||||
events.$emit('alert:open', {
|
||||
title: this.$t('popup_error.title'),
|
||||
|
||||
+1
-1
@@ -42,7 +42,7 @@ const actions = {
|
||||
location: folder.deleted_at || folder.location === 'trash' ? 'trash' : 'base'
|
||||
}
|
||||
|
||||
let url = currentFolder.location === 'trash' ?'/folder/' + currentFolder.unique_id + '?trash=true' : '/folder/' + currentFolder.unique_id
|
||||
let url = currentFolder.location === 'trash' ?'/folders/' + currentFolder.unique_id + '?trash=true' : '/folders/' + currentFolder.unique_id
|
||||
|
||||
axios
|
||||
.get(context.getters.api + url)
|
||||
|
||||
+12
-10
@@ -5,8 +5,7 @@ import i18n from '@/i18n/index'
|
||||
const actions = {
|
||||
moveItem: ({commit, getters}, [item_from, to_item]) => {
|
||||
axios
|
||||
.post(getters.api + '/move-item', {
|
||||
from_unique_id: item_from.unique_id,
|
||||
.patch(getters.api + '/move-item/' + item_from.unique_id, {
|
||||
from_type: item_from.type,
|
||||
to_unique_id: to_item.unique_id
|
||||
})
|
||||
@@ -36,7 +35,10 @@ const actions = {
|
||||
commit('UPDATE_NAME_IN_FAVOURITES', data)
|
||||
|
||||
axios
|
||||
.post(getters.api + '/rename-item', data)
|
||||
.patch(getters.api + '/rename-item/' + data.unique_id, {
|
||||
name: data.name,
|
||||
type: data.type,
|
||||
})
|
||||
.then(response => {
|
||||
commit('CHANGE_ITEM_NAME', response.data)
|
||||
})
|
||||
@@ -89,14 +91,13 @@ const actions = {
|
||||
commit('CLEAR_FILEINFO_DETAIL')
|
||||
|
||||
axios
|
||||
.post(getters.api + '/restore-item', {
|
||||
.patch(getters.api + '/restore-item/' + item.unique_id, {
|
||||
type: item.type,
|
||||
unique_id: item.unique_id,
|
||||
to_home: restoreToHome,
|
||||
})
|
||||
.catch(() => isSomethingWrong())
|
||||
},
|
||||
removeItem: ({commit, getters}, data) => {
|
||||
deleteItem: ({commit, getters}, data) => {
|
||||
|
||||
// Remove file
|
||||
commit('REMOVE_ITEM', data.unique_id)
|
||||
@@ -114,10 +115,11 @@ const actions = {
|
||||
commit('CLEAR_FILEINFO_DETAIL')
|
||||
|
||||
axios
|
||||
.post(getters.api + '/remove-item', {
|
||||
type: data.type,
|
||||
unique_id: data.unique_id,
|
||||
force_delete: data.deleted_at ? true : false
|
||||
.delete(getters.api + '/remove-item/' + data.unique_id, {
|
||||
data: {
|
||||
type: data.type,
|
||||
force_delete: data.deleted_at ? true : false
|
||||
}
|
||||
})
|
||||
.catch(() => isSomethingWrong())
|
||||
},
|
||||
|
||||
+4
-2
@@ -37,11 +37,13 @@ const actions = {
|
||||
location: 'public'
|
||||
}
|
||||
|
||||
let route = getters.sharedDetail.protected ? '/api/browse-private/' : '/api/browse-public/' + router.currentRoute.params.token +'/'
|
||||
let route = getters.sharedDetail.protected
|
||||
? '/api/folders/' + currentFolder.unique_id + '/private'
|
||||
: '/api/folders/' + currentFolder.unique_id + '/public/' + router.currentRoute.params.token +'/'
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
axios
|
||||
.get(route + currentFolder.unique_id)
|
||||
.get(route)
|
||||
.then(response => {
|
||||
|
||||
commit('LOADING_STATE', false)
|
||||
|
||||
+4
-2
@@ -42,7 +42,9 @@ const actions = {
|
||||
context.commit('ADD_TO_FAVOURITES', folder)
|
||||
|
||||
axios
|
||||
.post(context.getters.api + '/add-to-favourites', {unique_id: folder.unique_id})
|
||||
.post(context.getters.api + '/folders/favourites', {
|
||||
unique_id: folder.unique_id
|
||||
})
|
||||
.catch(() => {
|
||||
// Show error message
|
||||
events.$emit('alert:open', {
|
||||
@@ -57,7 +59,7 @@ const actions = {
|
||||
context.commit('REMOVE_ITEM_FROM_FAVOURITES', folder)
|
||||
|
||||
axios
|
||||
.post(context.getters.api + '/remove-from-favourites', {unique_id: folder.unique_id})
|
||||
.delete(context.getters.api + '/folders/favourites/' + folder.unique_id)
|
||||
.catch(() => {
|
||||
// Show error message
|
||||
events.$emit('alert:open', {
|
||||
|
||||
@@ -206,14 +206,14 @@
|
||||
.then(response => {
|
||||
|
||||
// Commit shared item options
|
||||
this.$store.commit('SET_SHARED_DETAIL', response.data)
|
||||
this.$store.commit('SET_PERMISSION', response.data.permission)
|
||||
this.$store.commit('SET_SHARED_DETAIL', response.data.data.attributes)
|
||||
this.$store.commit('SET_PERMISSION', response.data.data.attributes.permission)
|
||||
|
||||
// Hide page spinner
|
||||
this.isPageLoading = false
|
||||
|
||||
// Show password page
|
||||
if (response.data.protected) {
|
||||
if (response.data.data.attributes.protected) {
|
||||
this.currentPage = 'page-password'
|
||||
} else {
|
||||
this.currentPage = 'page-files'
|
||||
|
||||
Reference in New Issue
Block a user