public share navigation

This commit is contained in:
Peter Papp
2021-08-23 08:30:34 +02:00
parent 882b5543f0
commit 26e3194f21
11 changed files with 193 additions and 56 deletions
@@ -121,6 +121,7 @@
'isVisibleSidebar',
'FilePreviewType',
'currentFolder',
'sharedDetail',
'clipboard',
]),
isLoadedFolder() {
@@ -258,18 +258,19 @@ export default {
// Clear selected items after open another folder
this.$store.commit('CLIPBOARD_CLEAR')
if (this.$isThisLocation('public')) {
this.$store.dispatch('browseShared', [{folder: this.item, back: false, init: false}])
} else {
let route = this.$router.currentRoute.name
let route = this.$router.currentRoute.name
if (route === 'Files')
this.$router.push({name: 'Files', params: {id: this.item.id}})
if (route === 'Trash')
this.$router.push({name: 'Trash', params: {id: this.item.id}})
else
this.$router.push({name: 'Files', params: {id: this.item.id}})
}
if (route === 'Public') {
this.$router.push({name: 'Public', params: {token: this.$route.params.token, id: this.item.id}})
}
if (route === 'Trash') {
this.$router.push({name: 'Trash', params: {id: this.item.id}})
}
if (route === 'Files') {
this.$router.push({name: 'Files', params: {id: this.item.id}})
}
}
},
renameItem: debounce(function (e) {
+3 -3
View File
@@ -9,10 +9,10 @@ const routesShared = [
},
children: [
{
name: 'SharedFileBrowser',
path: '/share/:token/files',
name: 'Public',
path: '/share/:token/files/:id?',
component: () =>
import(/* webpackChunkName: "chunks/shared/file-browser" */ '../views/Shared/SharedFileBrowser'),
import(/* webpackChunkName: "chunks/shared/files" */ '../views/FileView/Public/Public'),
meta: {
requiresAuth: false
},
+8 -13
View File
@@ -1,4 +1,3 @@
import i18n from '/resources/js/i18n/index'
import router from '/resources/js/router'
import {events} from '/resources/js/bus'
import axios from 'axios'
@@ -21,26 +20,22 @@ const defaultState = {
sharedFile: undefined,
}
const actions = {
browseShared: ({commit, getters}, [payload]) => {
getSharedFolder: ({commit, getters}, id) => {
commit('LOADING_STATE', {loading: true, data: []})
payload.folder.location = 'public'
return new Promise((resolve, reject) => {
axios
.get(`/api/browse/folders/${payload.folder.id}/${router.currentRoute.params.token}${getters.sorting.URI}`)
.get(`/api/browse/folders/${id}/${router.currentRoute.params.token}${getters.sorting.URI}`)
.then(response => {
commit('LOADING_STATE', {loading: false, data: response.data})
commit('LOADING_STATE', {loading: false, data: response.data.content})
commit('SET_CURRENT_FOLDER', response.data.folder)
events.$emit('scrollTop')
resolve(response)
})
.catch((error) => {
// Show error message
events.$emit('alert:open', {
title: i18n.t('popup_error.title'),
message: i18n.t('popup_error.message'),
})
Vue.prototype.$isSomethingWrong()
reject(error)
})
@@ -67,8 +62,9 @@ const actions = {
.catch(error => {
reject(error)
if (error.response.status == 404)
if (error.response.status === 404) {
router.push({name: 'NotFound'})
}
})
})
},
@@ -102,7 +98,6 @@ const actions = {
// Flush shared data
commit('FLUSH_SHARED', item.id)
commit('CLIPBOARD_CLEAR')
})
resolve(true)
@@ -147,6 +147,7 @@
},
computed: {
...mapGetters([
'sharedDetail',
'clipboard',
'user',
]),
@@ -205,8 +206,8 @@
}
},
},
created() {
this.$store.dispatch('getFolder', this.$route.params.id)
mounted() {
this.$store.dispatch('getSharedFolder', this.$route.params.id)
events.$on('context-menu:show', (event, item) => this.item = item)
events.$on('mobile-context-menu:show', item => this.item = item)
+41 -8
View File
@@ -26,19 +26,23 @@
<DragUI />
<Alert />
<router-view :class="{'is-scaled-down': isScaledDown}" />
<div @contextmenu.prevent.capture="contextMenu($event, undefined)" id="file-view">
<DesktopToolbar/>
<router-view :key="$route.fullPath" />
</div>
</div>
</template>
<script>
import MultiSelectToolbar from '/resources/js/components/FilesView/MultiSelectToolbar'
import MobileContextMenu from '/resources/js/components/FilesView/MobileContextMenu'
import FileSortingMobile from '/resources/js/components/FilesView/FileSortingMobile'
import CreateFolderPopup from '/resources/js/components/Others/CreateFolderPopup'
import ProcessingPopup from '/resources/js/components/FilesView/ProcessingPopup'
import MobileContextMenu from '/resources/js/components/FilesView/MobileContextMenu'
import RenameItemPopup from '/resources/js/components/Others/RenameItemPopup'
import MoveItemPopup from '/resources/js/components/Others/MoveItemPopup'
import FilePreview from '/resources/js/components/FilePreview/FilePreview'
import MoveItemPopup from '/resources/js/components/Others/MoveItemPopup'
import DesktopToolbar from "../components/FilesView/DesktopToolbar"
import Spinner from '/resources/js/components/FilesView/Spinner'
import Vignette from '/resources/js/components/Others/Vignette'
import DragUI from '/resources/js/components/FilesView/DragUI'
@@ -52,9 +56,10 @@
MultiSelectToolbar,
CreateFolderPopup,
FileSortingMobile,
MobileContextMenu,
ProcessingPopup,
RenameItemPopup,
MobileContextMenu,
DesktopToolbar,
MoveItemPopup,
FilePreview,
Vignette,
@@ -73,6 +78,16 @@
isScaledDown: false
}
},
methods: {
spotlightListener(e) {
if (e.key === 'k' && e.metaKey) {
events.$emit('spotlight:show');
}
},
contextMenu(event, item) {
events.$emit('context-menu:show', event, item)
},
},
mounted() {
events.$on('mobile-menu:show', () => this.isScaledDown = true)
events.$on('fileItem:deselect', () => this.isScaledDown = false)
@@ -81,18 +96,22 @@
.then(response => {
this.isLoading = false
let type = response.data.data.attributes.type
let routeName = this.$router.currentRoute.name
let isProtected = response.data.data.attributes.is_protected
// Show public file browser
if (response.data.data.attributes.type === 'folder' && !response.data.data.attributes.is_protected && this.$router.currentRoute.name !== 'SharedFileBrowser') {
this.$router.push({name: 'SharedFileBrowser'})
if (type === 'folder' && !isProtected && routeName !== 'Public') {
this.$router.replace({name: 'Public', params: {token: this.$route.params.token, id: response.data.data.attributes.item_id}})
}
// Show public single file
if (response.data.data.attributes.type !== 'folder' && !response.data.data.attributes.is_protected && this.$router.currentRoute.name !== 'SharedSingleFile') {
if (type !== 'folder' && !isProtected && routeName !== 'SharedSingleFile') {
this.$router.push({name: 'SharedSingleFile'})
}
// Show authentication page
if (response.data.data.attributes.is_protected && this.$router.currentRoute.name !== 'SharedAuthentication') {
if (isProtected && routeName !== 'SharedAuthentication') {
this.$router.push({name: 'SharedAuthentication'})
}
})
@@ -103,6 +122,20 @@
<style lang="scss">
@import '/resources/sass/vuefilemanager/_mixins';
#file-view {
font-family: 'Nunito', sans-serif;
font-size: 16px;
width: 100%;
height: 100%;
position: relative;
min-width: 320px;
overflow-x: hidden;
padding-left: 15px;
padding-right: 15px;
overflow-y: hidden;
@include transition(120ms);
}
@media only screen and (max-width: 690px) {
.is-scaled-down {