diff --git a/src-ui/src/app/components/common/bootstrap-icon/icons.ts b/src-ui/src/app/components/common/bootstrap-icon/icons.ts index b3086aafef..e1339211bb 100644 --- a/src-ui/src/app/components/common/bootstrap-icon/icons.ts +++ b/src-ui/src/app/components/common/bootstrap-icon/icons.ts @@ -118,6 +118,7 @@ import personFill from 'bootstrap-icons/icons/person-fill.svg' import personLock from 'bootstrap-icons/icons/person-lock.svg' import personSquare from 'bootstrap-icons/icons/person-square.svg' import person from 'bootstrap-icons/icons/person.svg' +import playCircle from 'bootstrap-icons/icons/play-circle.svg' import playFill from 'bootstrap-icons/icons/play-fill.svg' import plusCircle from 'bootstrap-icons/icons/plus-circle.svg' import plus from 'bootstrap-icons/icons/plus.svg' @@ -279,6 +280,7 @@ export const icons: Record = { personFillLock, personLock, personSquare, + playCircle, playFill, plus, plusCircle, diff --git a/src-ui/src/app/components/common/confirm-dialog/run-workflow-confirm-dialog/run-workflow-confirm-dialog.component.html b/src-ui/src/app/components/common/confirm-dialog/run-workflow-confirm-dialog/run-workflow-confirm-dialog.component.html new file mode 100644 index 0000000000..e46d3454be --- /dev/null +++ b/src-ui/src/app/components/common/confirm-dialog/run-workflow-confirm-dialog/run-workflow-confirm-dialog.component.html @@ -0,0 +1,32 @@ + + + diff --git a/src-ui/src/app/components/common/confirm-dialog/run-workflow-confirm-dialog/run-workflow-confirm-dialog.component.ts b/src-ui/src/app/components/common/confirm-dialog/run-workflow-confirm-dialog/run-workflow-confirm-dialog.component.ts new file mode 100644 index 0000000000..12915141e8 --- /dev/null +++ b/src-ui/src/app/components/common/confirm-dialog/run-workflow-confirm-dialog/run-workflow-confirm-dialog.component.ts @@ -0,0 +1,24 @@ +import { Component } from '@angular/core' +import { FormsModule } from '@angular/forms' +import { Workflow } from 'src/app/data/workflow' +import { ConfirmDialogComponent } from '../confirm-dialog.component' + +@Component({ + selector: 'pngx-run-workflow-confirm-dialog', + templateUrl: './run-workflow-confirm-dialog.component.html', + imports: [FormsModule], +}) +export class RunWorkflowConfirmDialogComponent extends ConfirmDialogComponent { + public workflows: Workflow[] = [] + + public workflowId: number = null + + // i.e. ignore the workflow's trigger filters + public force: boolean = false + + override confirmButtonEnabled = false + + public workflowSelected(): void { + this.confirmButtonEnabled = !!this.workflowId + } +} diff --git a/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.html b/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.html index 1b96851515..5e9aff223a 100644 --- a/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.html +++ b/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.html @@ -98,6 +98,11 @@ + @if (manualWorkflows.length > 0) { + + } diff --git a/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.ts b/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.ts index 789060a8bd..103e47a1fc 100644 --- a/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.ts +++ b/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.ts @@ -306,6 +306,28 @@ export class BulkEditorComponent this.unsubscribeNotifier.complete() } + get canRunWorkflow(): boolean { + return this.userCanEditAll && this.manualWorkflows.length > 0 + } + + runWorkflowSelected() { + const modal = this.modalService.open(RunWorkflowConfirmDialogComponent, { + backdrop: 'static', + }) + modal.componentInstance.title = $localize`Run workflow` + modal.componentInstance.message = $localize`Run a workflow on ${this.getSelectionSize()} selected document(s).` + modal.componentInstance.btnCaption = $localize`Run` + modal.componentInstance.workflows = this.manualWorkflows + modal.componentInstance.confirmClicked + .pipe(takeUntil(this.unsubscribeNotifier)) + .subscribe(() => { + this.executeBulkEditMethod(modal, 'run_workflow', { + workflow: modal.componentInstance.workflowId, + filter_documents: !modal.componentInstance.force, + }) + }) + } + private executeBulkEditMethod( modal: NgbModalRef, method: DocumentBulkEditMethod, diff --git a/src-ui/src/app/services/rest/document.service.ts b/src-ui/src/app/services/rest/document.service.ts index 3272d9695e..d33bfa2c24 100644 --- a/src-ui/src/app/services/rest/document.service.ts +++ b/src-ui/src/app/services/rest/document.service.ts @@ -38,6 +38,7 @@ export type DocumentBulkEditMethod = | 'modify_tags' | 'modify_custom_fields' | 'set_permissions' + | 'run_workflow' export interface MergeDocumentsRequest { metadata_document_id?: number