Files
filebrowser/src/components/Header.vue
T

190 lines
5.8 KiB
Vue
Raw Normal View History

2018-02-01 12:17:04 +00:00
<template>
<header>
<div>
<button @click="openSidebar" :aria-label="$t('buttons.toggleSidebar')" :title="$t('buttons.toggleSidebar')" class="action">
<i class="material-icons">menu</i>
</button>
2019-01-05 16:12:09 +00:00
<img :src="logoURL" alt="File Browser">
<search v-if="isLogged"></search>
2018-02-01 12:17:04 +00:00
</div>
<div>
2019-01-05 16:12:09 +00:00
<template v-if="isLogged">
<button @click="openSearch" :aria-label="$t('buttons.search')" :title="$t('buttons.search')" class="search-button action">
<i class="material-icons">search</i>
2018-02-01 12:17:04 +00:00
</button>
2019-01-05 16:12:09 +00:00
<button v-show="showSaveButton" :aria-label="$t('buttons.save')" :title="$t('buttons.save')" class="action" id="save-button">
<i class="material-icons">save</i>
</button>
2018-02-01 12:17:04 +00:00
2019-01-05 16:12:09 +00:00
<button @click="openMore" id="more" :aria-label="$t('buttons.more')" :title="$t('buttons.more')" class="action">
<i class="material-icons">more_vert</i>
</button>
2018-02-01 12:17:04 +00:00
2019-01-05 16:12:09 +00:00
<!-- Menu that shows on listing AND mobile when there are files selected -->
<div id="file-selection" v-if="isMobile && isListing">
<span v-if="selectedCount > 0">{{ selectedCount }} selected</span>
<share-button v-show="showShareButton"></share-button>
2018-02-01 12:17:04 +00:00
<rename-button v-show="showRenameButton"></rename-button>
2019-01-05 16:12:09 +00:00
<copy-button v-show="showCopyButton"></copy-button>
2018-02-01 12:17:04 +00:00
<move-button v-show="showMoveButton"></move-button>
<delete-button v-show="showDeleteButton"></delete-button>
</div>
2019-01-05 16:12:09 +00:00
<!-- This buttons are shown on a dropdown on mobile phones -->
<div id="dropdown" :class="{ active: showMore }">
<div v-if="!isListing || !isMobile">
<share-button v-show="showShareButton"></share-button>
<rename-button v-show="showRenameButton"></rename-button>
<copy-button v-show="showCopyButton"></copy-button>
<move-button v-show="showMoveButton"></move-button>
<delete-button v-show="showDeleteButton"></delete-button>
</div>
<shell-button v-show="user.perm.execute" />
<switch-button v-show="isListing"></switch-button>
<download-button v-show="showDownloadButton"></download-button>
<upload-button v-show="showUpload"></upload-button>
<info-button v-show="isFiles"></info-button>
<button v-show="isListing" @click="openSelect" :aria-label="$t('buttons.selectMultiple')" :title="$t('buttons.selectMultiple')" class="action">
<i class="material-icons">check_circle</i>
<span>{{ $t('buttons.select') }}</span>
</button>
</div>
</template>
2018-02-01 12:17:04 +00:00
<div v-show="showOverlay" @click="resetPrompts" class="overlay"></div>
</div>
</header>
</template>
<script>
import Search from './Search'
import InfoButton from './buttons/Info'
import DeleteButton from './buttons/Delete'
import RenameButton from './buttons/Rename'
import UploadButton from './buttons/Upload'
import DownloadButton from './buttons/Download'
import SwitchButton from './buttons/SwitchView'
import MoveButton from './buttons/Move'
import CopyButton from './buttons/Copy'
import ShareButton from './buttons/Share'
2019-01-05 16:12:09 +00:00
import ShellButton from './buttons/Shell'
2018-02-01 12:17:04 +00:00
import {mapGetters, mapState} from 'vuex'
2019-01-05 16:12:09 +00:00
import { logoURL } from '@/utils/constants'
import * as api from '@/api'
2018-02-01 12:17:04 +00:00
import buttons from '@/utils/buttons'
export default {
2019-01-05 16:12:09 +00:00
name: 'header-layout',
2018-02-01 12:17:04 +00:00
components: {
Search,
InfoButton,
DeleteButton,
ShareButton,
RenameButton,
DownloadButton,
CopyButton,
UploadButton,
SwitchButton,
MoveButton,
2019-01-05 16:12:09 +00:00
ShellButton
2018-02-01 12:17:04 +00:00
},
data: function () {
return {
width: window.innerWidth,
pluginData: {
api,
buttons,
'store': this.$store,
'router': this.$router
}
}
},
created () {
window.addEventListener('resize', () => {
this.width = window.innerWidth
})
},
computed: {
...mapGetters([
2019-01-05 16:12:09 +00:00
'selectedCount',
'isFiles',
'isEditor',
'isListing',
'isLogged'
2018-02-01 12:17:04 +00:00
]),
...mapState([
'req',
'user',
'loading',
'reload',
2019-01-05 16:12:09 +00:00
'multiple'
2018-02-01 12:17:04 +00:00
]),
2019-01-05 16:12:09 +00:00
logoURL: () => logoURL,
2018-02-01 12:17:04 +00:00
isMobile () {
return this.width <= 736
},
2019-01-05 16:12:09 +00:00
showUpload () {
return this.isListing && this.user.perm.create
2018-02-01 12:17:04 +00:00
},
showSaveButton () {
2019-01-05 16:12:09 +00:00
return this.isEditor && this.user.perm.modify
2018-02-01 12:17:04 +00:00
},
2019-01-05 16:12:09 +00:00
showDownloadButton () {
return this.isFiles && this.user.perm.download
2018-02-01 12:17:04 +00:00
},
showDeleteButton () {
2019-01-05 16:12:09 +00:00
return this.isFiles && (this.isListing
? (this.selectedCount !== 0 && this.user.perm.delete)
: this.user.perm.delete)
2018-02-01 12:17:04 +00:00
},
showRenameButton () {
2019-01-05 16:12:09 +00:00
return this.isFiles && (this.isListing
? (this.selectedCount === 1 && this.user.perm.rename)
: this.user.perm.rename)
},
showShareButton () {
return this.isFiles && (this.isListing
? (this.selectedCount === 1 && this.user.perm.share)
: this.user.perm.share)
2018-02-01 12:17:04 +00:00
},
showMoveButton () {
2019-01-05 16:12:09 +00:00
return this.isFiles && (this.isListing
? (this.selectedCount > 0 && this.user.perm.rename)
: this.user.perm.rename)
},
showCopyButton () {
return this.isFiles && (this.isListing
? (this.selectedCount > 0 && this.user.perm.create)
: this.user.perm.create)
2018-02-01 12:17:04 +00:00
},
showMore () {
2019-01-05 16:12:09 +00:00
return this.isFiles && this.$store.state.show === 'more'
2018-02-01 12:17:04 +00:00
},
showOverlay () {
2019-01-05 16:12:09 +00:00
return this.showMore
2018-02-01 12:17:04 +00:00
}
},
methods: {
openSidebar () {
this.$store.commit('showHover', 'sidebar')
},
openMore () {
this.$store.commit('showHover', 'more')
},
openSearch () {
this.$store.commit('showHover', 'search')
},
openSelect () {
this.$store.commit('multiple', true)
this.resetPrompts()
},
resetPrompts () {
this.$store.commit('closeHovers')
}
}
}
</script>