mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-29 11:15:58 +00:00
Admin & User account frontend consolidation
This commit is contained in:
Vendored
+1
-16
@@ -1,7 +1,7 @@
|
||||
import i18n from '@/i18n/index'
|
||||
|
||||
const defaultState = {
|
||||
fileInfoPanelVisible: localStorage.getItem('file_info_visibility') == 'true' || true,
|
||||
fileInfoPanelVisible: localStorage.getItem('file_info_visibility') === 'true' || false,
|
||||
FilePreviewType: localStorage.getItem('preview_type') || 'list',
|
||||
config: undefined,
|
||||
index: undefined,
|
||||
@@ -968,21 +968,6 @@ const defaultState = {
|
||||
]
|
||||
}
|
||||
const actions = {
|
||||
getEmojisList: ({commit}) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
axios.get('/assets/emojis.json')
|
||||
.then((response) => {
|
||||
commit('LOAD_EMOJIS_LIST', response.data[0])
|
||||
|
||||
})
|
||||
.catch(() => Vue.prototype.$isSomethingWrong())
|
||||
.finally(() => {
|
||||
resolve(true)
|
||||
})
|
||||
})
|
||||
|
||||
},
|
||||
changePreviewType: ({commit, state}, preview) => {
|
||||
|
||||
// Get preview type
|
||||
|
||||
+15
-15
@@ -72,7 +72,7 @@ const actions = {
|
||||
commit('STORE_PREVIOUS_FOLDER', getters.currentFolder)
|
||||
commit('STORE_CURRENT_FOLDER', {
|
||||
name: i18n.t('sidebar.latest'),
|
||||
unique_id: undefined,
|
||||
id: undefined,
|
||||
location: 'latest',
|
||||
})
|
||||
|
||||
@@ -92,7 +92,7 @@ const actions = {
|
||||
let currentFolder = {
|
||||
name: i18n.t('sidebar.my_shared'),
|
||||
location: 'shared',
|
||||
unique_id: undefined,
|
||||
id: undefined,
|
||||
}
|
||||
|
||||
commit('STORE_CURRENT_FOLDER', currentFolder)
|
||||
@@ -113,7 +113,7 @@ const actions = {
|
||||
commit('STORE_PREVIOUS_FOLDER', getters.currentFolder)
|
||||
commit('STORE_CURRENT_FOLDER', {
|
||||
name: i18n.t('sidebar.participant_uploads'),
|
||||
unique_id: undefined,
|
||||
id: undefined,
|
||||
location: 'participant_uploads',
|
||||
})
|
||||
|
||||
@@ -132,7 +132,7 @@ const actions = {
|
||||
|
||||
let trash = {
|
||||
name: i18n.t('locations.trash'),
|
||||
unique_id: undefined,
|
||||
id: undefined,
|
||||
location: 'trash-root',
|
||||
}
|
||||
|
||||
@@ -213,9 +213,9 @@ const mutations = {
|
||||
FLUSH_FOLDER_HISTORY(state) {
|
||||
state.browseHistory = []
|
||||
},
|
||||
FLUSH_SHARED(state, unique_id) {
|
||||
FLUSH_SHARED(state, id) {
|
||||
state.data.find(item => {
|
||||
if (item.unique_id == unique_id) item.shared = undefined
|
||||
if (item.id === id) item.shared = undefined
|
||||
})
|
||||
},
|
||||
STORE_PREVIOUS_FOLDER(state, folder) {
|
||||
@@ -226,13 +226,13 @@ const mutations = {
|
||||
},
|
||||
CHANGE_ITEM_NAME(state, updatedFile) {
|
||||
// Rename filename in file info detail
|
||||
if (state.fileInfoDetail && state.fileInfoDetail.unique_id == updatedFile.unique_id) {
|
||||
if (state.fileInfoDetail && state.fileInfoDetail.id === updatedFile.id) {
|
||||
state.fileInfoDetail = updatedFile
|
||||
}
|
||||
|
||||
// Rename item name in data view
|
||||
state.data.find(item => {
|
||||
if (item.unique_id == updatedFile.unique_id) {
|
||||
if (item.id === updatedFile.id) {
|
||||
item.name = updatedFile.name
|
||||
item.icon_color = updatedFile.icon_color ? updatedFile.icon_color : null
|
||||
item.icon_emoji = updatedFile.icon_emoji ? updatedFile.icon_emoji : null
|
||||
@@ -240,7 +240,7 @@ const mutations = {
|
||||
})
|
||||
},
|
||||
REMOVE_ITEM_FILEINFO_DETAIL(state,item) {
|
||||
state.fileInfoDetail = state.fileInfoDetail.filter(element => element.unique_id !== item.unique_id)
|
||||
state.fileInfoDetail = state.fileInfoDetail.filter(element => element.id !== item.id)
|
||||
},
|
||||
CLEAR_FILEINFO_DETAIL(state) {
|
||||
state.fileInfoDetail = []
|
||||
@@ -250,7 +250,7 @@ const mutations = {
|
||||
state.fileInfoDetail.push(item)
|
||||
},
|
||||
GET_FILEINFO_DETAIL(state, item) {
|
||||
let checkData = state.data.find(el => el.unique_id == item.unique_id)
|
||||
let checkData = state.data.find(el => el.id === item.id)
|
||||
if(state.fileInfoDetail.includes(checkData)) return
|
||||
|
||||
state.fileInfoDetail.push(checkData ? checkData : state.currentFolder)
|
||||
@@ -263,7 +263,7 @@ const mutations = {
|
||||
},
|
||||
UPDATE_SHARED_ITEM(state, data) {
|
||||
state.data.find(item => {
|
||||
if (item.unique_id == data.item_id) item.shared = data
|
||||
if (item.id === data.item_id) item.shared = data
|
||||
})
|
||||
},
|
||||
ADD_NEW_FOLDER(state, folder) {
|
||||
@@ -272,12 +272,12 @@ const mutations = {
|
||||
ADD_NEW_ITEMS(state, items) {
|
||||
state.data = state.data.concat(items)
|
||||
},
|
||||
REMOVE_ITEM(state, unique_id) {
|
||||
state.data = state.data.filter(el => el.unique_id !== unique_id)
|
||||
REMOVE_ITEM(state, id) {
|
||||
state.data = state.data.filter(el => el.id !== id)
|
||||
},
|
||||
INCREASE_FOLDER_ITEM(state, unique_id) {
|
||||
INCREASE_FOLDER_ITEM(state, id) {
|
||||
state.data.map(el => {
|
||||
if (el.unique_id && el.unique_id == unique_id) el.items++
|
||||
if (el.id && el.id === id) el.items++
|
||||
})
|
||||
},
|
||||
STORE_CURRENT_FOLDER(state, folder) {
|
||||
|
||||
+22
-22
@@ -26,8 +26,8 @@ const actions = {
|
||||
|
||||
// Get route
|
||||
let route = getters.sharedDetail && !getters.sharedDetail.protected
|
||||
? '/api/zip-folder/' + folder.unique_id + '/public/' + router.currentRoute.params.token
|
||||
: '/api/zip-folder/' + folder.unique_id
|
||||
? '/api/zip-folder/' + folder.id + '/public/' + router.currentRoute.params.token
|
||||
: '/api/zip-folder/' + folder.id
|
||||
|
||||
axios.get(route)
|
||||
.then(response => {
|
||||
@@ -44,8 +44,8 @@ const actions = {
|
||||
downloadFiles: ({ commit, getters }) => {
|
||||
let files = []
|
||||
|
||||
// get unique_ids of selected files
|
||||
getters.fileInfoDetail.forEach(file => files.push(file.unique_id))
|
||||
// get ids of selected files
|
||||
getters.fileInfoDetail.forEach(file => files.push(file.id))
|
||||
|
||||
// Get route
|
||||
let route = getters.sharedDetail && !getters.sharedDetail.protected
|
||||
@@ -81,7 +81,7 @@ const actions = {
|
||||
|
||||
items.forEach(data => itemsToMove.push({
|
||||
'force_delete': data.deleted_at ? true : false,
|
||||
'unique_id': data.unique_id,
|
||||
'id': data.id,
|
||||
'type': data.type
|
||||
}))
|
||||
|
||||
@@ -97,13 +97,13 @@ const actions = {
|
||||
axios
|
||||
.post(route, {
|
||||
_method: 'post',
|
||||
to_unique_id: to_item.unique_id,
|
||||
to_id: to_item.id,
|
||||
items: itemsToMove
|
||||
})
|
||||
.then(() => {
|
||||
itemsToMove.forEach(item => {
|
||||
commit('REMOVE_ITEM', item.unique_id)
|
||||
commit('INCREASE_FOLDER_ITEM', to_item.unique_id)
|
||||
commit('REMOVE_ITEM', item.id)
|
||||
commit('INCREASE_FOLDER_ITEM', to_item.id)
|
||||
|
||||
if (item.type === 'folder')
|
||||
dispatch('getAppData')
|
||||
@@ -122,7 +122,7 @@ const actions = {
|
||||
|
||||
axios
|
||||
.post(route, {
|
||||
parent_id: getters.currentFolder.unique_id,
|
||||
parent_id: getters.currentFolder.id,
|
||||
name: folder.name,
|
||||
icon: folder.icon
|
||||
})
|
||||
@@ -133,7 +133,7 @@ const actions = {
|
||||
|
||||
//Set focus on new folder name
|
||||
setTimeout(() => {
|
||||
events.$emit('newFolder:focus', response.data.unique_id)
|
||||
events.$emit('newFolder:focus', response.data.id)
|
||||
}, 10)
|
||||
|
||||
if (getters.currentFolder.location !== 'public')
|
||||
@@ -152,8 +152,8 @@ const actions = {
|
||||
|
||||
// Get route
|
||||
let route = getters.sharedDetail && !getters.sharedDetail.protected
|
||||
? '/api/rename-item/' + data.unique_id + '/public/' + router.currentRoute.params.token
|
||||
: '/api/rename-item/' + data.unique_id
|
||||
? '/api/rename-item/' + data.id + '/public/' + router.currentRoute.params.token
|
||||
: '/api/rename-item/' + data.id
|
||||
|
||||
axios
|
||||
.post(route, {
|
||||
@@ -209,7 +209,7 @@ const actions = {
|
||||
commit('SHIFT_FROM_FILE_QUEUE')
|
||||
|
||||
// Check if user is in uploading folder, if yes, than show new file
|
||||
if (response.data.folder_id == getters.currentFolder.unique_id) {
|
||||
if (response.data.folder_id == getters.currentFolder.id) {
|
||||
|
||||
// Add uploaded item into view
|
||||
commit('ADD_NEW_ITEMS', response.data)
|
||||
@@ -284,8 +284,8 @@ const actions = {
|
||||
restoreToHome = true
|
||||
|
||||
items.forEach(data => itemToRestore.push({
|
||||
'type': data.type,
|
||||
'unique_id': data.unique_id
|
||||
type: data.type,
|
||||
id: data.id
|
||||
}))
|
||||
|
||||
// Remove file preview
|
||||
@@ -298,7 +298,7 @@ const actions = {
|
||||
})
|
||||
.then(
|
||||
// Remove file
|
||||
items.forEach(data => commit('REMOVE_ITEM', data.unique_id))
|
||||
items.forEach(data => commit('REMOVE_ITEM', data.id))
|
||||
)
|
||||
.catch(() => Vue.prototype.$isSomethingWrong())
|
||||
},
|
||||
@@ -313,13 +313,13 @@ const actions = {
|
||||
|
||||
items.forEach(data => {
|
||||
itemsToDelete.push({
|
||||
'force_delete': data.deleted_at ? true : false,
|
||||
'type': data.type,
|
||||
'unique_id': data.unique_id
|
||||
force_delete: data.deleted_at ? true : false,
|
||||
type: data.type,
|
||||
id: data.id
|
||||
})
|
||||
|
||||
// Remove file
|
||||
commit('REMOVE_ITEM', data.unique_id)
|
||||
commit('REMOVE_ITEM', data.id)
|
||||
|
||||
// Remove item from sidebar
|
||||
if (getters.permission === 'master') {
|
||||
@@ -329,7 +329,7 @@ const actions = {
|
||||
}
|
||||
|
||||
// Remove file
|
||||
commit('REMOVE_ITEM', data.unique_id)
|
||||
commit('REMOVE_ITEM', data.id)
|
||||
|
||||
// Remove item from sidebar
|
||||
if (getters.permission === 'master') {
|
||||
@@ -361,7 +361,7 @@ const actions = {
|
||||
// If is folder, update app data
|
||||
if (data.type === 'folder') {
|
||||
|
||||
if (data.unique_id === getters.currentFolder.unique_id) {
|
||||
if (data.id === getters.currentFolder.id) {
|
||||
|
||||
if (getters.currentFolder.location === 'public') {
|
||||
dispatch('browseShared', [{ folder: last(getters.browseHistory), back: true, init: false }])
|
||||
|
||||
+6
-5
@@ -2,6 +2,7 @@ import i18n from '@/i18n/index'
|
||||
import router from '@/router'
|
||||
import {events} from '@/bus'
|
||||
import axios from 'axios'
|
||||
import Vue from "vue";
|
||||
|
||||
const defaultState = {
|
||||
permissionOptions: [
|
||||
@@ -38,8 +39,8 @@ const actions = {
|
||||
payload.folder.location = 'public'
|
||||
|
||||
let route = getters.sharedDetail.protected
|
||||
? '/api/folders/' + payload.folder.unique_id + '/private'
|
||||
: '/api/folders/' + payload.folder.unique_id + '/public/' + router.currentRoute.params.token
|
||||
? '/api/browse/folders/' + payload.folder.id + '/private'
|
||||
: '/api/browse/folders/' + payload.folder.id + '/public/' + router.currentRoute.params.token
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
axios
|
||||
@@ -90,11 +91,11 @@ const actions = {
|
||||
|
||||
// Remove item from file browser
|
||||
if ( getters.currentFolder , getters.currentFolder.location === 'shared' ) {
|
||||
commit('REMOVE_ITEM', item.unique_id)
|
||||
commit('REMOVE_ITEM', item.id)
|
||||
}
|
||||
|
||||
// Flush shared data
|
||||
commit('FLUSH_SHARED', item.unique_id)
|
||||
commit('FLUSH_SHARED', item.id)
|
||||
|
||||
commit('CLEAR_FILEINFO_DETAIL')
|
||||
})
|
||||
@@ -102,7 +103,7 @@ const actions = {
|
||||
|
||||
})
|
||||
.catch((error) => {
|
||||
isSomethingWrong()
|
||||
Vue.prototype.$isSomethingWrong()
|
||||
|
||||
reject(error)
|
||||
})
|
||||
|
||||
+13
-11
@@ -67,10 +67,10 @@ const actions = {
|
||||
items.forEach((data) => {
|
||||
if(data.type === 'folder' ) {
|
||||
|
||||
if(context.getters.user.relationships.favourites.data.attributes.folders.find(folder => folder.unique_id === data.unique_id)) return
|
||||
if(context.getters.user.data.relationships.favourites.data.attributes.folders.find(folder => folder.id === data.id)) return
|
||||
|
||||
addFavourites.push({
|
||||
'unique_id': data.unique_id
|
||||
id: data.id
|
||||
})
|
||||
}
|
||||
})
|
||||
@@ -84,7 +84,7 @@ const actions = {
|
||||
|
||||
// Check is favorites already don't include some of pushed folders
|
||||
items.map(data => {
|
||||
if(!context.getters.user.relationships.favourites.data.attributes.folders.find(folder => folder.unique_id === data.unique_id)){
|
||||
if(!context.getters.user.data.relationships.favourites.data.attributes.folders.find(folder => folder.id === data.id)){
|
||||
pushToFavorites.push(data)
|
||||
}
|
||||
})
|
||||
@@ -106,7 +106,7 @@ const actions = {
|
||||
commit('REMOVE_ITEM_FROM_FAVOURITES', folder)
|
||||
|
||||
axios
|
||||
.post(getters.api + '/folders/favourites/' + folder.unique_id, {
|
||||
.post(getters.api + '/folders/favourites/' + folder.id, {
|
||||
_method: 'delete'
|
||||
})
|
||||
.catch(() => {
|
||||
@@ -128,25 +128,27 @@ const mutations = {
|
||||
},
|
||||
ADD_TO_FAVOURITES(state, folder) {
|
||||
folder.forEach(item => {
|
||||
state.user.relationships.favourites.data.attributes.folders.push({
|
||||
unique_id: item.unique_id,
|
||||
state.user.data.relationships.favourites.data.attributes.folders.push({
|
||||
id: item.id,
|
||||
name: item.name,
|
||||
type: item.type,
|
||||
})
|
||||
})
|
||||
},
|
||||
UPDATE_NAME(state, name) {
|
||||
state.user.data.attributes.name = name
|
||||
state.user.data.relationships.settings.data.attributes.name = name
|
||||
},
|
||||
UPDATE_AVATAR(state, avatar) {
|
||||
state.user.data.attributes.avatar = avatar
|
||||
state.user.data.relationships.settings.data.attributes.avatar = avatar
|
||||
},
|
||||
REMOVE_ITEM_FROM_FAVOURITES(state, item) {
|
||||
state.user.relationships.favourites.data.attributes.folders = state.user.relationships.favourites.data.attributes.folders.filter(folder => folder.unique_id !== item.unique_id)
|
||||
state.user.data.relationships.favourites.data.attributes.folders = state.user.data.relationships.favourites.data.attributes.folders.filter(folder => folder.id !== item.id)
|
||||
},
|
||||
UPDATE_NAME_IN_FAVOURITES(state, data) {
|
||||
state.user.relationships.favourites.data.attributes.folders.find(folder => {
|
||||
if (folder.unique_id == data.unique_id) folder.name = data.name
|
||||
state.user.data.relationships.favourites.data.attributes.folders.find(folder => {
|
||||
if (folder.id === data.id) {
|
||||
folder.name = data.name
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user