frontend/backend update

This commit is contained in:
carodej
2020-04-23 12:40:22 +02:00
parent 8740cc7685
commit 8cbc58f775
46 changed files with 1838 additions and 861 deletions
@@ -2,7 +2,7 @@ import axios from 'axios'
import {events} from '@/bus'
import router from '@/router'
import { includes } from 'lodash'
import i18n from '@/i18n/index.js'
import i18n from '@/i18n/index'
const defaultState = {
fileInfoPanelVisible: localStorage.getItem('file_info_visibility') == 'true' || false,
@@ -90,7 +90,7 @@ const actions = {
}
axios
.get(context.getters.api + '/shared')
.get(context.getters.api + '/shared-all')
.then(response => {
context.commit('GET_DATA', response.data)
context.commit('LOADING_STATE', false)
@@ -215,10 +215,10 @@ const actions = {
// Remove file
commit('REMOVE_ITEM', data.unique_id)
if (data.type === 'file' || data.type === 'image')
commit('REMOVE_ITEM_FROM_RECENT_UPLOAD', data.unique_id)
if (data.type === 'folder')
commit('REMOVE_ITEM_FROM_FAVOURITES', data)
else
commit('REMOVE_ITEM_FROM_RECENT_UPLOAD', data.unique_id)
// Remove file preview
commit('CLEAR_FILEINFO_DETAIL')
@@ -356,7 +356,12 @@ const actions = {
dispatch('getTrash')
} else {
dispatch('goToFolder', [state.currentFolder, false, true])
if ( this.$isThisLocation('public') ) {
dispatch('browseShared', [this.currentFolder(), false, true])
} else {
dispatch('goToFolder', [state.currentFolder, false, true])
}
}
},
fileInfoToggle: (context, visibility = undefined) => {
@@ -419,6 +424,11 @@ const mutations = {
FLUSH_BROWSER_HISTORY(state) {
state.browseHistory = []
},
FLUSH_SHARED(state, unique_id) {
state.data.find(item => {
if (item.unique_id == unique_id) item.shared = undefined
})
},
ADD_BROWSER_HISTORY(state, folder) {
state.browseHistory.push(folder)
},
@@ -465,6 +475,11 @@ const mutations = {
UPDATE_FILE_COUNT_PROGRESS(state, data) {
state.uploadingFilesCount = data
},
UPDATE_SHARED_ITEM(state, data) {
state.data.find(item => {
if (item.unique_id == data.item_id) item.shared = data
})
},
FLUSH_DATA(state) {
state.data = []
},
@@ -477,11 +492,6 @@ const mutations = {
ADD_NEW_ITEMS(state, items) {
state.data = state.data.concat(items)
},
REMOVE_ITEMS(state, ids) {
state.data = state.data.filter(
el => -1 == ids.indexOf(el.unique_id)
)
},
REMOVE_ITEM(state, unique_id) {
state.data = state.data.filter(el => el.unique_id !== unique_id)
},
+106
View File
@@ -0,0 +1,106 @@
import i18n from '@/i18n/index'
import router from '@/router'
import {events} from '@/bus'
import axios from 'axios'
const defaultState = {
permissionOptions: [
{
label: 'Can edit and upload files',
value: 'editor',
icon: 'user-edit',
},
{
label: 'Can only view and download',
value: 'visitor',
icon: 'user',
},
],
sharedDetail: undefined,
sharedFile: undefined,
}
const actions = {
browseShared: ({commit, state, getters}, [folder, back = false, init = false]) => {
commit('LOADING_STATE', true)
commit('FLUSH_DATA')
// Clear search
if (getters.isSearching) {
commit('CHANGE_SEARCHING_STATE', false)
events.$emit('clear-query')
}
// Create current folder for history
let currentFolder = {
name: folder.name,
unique_id: folder.unique_id,
location: 'public'
}
let route = state.sharedDetail.protected ? '/api/browse-private/' : '/api/browse-public/'
return new Promise((resolve, reject) => {
axios
.get(route + currentFolder.unique_id, {
params: {
token: router.currentRoute.params.token
}
})
.then(response => {
commit('LOADING_STATE', false)
commit('GET_DATA', response.data)
commit('STORE_CURRENT_FOLDER', currentFolder)
events.$emit('scrollTop')
if (back) {
commit('REMOVE_BROWSER_HISTORY')
} else {
if (!init)
commit('ADD_BROWSER_HISTORY', currentFolder)
}
resolve(response)
})
.catch((error) => {
// Show error message
events.$emit('alert:open', {
title: i18n.t('popup_error.title'),
message: i18n.t('popup_error.message'),
})
reject(error)
})
})
},
getSingleFile: ({commit, state}) => {
let route = state.sharedDetail.protected ? '/api/file-private/' : '/api/file-public/'
axios.get(route + router.currentRoute.params.token)
.then(response => {
commit('STORE_SHARED_FILE', response.data)
})
},
}
const mutations = {
SET_SHARED_DETAIL(state, data) {
state.sharedDetail = data
},
STORE_SHARED_FILE(state, data) {
state.sharedFile = data
}
}
const getters = {
permissionOptions: state => state.permissionOptions,
sharedDetail: state => state.sharedDetail,
sharedFile: state => state.sharedFile,
}
export default {
state: defaultState,
getters,
actions,
mutations
}
+3
View File
@@ -97,6 +97,9 @@ const mutations = {
UPDATE_FOLDER_TREE(state, tree) {
state.app.folders = tree
},
SET_PERMISSION(state, role) {
state.permission = role
},
SET_AUTHORIZED(state, data) {
state.authorized = data
},