Frontend UI for redo OCR

This commit is contained in:
Michael Shamoon 2022-06-22 05:53:41 -07:00
parent 13ffe468df
commit c9bdf1c184
4 changed files with 47 additions and 15 deletions

View File

@ -66,23 +66,30 @@
</div> </div>
<div class="col-auto ms-auto mb-2 mb-xl-0 d-flex"> <div class="col-auto ms-auto mb-2 mb-xl-0 d-flex">
<div class="btn-group btn-group-sm me-2"> <div class="btn-group btn-group-sm me-2">
<button type="button" [disabled]="awaitingDownload" class="btn btn-outline-primary btn-sm" (click)="downloadSelected()">
<svg *ngIf="!awaitingDownload" width="1em" height="1em" viewBox="0 0 16 16" fill="currentColor"> <div ngbDropdown class="me-2 d-flex">
<use xlink:href="assets/bootstrap-icons.svg#download" /> <button class="btn btn-sm btn-outline-primary" id="dropdownSelect" ngbDropdownToggle>
</svg> <svg class="toolbaricon" fill="currentColor">
<div *ngIf="awaitingDownload" class="spinner-border spinner-border-sm" role="status"> <use xlink:href="assets/bootstrap-icons.svg#three-dots" />
<span class="visually-hidden">Preparing download...</span> </svg>
</div> <div class="d-none d-sm-inline">&nbsp;<ng-container i18n>Actions</ng-container></div>
&nbsp; </button>
<ng-container i18n>Download</ng-container> <div ngbDropdownMenu aria-labelledby="dropdownSelect" class="shadow">
</button> <button ngbDropdownItem [disabled]="awaitingDownload" (click)="downloadSelected()" i18n>
<div class="btn-group" ngbDropdown role="group" aria-label="Button group with nested dropdown"> Download
<button [disabled]="awaitingDownload" class="btn btn-outline-primary btn-sm dropdown-toggle-split" ngbDropdownToggle></button> <div *ngIf="awaitingDownload" class="spinner-border spinner-border-sm" role="status">
<div class="dropdown-menu shadow" ngbDropdownMenu> <span class="visually-hidden">Preparing download...</span>
<button ngbDropdownItem i18n (click)="downloadSelected('originals')">Download originals</button> </div>
</button>
<button ngbDropdownItem [disabled]="awaitingDownload" (click)="downloadSelected('originals')" i18n>
Download originals
<div *ngIf="awaitingDownload" class="spinner-border spinner-border-sm" role="status">
<span class="visually-hidden">Preparing download...</span>
</div>
</button>
<button ngbDropdownItem (click)="redoOcrSelected()" i18n>Redo OCR</button>
</div> </div>
</div> </div>
</div>
<button type="button" class="btn btn-sm btn-outline-danger" (click)="applyDelete()"> <button type="button" class="btn btn-sm btn-outline-danger" (click)="applyDelete()">
<svg width="1em" height="1em" viewBox="0 0 16 16" fill="currentColor"> <svg width="1em" height="1em" viewBox="0 0 16 16" fill="currentColor">

View File

@ -379,4 +379,19 @@ export class BulkEditorComponent {
this.awaitingDownload = false this.awaitingDownload = false
}) })
} }
redoOcrSelected() {
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.list.selected.size} selected document(s).`
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.executeBulkOperation(modal, 'redo_ocr', {})
})
}
} }

View File

@ -118,3 +118,10 @@ def delete(doc_ids):
index.remove_document_by_id(writer, id) index.remove_document_by_id(writer, id)
return "OK" return "OK"
def redo_ocr(doc_ids):
async_task("documents.tasks.redo_ocr", document_ids=doc_ids)
return "OK"

View File

@ -323,6 +323,7 @@ class BulkEditSerializer(DocumentListSerializer):
"remove_tag", "remove_tag",
"modify_tags", "modify_tags",
"delete", "delete",
"redo_ocr",
], ],
label="Method", label="Method",
write_only=True, write_only=True,
@ -356,6 +357,8 @@ class BulkEditSerializer(DocumentListSerializer):
return bulk_edit.modify_tags return bulk_edit.modify_tags
elif method == "delete": elif method == "delete":
return bulk_edit.delete return bulk_edit.delete
elif method == "redo_ocr":
return bulk_edit.redo_ocr
else: else:
raise serializers.ValidationError("Unsupported method.") raise serializers.ValidationError("Unsupported method.")