mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-18 16:22:14 +00:00
added prettier
This commit is contained in:
@@ -1,173 +1,166 @@
|
||||
<template>
|
||||
<div class="navigation-panel" v-if="currentFile">
|
||||
<div class="name-wrapper">
|
||||
<div class="navigation-panel" v-if="currentFile">
|
||||
<div class="name-wrapper">
|
||||
<!--Close icon-->
|
||||
<span @click="closeFullPreview" class="-m-3 p-3">
|
||||
<x-icon size="17" class="icon-close hover-text-theme" />
|
||||
</span>
|
||||
|
||||
<!--Close icon-->
|
||||
<span @click="closeFullPreview" class="p-3 -m-3">
|
||||
<x-icon size="17" class="icon-close hover-text-theme" />
|
||||
</span>
|
||||
<!--Item name-->
|
||||
<div class="name-count-wrapper">
|
||||
<p class="title">{{ currentFile.data.attributes.name }}</p>
|
||||
<span v-if="!fastPreview" class="file-count"> ({{ showingImageIndex + ' ' + $t('pronouns.of') + ' ' + files.length }}) </span>
|
||||
</div>
|
||||
|
||||
<!--Item name-->
|
||||
<div class="name-count-wrapper">
|
||||
<p class="title">{{ currentFile.data.attributes.name }}</p>
|
||||
<span v-if="! fastPreview" class="file-count"> ({{ showingImageIndex + ' ' + $t('pronouns.of') + ' ' + files.length }}) </span>
|
||||
</div>
|
||||
<!--Context menu handler-->
|
||||
<PopoverWrapper>
|
||||
<!--Icon-->
|
||||
<span @click.stop="showItemContextMenu" class="-m-3 p-3">
|
||||
<div class="inline-block rounded-md bg-light-background py-0.5 px-1.5 align-middle transition-all duration-200 dark:bg-dark-foreground lg:bg-transparent">
|
||||
<more-horizontal-icon size="14" />
|
||||
</div>
|
||||
</span>
|
||||
|
||||
<!--Context menu handler-->
|
||||
<PopoverWrapper>
|
||||
<!--Desktop context menu-->
|
||||
<PopoverItem name="file-preview-contextmenu" side="right">
|
||||
<OptionGroup>
|
||||
<Option @click.native="$renameFileOrFolder(currentFile)" :title="$t('context_menu.rename')" icon="rename" />
|
||||
<Option @click.native="$moveFileOrFolder(currentFile)" :title="$t('context_menu.move')" icon="move-item" />
|
||||
<Option @click.native="$shareFileOrFolder(currentFile)" :title="sharingTitle" icon="share" v-if="$checkPermission('master')" />
|
||||
<Option @click.native="$deleteFileOrFolder(currentFile)" :title="$t('context_menu.delete')" icon="trash" class="menu-option" />
|
||||
</OptionGroup>
|
||||
<OptionGroup>
|
||||
<Option @click.native="downloadItem" :title="$t('context_menu.download')" icon="download" />
|
||||
</OptionGroup>
|
||||
</PopoverItem>
|
||||
</PopoverWrapper>
|
||||
</div>
|
||||
|
||||
<!--Icon-->
|
||||
<span @click.stop="showItemContextMenu" class="p-3 -m-3">
|
||||
<div class="py-0.5 px-1.5 align-middle inline-block rounded-md lg:bg-transparent dark:bg-dark-foreground bg-light-background transition-all duration-200">
|
||||
<more-horizontal-icon size="14" />
|
||||
</div>
|
||||
</span>
|
||||
<!--Item metadata-->
|
||||
<div class="created-at-wrapper">
|
||||
<p>
|
||||
{{ currentFile.data.attributes.filesize }},
|
||||
{{ currentFile.data.attributes.created_at }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<!--Desktop context menu-->
|
||||
<PopoverItem name="file-preview-contextmenu" side="right">
|
||||
<OptionGroup>
|
||||
<Option @click.native="$renameFileOrFolder(currentFile)" :title="$t('context_menu.rename')" icon="rename" />
|
||||
<Option @click.native="$moveFileOrFolder(currentFile)" :title="$t('context_menu.move')" icon="move-item" />
|
||||
<Option @click.native="$shareFileOrFolder(currentFile)" :title="sharingTitle" icon="share" v-if="$checkPermission('master')" />
|
||||
<Option @click.native="$deleteFileOrFolder(currentFile)" :title="$t('context_menu.delete')" icon="trash" class="menu-option" />
|
||||
</OptionGroup>
|
||||
<OptionGroup>
|
||||
<Option @click.native="downloadItem" :title="$t('context_menu.download')" icon="download" />
|
||||
</OptionGroup>
|
||||
</PopoverItem>
|
||||
</PopoverWrapper>
|
||||
</div>
|
||||
|
||||
<!--Item metadata-->
|
||||
<div class="created-at-wrapper">
|
||||
<p>{{ currentFile.data.attributes.filesize }}, {{ currentFile.data.attributes.created_at }}</p>
|
||||
</div>
|
||||
|
||||
<!--Icon actions-->
|
||||
<div class="navigation-icons">
|
||||
<div v-if="isPdf" class="navigation-tool-wrapper">
|
||||
<ToolbarButton @click.native="decreaseSizeOfPDF" source="zoom-out" :action="$t('pdf_zoom_out')" />
|
||||
<ToolbarButton @click.native="increaseSizeOfPDF" source="zoom-in" :action="$t('pdf_zoom_in')" />
|
||||
</div>
|
||||
<div class="navigation-tool-wrapper">
|
||||
<ToolbarButton @click.native="downloadItem" class="mobile-hide" source="download" :action="$t('actions.download')" />
|
||||
<ToolbarButton v-if="canShareItem" @click.native="$shareFileOrFolder(currentFile)" class="mobile-hide" :class="{ 'is-inactive': !canShareItem }" source="share" :action="$t('actions.share')" />
|
||||
<ToolbarButton v-if="isImage" @click.native="printMethod()" source="print" :action="$t('actions.print')" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!--Icon actions-->
|
||||
<div class="navigation-icons">
|
||||
<div v-if="isPdf" class="navigation-tool-wrapper">
|
||||
<ToolbarButton @click.native="decreaseSizeOfPDF" source="zoom-out" :action="$t('pdf_zoom_out')" />
|
||||
<ToolbarButton @click.native="increaseSizeOfPDF" source="zoom-in" :action="$t('pdf_zoom_in')" />
|
||||
</div>
|
||||
<div class="navigation-tool-wrapper">
|
||||
<ToolbarButton @click.native="downloadItem" class="mobile-hide" source="download" :action="$t('actions.download')" />
|
||||
<ToolbarButton
|
||||
v-if="canShareItem"
|
||||
@click.native="$shareFileOrFolder(currentFile)"
|
||||
class="mobile-hide"
|
||||
:class="{ 'is-inactive': !canShareItem }"
|
||||
source="share"
|
||||
:action="$t('actions.share')"
|
||||
/>
|
||||
<ToolbarButton v-if="isImage" @click.native="printMethod()" source="print" :action="$t('actions.print')" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import PopoverWrapper from "../Desktop/PopoverWrapper";
|
||||
import PopoverItem from "../Desktop/PopoverItem";
|
||||
import OptionGroup from "../FilesView/OptionGroup";
|
||||
import Option from "../FilesView/Option";
|
||||
import PopoverWrapper from '../Desktop/PopoverWrapper'
|
||||
import PopoverItem from '../Desktop/PopoverItem'
|
||||
import OptionGroup from '../FilesView/OptionGroup'
|
||||
import Option from '../FilesView/Option'
|
||||
|
||||
import ToolbarButton from "../FilesView/ToolbarButton";
|
||||
import {XIcon, MoreHorizontalIcon} from 'vue-feather-icons'
|
||||
import {mapGetters} from 'vuex'
|
||||
import {events} from "../../bus";
|
||||
import ToolbarButton from '../FilesView/ToolbarButton'
|
||||
import { XIcon, MoreHorizontalIcon } from 'vue-feather-icons'
|
||||
import { mapGetters } from 'vuex'
|
||||
import { events } from '../../bus'
|
||||
|
||||
export default {
|
||||
name: 'FilePreviewToolbar',
|
||||
components: {
|
||||
MoreHorizontalIcon,
|
||||
PopoverWrapper,
|
||||
ToolbarButton,
|
||||
PopoverItem,
|
||||
OptionGroup,
|
||||
Option,
|
||||
XIcon,
|
||||
export default {
|
||||
name: 'FilePreviewToolbar',
|
||||
components: {
|
||||
MoreHorizontalIcon,
|
||||
PopoverWrapper,
|
||||
ToolbarButton,
|
||||
PopoverItem,
|
||||
OptionGroup,
|
||||
Option,
|
||||
XIcon,
|
||||
},
|
||||
computed: {
|
||||
...mapGetters(['fastPreview', 'clipboard', 'entries']),
|
||||
currentFile() {
|
||||
return this.fastPreview ? this.fastPreview : this.clipboard[0]
|
||||
},
|
||||
computed: {
|
||||
...mapGetters([
|
||||
'fastPreview',
|
||||
'clipboard',
|
||||
'entries'
|
||||
]),
|
||||
currentFile() {
|
||||
return this.fastPreview ? this.fastPreview : this.clipboard[0]
|
||||
},
|
||||
sharingTitle() {
|
||||
return this.currentFile.data.relationships.shared
|
||||
? this.$t('context_menu.share_edit')
|
||||
: this.$t('context_menu.share')
|
||||
},
|
||||
isImage() {
|
||||
return this.currentFile.data.type === 'image'
|
||||
},
|
||||
isPdf() {
|
||||
return this.currentFile.data.attributes.mimetype === 'pdf'
|
||||
},
|
||||
files() {
|
||||
let files = []
|
||||
|
||||
this.entries.map(element => {
|
||||
|
||||
if (this.currentFile.data.attributes.mimetype === 'pdf') {
|
||||
|
||||
if (element.data.attributes.mimetype === 'pdf')
|
||||
files.push(element)
|
||||
|
||||
} else {
|
||||
|
||||
if (element.data.type === this.currentFile.data.type)
|
||||
files.push(element)
|
||||
}
|
||||
})
|
||||
|
||||
return files
|
||||
},
|
||||
showingImageIndex() {
|
||||
let activeIndex = undefined
|
||||
|
||||
this.files.forEach((element, index) => {
|
||||
if (element.data.id === this.currentFile.data.id) {
|
||||
activeIndex = index + 1
|
||||
}
|
||||
})
|
||||
|
||||
return activeIndex
|
||||
},
|
||||
canShareItem() {
|
||||
return this.$isThisRoute(this.$route, ['Files', 'RecentUploads', 'MySharedItems'])
|
||||
},
|
||||
sharingTitle() {
|
||||
return this.currentFile.data.relationships.shared ? this.$t('context_menu.share_edit') : this.$t('context_menu.share')
|
||||
},
|
||||
methods: {
|
||||
showItemContextMenu() {
|
||||
if (this.$isMobile()) {
|
||||
events.$emit('mobile-context-menu:show', this.currentFile)
|
||||
this.$showMobileMenu('file-menu')
|
||||
} else {
|
||||
events.$emit('popover:open', 'file-preview-contextmenu')
|
||||
}
|
||||
},
|
||||
increaseSizeOfPDF() {
|
||||
events.$emit('document-zoom:in')
|
||||
},
|
||||
decreaseSizeOfPDF() {
|
||||
events.$emit('document-zoom:out')
|
||||
},
|
||||
printMethod() {
|
||||
let tab = document.getElementById('printable-file')
|
||||
let win = window.open('', '', 'height=700,width=700')
|
||||
isImage() {
|
||||
return this.currentFile.data.type === 'image'
|
||||
},
|
||||
isPdf() {
|
||||
return this.currentFile.data.attributes.mimetype === 'pdf'
|
||||
},
|
||||
files() {
|
||||
let files = []
|
||||
|
||||
win.document.write(tab.outerHTML)
|
||||
win.document.close()
|
||||
win.print()
|
||||
},
|
||||
downloadItem() {
|
||||
this.$downloadFile(
|
||||
this.currentFile.data.attributes.file_url,
|
||||
this.currentFile.data.attributes.name + '.' + this.currentFile.data.attributes.mimetype
|
||||
)
|
||||
},
|
||||
closeFullPreview() {
|
||||
events.$emit('file-preview:hide')
|
||||
this.entries.map((element) => {
|
||||
if (this.currentFile.data.attributes.mimetype === 'pdf') {
|
||||
if (element.data.attributes.mimetype === 'pdf') files.push(element)
|
||||
} else {
|
||||
if (element.data.type === this.currentFile.data.type) files.push(element)
|
||||
}
|
||||
})
|
||||
|
||||
return files
|
||||
},
|
||||
showingImageIndex() {
|
||||
let activeIndex = undefined
|
||||
|
||||
this.files.forEach((element, index) => {
|
||||
if (element.data.id === this.currentFile.data.id) {
|
||||
activeIndex = index + 1
|
||||
}
|
||||
})
|
||||
|
||||
return activeIndex
|
||||
},
|
||||
canShareItem() {
|
||||
return this.$isThisRoute(this.$route, ['Files', 'RecentUploads', 'MySharedItems'])
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
showItemContextMenu() {
|
||||
if (this.$isMobile()) {
|
||||
events.$emit('mobile-context-menu:show', this.currentFile)
|
||||
this.$showMobileMenu('file-menu')
|
||||
} else {
|
||||
events.$emit('popover:open', 'file-preview-contextmenu')
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
increaseSizeOfPDF() {
|
||||
events.$emit('document-zoom:in')
|
||||
},
|
||||
decreaseSizeOfPDF() {
|
||||
events.$emit('document-zoom:out')
|
||||
},
|
||||
printMethod() {
|
||||
let tab = document.getElementById('printable-file')
|
||||
let win = window.open('', '', 'height=700,width=700')
|
||||
|
||||
win.document.write(tab.outerHTML)
|
||||
win.document.close()
|
||||
win.print()
|
||||
},
|
||||
downloadItem() {
|
||||
this.$downloadFile(this.currentFile.data.attributes.file_url, this.currentFile.data.attributes.name + '.' + this.currentFile.data.attributes.mimetype)
|
||||
},
|
||||
closeFullPreview() {
|
||||
events.$emit('file-preview:hide')
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@@ -300,9 +293,7 @@
|
||||
}
|
||||
|
||||
@media (max-width: 960px) {
|
||||
|
||||
.context-menu {
|
||||
|
||||
.name-wrapper {
|
||||
width: 67%;
|
||||
}
|
||||
@@ -355,4 +346,4 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user