diff --git a/client/components/app/Appbar.vue b/client/components/app/Appbar.vue index 8f30c5d9..bd98283b 100644 --- a/client/components/app/Appbar.vue +++ b/client/components/app/Appbar.vue @@ -7,7 +7,7 @@ -

audiobookshelf

+

audiobookshelf logo_dev

@@ -15,7 +15,7 @@
- logo_dev +
- Open Manager launch diff --git a/client/components/widgets/NotificationWidget.vue b/client/components/widgets/NotificationWidget.vue new file mode 100644 index 00000000..6c3e82fd --- /dev/null +++ b/client/components/widgets/NotificationWidget.vue @@ -0,0 +1,25 @@ + + + \ No newline at end of file diff --git a/client/layouts/default.vue b/client/layouts/default.vue index 1a23cde7..826c0cb7 100644 --- a/client/layouts/default.vue +++ b/client/layouts/default.vue @@ -270,6 +270,14 @@ export default { this.$store.commit('scanners/addUpdate', data) }, + taskStarted(task) { + console.log('Task started', task) + this.$store.commit('tasks/addUpdateTask', task) + }, + taskFinished(task) { + console.log('Task finished', task) + this.$store.commit('tasks/addUpdateTask', task) + }, userUpdated(user) { if (this.$store.state.user.user.id === user.id) { this.$store.commit('user/setUser', user) @@ -302,53 +310,6 @@ export default { } this.$store.commit('user/removeCollection', collection) }, - abmergeStarted(download) { - download.status = this.$constants.DownloadStatus.PENDING - download.toastId = this.$toast(`Preparing download "${download.filename}"`, { timeout: false, draggable: false, closeOnClick: false }) - this.$store.commit('downloads/addUpdateDownload', download) - }, - abmergeReady(download) { - download.status = this.$constants.DownloadStatus.READY - var existingDownload = this.$store.getters['downloads/getDownload'](download.id) - - if (existingDownload && existingDownload.toastId !== undefined) { - download.toastId = existingDownload.toastId - this.$toast.update(existingDownload.toastId, { content: `Download "${download.filename}" is ready!`, options: { timeout: 5000, type: 'success' } }, true) - } else { - this.$toast.success(`Download "${download.filename}" is ready!`) - } - this.$store.commit('downloads/addUpdateDownload', download) - }, - abmergeFailed(download) { - download.status = this.$constants.DownloadStatus.FAILED - var existingDownload = this.$store.getters['downloads/getDownload'](download.id) - - var failedMsg = download.isTimedOut ? 'timed out' : 'failed' - - if (existingDownload && existingDownload.toastId !== undefined) { - download.toastId = existingDownload.toastId - this.$toast.update(existingDownload.toastId, { content: `Download "${download.filename}" ${failedMsg}`, options: { timeout: 5000, type: 'error' } }, true) - } else { - console.warn('Download failed no existing download', existingDownload) - this.$toast.error(`Download "${download.filename}" ${failedMsg}`) - } - this.$store.commit('downloads/addUpdateDownload', download) - }, - abmergeKilled(download) { - var existingDownload = this.$store.getters['downloads/getDownload'](download.id) - if (existingDownload && existingDownload.toastId !== undefined) { - download.toastId = existingDownload.toastId - this.$toast.update(existingDownload.toastId, { content: `Download "${download.filename}" was terminated`, options: { timeout: 5000, type: 'error' } }, true) - } else { - console.warn('Download killed no existing download found', existingDownload) - this.$toast.error(`Download "${download.filename}" was terminated`) - } - this.$store.commit('downloads/removeDownload', download) - }, - abmergeExpired(download) { - download.status = this.$constants.DownloadStatus.EXPIRED - this.$store.commit('downloads/addUpdateDownload', download) - }, rssFeedOpen(data) { this.$store.commit('feeds/addFeed', data) }, @@ -362,7 +323,7 @@ export default { batchQuickMatchComplete(result) { var success = result.success || false var toast = 'Batch quick match complete!\n' + result.updates + ' Updated' - if (result.unmatched && (result.unmatched > 0)) { + if (result.unmatched && result.unmatched > 0) { toast += '\n' + result.unmatched + ' with no matches' } if (success) { @@ -430,19 +391,16 @@ export default { this.socket.on('scan_complete', this.scanComplete) this.socket.on('scan_progress', this.scanProgress) - // Download Listeners - this.socket.on('abmerge_started', this.abmergeStarted) - this.socket.on('abmerge_ready', this.abmergeReady) - this.socket.on('abmerge_failed', this.abmergeFailed) - this.socket.on('abmerge_killed', this.abmergeKilled) - this.socket.on('abmerge_expired', this.abmergeExpired) + // Task Listeners + this.socket.on('task_started', this.taskStarted) + this.socket.on('task_finished', this.taskFinished) // Feed Listeners this.socket.on('rss_feed_open', this.rssFeedOpen) this.socket.on('rss_feed_closed', this.rssFeedClosed) this.socket.on('backup_applied', this.backupApplied) - + this.socket.on('batch_quickmatch_complete', this.batchQuickMatchComplete) }, showUpdateToast(versionData) { @@ -548,6 +506,19 @@ export default { // Queue auto play var playerQueueAutoPlay = localStorage.getItem('playerQueueAutoPlay') this.$store.commit('setPlayerQueueAutoPlay', playerQueueAutoPlay !== '0') + }, + loadTasks() { + this.$axios + .$get('/api/tasks') + .then((payload) => { + console.log('Fetched tasks', payload) + if (payload.tasks) { + this.$store.commit('tasks/setTasks', payload.tasks) + } + }) + .catch((error) => { + console.error('Failed to load tasks', error) + }) } }, beforeMount() { @@ -565,6 +536,8 @@ export default { this.checkVersionUpdate() + this.loadTasks() + if (this.$route.query.error) { this.$toast.error(this.$route.query.error) this.$router.replace(this.$route.path) diff --git a/client/pages/audiobook/_id/manage.vue b/client/pages/audiobook/_id/manage.vue index f9198c63..af277048 100644 --- a/client/pages/audiobook/_id/manage.vue +++ b/client/pages/audiobook/_id/manage.vue @@ -45,7 +45,7 @@

No chapters