mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-01-17 00:19:39 +00:00
parent
8512d5e693
commit
1dec8ae122
13 changed files with 213 additions and 83 deletions
|
|
@ -8,6 +8,7 @@
|
|||
<p class="truncate text-sm">{{ title }}</p>
|
||||
|
||||
<p class="truncate text-xs text-gray-300">{{ description }}</p>
|
||||
<p v-if="specialMessage" class="truncate text-xs text-gray-300">{{ specialMessage }}</p>
|
||||
|
||||
<p v-if="isFailed && failedMessage" class="text-xs truncate text-red-500">{{ failedMessage }}</p>
|
||||
<p v-else-if="!isFinished && cancelingScan" class="text-xs truncate">Canceling...</p>
|
||||
|
|
@ -26,7 +27,16 @@ export default {
|
|||
},
|
||||
data() {
|
||||
return {
|
||||
cancelingScan: false
|
||||
cancelingScan: false,
|
||||
specialMessage: ''
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
task: {
|
||||
immediate: true,
|
||||
handler() {
|
||||
this.initTask()
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
|
|
@ -34,14 +44,17 @@ export default {
|
|||
return this.$store.getters['user/getIsAdminOrUp']
|
||||
},
|
||||
title() {
|
||||
if (this.task.titleKey && this.$strings[this.task.titleKey]) {
|
||||
return this.$getString(this.task.titleKey, this.task.titleSubs)
|
||||
}
|
||||
return this.task.title || 'No Title'
|
||||
},
|
||||
description() {
|
||||
if (this.task.descriptionKey && this.$strings[this.task.descriptionKey]) {
|
||||
return this.$getString(this.task.descriptionKey, this.task.descriptionSubs)
|
||||
}
|
||||
return this.task.description || ''
|
||||
},
|
||||
details() {
|
||||
return this.task.details || 'Unknown'
|
||||
},
|
||||
isFinished() {
|
||||
return !!this.task.isFinished
|
||||
},
|
||||
|
|
@ -52,6 +65,9 @@ export default {
|
|||
return this.isFinished && !this.isFailed
|
||||
},
|
||||
failedMessage() {
|
||||
if (this.task.errorKey && this.$strings[this.task.errorKey]) {
|
||||
return this.$getString(this.task.errorKey, this.task.errorSubs)
|
||||
}
|
||||
return this.task.error || ''
|
||||
},
|
||||
action() {
|
||||
|
|
@ -87,6 +103,21 @@ export default {
|
|||
}
|
||||
},
|
||||
methods: {
|
||||
initTask() {
|
||||
// special message for library scan tasks
|
||||
if (this.task?.data?.scanResults) {
|
||||
const scanResults = this.task.data.scanResults
|
||||
const strs = []
|
||||
if (scanResults.added) strs.push(this.$getString('MessageTaskScanItemsAdded', [scanResults.added]))
|
||||
if (scanResults.updated) strs.push(this.$getString('MessageTaskScanItemsUpdated', [scanResults.updated]))
|
||||
if (scanResults.missing) strs.push(this.$getString('MessageTaskScanItemsMissing', [scanResults.missing]))
|
||||
const changesDetected = strs.length > 0 ? strs.join(', ') : this.$strings.MessageTaskScanNoChangesNeeded
|
||||
const timeElapsed = scanResults.elapsed ? ` (${this.$elapsedPretty(scanResults.elapsed / 1000, false, true)})` : ''
|
||||
this.specialMessage = `${changesDetected}${timeElapsed}`
|
||||
} else {
|
||||
this.specialMessage = ''
|
||||
}
|
||||
},
|
||||
cancelScan() {
|
||||
const libraryId = this.task?.data?.libraryId
|
||||
if (!libraryId) {
|
||||
|
|
|
|||
|
|
@ -89,10 +89,10 @@ Vue.prototype.$strings = { ...enUsStrings }
|
|||
* Get string and substitute
|
||||
*
|
||||
* @param {string} key
|
||||
* @param {string[]} subs
|
||||
* @param {string[]} [subs=[]]
|
||||
* @returns {string}
|
||||
*/
|
||||
Vue.prototype.$getString = (key, subs) => {
|
||||
Vue.prototype.$getString = (key, subs = []) => {
|
||||
if (!Vue.prototype.$strings[key]) return ''
|
||||
if (subs?.length && Array.isArray(subs)) {
|
||||
return supplant(Vue.prototype.$strings[key], subs)
|
||||
|
|
|
|||
|
|
@ -18,7 +18,10 @@ Vue.prototype.$bytesPretty = (bytes, decimals = 2) => {
|
|||
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i]
|
||||
}
|
||||
|
||||
Vue.prototype.$elapsedPretty = (seconds, useFullNames = false) => {
|
||||
Vue.prototype.$elapsedPretty = (seconds, useFullNames = false, useMilliseconds = false) => {
|
||||
if (useMilliseconds && seconds > 0 && seconds < 1) {
|
||||
return `${Math.floor(seconds * 1000)} ms`
|
||||
}
|
||||
if (seconds < 60) {
|
||||
return `${Math.floor(seconds)} sec${useFullNames ? 'onds' : ''}`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -777,6 +777,38 @@
|
|||
"MessageShareExpiresIn": "Expires in {0}",
|
||||
"MessageShareURLWillBe": "Share URL will be <strong>{0}</strong>",
|
||||
"MessageStartPlaybackAtTime": "Start playback for \"{0}\" at {1}?",
|
||||
"MessageTaskAudioFileNotWritable": "Audio file \"{0}\" is not writable",
|
||||
"MessageTaskCanceledByUser": "Task canceled by user",
|
||||
"MessageTaskDownloadingEpisodeDescription": "Downloading episode \"{0}\"",
|
||||
"MessageTaskEmbeddingMetadata": "Embedding metadata",
|
||||
"MessageTaskEmbeddingMetadataDescription": "Embedding metadata in audiobook \"{0}\"",
|
||||
"MessageTaskEncodingM4b": "Encoding M4B",
|
||||
"MessageTaskEncodingM4bDescription": "Encoding audiobook \"{0}\" into a single m4b file",
|
||||
"MessageTaskFailed": "Failed",
|
||||
"MessageTaskFailedToBackupAudioFile": "Failed to backup audio file \"{0}\"",
|
||||
"MessageTaskFailedToCreateCacheDirectory": "Failed to create cache directory",
|
||||
"MessageTaskFailedToEmbedMetadataInFile": "Failed to embed metadata in file \"{0}\"",
|
||||
"MessageTaskFailedToMergeAudioFiles": "Failed to merge audio files",
|
||||
"MessageTaskFailedToMoveM4bFile": "Failed to move m4b file",
|
||||
"MessageTaskFailedToWriteMetadataFile": "Failed to write metadata file",
|
||||
"MessageTaskMatchingBooksInLibrary": "Matching books in library \"{0}\"",
|
||||
"MessageTaskNoFilesToScan": "No files to scan",
|
||||
"MessageTaskOpmlImport": "OPML import",
|
||||
"MessageTaskOpmlImportDescription": "Creating podcasts from {0} RSS feeds",
|
||||
"MessageTaskOpmlImportFeed": "OPML import feed",
|
||||
"MessageTaskOpmlImportFeedDescription": "Importing RSS feed \"{0}\"",
|
||||
"MessageTaskOpmlImportFeedFailed": "Failed to get podcast feed",
|
||||
"MessageTaskOpmlImportFeedPodcastDescription": "Creating podcast \"{0}\"",
|
||||
"MessageTaskOpmlImportFeedPodcastExists": "Podcast already exists at path",
|
||||
"MessageTaskOpmlImportFeedPodcastFailed": "Failed to create podcast",
|
||||
"MessageTaskOpmlImportFinished": "Added {0} podcasts",
|
||||
"MessageTaskScanItemsAdded": "{0} added",
|
||||
"MessageTaskScanItemsMissing": "{0} missing",
|
||||
"MessageTaskScanItemsUpdated": "{0} updated",
|
||||
"MessageTaskScanNoChangesNeeded": "No changes needed",
|
||||
"MessageTaskScanningFileChanges": "Scanning file changes in \"{0}\"",
|
||||
"MessageTaskScanningLibrary": "Scanning \"{0}\" library",
|
||||
"MessageTaskTargetDirectoryNotWritable": "Target directory is not writable",
|
||||
"MessageThinking": "Thinking...",
|
||||
"MessageUploaderItemFailed": "Failed to upload",
|
||||
"MessageUploaderItemSuccess": "Successfully Uploaded!",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue