2021-11-14 19:59:34 -06:00
|
|
|
<template>
|
2021-12-31 16:57:53 -06:00
|
|
|
<div class="fixed top-0 left-0 right-0 layout-wrapper w-full z-50 overflow-hidden pointer-events-none">
|
2021-11-14 19:59:34 -06:00
|
|
|
<div class="absolute top-0 left-0 w-full h-full bg-black transition-opacity duration-200" :class="show ? 'bg-opacity-60 pointer-events-auto' : 'bg-opacity-0'" @click="clickBackground" />
|
2023-12-10 17:53:27 -06:00
|
|
|
<div class="absolute top-0 right-0 w-64 h-full bg-bg transform transition-transform py-6 pointer-events-auto" :class="show ? '' : 'translate-x-64'" @click.stop>
|
2021-11-14 19:59:34 -06:00
|
|
|
<div class="px-6 mb-4">
|
2022-04-03 14:24:17 -05:00
|
|
|
<p v-if="user" class="text-base">
|
2021-12-31 16:57:53 -06:00
|
|
|
Welcome,
|
|
|
|
<strong>{{ username }}</strong>
|
2021-11-14 19:59:34 -06:00
|
|
|
</p>
|
|
|
|
</div>
|
2022-04-08 18:07:31 -05:00
|
|
|
|
2021-11-14 19:59:34 -06:00
|
|
|
<div class="w-full overflow-y-auto">
|
|
|
|
<template v-for="item in navItems">
|
2023-12-10 17:53:27 -06:00
|
|
|
<button v-if="item.action" :key="item.text" class="w-full hover:bg-bg/60 flex items-center py-3 px-6 text-fg-muted" @click="clickAction(item.action)">
|
2025-03-30 23:26:14 -07:00
|
|
|
<span class="material-symbols text-lg">{{ item.icon }}</span>
|
2023-09-17 10:23:35 -05:00
|
|
|
<p class="pl-4">{{ item.text }}</p>
|
|
|
|
</button>
|
2023-12-10 17:53:27 -06:00
|
|
|
<nuxt-link v-else :to="item.to" :key="item.text" class="w-full hover:bg-bg/60 flex items-center py-3 px-6 text-fg" :class="currentRoutePath.startsWith(item.to) ? 'bg-bg-hover/50' : 'text-fg-muted'">
|
2025-03-30 23:26:14 -07:00
|
|
|
<span class="material-symbols text-lg">{{ item.icon }}</span>
|
2021-11-14 19:59:34 -06:00
|
|
|
<p class="pl-4">{{ item.text }}</p>
|
|
|
|
</nuxt-link>
|
|
|
|
</template>
|
|
|
|
</div>
|
2023-12-10 17:53:27 -06:00
|
|
|
<div class="absolute bottom-0 left-0 w-full py-6 px-6 text-fg">
|
2022-04-03 14:24:17 -05:00
|
|
|
<div v-if="serverConnectionConfig" class="mb-4 flex justify-center">
|
2023-12-10 17:53:27 -06:00
|
|
|
<p class="text-xs text-fg-muted" style="word-break: break-word">{{ serverConnectionConfig.address }} (v{{ serverSettings.version }})</p>
|
2022-04-03 14:24:17 -05:00
|
|
|
</div>
|
|
|
|
<div class="flex items-center">
|
|
|
|
<p class="text-xs">{{ $config.version }}</p>
|
|
|
|
<div class="flex-grow" />
|
2023-09-17 10:23:35 -05:00
|
|
|
<div v-if="user" class="flex items-center" @click="disconnect">
|
2023-12-03 17:37:01 -06:00
|
|
|
<p class="text-xs pr-2">{{ $strings.ButtonDisconnect }}</p>
|
2025-03-30 23:26:14 -07:00
|
|
|
<i class="material-symbols text-sm -mb-0.5">cloud_off</i>
|
2022-04-03 14:24:17 -05:00
|
|
|
</div>
|
2021-11-14 19:59:34 -06:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2021-12-04 19:56:29 -06:00
|
|
|
import TouchEvent from '@/objects/TouchEvent'
|
|
|
|
|
2021-11-14 19:59:34 -06:00
|
|
|
export default {
|
|
|
|
data() {
|
2021-12-04 19:56:29 -06:00
|
|
|
return {
|
|
|
|
touchEvent: null
|
|
|
|
}
|
2021-11-14 19:59:34 -06:00
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
$route: {
|
|
|
|
handler() {
|
|
|
|
this.show = false
|
|
|
|
}
|
2021-12-04 19:56:29 -06:00
|
|
|
},
|
|
|
|
show: {
|
|
|
|
handler(newVal) {
|
|
|
|
if (newVal) this.registerListener()
|
|
|
|
else this.removeListener()
|
|
|
|
}
|
2021-11-14 19:59:34 -06:00
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
show: {
|
|
|
|
get() {
|
|
|
|
return this.$store.state.showSideDrawer
|
|
|
|
},
|
|
|
|
set(val) {
|
|
|
|
this.$store.commit('setShowSideDrawer', val)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
user() {
|
|
|
|
return this.$store.state.user.user
|
|
|
|
},
|
2022-04-03 14:24:17 -05:00
|
|
|
serverConnectionConfig() {
|
|
|
|
return this.$store.state.user.serverConnectionConfig
|
|
|
|
},
|
2022-06-09 12:08:04 -07:00
|
|
|
serverSettings() {
|
2022-06-09 15:28:49 -07:00
|
|
|
return this.$store.state.serverSettings || {}
|
2022-06-09 11:57:44 -07:00
|
|
|
},
|
2021-11-14 19:59:34 -06:00
|
|
|
username() {
|
2024-03-22 17:54:56 -05:00
|
|
|
return this.user?.username || ''
|
|
|
|
},
|
|
|
|
userIsAdminOrUp() {
|
|
|
|
return this.$store.getters['user/getIsAdminOrUp']
|
2021-11-14 19:59:34 -06:00
|
|
|
},
|
|
|
|
navItems() {
|
|
|
|
var items = [
|
|
|
|
{
|
|
|
|
icon: 'home',
|
2023-12-03 17:37:01 -06:00
|
|
|
text: this.$strings.ButtonHome,
|
2021-11-14 19:59:34 -06:00
|
|
|
to: '/bookshelf'
|
|
|
|
}
|
|
|
|
]
|
2022-04-08 18:07:31 -05:00
|
|
|
if (!this.serverConnectionConfig) {
|
2021-11-14 19:59:34 -06:00
|
|
|
items = [
|
|
|
|
{
|
|
|
|
icon: 'cloud_off',
|
2023-12-03 17:37:01 -06:00
|
|
|
text: this.$strings.ButtonConnectToServer,
|
2021-11-14 19:59:34 -06:00
|
|
|
to: '/connect'
|
|
|
|
}
|
|
|
|
].concat(items)
|
2022-04-08 18:07:31 -05:00
|
|
|
} else {
|
|
|
|
items.push({
|
|
|
|
icon: 'person',
|
2023-12-03 17:37:01 -06:00
|
|
|
text: this.$strings.HeaderAccount,
|
2022-04-08 18:07:31 -05:00
|
|
|
to: '/account'
|
|
|
|
})
|
2022-08-04 17:22:56 -05:00
|
|
|
items.push({
|
|
|
|
icon: 'equalizer',
|
2023-12-03 17:37:01 -06:00
|
|
|
text: this.$strings.ButtonUserStats,
|
2022-08-04 17:22:56 -05:00
|
|
|
to: '/stats'
|
|
|
|
})
|
2021-11-14 19:59:34 -06:00
|
|
|
}
|
2022-04-08 18:07:31 -05:00
|
|
|
|
2022-04-15 20:48:39 -05:00
|
|
|
if (this.$platform !== 'ios') {
|
|
|
|
items.push({
|
|
|
|
icon: 'folder',
|
|
|
|
iconOutlined: true,
|
2023-12-03 17:37:01 -06:00
|
|
|
text: this.$strings.ButtonLocalMedia,
|
2022-04-15 20:48:39 -05:00
|
|
|
to: '/localMedia/folders'
|
|
|
|
})
|
2022-08-21 15:02:22 -04:00
|
|
|
} else {
|
|
|
|
items.push({
|
2023-01-08 15:32:15 -06:00
|
|
|
icon: 'download',
|
|
|
|
iconOutlined: false,
|
2023-12-03 17:37:01 -06:00
|
|
|
text: this.$strings.HeaderDownloads,
|
2023-01-08 15:32:15 -06:00
|
|
|
to: '/downloads'
|
2022-08-21 15:02:22 -04:00
|
|
|
})
|
2022-04-15 20:48:39 -05:00
|
|
|
}
|
2022-07-02 18:29:41 -05:00
|
|
|
items.push({
|
|
|
|
icon: 'settings',
|
2023-12-03 17:37:01 -06:00
|
|
|
text: this.$strings.HeaderSettings,
|
2022-07-02 18:29:41 -05:00
|
|
|
to: '/settings'
|
|
|
|
})
|
2023-09-17 10:23:35 -05:00
|
|
|
|
|
|
|
if (this.serverConnectionConfig) {
|
2024-03-25 16:33:30 -05:00
|
|
|
items.push({
|
|
|
|
icon: 'language',
|
|
|
|
text: this.$strings.ButtonGoToWebClient,
|
|
|
|
action: 'openWebClient'
|
|
|
|
})
|
|
|
|
|
2023-09-17 10:23:35 -05:00
|
|
|
items.push({
|
|
|
|
icon: 'login',
|
2023-12-03 17:37:01 -06:00
|
|
|
text: this.$strings.ButtonSwitchServerUser,
|
2023-09-17 10:23:35 -05:00
|
|
|
action: 'logout'
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2021-11-14 19:59:34 -06:00
|
|
|
return items
|
2022-04-08 18:07:31 -05:00
|
|
|
},
|
|
|
|
currentRoutePath() {
|
|
|
|
return this.$route.path
|
2021-11-14 19:59:34 -06:00
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
2023-09-17 10:23:35 -05:00
|
|
|
async clickAction(action) {
|
|
|
|
await this.$hapticsImpact()
|
|
|
|
if (action === 'logout') {
|
|
|
|
await this.logout()
|
|
|
|
this.$router.push('/connect')
|
2024-03-22 17:54:56 -05:00
|
|
|
} else if (action === 'openWebClient') {
|
|
|
|
this.show = false
|
|
|
|
let path = `/library/${this.$store.state.libraries.currentLibraryId}`
|
|
|
|
await this.$store.dispatch('user/openWebClient', path)
|
2023-09-17 10:23:35 -05:00
|
|
|
}
|
|
|
|
},
|
2021-11-14 19:59:34 -06:00
|
|
|
clickBackground() {
|
|
|
|
this.show = false
|
|
|
|
},
|
|
|
|
async logout() {
|
2022-06-05 16:32:28 -05:00
|
|
|
if (this.user) {
|
2024-11-03 14:53:35 -06:00
|
|
|
if (this.$store.getters['getIsPlayerOpen']) {
|
|
|
|
this.$eventBus.$emit('close-stream')
|
|
|
|
}
|
|
|
|
|
2023-09-15 17:35:44 -05:00
|
|
|
await this.$nativeHttp.post('/logout').catch((error) => {
|
|
|
|
console.error('Failed to logout', error)
|
2022-06-05 16:32:28 -05:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2022-04-03 14:24:17 -05:00
|
|
|
this.$socket.logout()
|
|
|
|
await this.$db.logout()
|
2022-06-05 16:32:28 -05:00
|
|
|
this.$localStore.removeLastLibraryId()
|
2022-04-03 14:24:17 -05:00
|
|
|
this.$store.commit('user/logout')
|
2023-09-17 10:23:35 -05:00
|
|
|
this.$store.commit('libraries/setCurrentLibrary', null)
|
|
|
|
},
|
|
|
|
async disconnect() {
|
|
|
|
await this.$hapticsImpact()
|
|
|
|
await this.logout()
|
|
|
|
|
|
|
|
if (this.$route.name !== 'bookshelf') {
|
|
|
|
this.$router.replace('/bookshelf')
|
|
|
|
} else {
|
|
|
|
location.reload()
|
|
|
|
}
|
2021-12-04 19:56:29 -06:00
|
|
|
},
|
|
|
|
touchstart(e) {
|
|
|
|
this.touchEvent = new TouchEvent(e)
|
|
|
|
},
|
|
|
|
touchend(e) {
|
|
|
|
if (!this.touchEvent) return
|
|
|
|
this.touchEvent.setEndEvent(e)
|
|
|
|
if (this.touchEvent.isSwipeRight()) {
|
|
|
|
this.show = false
|
|
|
|
}
|
|
|
|
this.touchEvent = null
|
|
|
|
},
|
|
|
|
registerListener() {
|
|
|
|
document.addEventListener('touchstart', this.touchstart)
|
|
|
|
document.addEventListener('touchend', this.touchend)
|
|
|
|
},
|
|
|
|
removeListener() {
|
|
|
|
document.removeEventListener('touchstart', this.touchstart)
|
|
|
|
document.removeEventListener('touchend', this.touchend)
|
2021-11-14 19:59:34 -06:00
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted() {},
|
|
|
|
beforeDestroy() {
|
|
|
|
this.show = false
|
|
|
|
}
|
|
|
|
}
|
2022-08-03 22:17:11 -04:00
|
|
|
</script>
|