feat: Add reset metadata capability

This commit is contained in:
Tiberiu Ichim 2026-02-14 21:57:54 +02:00
parent 98ce898f41
commit feb87e20d1
5 changed files with 167 additions and 0 deletions

View file

@ -13,6 +13,10 @@
<ui-btn v-if="userIsAdminOrUp && !isFile" :loading="rescanning" :disabled="isLibraryScanning" color="bg-bg" type="button" class="h-full" small @click.stop.prevent="rescan">{{ $strings.ButtonReScan }}</ui-btn>
<ui-tooltip v-if="userIsAdminOrUp && !isFile" text="Reset metadata to file tags" direction="bottom" class="ml-2">
<ui-btn :loading="resetting" :disabled="isLibraryScanning" color="bg-error" type="button" class="h-full" small @click.stop.prevent="resetMetadata">Reset</ui-btn>
</ui-tooltip>
<div class="grow" />
<!-- desktop -->
@ -37,6 +41,7 @@ export default {
data() {
return {
resettingProgress: false,
resetting: false,
isScrollable: false,
rescanning: false,
quickMatching: false
@ -141,6 +146,39 @@ export default {
this.rescanning = false
})
},
resetMetadata() {
const payload = {
message: 'Are you sure you want to reset metadata? This will remove the metadata file and re-scan the item from files.',
callback: (confirmed) => {
if (confirmed) {
this.runResetMetadata()
}
},
type: 'yesNo'
}
this.$store.commit('globals/setConfirmPrompt', payload)
},
runResetMetadata() {
this.resetting = true
this.$axios
.$post(`/api/items/${this.libraryItemId}/reset-metadata`)
.then((data) => {
this.resetting = false
this.$toast.success('Metadata reset successfully')
// Update the library item in the parent component
if (data) {
this.$emit('submit', { updatePayload: {}, hasChanges: false }) // Just to close or maybe I should trigger an update event
// Currently saveAndClose emits 'close'.
// We probably want to just update the local view or close.
// If I close, the user sees the updated card in the library.
}
})
.catch((error) => {
console.error('Failed to reset metadata', error)
this.$toast.error('Failed to reset metadata')
this.resetting = false
})
},
async saveAndClose() {
const wasUpdated = await this.save()
if (wasUpdated !== null) this.$emit('close')