Change: njodb version bump, Fix: Socket reconnect & toast, Fix: Mobile config nav drawer

This commit is contained in:
advplyr 2021-11-07 13:02:56 -06:00
parent 2af017e3b1
commit d115382abe
6 changed files with 81 additions and 26 deletions

View File

@ -1,6 +1,6 @@
<template> <template>
<div class="w-44 fixed left-0 top-16 z-40 h-full bg-bg bg-opacity-100 md:bg-opacity-70 shadow-lg border-r border-white border-opacity-5 py-4 transform transition-transform" :class="drawerOpen ? 'translate-x-0' : '-translate-x-44'" v-click-outside="clickOutside"> <div class="w-44 fixed left-0 top-16 h-full bg-bg bg-opacity-100 md:bg-opacity-70 shadow-lg border-r border-white border-opacity-5 py-3 transform transition-transform" :class="wrapperClass" v-click-outside="clickOutside">
<div class="md:hidden flex items-center justify-end py-2 px-4 mb-1" @click="closeDrawer"> <div class="md:hidden flex items-center justify-end pb-2 px-4 mb-1" @click="closeDrawer">
<span class="material-icons text-2xl">arrow_back</span> <span class="material-icons text-2xl">arrow_back</span>
</div> </div>
<nuxt-link to="/config" class="w-full px-4 h-12 border-b border-opacity-0 flex items-center cursor-pointer relative" :class="routeName === 'config' ? 'bg-primary bg-opacity-70' : 'hover:bg-primary hover:bg-opacity-30'"> <nuxt-link to="/config" class="w-full px-4 h-12 border-b border-opacity-0 flex items-center cursor-pointer relative" :class="routeName === 'config' ? 'bg-primary bg-opacity-70' : 'hover:bg-primary hover:bg-opacity-30'">
@ -24,7 +24,7 @@
<div v-show="routeName === 'config-log'" class="h-full w-0.5 bg-yellow-400 absolute top-0 left-0" /> <div v-show="routeName === 'config-log'" class="h-full w-0.5 bg-yellow-400 absolute top-0 left-0" />
</nuxt-link> </nuxt-link>
<div class="w-full h-12 px-4 border-t border-black border-opacity-20 absolute bottom-20 left-0 flex flex-col justify-center"> <div class="w-full h-10 px-4 border-t border-black border-opacity-20 absolute left-0 flex flex-col justify-center" :style="{ bottom: streamAudiobook && windowHeight > 700 && !isMobile ? '300px' : '65px' }">
<p class="font-mono text-sm">v{{ $config.version }}</p> <p class="font-mono text-sm">v{{ $config.version }}</p>
<a v-if="hasUpdate" :href="githubTagUrl" target="_blank" class="text-warning text-sm">Update available: {{ latestVersion }}</a> <a v-if="hasUpdate" :href="githubTagUrl" target="_blank" class="text-warning text-sm">Update available: {{ latestVersion }}</a>
</div> </div>
@ -38,12 +38,24 @@ export default {
}, },
data() { data() {
return { return {
windowWidth: 0 windowWidth: 0,
windowHeight: 0
} }
}, },
computed: { computed: {
wrapperClass() {
var classes = []
if (this.drawerOpen) classes.push('translate-x-0')
else classes.push('-translate-x-44')
if (this.isMobile) classes.push('z-50')
else classes.push('z-40')
return classes.join(' ')
},
isMobile() {
return this.windowWidth < 758
},
drawerOpen() { drawerOpen() {
if (this.windowWidth < 758) return this.isOpen if (this.isMobile) return this.isOpen
return true return true
}, },
routeName() { routeName() {
@ -60,6 +72,9 @@ export default {
}, },
githubTagUrl() { githubTagUrl() {
return this.versionData.githubTagUrl return this.versionData.githubTagUrl
},
streamAudiobook() {
return this.$store.state.streamAudiobook
} }
}, },
methods: { methods: {
@ -72,11 +87,13 @@ export default {
}, },
resize() { resize() {
this.windowWidth = window.innerWidth this.windowWidth = window.innerWidth
this.windowHeight = window.innerHeight
} }
}, },
mounted() { mounted() {
window.addEventListener('resize', this.resize) window.addEventListener('resize', this.resize)
this.windowWidth = this.resize this.windowWidth = window.innerWidth
this.windowHeight = window.innerHeight
}, },
beforeDestroy() { beforeDestroy() {
window.removeEventListener('resize', this.resize) window.removeEventListener('resize', this.resize)

View File

@ -20,7 +20,10 @@ export default {
middleware: 'authenticated', middleware: 'authenticated',
data() { data() {
return { return {
socket: null socket: null,
isSocketConnected: false,
isFirstSocketConnection: true,
socketConnectionToastId: null
} }
}, },
watch: { watch: {
@ -46,14 +49,46 @@ export default {
console.log('[SOCKET] Connected') console.log('[SOCKET] Connected')
var token = this.$store.getters['user/getToken'] var token = this.$store.getters['user/getToken']
this.socket.emit('auth', token) this.socket.emit('auth', token)
if (this.socketConnectionToastId !== null) {
this.$toast.update(this.socketConnectionToastId, { content: 'Socket Connected', options: { timeout: 5000, type: 'success', closeButton: false, position: 'bottom-center', onClose: () => null } }, true)
} else if (!this.isFirstSocketConnection) {
this.$toast.success('Socket Connected', { position: 'bottom-center' })
}
this.isFirstSocketConnection = false
this.isSocketConnected = true
},
connectError() {
console.error('[SOCKET] connect error')
// if (this.socketConnectionToastId) {
// this.$toast.update(this.socketConnectionToastId, { content: 'Socket Connection Error', options: { timeout: 5000, type: 'error', closeButton: false, position: 'bottom-center', onClose: () => null } }, true)
// } else {
// this.$toast.error('Socket Connection Error', { position: 'bottom-center' })
// }
}, },
connectError() {},
disconnect() { disconnect() {
console.log('[SOCKET] Disconnected') console.log('[SOCKET] Disconnected')
this.isSocketConnected = false
if (this.socketConnectionToastId !== null) {
this.socketConnectionToastId = this.$toast.update(this.socketConnectionToastId, { content: 'Socket Disconnected', options: { timeout: null, type: 'error', closeButton: false, position: 'bottom-center', onClose: () => null } }, true)
} else {
this.socketConnectionToastId = this.$toast.error('Socket Disconnected', { timeout: null, position: 'bottom-center' })
}
},
reconnect() {
console.error('[SOCKET] reconnected')
},
reconnection_attempt(val) {
console.log(`[SOCKET] Reconnection attempt ${val}`)
},
reconnectError() {
console.error('[SOCKET] reconnect error')
},
reconnectFailed() {
console.error('[SOCKET] reconnect failed')
}, },
reconnect() {},
reconnectError() {},
reconnectFailed() {},
init(payload) { init(payload) {
console.log('Init Payload', payload) console.log('Init Payload', payload)
if (payload.stream) { if (payload.stream) {
@ -269,20 +304,20 @@ export default {
this.socket = this.$nuxtSocket({ this.socket = this.$nuxtSocket({
name: process.env.NODE_ENV === 'development' ? 'dev' : 'prod', name: process.env.NODE_ENV === 'development' ? 'dev' : 'prod',
persist: 'main', persist: 'main',
teardown: true, teardown: false,
transports: ['websocket'], transports: ['websocket'],
upgrade: false upgrade: false,
reconnection: true
}) })
this.$root.socket = this.socket // this.$root.socket = this.socket
// Connection Listeners
this.socket.on('connect', this.connect) this.socket.on('connect', this.connect)
this.socket.on('connect_error', this.connectError) this.socket.on('connect_error', this.connectError)
this.socket.on('disconnect', this.disconnect) this.socket.on('disconnect', this.disconnect)
this.socket.on('reconnecting', this.reconnecting) this.socket.io.on('reconnection_attempt', this.reconnection_attempt)
this.socket.on('reconnect', this.reconnect) this.socket.io.on('reconnect', this.reconnect)
this.socket.on('reconnect_error', this.reconnectError) this.socket.io.on('reconnect_error', this.reconnectError)
this.socket.on('reconnect_failed', this.reconnectFailed) this.socket.io.on('reconnect_failed', this.reconnectFailed)
this.socket.on('init', this.init) this.socket.on('init', this.init)

View File

@ -1,6 +1,6 @@
{ {
"name": "audiobookshelf-client", "name": "audiobookshelf-client",
"version": "1.6.8", "version": "1.6.9",
"description": "Audiobook manager and player", "description": "Audiobook manager and player",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {

View File

@ -68,6 +68,9 @@ module.exports = {
sans: ['Source Sans Pro', ...defaultTheme.fontFamily.sans], sans: ['Source Sans Pro', ...defaultTheme.fontFamily.sans],
mono: ['Ubuntu Mono', ...defaultTheme.fontFamily.mono], mono: ['Ubuntu Mono', ...defaultTheme.fontFamily.mono],
book: ['Gentium Book Basic', 'serif'] book: ['Gentium Book Basic', 'serif']
},
zIndex: {
'50': 50
} }
} }
}, },

8
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "audiobookshelf", "name": "audiobookshelf",
"version": "1.6.6", "version": "1.6.8",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
@ -1222,9 +1222,9 @@
"integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==" "integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw=="
}, },
"njodb": { "njodb": {
"version": "0.4.24", "version": "0.4.26",
"resolved": "https://registry.npmjs.org/njodb/-/njodb-0.4.24.tgz", "resolved": "https://registry.npmjs.org/njodb/-/njodb-0.4.26.tgz",
"integrity": "sha512-d7S5mJJlEwWMhKblOE5BVKLnCubYuwZTLeoVq054GawnrxK3ATwauX/mkOKiZdBjbzrWoHg+dgatUkxoQIUvCA==", "integrity": "sha512-cUEQzZT/jbwK5tBLZM/A4bCsYIB9oqGwfip79NWMMzUi0RBFVccPYGh9gTf2PhcrTn2y1ftbxlV+J/c4s9RR8g==",
"requires": { "requires": {
"proper-lockfile": "^4.1.2" "proper-lockfile": "^4.1.2"
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "audiobookshelf", "name": "audiobookshelf",
"version": "1.6.8", "version": "1.6.9",
"description": "Self-hosted audiobook server for managing and playing audiobooks", "description": "Self-hosted audiobook server for managing and playing audiobooks",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
@ -38,7 +38,7 @@
"ip": "^1.1.5", "ip": "^1.1.5",
"jsonwebtoken": "^8.5.1", "jsonwebtoken": "^8.5.1",
"libgen": "^2.1.0", "libgen": "^2.1.0",
"njodb": "^0.4.24", "njodb": "^0.4.26",
"node-cron": "^3.0.0", "node-cron": "^3.0.0",
"node-stream-zip": "^1.15.0", "node-stream-zip": "^1.15.0",
"podcast": "^1.3.0", "podcast": "^1.3.0",