Merge remote-tracking branch 'origin/master' into folders_upload

This commit is contained in:
Milos Holba
2021-08-11 17:46:57 +02:00
330 changed files with 3749 additions and 3423 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
import i18n from '@/i18n/index'
import i18n from '/resources/js/i18n/index'
import axios from "axios";
const defaultState = {
+11 -60
View File
@@ -1,17 +1,17 @@
import Vue from "vue"
import axios from 'axios'
import {events} from '@/bus'
import router from '@/router'
import i18n from '@/i18n/index'
import {events} from '/resources/js/bus'
import router from '/resources/js/router'
import i18n from '/resources/js/i18n/index'
const defaultState = {
currentFolder: undefined,
navigation: undefined,
isSearching: false,
isLoading: true,
browseHistory: [],
fastPreview: undefined,
clipboard: [],
entries: [],
}
@@ -23,12 +23,6 @@ const actions = {
if (payload.init)
commit('FLUSH_FOLDER_HISTORY')
// Clear search
if (getters.isSearching) {
commit('CHANGE_SEARCHING_STATE', false)
events.$emit('clear-query')
}
// Set folder location
payload.folder.location = payload.folder.deleted_at || payload.folder.location === 'trash' ? 'trash' : 'base'
@@ -108,25 +102,6 @@ const actions = {
})
.catch(() => Vue.prototype.$isSomethingWrong())
},
getParticipantUploads: ({commit, getters}) => {
commit('LOADING_STATE', {loading: true, data: []})
commit('STORE_PREVIOUS_FOLDER', getters.currentFolder)
commit('STORE_CURRENT_FOLDER', {
name: i18n.t('sidebar.participant_uploads'),
id: undefined,
location: 'participant_uploads',
})
axios
.get(getters.api + '/browse/participants' + getters.sorting.URI)
.then(response => {
commit('LOADING_STATE', {loading: false, data: response.data})
events.$emit('scrollTop')
})
.catch(() => Vue.prototype.$isSomethingWrong())
},
getTrash: ({commit, getters}) => {
commit('LOADING_STATE', {loading: true, data: []})
commit('FLUSH_FOLDER_HISTORY')
@@ -149,33 +124,6 @@ const actions = {
})
.catch(() => Vue.prototype.$isSomethingWrong())
},
getSearchResult: ({commit, getters}, query) => {
commit('LOADING_STATE', {loading: true, data: []})
commit('CHANGE_SEARCHING_STATE', true)
// Get route
let route = undefined
if (getters.sharedDetail) {
let permission = getters.sharedDetail.is_protected
? 'private'
: 'public'
route = `/api/browse/search/${permission}/${router.currentRoute.params.token}`
} else {
route = '/api/browse/search'
}
axios
.get(route, {
params: {query: query}
})
.then(response => {
commit('LOADING_STATE', {loading: false, data: response.data})
})
.catch(() => Vue.prototype.$isSomethingWrong())
},
getFolderTree: ({commit, getters}) => {
return new Promise((resolve, reject) => {
@@ -243,9 +191,6 @@ const mutations = {
}
})
},
CHANGE_SEARCHING_STATE(state, searchState) {
state.isSearching = searchState
},
UPDATE_SHARED_ITEM(state, data) {
state.entries.find(item => {
if (item.id === data.item_id) item.shared = data
@@ -284,13 +229,19 @@ const mutations = {
CLIPBOARD_CLEAR(state) {
state.clipboard = []
},
ADD_TO_FAST_PREVIEW(state, item) {
state.fastPreview = item
},
FAST_PREVIEW_CLEAR(state) {
state.fastPreview = undefined
},
}
const getters = {
fastPreview: state => state.fastPreview,
clipboard: state => state.clipboard,
currentFolder: state => state.currentFolder,
browseHistory: state => state.browseHistory,
isSearching: state => state.isSearching,
navigation: state => state.navigation,
isLoading: state => state.isLoading,
entries: state => state.entries,
+16 -46
View File
@@ -1,6 +1,6 @@
import i18n from '@/i18n/index'
import router from '@/router'
import {events} from '@/bus'
import i18n from '/resources/js/i18n/index'
import router from '/resources/js/router'
import {events} from '/resources/js/bus'
import {last} from 'lodash'
import axios from 'axios'
import Vue from 'vue'
@@ -15,56 +15,26 @@ const defaultState = {
}
const actions = {
downloadFolder: ({commit, getters}, folder) => {
commit('PROCESSING_POPUP', {
title: i18n.t('popup_zipping.title'),
message: i18n.t('popup_zipping.message')
})
let route = getters.sharedDetail
? `/api/zip/folder/${folder.id}/${router.currentRoute.params.token}`
: `/api/zip/folder/${folder.id}`
axios.get(route)
.then(response => {
Vue.prototype.$downloadFile(response.data.url, response.data.name)
})
.catch(() => {
Vue.prototype.$isSomethingWrong()
})
.finally(() => {
commit('PROCESSING_POPUP', undefined)
})
},
downloadFiles: ({commit, getters}) => {
downloadZip: ({getters}) => {
let files = []
// get ids of selected files
getters.clipboard.forEach(file => files.push(file.id))
getters.clipboard.forEach(file => {
let type = file.type === 'folder'
? 'folder'
: 'file'
files.push(file.id + '|' + type)
})
let items = files.join(',')
// Get route
let route = getters.sharedDetail
? `/api/zip/files/${router.currentRoute.params.token}`
: '/api/zip/files'
? `/api/zip/${router.currentRoute.params.token}?items=${items}`
: `/api/zip?items=${items}`
commit('PROCESSING_POPUP', {
title: i18n.t('popup_zipping.title'),
message: i18n.t('popup_zipping.message'),
})
axios.post(route, {
items: files
})
.then(response => {
Vue.prototype.$downloadFile(response.data.url, response.data.name)
})
.catch(() => {
Vue.prototype.$isSomethingWrong()
})
.finally(() => {
commit('PROCESSING_POPUP', undefined)
})
Vue.prototype.$downloadFile(route, 'files.zip')
},
moveItem: ({commit, getters, dispatch}, {to_item, noSelectedItem}) => {
+3 -9
View File
@@ -1,6 +1,6 @@
import i18n from '@/i18n/index'
import router from '@/router'
import {events} from '@/bus'
import i18n from '/resources/js/i18n/index'
import router from '/resources/js/router'
import {events} from '/resources/js/bus'
import axios from 'axios'
import Vue from "vue";
@@ -27,12 +27,6 @@ const actions = {
if (payload.init)
commit('FLUSH_FOLDER_HISTORY')
// Clear search
if (getters.isSearching) {
commit('CHANGE_SEARCHING_STATE', false)
events.$emit('clear-query')
}
if (! payload.back && !payload.sorting)
commit('STORE_PREVIOUS_FOLDER', getters.currentFolder)
+1 -1
View File
@@ -1,5 +1,5 @@
import axios from 'axios'
import router from '@/router'
import router from '/resources/js/router'
import Vue from 'vue'
const defaultState = {