Skip to content

Commit

Permalink
feat: preview size button
Browse files Browse the repository at this point in the history
  • Loading branch information
ramiresviana committed Aug 25, 2020
1 parent 7787344 commit 3d2cb83
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 4 deletions.
22 changes: 22 additions & 0 deletions frontend/src/components/buttons/PreviewSize.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<template>
<button :title="$t('buttons.info')" :aria-label="$t('buttons.info')" class="action" @click="$emit('change-size')">
<i class="material-icons">{{ this.icon }}</i>
<span>{{ $t('buttons.info') }}</span>
</button>
</template>

<script>
export default {
name: 'preview-size-button',
props: [ 'size' ],
computed: {
icon () {
if (this.size) {
return 'photo_size_select_large'
}
return 'hd'
}
}
}
</script>
7 changes: 7 additions & 0 deletions frontend/src/components/files/ExtendedImage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ export default {
window.removeEventListener('resize', this.onResize)
document.removeEventListener('mouseup', this.onMouseUp)
},
watch: {
src: function () {
this.scale = 1
this.setZoom()
this.setCenter()
}
},
methods: {
onLoad() {
let img = this.$refs.imgex
Expand Down
16 changes: 13 additions & 3 deletions frontend/src/components/files/Preview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<span>{{ this.name }}</span>
</div>

<preview-size-button v-if="isResizeEnabled && this.req.type === 'image'" @change-size="toggleSize" v-bind:size="fullSize" :disabled="loading"></preview-size-button>
<button @click="openMore" id="more" :aria-label="$t('buttons.more')" :title="$t('buttons.more')" class="action">
<i class="material-icons">more_vert</i>
</button>
Expand Down Expand Up @@ -65,8 +66,9 @@
<script>
import { mapState } from 'vuex'
import url from '@/utils/url'
import { baseURL } from '@/utils/constants'
import { baseURL, resizePreview } from '@/utils/constants'
import { files as api } from '@/api'
import PreviewSizeButton from '@/components/buttons/PreviewSize'
import InfoButton from '@/components/buttons/Info'
import DeleteButton from '@/components/buttons/Delete'
import RenameButton from '@/components/buttons/Rename'
Expand All @@ -83,6 +85,7 @@ const mediaTypes = [
export default {
name: 'preview',
components: {
PreviewSizeButton,
InfoButton,
DeleteButton,
RenameButton,
Expand All @@ -95,7 +98,8 @@ export default {
nextLink: '',
listing: null,
name: '',
subtitles: []
subtitles: [],
fullSize: false
}
},
computed: {
Expand All @@ -110,7 +114,7 @@ export default {
return `${baseURL}/api/raw${url.encodePath(this.req.path)}?auth=${this.jwt}`
},
previewUrl () {
if (this.req.type === 'image') {
if (this.req.type === 'image' && !this.fullSize) {
return `${baseURL}/api/preview/big${url.encodePath(this.req.path)}?auth=${this.jwt}`
}
return `${baseURL}/api/raw${url.encodePath(this.req.path)}?auth=${this.jwt}`
Expand All @@ -120,6 +124,9 @@ export default {
},
showMore () {
return this.$store.state.show === 'more'
},
isResizeEnabled () {
return resizePreview
}
},
watch: {
Expand Down Expand Up @@ -206,6 +213,9 @@ export default {
},
resetPrompts () {
this.$store.commit('closeHovers')
},
toggleSize () {
this.fullSize = !this.fullSize
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/utils/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const authMethod = window.FileBrowser.AuthMethod
const loginPage = window.FileBrowser.LoginPage
const theme = window.FileBrowser.Theme
const enableThumbs = window.FileBrowser.EnableThumbs
const resizePreview = window.FileBrowser.ResizePreview

export {
name,
Expand All @@ -26,5 +27,6 @@ export {
authMethod,
loginPage,
theme,
enableThumbs
enableThumbs,
resizePreview
}
1 change: 1 addition & 0 deletions http/static.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func handleWithStaticData(w http.ResponseWriter, _ *http.Request, d *data, box *
"ReCaptcha": false,
"Theme": d.settings.Branding.Theme,
"EnableThumbs": d.server.EnableThumbnails,
"ResizePreview": d.server.ResizePreview,
}

if d.settings.Branding.Files != "" {
Expand Down

0 comments on commit 3d2cb83

Please sign in to comment.