audiobookshelf/client/components/app/ConfigSideNav.vue

180 lines
5.4 KiB
Vue
Raw Normal View History

<template>
<div>
<div class="w-44 fixed left-0 top-16 bg-bg bg-opacity-100 md:bg-opacity-70 shadow-lg border-r border-white border-opacity-5 py-3 transform transition-transform mb-12 overflow-y-auto" :class="wrapperClass + ' ' + (streamLibraryItem ? 'h-[calc(100%-270px)]' : 'h-[calc(100%-110px)]')" v-click-outside="clickOutside">
<div v-show="isMobilePortrait" class="flex items-center justify-end pb-2 px-4 mb-1" @click="closeDrawer">
<span class="material-symbols text-2xl">arrow_back</span>
</div>
<nuxt-link v-for="route in configRoutes" :key="route.id" :to="route.path" class="w-full px-3 h-12 border-b border-primary border-opacity-30 flex items-center cursor-pointer relative" :class="routeName === route.id ? 'bg-primary bg-opacity-70' : 'hover:bg-primary hover:bg-opacity-30'">
<p class="leading-4">{{ route.title }}</p>
<div v-show="routeName === route.iod" class="h-full w-0.5 bg-yellow-400 absolute top-0 left-0" />
</nuxt-link>
<modals-changelog-view-modal v-model="showChangelogModal" :versionData="versionData" />
</div>
<div class="w-44 h-12 px-4 border-t bg-bg border-black border-opacity-20 fixed left-0 flex flex-col justify-center" :class="wrapperClass" :style="{ bottom: streamLibraryItem ? '160px' : '0px' }">
<div class="flex items-center justify-between">
<button type="button" class="underline font-mono text-sm" @click="clickChangelog">v{{ $config.version }}</button>
<p class="text-xs text-gray-300 italic">{{ Source }}</p>
</div>
<a v-if="hasUpdate" :href="githubTagUrl" target="_blank" class="text-warning text-xs">Latest: {{ versionData.latestVersion }}</a>
</div>
</div>
</template>
<script>
export default {
props: {
isOpen: Boolean
},
data() {
2022-07-09 05:29:18 +02:00
return {
showChangelogModal: false
}
},
computed: {
Source() {
return this.$store.state.Source
},
currentLibraryId() {
return this.$store.state.libraries.currentLibraryId
},
userIsAdminOrUp() {
return this.$store.getters['user/getIsAdminOrUp']
},
configRoutes() {
if (!this.userIsAdminOrUp) {
return [
{
id: 'config-stats',
2022-11-08 01:27:17 +01:00
title: this.$strings.HeaderYourStats,
path: '/config/stats'
}
]
}
const configRoutes = [
{
id: 'config',
2022-11-08 01:27:17 +01:00
title: this.$strings.HeaderSettings,
path: '/config'
},
{
id: 'config-libraries',
2022-11-08 01:27:17 +01:00
title: this.$strings.HeaderLibraries,
path: '/config/libraries'
},
{
id: 'config-users',
2022-11-08 01:27:17 +01:00
title: this.$strings.HeaderUsers,
path: '/config/users'
},
2022-06-04 19:44:42 +02:00
{
id: 'config-sessions',
2022-11-08 01:27:17 +01:00
title: this.$strings.HeaderListeningSessions,
2022-06-04 19:44:42 +02:00
path: '/config/sessions'
},
{
id: 'config-backups',
2022-11-08 01:27:17 +01:00
title: this.$strings.HeaderBackups,
path: '/config/backups'
},
{
id: 'config-log',
2022-11-08 01:27:17 +01:00
title: this.$strings.HeaderLogs,
path: '/config/log'
},
{
id: 'config-notifications',
2022-11-08 01:27:17 +01:00
title: this.$strings.HeaderNotifications,
path: '/config/notifications'
},
{
id: 'config-email',
title: this.$strings.HeaderEmail,
path: '/config/email'
},
{
id: 'config-item-metadata-utils',
title: this.$strings.HeaderItemMetadataUtils,
path: '/config/item-metadata-utils'
2023-08-22 18:42:55 +02:00
},
{
id: 'config-rss-feeds',
title: this.$strings.HeaderRSSFeeds,
path: '/config/rss-feeds'
},
{
id: 'config-authentication',
title: this.$strings.HeaderAuthentication,
path: '/config/authentication'
}
]
if (this.currentLibraryId) {
configRoutes.push({
id: 'library-stats',
2022-11-08 01:27:17 +01:00
title: this.$strings.HeaderLibraryStats,
path: `/library/${this.currentLibraryId}/stats`
})
configRoutes.push({
id: 'config-stats',
2022-11-08 01:27:17 +01:00
title: this.$strings.HeaderYourStats,
path: '/config/stats'
})
}
return configRoutes
},
wrapperClass() {
var classes = []
if (this.drawerOpen) classes.push('translate-x-0')
else classes.push('-translate-x-44')
if (this.isMobilePortrait) classes.push('z-50')
else classes.push('z-40')
return classes.join(' ')
},
isMobile() {
2022-02-09 18:19:02 +01:00
return this.$store.state.globals.isMobile
},
isMobileLandscape() {
return this.$store.state.globals.isMobileLandscape
},
isMobilePortrait() {
return this.$store.state.globals.isMobilePortrait
},
drawerOpen() {
return !this.isMobilePortrait || this.isOpen
},
routeName() {
return this.$route.name
},
versionData() {
return this.$store.state.versionData || {}
},
hasUpdate() {
return !!this.versionData.hasUpdate
},
githubTagUrl() {
return this.versionData.githubTagUrl
},
streamLibraryItem() {
return this.$store.state.streamLibraryItem
}
},
methods: {
2022-11-08 01:27:17 +01:00
clickChangelog() {
2022-07-09 05:29:18 +02:00
this.showChangelogModal = true
},
clickOutside() {
if (!this.isOpen) return
this.closeDrawer()
},
closeDrawer() {
this.$emit('update:isOpen', false)
2022-11-08 01:27:17 +01:00
}
}
}
</script>