backend refactoring

This commit is contained in:
carodej
2020-04-27 08:34:09 +02:00
parent 586f0bba68
commit 65147870fd
22 changed files with 322 additions and 169 deletions
+1 -1
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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', {