Merge pull request #1277 from paperless-ngx/fix/redo-ocr-button-on-edit

Fix/feature: add redo ocr button to document edit view
This commit is contained in:
shamoon
2022-07-26 11:21:42 -07:00
committed by GitHub
3 changed files with 145 additions and 64 deletions

View File

@@ -8,7 +8,7 @@
<button type="button" class="btn btn-sm btn-outline-danger me-2 ms-auto" (click)="delete()">
<svg class="buttonicon" fill="currentColor">
<use xlink:href="assets/bootstrap-icons.svg#trash" />
</svg>&nbsp;<span class="d-none d-lg-inline" i18n>Delete</span>
</svg><span class="d-none d-lg-inline ps-1" i18n>Delete</span>
</button>
<div class="btn-group me-2">
@@ -16,7 +16,7 @@
<a [href]="downloadUrl" class="btn btn-sm btn-outline-primary">
<svg class="buttonicon" fill="currentColor">
<use xlink:href="assets/bootstrap-icons.svg#download" />
</svg>&nbsp;<span class="d-none d-lg-inline" i18n>Download</span>
</svg><span class="d-none d-lg-inline ps-1" i18n>Download</span>
</a>
<div class="btn-group" ngbDropdown role="group" *ngIf="metadata?.has_archive_version">
@@ -28,10 +28,16 @@
</div>
<button type="button" class="btn btn-sm btn-outline-primary me-2" (click)="redoOcr()">
<svg class="buttonicon" fill="currentColor">
<use xlink:href="assets/bootstrap-icons.svg#arrow-counterclockwise" />
</svg><span class="d-none d-lg-inline ps-1" i18n>Redo OCR</span>
</button>
<button type="button" class="btn btn-sm btn-outline-primary me-2" (click)="moreLike()">
<svg class="buttonicon" fill="currentColor">
<use xlink:href="assets/bootstrap-icons.svg#diagram-3" />
</svg>&nbsp;<span class="d-none d-lg-inline" i18n>More like this</span>
</svg><span class="d-none d-lg-inline ps-1" i18n>More like this</span>
</button>
<button type="button" class="btn btn-sm btn-outline-primary me-2" i18n-title title="Close" (click)="close()">

View File

@@ -472,6 +472,42 @@ export class DocumentDetailComponent
])
}
redoOcr() {
let modal = this.modalService.open(ConfirmDialogComponent, {
backdrop: 'static',
})
modal.componentInstance.title = $localize`Redo OCR confirm`
modal.componentInstance.messageBold = $localize`This operation will permanently redo OCR for this document.`
modal.componentInstance.message = $localize`This operation cannot be undone.`
modal.componentInstance.btnClass = 'btn-danger'
modal.componentInstance.btnCaption = $localize`Proceed`
modal.componentInstance.confirmClicked.subscribe(() => {
modal.componentInstance.buttonsEnabled = false
this.documentsService
.bulkEdit([this.document.id], 'redo_ocr', {})
.subscribe({
next: () => {
this.toastService.showInfo(
$localize`Redo OCR operation will begin in the background.`
)
if (modal) {
modal.close()
}
},
error: (error) => {
if (modal) {
modal.componentInstance.buttonsEnabled = true
}
this.toastService.showError(
$localize`Error executing operation: ${JSON.stringify(
error.error
)}`
)
},
})
})
}
hasNext() {
return this.documentListViewService.hasNext(this.documentId)
}