Merge pull request #1066 from ramiresviana/preview-mobile-dropdown
This commit is contained in:
		
						commit
						b9ede79888
					
				| 
						 | 
					@ -1,5 +1,5 @@
 | 
				
			||||||
<template>
 | 
					<template>
 | 
				
			||||||
  <header v-if="!isEditor">
 | 
					  <header v-if="!isEditor && !isPreview">
 | 
				
			||||||
    <div>
 | 
					    <div>
 | 
				
			||||||
      <button @click="openSidebar" :aria-label="$t('buttons.toggleSidebar')" :title="$t('buttons.toggleSidebar')" class="action">
 | 
					      <button @click="openSidebar" :aria-label="$t('buttons.toggleSidebar')" :title="$t('buttons.toggleSidebar')" class="action">
 | 
				
			||||||
        <i class="material-icons">menu</i>
 | 
					        <i class="material-icons">menu</i>
 | 
				
			||||||
| 
						 | 
					@ -108,6 +108,7 @@ export default {
 | 
				
			||||||
      'selectedCount',
 | 
					      'selectedCount',
 | 
				
			||||||
      'isFiles',
 | 
					      'isFiles',
 | 
				
			||||||
      'isEditor',
 | 
					      'isEditor',
 | 
				
			||||||
 | 
					      'isPreview',
 | 
				
			||||||
      'isListing',
 | 
					      'isListing',
 | 
				
			||||||
      'isLogged'
 | 
					      'isLogged'
 | 
				
			||||||
    ]),
 | 
					    ]),
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -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>
 | 
				
			||||||
| 
						 | 
					@ -77,6 +77,13 @@ export default {
 | 
				
			||||||
    window.removeEventListener('resize', this.onResize)
 | 
					    window.removeEventListener('resize', this.onResize)
 | 
				
			||||||
    document.removeEventListener('mouseup', this.onMouseUp)
 | 
					    document.removeEventListener('mouseup', this.onMouseUp)
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
 | 
					  watch: {
 | 
				
			||||||
 | 
					    src: function () {
 | 
				
			||||||
 | 
					      this.scale = 1
 | 
				
			||||||
 | 
					      this.setZoom()
 | 
				
			||||||
 | 
					      this.setCenter()
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
  methods: {
 | 
					  methods: {
 | 
				
			||||||
    onLoad() {
 | 
					    onLoad() {
 | 
				
			||||||
      let img = this.$refs.imgex
 | 
					      let img = this.$refs.imgex
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -9,10 +9,17 @@
 | 
				
			||||||
        <span>{{ this.name }}</span>
 | 
					        <span>{{ this.name }}</span>
 | 
				
			||||||
      </div>
 | 
					      </div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      <rename-button :disabled="loading" v-if="user.perm.rename"></rename-button>
 | 
					      <preview-size-button v-if="isResizeEnabled && this.req.type === 'image'" @change-size="toggleSize" v-bind:size="fullSize" :disabled="loading"></preview-size-button>
 | 
				
			||||||
      <delete-button :disabled="loading" v-if="user.perm.delete"></delete-button>
 | 
					      <button @click="openMore" id="more" :aria-label="$t('buttons.more')" :title="$t('buttons.more')" class="action">
 | 
				
			||||||
      <download-button :disabled="loading" v-if="user.perm.download"></download-button>
 | 
					        <i class="material-icons">more_vert</i>
 | 
				
			||||||
      <info-button :disabled="loading"></info-button>
 | 
					      </button>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      <div id="dropdown" :class="{ active : showMore }">
 | 
				
			||||||
 | 
					        <rename-button :disabled="loading" v-if="user.perm.rename"></rename-button>
 | 
				
			||||||
 | 
					        <delete-button :disabled="loading" v-if="user.perm.delete"></delete-button>
 | 
				
			||||||
 | 
					        <download-button :disabled="loading" v-if="user.perm.download"></download-button>
 | 
				
			||||||
 | 
					        <info-button :disabled="loading"></info-button>
 | 
				
			||||||
 | 
					      </div>
 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <div class="loading" v-if="loading">
 | 
					    <div class="loading" v-if="loading">
 | 
				
			||||||
| 
						 | 
					@ -51,14 +58,17 @@
 | 
				
			||||||
        </a>
 | 
					        </a>
 | 
				
			||||||
      </div>
 | 
					      </div>
 | 
				
			||||||
    </template>
 | 
					    </template>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <div v-show="showMore" @click="resetPrompts" class="overlay"></div>
 | 
				
			||||||
  </div>
 | 
					  </div>
 | 
				
			||||||
</template>
 | 
					</template>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<script>
 | 
					<script>
 | 
				
			||||||
import { mapState } from 'vuex'
 | 
					import { mapState } from 'vuex'
 | 
				
			||||||
import url from '@/utils/url'
 | 
					import url from '@/utils/url'
 | 
				
			||||||
import { baseURL } from '@/utils/constants'
 | 
					import { baseURL, resizePreview } from '@/utils/constants'
 | 
				
			||||||
import { files as api } from '@/api'
 | 
					import { files as api } from '@/api'
 | 
				
			||||||
 | 
					import PreviewSizeButton from '@/components/buttons/PreviewSize'
 | 
				
			||||||
import InfoButton from '@/components/buttons/Info'
 | 
					import InfoButton from '@/components/buttons/Info'
 | 
				
			||||||
import DeleteButton from '@/components/buttons/Delete'
 | 
					import DeleteButton from '@/components/buttons/Delete'
 | 
				
			||||||
import RenameButton from '@/components/buttons/Rename'
 | 
					import RenameButton from '@/components/buttons/Rename'
 | 
				
			||||||
| 
						 | 
					@ -75,6 +85,7 @@ const mediaTypes = [
 | 
				
			||||||
export default {
 | 
					export default {
 | 
				
			||||||
  name: 'preview',
 | 
					  name: 'preview',
 | 
				
			||||||
  components: {
 | 
					  components: {
 | 
				
			||||||
 | 
					    PreviewSizeButton,
 | 
				
			||||||
    InfoButton,
 | 
					    InfoButton,
 | 
				
			||||||
    DeleteButton,
 | 
					    DeleteButton,
 | 
				
			||||||
    RenameButton,
 | 
					    RenameButton,
 | 
				
			||||||
| 
						 | 
					@ -87,7 +98,8 @@ export default {
 | 
				
			||||||
      nextLink: '',
 | 
					      nextLink: '',
 | 
				
			||||||
      listing: null,
 | 
					      listing: null,
 | 
				
			||||||
      name: '',
 | 
					      name: '',
 | 
				
			||||||
      subtitles: []
 | 
					      subtitles: [],
 | 
				
			||||||
 | 
					      fullSize: false
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
  computed: {
 | 
					  computed: {
 | 
				
			||||||
| 
						 | 
					@ -102,13 +114,19 @@ export default {
 | 
				
			||||||
      return `${baseURL}/api/raw${url.encodePath(this.req.path)}?auth=${this.jwt}`
 | 
					      return `${baseURL}/api/raw${url.encodePath(this.req.path)}?auth=${this.jwt}`
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    previewUrl () {
 | 
					    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/preview/big${url.encodePath(this.req.path)}?auth=${this.jwt}`
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      return `${baseURL}/api/raw${url.encodePath(this.req.path)}?auth=${this.jwt}`
 | 
					      return `${baseURL}/api/raw${url.encodePath(this.req.path)}?auth=${this.jwt}`
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    raw () {
 | 
					    raw () {
 | 
				
			||||||
      return `${this.previewUrl}&inline=true`
 | 
					      return `${this.previewUrl}&inline=true`
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    showMore () {
 | 
				
			||||||
 | 
					      return this.$store.state.show === 'more'
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    isResizeEnabled () {
 | 
				
			||||||
 | 
					      return resizePreview
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
  watch: {
 | 
					  watch: {
 | 
				
			||||||
| 
						 | 
					@ -189,6 +207,15 @@ export default {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return
 | 
					        return
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    openMore () {
 | 
				
			||||||
 | 
					      this.$store.commit('showHover', 'more')
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    resetPrompts () {
 | 
				
			||||||
 | 
					      this.$store.commit('closeHovers')
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    toggleSize () {
 | 
				
			||||||
 | 
					      this.fullSize = !this.fullSize
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -3,6 +3,7 @@ const getters = {
 | 
				
			||||||
  isFiles: state => !state.loading && state.route.name === 'Files',
 | 
					  isFiles: state => !state.loading && state.route.name === 'Files',
 | 
				
			||||||
  isListing: (state, getters) => getters.isFiles && state.req.isDir,
 | 
					  isListing: (state, getters) => getters.isFiles && state.req.isDir,
 | 
				
			||||||
  isEditor: (state, getters) => getters.isFiles && (state.req.type === 'text' || state.req.type === 'textImmutable'),
 | 
					  isEditor: (state, getters) => getters.isFiles && (state.req.type === 'text' || state.req.type === 'textImmutable'),
 | 
				
			||||||
 | 
					  isPreview: state => state.previewMode,
 | 
				
			||||||
  selectedCount: state => state.selected.length,
 | 
					  selectedCount: state => state.selected.length,
 | 
				
			||||||
  progress : state => {
 | 
					  progress : state => {
 | 
				
			||||||
    if (state.upload.progress.length == 0) {
 | 
					    if (state.upload.progress.length == 0) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -12,6 +12,7 @@ const authMethod = window.FileBrowser.AuthMethod
 | 
				
			||||||
const loginPage = window.FileBrowser.LoginPage
 | 
					const loginPage = window.FileBrowser.LoginPage
 | 
				
			||||||
const theme = window.FileBrowser.Theme
 | 
					const theme = window.FileBrowser.Theme
 | 
				
			||||||
const enableThumbs = window.FileBrowser.EnableThumbs
 | 
					const enableThumbs = window.FileBrowser.EnableThumbs
 | 
				
			||||||
 | 
					const resizePreview = window.FileBrowser.ResizePreview
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export {
 | 
					export {
 | 
				
			||||||
  name,
 | 
					  name,
 | 
				
			||||||
| 
						 | 
					@ -26,5 +27,6 @@ export {
 | 
				
			||||||
  authMethod,
 | 
					  authMethod,
 | 
				
			||||||
  loginPage,
 | 
					  loginPage,
 | 
				
			||||||
  theme,
 | 
					  theme,
 | 
				
			||||||
  enableThumbs
 | 
					  enableThumbs,
 | 
				
			||||||
 | 
					  resizePreview
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -40,6 +40,7 @@ func handleWithStaticData(w http.ResponseWriter, _ *http.Request, d *data, box *
 | 
				
			||||||
		"ReCaptcha":       false,
 | 
							"ReCaptcha":       false,
 | 
				
			||||||
		"Theme":           d.settings.Branding.Theme,
 | 
							"Theme":           d.settings.Branding.Theme,
 | 
				
			||||||
		"EnableThumbs":    d.server.EnableThumbnails,
 | 
							"EnableThumbs":    d.server.EnableThumbnails,
 | 
				
			||||||
 | 
							"ResizePreview":   d.server.ResizePreview,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if d.settings.Branding.Files != "" {
 | 
						if d.settings.Branding.Files != "" {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue