- close
+ close
@@ -27,8 +27,6 @@ export default {
show(newVal) {
if (newVal) {
this.init()
- } else {
- this.close()
}
}
},
@@ -89,27 +87,23 @@ export default {
getEbookUrl(path) {
return `/ebook/${this.libraryId}/${this.folderId}/${path}`
},
- keyUp(e) {
- if (!this.$refs.readerComponent) {
- return
- }
- if ((e.keyCode || e.which) == 37) {
- if (this.$refs.readerComponent.prev) {
- this.$refs.readerComponent.prev()
- }
- } else if ((e.keyCode || e.which) == 39) {
- if (this.$refs.readerComponent.next) {
- this.$refs.readerComponent.next()
- }
- } else if ((e.keyCode || e.which) == 27) {
- this.show = false
+ hotkey(action) {
+ console.log('Reader hotkey', action)
+ if (!this.$refs.readerComponent) return
+
+ if (action === 'ArrowRight') {
+ if (this.$refs.readerComponent.next) this.$refs.readerComponent.next()
+ } else if (action === 'ArrowLeft') {
+ if (this.$refs.readerComponent.prev) this.$refs.readerComponent.prev()
+ } else if (action === 'Escape') {
+ this.close()
}
},
registerListeners() {
- document.addEventListener('keyup', this.keyUp)
+ this.$eventBus.$on('reader-hotkey', this.hotkey)
},
unregisterListeners() {
- document.removeEventListener('keyup', this.keyUp)
+ this.$eventBus.$off('reader-hotkey', this.hotkey)
},
init() {
this.registerListeners()
@@ -144,16 +138,15 @@ export default {
}
},
close() {
- if (this.ebookType === 'epub') {
- this.unregisterListeners()
- }
+ this.unregisterListeners()
+ this.show = false
}
},
mounted() {
if (this.show) this.init()
},
beforeDestroy() {
- this.close()
+ this.unregisterListeners()
}
}
diff --git a/client/components/tables/LibrariesTable.vue b/client/components/tables/LibrariesTable.vue
index 799c5e80..f9911398 100644
--- a/client/components/tables/LibrariesTable.vue
+++ b/client/components/tables/LibrariesTable.vue
@@ -102,11 +102,17 @@ export default {
this.libraryCopies = this.libraries.map((lib) => {
return { ...lib }
})
+ },
+ librariesUpdated() {
+ this.init()
}
},
mounted() {
+ this.$store.commit('libraries/addListener', { id: 'libraries-table', meth: this.librariesUpdated })
this.init()
},
- beforeDestroy() {}
+ beforeDestroy() {
+ this.$store.commit('libraries/removeListener', 'libraries-table')
+ }
}
\ No newline at end of file
diff --git a/client/layouts/default.vue b/client/layouts/default.vue
index c7d5f853..661e2d12 100644
--- a/client/layouts/default.vue
+++ b/client/layouts/default.vue
@@ -332,25 +332,49 @@ export default {
return activeElement && inputs.indexOf(activeElement.tagName.toLowerCase()) !== -1
},
keyUp(e) {
- if (!this.$store.state.showExperimentalFeatures) {
+ var keyCode = e.keyCode || e.which
+ if (!this.$keynames[keyCode]) {
+ // Unused hotkey
return
}
- var keyCode = e.keyCode || e.which
- // If an input is focused then ignore key press
+ var keyName = this.$keynames[keyCode]
+ var name = keyName
+ if (e.shiftKey) name = 'Shift-' + keyName
+
+ if (process.env.NODE_ENV !== 'production') {
+ console.log('Hotkey command', name)
+ }
+
+ // Input is focused then ignore key press
if (this.checkActiveElementIsInput()) {
return
}
- // Modal is open ignore key press
+ // Modal is open
if (this.$store.state.openModal) {
- // console.log('Modal is open', this.$store.state.openModal)
+ this.$eventBus.$emit('modal-hotkey', name)
+ return
+ }
+
+ // EReader is open
+ if (this.$store.state.showEReader) {
+ this.$eventBus.$emit('reader-hotkey', name)
+ return
+ }
+
+ // Batch selecting
+ if (this.$store.getters['getNumAudiobooksSelected']) {
+ // ESCAPE key cancels batch selection
+ if (name === 'Escape') {
+ this.$store.commit('setSelectedAudiobooks', [])
+ }
return
}
// Playing audiobook
if (this.$store.state.streamAudiobook) {
- this.$eventBus.$emit('player-hotkey', keyCode)
+ this.$eventBus.$emit('player-hotkey', name)
}
}
},
diff --git a/client/package.json b/client/package.json
index ad443764..54894eb9 100644
--- a/client/package.json
+++ b/client/package.json
@@ -1,6 +1,6 @@
{
"name": "audiobookshelf-client",
- "version": "1.4.15",
+ "version": "1.4.16",
"description": "Audiobook manager and player",
"main": "index.js",
"scripts": {
diff --git a/client/pages/audiobook/_id/edit.vue b/client/pages/audiobook/_id/edit.vue
index ee339cf4..d6a77f92 100644
--- a/client/pages/audiobook/_id/edit.vue
+++ b/client/pages/audiobook/_id/edit.vue
@@ -10,9 +10,18 @@
New
-
Old
-
Track Parsed from Filename
-
Track From Metadata
+
+ Current
+ {{ currentSort === 'current' ? 'expand_more' : 'unfold_more' }}
+
+
+ Track From Filename
+ {{ currentSort === 'filename' ? 'expand_more' : 'unfold_more' }}
+
+
+ Track From Metadata
+ {{ currentSort === 'metadata' ? 'expand_more' : 'unfold_more' }}
+
Filename
Size
@@ -21,13 +30,13 @@
Notes
Include in Tracklist
-
+
{{ audio.include ? index - numExcluded + 1 : -1 }}
- {{ audio.index }}
+ {{ audio.index }}
{{ audio.trackNumFromFilename }}
@@ -121,7 +130,8 @@ export default {
},
saving: false,
checkingTrackNumbers: false,
- trackNumData: []
+ trackNumData: [],
+ currentSort: 'current'
}
},
computed: {
@@ -204,12 +214,35 @@ export default {
}
},
methods: {
+ draggableUpdate(e) {
+ this.currentSort = ''
+ },
+ sortByCurrent() {
+ this.files.sort((a, b) => {
+ if (a.index === null) return 1
+ return a.index - b.index
+ })
+ this.currentSort = 'current'
+ },
+ sortByMetadataTrack() {
+ this.files.sort((a, b) => {
+ if (a.trackNumFromMeta === null) return 1
+ return a.trackNumFromMeta - b.trackNumFromMeta
+ })
+ this.currentSort = 'metadata'
+ },
+ sortByFilenameTrack() {
+ this.files.sort((a, b) => {
+ if (a.trackNumFromFilename === null) return 1
+ return a.trackNumFromFilename - b.trackNumFromFilename
+ })
+ this.currentSort = 'filename'
+ },
checkTrackNumbers() {
this.checkingTrackNumbers = true
this.$axios
.$get(`/api/scantracks/${this.audiobookId}`)
.then((res) => {
- console.log('RES', res)
this.trackNumData = res
this.checkingTrackNumbers = false
})
diff --git a/client/plugins/constants.js b/client/plugins/constants.js
index fd631ff5..a4e4849a 100644
--- a/client/plugins/constants.js
+++ b/client/plugins/constants.js
@@ -15,17 +15,18 @@ const Constants = {
CoverDestination
}
-const Hotkeys = {
- PLAY_PAUSE: 32, // Space
- JUMP_FORWARD: 39, // ArrowRight
- JUMP_BACKWARD: 37, // ArrowLeft
- CLOSE: 27, // ESCAPE
- VOLUME_UP: 38, // ArrowUp
- VOLUME_DOWN: 40, // ArrowDown
- MUTE: 77, // M
+const KeyNames = {
+ 27: 'Escape',
+ 32: 'Space',
+ 37: 'ArrowLeft',
+ 38: 'ArrowUp',
+ 39: 'ArrowRight',
+ 40: 'ArrowDown',
+ 76: 'KeyL',
+ 77: 'KeyM'
}
export default ({ app }, inject) => {
inject('constants', Constants)
- inject('hotkeys', Hotkeys)
+ inject('keynames', KeyNames)
}
\ No newline at end of file
diff --git a/package.json b/package.json
index d820377f..b9f6d82a 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "audiobookshelf",
- "version": "1.4.15",
+ "version": "1.4.16",
"description": "Self-hosted audiobook server for managing and playing audiobooks",
"main": "index.js",
"scripts": {