mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-19 00:22:15 +00:00
- pdf implementation
- file preview refactoring
This commit is contained in:
@@ -4,9 +4,9 @@
|
||||
<x-icon @click="closeFullPreview" size="22" class="icon-close hover-text-theme" />
|
||||
<div class="name-count-wrapper">
|
||||
<p class="title">{{ fileInfoDetail[0].name }}</p>
|
||||
<span class="file-count"> ({{ showingImageIndex + ' ' + $t('pronouns.of') + ' ' + filteredFiles.length }}) </span>
|
||||
<span class="file-count"> ({{ showingImageIndex + ' ' + $t('pronouns.of') + ' ' + files.length }}) </span>
|
||||
</div>
|
||||
<span id="fast-preview-menu" class="fast-menu-icon group" @click.stop="menuOpen" v-if="$checkPermission(['master', 'editor', 'visitor'])">
|
||||
<span @click.stop="menuOpen" id="fast-preview-menu" class="fast-menu-icon group">
|
||||
<more-horizontal-icon class="more-icon group-hover-text-theme" size="14" />
|
||||
</span>
|
||||
</div>
|
||||
@@ -14,96 +14,112 @@
|
||||
<div class="created-at-wrapper">
|
||||
<p>{{ fileInfoDetail[0].filesize }}, {{ fileInfoDetail[0].created_at }}</p>
|
||||
</div>
|
||||
|
||||
<div class="navigation-icons">
|
||||
<div class="navigation-tool-wrapper">
|
||||
<ToolbarButton source="download" class="mobile-hide" @click.native="downloadItem" :action="$t('actions.download')" />
|
||||
<ToolbarButton v-if="canShowShareView" :class="{ 'is-inactive': canShareInView }" @click.native="shareItem" source="share" class="mobile-hide" :action="$t('actions.share')" />
|
||||
<ToolbarButton v-if="this.fileInfoDetail[0].type === 'image'" source="print" :action="$t('actions.print')" @click.native="printMethod()" />
|
||||
<ToolbarButton @click.native="downloadItem" class="mobile-hide" source="download" :action="$t('actions.download')" />
|
||||
<ToolbarButton v-if="canShareItem" @click.native="shareItem" 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 { events } from '@/bus'
|
||||
import { mapGetters } from 'vuex'
|
||||
import { XIcon, MoreHorizontalIcon } from 'vue-feather-icons'
|
||||
import ToolbarButton from '@/components/FilesView/ToolbarButton'
|
||||
import {XIcon, MoreHorizontalIcon} from 'vue-feather-icons'
|
||||
import {mapGetters} from 'vuex'
|
||||
import {events} from '@/bus'
|
||||
|
||||
import ToolbarButton from '@/components/FilesView/ToolbarButton'
|
||||
|
||||
export default {
|
||||
name: 'FilePreviewNavigationPanel',
|
||||
components: { ToolbarButton, XIcon, MoreHorizontalIcon },
|
||||
computed: {
|
||||
...mapGetters(['fileInfoDetail', 'data']),
|
||||
filteredFiles() {
|
||||
let files = []
|
||||
this.data.filter((element) => {
|
||||
if (element.type == this.fileInfoDetail[0].type) {
|
||||
files.push(element)
|
||||
}
|
||||
})
|
||||
return files
|
||||
},
|
||||
showingImageIndex() {
|
||||
let activeIndex = ''
|
||||
this.filteredFiles.filter((element, index) => {
|
||||
if (element.id === this.fileInfoDetail[0].id) {
|
||||
activeIndex = index + 1
|
||||
}
|
||||
})
|
||||
return activeIndex
|
||||
},
|
||||
canShowShareView() {
|
||||
return this.$isThisLocation(['base', 'participant_uploads', 'latest', 'shared'])
|
||||
export default {
|
||||
name: 'FilePreviewNavigationPanel',
|
||||
components: {
|
||||
MoreHorizontalIcon,
|
||||
ToolbarButton,
|
||||
XIcon,
|
||||
},
|
||||
canShareInView() {
|
||||
return ! this.$isThisLocation(['base', 'participant_uploads', 'latest', 'shared'])
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
showContextMenu: false
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
printMethod() {
|
||||
var tab = document.getElementById('image')
|
||||
var win = window.open('', '', 'height=700,width=700')
|
||||
win.document.write(tab.outerHTML)
|
||||
win.document.close()
|
||||
win.print()
|
||||
},
|
||||
downloadItem() {
|
||||
// Download file
|
||||
this.$downloadFile(this.fileInfoDetail[0].file_url, this.fileInfoDetail[0].name + '.' + this.fileInfoDetail[0].mimetype)
|
||||
},
|
||||
shareItem() {
|
||||
if (this.fileInfoDetail[0].shared) {
|
||||
events.$emit('popup:open', {
|
||||
name: 'share-edit',
|
||||
item: this.fileInfoDetail[0]
|
||||
})
|
||||
} else {
|
||||
events.$emit('popup:open', {
|
||||
name: 'share-create',
|
||||
item: this.fileInfoDetail[0]
|
||||
})
|
||||
}
|
||||
},
|
||||
menuOpen() {
|
||||
if (this.$isMobile()) {
|
||||
events.$emit('mobile-menu:show', 'file-menu')
|
||||
} else {
|
||||
events.$emit('showContextMenuPreview:show', this.fileInfoDetail[0])
|
||||
}
|
||||
},
|
||||
closeFullPreview() {
|
||||
events.$emit('fileFullPreview:hide')
|
||||
events.$emit('showContextMenuPreview:hide')
|
||||
}
|
||||
}
|
||||
}
|
||||
computed: {
|
||||
...mapGetters([
|
||||
'fileInfoDetail',
|
||||
'data'
|
||||
]),
|
||||
isImage() {
|
||||
return this.fileInfoDetail[0].type === 'image'
|
||||
},
|
||||
files() {
|
||||
let files = []
|
||||
|
||||
this.data.map(element => {
|
||||
|
||||
if (this.fileInfoDetail[0].mimetype === 'pdf') {
|
||||
|
||||
if (element.mimetype === 'pdf')
|
||||
files.push(element)
|
||||
|
||||
} else {
|
||||
|
||||
if (element.type === this.fileInfoDetail[0].type)
|
||||
files.push(element)
|
||||
}
|
||||
})
|
||||
|
||||
return files
|
||||
},
|
||||
showingImageIndex() {
|
||||
let activeIndex = undefined
|
||||
|
||||
this.files.forEach((element, index) => {
|
||||
if (element.id === this.fileInfoDetail[0].id) {
|
||||
activeIndex = index + 1
|
||||
}
|
||||
})
|
||||
|
||||
return activeIndex
|
||||
},
|
||||
canShareItem() {
|
||||
return this.$isThisLocation([
|
||||
'base', 'participant_uploads', 'latest', 'shared'
|
||||
])
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
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.fileInfoDetail[0].file_url,
|
||||
this.fileInfoDetail[0].name + '.' + this.fileInfoDetail[0].mimetype
|
||||
)
|
||||
},
|
||||
shareItem() {
|
||||
let event = this.fileInfoDetail[0].shared
|
||||
? 'share-edit'
|
||||
: 'share-create'
|
||||
|
||||
events.$emit('popup:open', {
|
||||
name: event,
|
||||
item: this.fileInfoDetail[0]
|
||||
})
|
||||
},
|
||||
menuOpen() {
|
||||
if (this.$isMobile()) {
|
||||
events.$emit('mobile-menu:show', 'file-menu')
|
||||
} else {
|
||||
events.$emit('showContextMenuPreview:show', this.fileInfoDetail[0])
|
||||
}
|
||||
},
|
||||
closeFullPreview() {
|
||||
events.$emit('file-preview:hide')
|
||||
events.$emit('showContextMenuPreview:hide')
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@@ -111,150 +127,158 @@ export default {
|
||||
@import '@assets/vuefilemanager/_mixins';
|
||||
|
||||
.name-wrapper {
|
||||
width: 33%;
|
||||
height: 22px;
|
||||
display: flex;
|
||||
position: relative;
|
||||
align-items: center;
|
||||
flex-grow: 1;
|
||||
align-self: center;
|
||||
white-space: nowrap;
|
||||
width: 33%;
|
||||
height: 22px;
|
||||
display: flex;
|
||||
position: relative;
|
||||
align-items: center;
|
||||
flex-grow: 1;
|
||||
align-self: center;
|
||||
white-space: nowrap;
|
||||
|
||||
.name-count-wrapper {
|
||||
.name-count-wrapper {
|
||||
margin-left: 6px;
|
||||
margin-right: 6px;
|
||||
|
||||
.file-count {
|
||||
@include font-size(15);
|
||||
line-height: 1;
|
||||
font-weight: 700;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
align-self: center;
|
||||
color: $text;
|
||||
}
|
||||
.title {
|
||||
@include font-size(15);
|
||||
max-width: 250px;
|
||||
line-height: 1;
|
||||
font-weight: 700;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
color: $text;
|
||||
}
|
||||
@media (max-width: 570px) {
|
||||
.title{
|
||||
max-width: 180px;
|
||||
@include font-size(17);
|
||||
}
|
||||
.file-count {
|
||||
@include font-size(17);
|
||||
}
|
||||
}
|
||||
}
|
||||
.icon-close {
|
||||
min-width: 22px;
|
||||
padding: 1px 4px;
|
||||
border-radius: 6px;
|
||||
vertical-align: middle;
|
||||
cursor: pointer;
|
||||
@include transition(150ms);
|
||||
@include font-size(15);
|
||||
line-height: 1;
|
||||
font-weight: 700;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
align-self: center;
|
||||
color: $text;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background: $light_background;
|
||||
.title {
|
||||
@include font-size(15);
|
||||
max-width: 250px;
|
||||
line-height: 1;
|
||||
font-weight: 700;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
color: $text;
|
||||
}
|
||||
|
||||
line {
|
||||
color: inherit;
|
||||
}
|
||||
}
|
||||
}
|
||||
.fast-menu-icon {
|
||||
height: 24px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
vertical-align: middle;
|
||||
padding: 1px 4px;
|
||||
line-height: 0;
|
||||
border-radius: 3px;
|
||||
cursor: pointer;
|
||||
@include transition(150ms);
|
||||
@media (max-width: 570px) {
|
||||
.title {
|
||||
max-width: 180px;
|
||||
@include font-size(17);
|
||||
}
|
||||
.file-count {
|
||||
@include font-size(17);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
svg circle {
|
||||
@include transition(150ms);
|
||||
}
|
||||
&:hover {
|
||||
background: $light_background;
|
||||
.icon-close {
|
||||
min-width: 22px;
|
||||
padding: 1px 4px;
|
||||
border-radius: 6px;
|
||||
vertical-align: middle;
|
||||
cursor: pointer;
|
||||
@include transition(150ms);
|
||||
|
||||
svg circle {
|
||||
color: inherit;
|
||||
}
|
||||
}
|
||||
.more-icon {
|
||||
vertical-align: middle;
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
&:hover {
|
||||
background: $light_background;
|
||||
|
||||
line {
|
||||
color: inherit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.fast-menu-icon {
|
||||
height: 24px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
vertical-align: middle;
|
||||
padding: 1px 4px;
|
||||
line-height: 0;
|
||||
border-radius: 3px;
|
||||
cursor: pointer;
|
||||
@include transition(150ms);
|
||||
|
||||
svg circle {
|
||||
@include transition(150ms);
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background: $light_background;
|
||||
|
||||
svg circle {
|
||||
color: inherit;
|
||||
}
|
||||
}
|
||||
|
||||
.more-icon {
|
||||
vertical-align: middle;
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
}
|
||||
.context-menu {
|
||||
min-width: 250px;
|
||||
position: absolute;
|
||||
z-index: 99;
|
||||
box-shadow: $shadow;
|
||||
background: white;
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
top: 29px;
|
||||
|
||||
&.showed {
|
||||
display: block;
|
||||
}
|
||||
.context-menu {
|
||||
min-width: 250px;
|
||||
position: absolute;
|
||||
z-index: 99;
|
||||
box-shadow: $shadow;
|
||||
background: white;
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
top: 29px;
|
||||
|
||||
&.showed {
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
|
||||
.created-at-wrapper {
|
||||
width: 33%;
|
||||
display: flex;
|
||||
text-align: center;
|
||||
justify-content: center;
|
||||
width: 33%;
|
||||
display: flex;
|
||||
text-align: center;
|
||||
justify-content: center;
|
||||
|
||||
p {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@include font-size(11);
|
||||
}
|
||||
p {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@include font-size(11);
|
||||
}
|
||||
}
|
||||
|
||||
.navigation-icons {
|
||||
width: 33%;
|
||||
text-align: right;
|
||||
width: 33%;
|
||||
text-align: right;
|
||||
|
||||
.navigation-tool-wrapper {
|
||||
margin-left: 28px;
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
}
|
||||
.navigation-tool-wrapper {
|
||||
margin-left: 28px;
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.button {
|
||||
margin-left: 5px;
|
||||
&:hover {
|
||||
background: $light_background;
|
||||
}
|
||||
}
|
||||
.button {
|
||||
margin-left: 5px;
|
||||
|
||||
&:hover {
|
||||
background: $light_background;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.navigation-panel {
|
||||
height: 63px;
|
||||
width: 100%;
|
||||
padding: 10px 15px;
|
||||
display: flex;
|
||||
position: absolute;
|
||||
z-index: 8;
|
||||
align-items: center;
|
||||
background-color: white;
|
||||
color: $text;
|
||||
height: 63px;
|
||||
width: 100%;
|
||||
padding: 10px 15px;
|
||||
display: flex;
|
||||
position: absolute;
|
||||
z-index: 8;
|
||||
align-items: center;
|
||||
background-color: white;
|
||||
color: $text;
|
||||
}
|
||||
|
||||
@media (max-width: 960px) {
|
||||
@@ -287,33 +311,34 @@ export default {
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
.navigation-panel {
|
||||
background-color: $dark_mode_background;
|
||||
color: $dark_mode_text_primary;
|
||||
.navigation-panel {
|
||||
background-color: $dark_mode_background;
|
||||
color: $dark_mode_text_primary;
|
||||
|
||||
.icon-close {
|
||||
color: $dark_mode_text_primary;
|
||||
&:hover {
|
||||
background-color: $dark_mode_background;
|
||||
}
|
||||
}
|
||||
.icon-close {
|
||||
color: $dark_mode_text_primary;
|
||||
|
||||
.fast-menu-icon:hover {
|
||||
background: $dark_mode_background;
|
||||
}
|
||||
}
|
||||
&:hover {
|
||||
background-color: $dark_mode_background;
|
||||
}
|
||||
}
|
||||
|
||||
.name-wrapper {
|
||||
.title,
|
||||
.file-count {
|
||||
color: $dark_mode_text_primary !important;
|
||||
}
|
||||
}
|
||||
.fast-menu-icon:hover {
|
||||
background: $dark_mode_background;
|
||||
}
|
||||
}
|
||||
|
||||
.navigation-icons {
|
||||
.button:hover {
|
||||
background: $dark_mode_background;
|
||||
}
|
||||
}
|
||||
.name-wrapper {
|
||||
.title,
|
||||
.file-count {
|
||||
color: $dark_mode_text_primary !important;
|
||||
}
|
||||
}
|
||||
|
||||
.navigation-icons {
|
||||
.button:hover {
|
||||
background: $dark_mode_background;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user