Allow removing authors with no books

This commit is contained in:
Tiberiu Ichim 2026-02-12 19:21:25 +02:00
parent 771f8c586f
commit fc97b10f58
4 changed files with 127 additions and 16 deletions

View file

@ -25,6 +25,18 @@
</div>
</div>
</div>
<div v-if="isBookLibrary" class="w-full border border-black-200 p-4 my-8">
<div class="flex flex-wrap items-center">
<div>
<p class="text-lg">{{ $strings.LabelCleanupAuthors }}</p>
<p class="max-w-sm text-sm pt-2 text-gray-300">{{ $strings.LabelCleanupAuthorsHelp }}</p>
</div>
<div class="grow" />
<div>
<ui-btn @click.stop="cleanupAuthorsClick">{{ $strings.ButtonRemove }}</ui-btn>
</div>
</div>
</div>
</div>
</template>
@ -114,6 +126,38 @@ export default {
.finally(() => {
this.$emit('update:processing', false)
})
},
cleanupAuthorsClick() {
const payload = {
message: this.$strings.MessageConfirmCleanupAuthors,
persistent: true,
callback: (confirmed) => {
if (confirmed) {
this.cleanupAuthors()
}
},
type: 'yesNo'
}
this.$store.commit('globals/setConfirmPrompt', payload)
},
cleanupAuthors() {
this.$emit('update:processing', true)
this.$axios
.$delete(`/api/libraries/${this.libraryId}/authors/cleanup?force=1`)
.then((data) => {
if (data.removed) {
this.$toast.success(this.$getString('ToastCleanupAuthorsSuccess', [data.removed]))
} else {
this.$toast.info(this.$strings.ToastCleanupAuthorsNoAuthors)
}
})
.catch((error) => {
console.error('Failed to cleanup authors', error)
this.$toast.error(this.$strings.ToastCleanupAuthorsFailed)
})
.finally(() => {
this.$emit('update:processing', false)
})
}
},
mounted() {}

View file

@ -284,6 +284,8 @@
"LabelChapterTitle": "Chapter Title",
"LabelChapters": "Chapters",
"LabelChaptersFound": "chapters found",
"LabelCleanupAuthors": "Cleanup authors",
"LabelCleanupAuthorsHelp": "Remove authors that have no books in this library.",
"LabelClickForMoreInfo": "Click for more info",
"LabelClickToUseCurrentValue": "Click to use current value",
"LabelClosePlayer": "Close player",
@ -800,6 +802,7 @@
"MessageConfirmRemoveCollection": "Are you sure you want to remove collection \"{0}\"?",
"MessageConfirmRemoveEpisode": "Are you sure you want to remove episode \"{0}\"?",
"MessageConfirmRemoveItemsWithIssues": "Are you sure you want to remove all items with issues?",
"MessageConfirmCleanupAuthors": "Are you sure you want to remove all authors with no books in this library?",
"MessageConfirmRemoveEpisodeNote": "Note: This does not delete the audio file unless toggling \"Hard delete file\"",
"MessageConfirmRemoveEpisodes": "Are you sure you want to remove {0} episodes?",
"MessageConfirmRemoveListeningSessions": "Are you sure you want to remove {0} listening sessions?",
@ -1085,6 +1088,9 @@
"ToastLibraryItemsWithIssuesNoneFound": "No items with issues found",
"ToastLibraryItemsWithIssuesRemoved": "Removed items with issues",
"ToastLibraryItemsWithIssuesRemoveFailed": "Failed to remove items with issues",
"ToastCleanupAuthorsSuccess": "Cleaned up {0} authors",
"ToastCleanupAuthorsNoAuthors": "No authors found to cleanup",
"ToastCleanupAuthorsFailed": "Failed to cleanup authors",
"ToastLibraryScanStarted": "Library scan started",
"ToastLibraryUpdateSuccess": "Library \"{0}\" updated",
"ToastMatchAllAuthorsFailed": "Failed to match all authors",