diff --git a/.github/DISCUSSION_TEMPLATE/feature-requests.yml b/.github/DISCUSSION_TEMPLATE/feature-requests.yml index b24abdb460..e76594999a 100644 --- a/.github/DISCUSSION_TEMPLATE/feature-requests.yml +++ b/.github/DISCUSSION_TEMPLATE/feature-requests.yml @@ -1,5 +1,23 @@ title: "[Feature Request] " body: + - type: markdown + attributes: + value: | + #### Use of AI tools + + If this request was generated, in whole or in part, by an AI tool or agent you **must** say so using the field below. Failing to clearly disclose this is a violation of our [Code of Conduct](https://github.com/paperless-ngx/paperless-ngx/blob/main/CODE_OF_CONDUCT.md). + + The project prefers thoughtful, well-described ideas to AI-generated content. Please describe the problem, your use case, the desired behavior, and who would benefit. + - type: dropdown + id: ai-usage + attributes: + label: AI usage + description: Was any part of this request written by an AI tool or agent? + options: + - No AI tools were used + - Yes, AI tools helped write this request + validations: + required: true - type: textarea id: description attributes: diff --git a/.github/DISCUSSION_TEMPLATE/support.yml b/.github/DISCUSSION_TEMPLATE/support.yml index f0154aa8be..fc567dbc4c 100644 --- a/.github/DISCUSSION_TEMPLATE/support.yml +++ b/.github/DISCUSSION_TEMPLATE/support.yml @@ -1,5 +1,21 @@ title: "[Support] " body: + - type: markdown + attributes: + value: | + #### Use of AI tools + + If this post was generated, in whole or in part, by an AI tool or agent you **must** say so using the field below. Failing to clearly disclose this is a violation of our [Code of Conduct](https://github.com/paperless-ngx/paperless-ngx/blob/main/CODE_OF_CONDUCT.md). + - type: dropdown + id: ai-usage + attributes: + label: AI usage + description: Was any part of this post written by an AI tool or agent? + options: + - No AI tools were used + - Yes, AI tools helped write this post + validations: + required: true - type: textarea id: description attributes: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d037198abb..a25eaa760c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -38,7 +38,7 @@ repos: - json # See https://github.com/prettier/prettier/issues/15742 for the fork reason - repo: https://github.com/rbubley/mirrors-prettier - rev: 'v3.9.9' + rev: 'v3.9.10' hooks: - id: prettier types_or: @@ -46,16 +46,16 @@ repos: - ts - markdown additional_dependencies: - - prettier@3.9.9 + - prettier@3.9.10 - 'prettier-plugin-organize-imports@4.3.0' # Python hooks - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.16.9 + rev: v0.17.2 hooks: - id: ruff-check - id: ruff-format - repo: https://github.com/tox-dev/pyproject-fmt - rev: "v2.29.4" + rev: "v2.30.3" hooks: - id: pyproject-fmt additional_dependencies: [tomli] diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000000..570291bb92 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,44 @@ +# Guidance for AI agents + +Read [CONTRIBUTING.md](CONTRIBUTING.md) before working on this repository, especially [Use of AI Tools](CONTRIBUTING.md#use-of-ai-tools). These contribution rules apply to all agent-assisted work. + +## Contribution boundaries + +- Do not open or submit pull requests, including "on behalf of" a human. The project does not accept PRs from AI agents. Prepare local changes for a human to review, verify, and submit personally. +- The project does not accept PRs that are entirely or mostly AI-derived. Human submission and disclosure do not override this rule. +- AI-generated content must be clearly disclosed as described in the contributing guidelines. When handing work back to a human, identify what was generated or changed with AI assistance so they can disclose it accurately. +- Trust matters. Encourage first-time contributors to discuss their proposed change before preparing a PR, especially for large changes or changes involving AI-generated code. New features and enhancements should almost always target an existing feature request with community interest and discussion. +- The project prefers thoughtful, well-described ideas to AI-generated pull requests. Help contributors describe their problem, use case, desired behavior, and who would benefit. An implementation is not required for a valuable contribution, and a flawed implementation can obscure a useful idea before it receives proper discussion. +- AI tools have lowered the effort needed to produce a PR, but reviewing and maintaining it still requires substantial work. Encourage discussion of the idea before investing in implementation and review. +- Issue reports must describe observed behavior, reproduction steps, and relevant logs. Do not add speculative root causes, code analysis, or proposed fixes to agent-generated reports. + +## Security reports + +- AI-assisted security reports must meet the legitimacy and verification requirements in [SECURITY.md](SECURITY.md#ai-assisted-submissions). A human must verify a real Paperless-ngx code path, concrete reproduction steps, affected versions, and realistic security impact before submission. +- Account for existing permission checks, configuration requirements, and trust boundaries. Speculation, scanner output, or concerns about third-party software or deployment choices without a demonstrated Paperless-ngx vulnerability do not meet this threshold and may be closed without extended discussion. +- Disclose AI assistance and use the private vulnerability reporting channel specified in [SECURITY.md](SECURITY.md#reporting-a-vulnerability). + +## Working on changes + +- Read the relevant code, tests, and documentation before editing. Paperless-ngx is complex: trace interactions between affected components rather than assuming a change is isolated. +- Keep changes focused on the requested work and follow existing patterns. Avoid unrelated refactoring, formatting, dependency updates, or generated-file changes. +- Consider effects on permissions, document processing, background tasks, storage, and the API when those areas are involved. +- Add or update meaningful tests for behavior changes and regressions. Do not weaken tests or checks to make a change pass. +- Update user or developer documentation when behavior or setup changes. +- Keep credentials and private documents out of commits, fixtures, logs, and examples. + +## Repository and validation + +- `src/`: Django back end. +- `src-ui/`: Angular front end, managed with `pnpm`. +- `docs/`: Documentation. +- `docker/` and `scripts/`: Deployment and development tooling. +- Base functional changes on `dev`; documentation-only changes may target `main`. + +Follow [the development documentation](docs/development.md) for environment setup and testing. Common checks after setup are: + +- Back end: run `uv run pytest` from `src/` (use a test path to focus on the affected area). +- Front end: run `pnpm test` and `pnpm lint` from `src-ui/`. +- Formatting and other pre-commit checks: run `uv run prek run --files ` from the repository root. + +When handing work back, summarize the changes, the checks actually run and their results, and any remaining uncertainty. Clearly state when a check could not be run; do not claim verification that did not happen. The human contributor must understand and independently verify the contribution before submitting it. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f0c9f528cc..0695b7e5d4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -4,6 +4,18 @@ If you feel like contributing to the project, please do! Bug fixes and improveme ⚠️ Please note: Pull requests that implement a new feature or enhancement _should almost always target an existing feature request_ with evidence of community interest and discussion. This is in order to balance the work of implementing and maintaining new features / enhancements. Pull requests that are opened without meeting this requirement may not be merged. +## Trust and collaboration + +Paperless-ngx places a high value on trust between contributors and maintainers. If you have not contributed before, consider starting with a discussion before preparing a pull request, especially for a large contribution or one involving AI-generated code. + +Paperless-ngx is complex, and understanding how its components interact takes time. A change that appears correct in isolation can have consequences elsewhere in the application. Contributors should understand the code they submit, explain how it fits into the project, and work with maintainers through review. Starting with smaller, focused contributions can help build that understanding and trust. + +We prefer thoughtful, well-described ideas to AI-generated pull requests. You do not need to supply an implementation for your contribution to be valuable. Explain the problem you have encountered, your use case, the behavior you would like to see, and who would benefit. Concrete examples, alternatives you have considered, and relevant constraints help the community discuss and refine the idea. + +AI tools have lowered the effort needed to produce a pull request, but evaluating one still requires substantial maintainer time. Maintainers still need to establish whether the implementation is correct, fits the project, and can be maintained over time. + +A flawed implementation can also obscure a good idea: discussion becomes focused on problems with the generated code before the community has considered whether the underlying proposal is useful. Starting with the idea gives it a fair discussion on its own merits and lets contributors and maintainers agree on an approach before investing in implementation and review. + If you want to implement something big: - As above, please start with a discussion! Maybe something similar is already in development and we can make it happen together. @@ -61,9 +73,10 @@ This project does not specifically prohibit the use of AI tools or agents _durin 1. Any content — code, pull request descriptions, issue reports or comments — that was generated in whole or in part by an AI tool or agent **must be clearly disclosed as such**. Failing to clearly disclose this is considered a violation of our [Code of Conduct](CODE_OF_CONDUCT.md) and may result in your contributions being closed and further action being taken. 2. AI-generated code must not violate copyright protections. -3. We will not accept PRs that are entirely or mostly AI-derived. -4. Issue reports must describe _observed behavior only_: what happened, how to reproduce it and the relevant logs. Reports generated by an AI agent should not include code analysis, speculation about the root cause or suggest fixes. -5. Contributors are responsible for everything they submit, regardless of how it was produced. Please do not open issues or PRs you have not verified yourself. +3. We will not accept PRs opened or submitted by AI agents, including agents acting "on behalf of" a human. A human contributor must personally review, verify, and submit the contribution and take responsibility for it throughout review. +4. We will not accept PRs that are entirely or mostly AI-derived. +5. Issue reports must describe _observed behavior only_: what happened, how to reproduce it and the relevant logs. Reports generated by an AI agent should not include code analysis, speculation about the root cause or suggest fixes. +6. Contributors are responsible for everything they submit, regardless of how it was produced. Please do not open issues or PRs you have not verified yourself. # Translating Paperless-ngx diff --git a/docs/administration.md b/docs/administration.md index 155716660e..80ca53eaaf 100644 --- a/docs/administration.md +++ b/docs/administration.md @@ -565,6 +565,8 @@ Specify `rebuild` to build the index from scratch from all documents in the data this the first time you enable the feature, or after changing the embedding backend or model. +When using the `huggingface` embedding backend, a model that is already downloaded is loaded from the local cache without contacting the Hugging Face Hub. Only `rebuild` checks the Hub for a newer revision of the model, so a model update is picked up together with re-embedding every document. If the model is not cached yet, it is downloaded on first use. + Specify `update` to incrementally index new and changed documents. This is what the scheduled task runs. diff --git a/docs/configuration.md b/docs/configuration.md index 39fc30e95f..903347abab 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -501,20 +501,20 @@ See the [Django project documentation on the settings](https://docs.djangoprojec #### [`PAPERLESS_ALLOWED_HOSTS=`](#PAPERLESS_ALLOWED_HOSTS) {#PAPERLESS_ALLOWED_HOSTS} -: If you're planning on putting Paperless on the open internet, then -you really should set this value to the domain name you're using. -Failing to do so leaves you open to HTTP host header attacks. +: If you expose Paperless to the internet, set `PAPERLESS_URL` to its public URL +or list its public hostname in `PAPERLESS_ALLOWED_HOSTS` to help protect against +HTTP Host header attacks. You can read more about this in [the Django project's documentation](https://docs.djangoproject.com/en/4.1/topics/security/#host-header-validation) - Just remember that this is a comma-separated list, so - "example.com" is fine, as is "example.com,www.example.com", but - NOT " example.com" or "example.com," + Separate multiple hostnames with commas, as in `example.com,www.example.com`. - Can also be set using PAPERLESS_URL (see above). - - "localhost" is always allowed for docker healthcheck - - Defaults to "\*", which is all hosts. + - With neither setting configured, Paperless accepts any host. + - With only `PAPERLESS_URL` set, Paperless accepts the hostname from that URL + and `localhost` (used by the Docker health check). + - `PAPERLESS_ALLOWED_HOSTS` adds hosts to `localhost` and the hostname from + `PAPERLESS_URL`, if set. A blank list adds no hosts. + - With `PAPERLESS_ALLOWED_HOSTS=*`, Paperless accepts any host, even when + `PAPERLESS_URL` is set. #### [`PAPERLESS_CORS_ALLOWED_HOSTS=`](#PAPERLESS_CORS_ALLOWED_HOSTS) {#PAPERLESS_CORS_ALLOWED_HOSTS} @@ -873,6 +873,14 @@ If both the [PAPERLESS_ACCOUNT_DEFAULT_GROUPS](#PAPERLESS_ACCOUNT_DEFAULT_GROUPS Defaults to 1209600 (2 weeks) +#### [`PAPERLESS_SESSION_CLEANUP_TASK_CRON=`](#PAPERLESS_SESSION_CLEANUP_TASK_CRON) {#PAPERLESS_SESSION_CLEANUP_TASK_CRON} + +: Configures the schedule to remove expired sessions from the session store. +Django does not prune these automatically, so without this they would +accumulate indefinitely. + + Defaults to `0 3 * * *`, once per day at 03:00. + #### [`PAPERLESS_TOKEN_THROTTLE_RATE=`](#PAPERLESS_TOKEN_THROTTLE_RATE) {#PAPERLESS_TOKEN_THROTTLE_RATE} : Rate limit for the API token authentication endpoint (`/api/token/`), used to mitigate brute-force login attempts. @@ -1149,6 +1157,9 @@ they use underscores instead of dashes. be changed by trusted users. This applies to the `AppConfig` permission as well, which allows setting these arguments from the UI. + Arguments paperless manages itself (`input_file_or_options`, `output_file` + and `sidecar`) are rejected by the API and ignored if set here. + Specify arguments as a JSON dictionary. Keep note of lower case booleans and double quoted parameter names and strings. Examples: diff --git a/docs/usage.md b/docs/usage.md index cc0b52907c..fd4fa22da8 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -493,7 +493,7 @@ fields and permissions, which will be merged. #### Types {#workflow-trigger-types} -Currently, there are four events that correspond to workflow trigger 'types': +Currently, there are five events that correspond to workflow trigger 'types': 1. **Consumption Started**: _before_ a document is consumed, so events can include filters by source (mail, consumption folder or API), file path, file name, mail rule @@ -505,8 +505,10 @@ Currently, there are four events that correspond to workflow trigger 'types': 4. **Scheduled**: a scheduled trigger that can be used to run workflows at a specific time. The date used can be either the document added, created, updated date or you can specify a (date) custom field. You can also specify a day offset from the date (positive offsets will trigger after the date, negative offsets will trigger before). +5. **Manual**: a trigger that only runs when you explicitly choose to run the workflow against one or more existing documents. See + [running a workflow manually](#running-a-workflow-manually) below. -The following flow diagram illustrates the four document trigger types: +The following flow diagram illustrates the document trigger types: ```mermaid flowchart TD @@ -526,6 +528,10 @@ flowchart TD matching trigger(s)"} + manual{"Matching + 'Manual' + trigger(s)"} + A[New Document] --> consumption consumption --> |Yes| C[Workflow Actions Run] consumption --> |No| D @@ -543,6 +549,10 @@ flowchart TD scheduled --> |Yes| N[Workflow Actions Run] scheduled --> |No| O[Document Saved] N --> O + P[User Runs Workflow] --> manual + manual --> |Yes| Q[Workflow Actions Run] + manual --> |No| R[Document Saved] + Q --> R ``` #### Filters {#workflow-trigger-filters} @@ -554,9 +564,9 @@ Workflows allow you to filter by: - File path, including wildcards. Note that enabling `PAPERLESS_CONSUMER_RECURSIVE` would allow, for example, automatically assigning documents to different owners based on the upload directory. - Mail rule. Choosing this option will force 'mail fetch' to be the workflow source. -- Content matching (`Added`, `Updated` and `Scheduled` triggers only). Filter document content using the matching settings. +- Content matching (`Added`, `Updated`, `Scheduled` and `Manual` triggers only). Filter document content using the matching settings. -There are also 'advanced' filters available for `Added`, `Updated` and `Scheduled` triggers: +There are also 'advanced' filters available for `Added`, `Updated`, `Scheduled` and `Manual` triggers: - Any Tags: Filter for documents with any of the specified tags. - All Tags: Filter for documents with all of the specified tags. @@ -569,6 +579,21 @@ There are also 'advanced' filters available for `Added`, `Updated` and `Schedule - Not Storage paths: Filter documents without any of these storage paths. - Custom field query: Filter documents with a custom field query (the same as used for the document list filters). +#### Running a workflow manually {#running-a-workflow-manually} + +A workflow with a **Manual** trigger does not run automatically. Instead, it can be run on demand against existing +documents from the web UI: + +- From the document list, select one or more documents and choose **Run workflow** from the "Actions" menu. +- From an individual document, choose **Run workflow** from the "Actions" menu. + +You will be asked which workflow to run. By default the workflow's trigger filters still apply, so documents that do +not match are skipped. You can instead choose to **run on all selected documents**, which ignores the trigger filters +and runs the workflow's actions on every selected document. + +Manual runs happen in the background. As with scheduled workflows, the document list is not refreshed automatically when +they finish, so you may need to reload the list to see the results. + ### Workflow Actions #### Types {#workflow-action-types} @@ -649,7 +674,7 @@ new version of the same document, this time with normal OCR/text extraction appl a password-protected file added with this trigger will briefly exist as an un-OCR'd version before the properly processed version is created. -**Document Added**, **Document Updated**, **Scheduled**: these triggers run against a document that +**Document Added**, **Document Updated**, **Scheduled**, **Manual**: these triggers run against a document that already exists, so password removal happens immediately: the decrypted content is queued for consumption as a new version right away. Note that if the document's initial consumption also happened while it was still encrypted, that original version will likewise be missing OCR text. diff --git a/pyproject.toml b/pyproject.toml index 5eb0f59ed2..cef735f65a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -212,12 +212,7 @@ extend-select = [ "UP", # https://docs.astral.sh/ruff/rules/#pyupgrade-up "W", # https://docs.astral.sh/ruff/rules/#pycodestyle-e-w ] -ignore = [ - "DJ001", - "PLC0415", - "RUF012", - "SIM105", -] +ignore = [ "DJ001", "ICN001", "PLC0415", "RUF012", "SIM105" ] # Migrations per-file-ignores."*/migrations/*.py" = [ "E501", diff --git a/src-ui/messages.xlf b/src-ui/messages.xlf index 134be4c5de..a6f38b976e 100644 --- a/src-ui/messages.xlf +++ b/src-ui/messages.xlf @@ -687,11 +687,11 @@ src/app/components/document-detail/document-detail.component.html - 442 + 448 src/app/components/document-detail/document-detail.component.html - 443,444 + 449,450 src/app/components/document-list/bulk-editor/custom-fields-bulk-edit-dialog/custom-fields-bulk-edit-dialog.component.html @@ -863,7 +863,7 @@ src/app/components/document-detail/document-detail.component.html - 474 + 480 src/app/components/document-list/document-list.component.html @@ -1362,11 +1362,11 @@ src/app/components/document-detail/document-detail.component.html - 61 + 67 src/app/components/document-detail/document-detail.component.ts - 1918 + 1971 @@ -1444,7 +1444,7 @@ src/app/components/document-detail/document-detail.component.html - 386,387 + 392,393 src/app/components/document-list/bulk-editor/bulk-editor.component.html @@ -1683,7 +1683,7 @@ src/app/components/document-detail/document-detail.component.html - 145 + 151 @@ -1694,11 +1694,11 @@ src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.ts - 174 + 178 src/app/components/document-detail/document-detail.component.html - 150 + 156 src/app/components/document-list/bulk-editor/bulk-editor.component.html @@ -1729,11 +1729,11 @@ src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.ts - 178 + 182 src/app/components/document-detail/document-detail.component.html - 154 + 160 src/app/components/document-list/bulk-editor/bulk-editor.component.html @@ -1764,11 +1764,11 @@ src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.ts - 182 + 186 src/app/components/document-detail/document-detail.component.html - 158 + 164 src/app/components/document-list/bulk-editor/bulk-editor.component.html @@ -1799,7 +1799,7 @@ src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.ts - 170 + 174 src/app/components/common/input/tags/tags.component.ts @@ -1854,7 +1854,7 @@ src/app/components/document-detail/document-detail.component.html - 78,79 + 84,85 @@ -1989,15 +1989,15 @@ src/app/components/app-frame/app-frame.component.ts - 214 + 260 src/app/components/app-frame/app-frame.component.ts - 332 + 378 src/app/components/app-frame/app-frame.component.ts - 361 + 407 @@ -2052,7 +2052,7 @@ src/app/components/admin/tasks/tasks.component.ts - 58 + 60 src/app/components/common/custom-fields-query-dropdown/custom-fields-query-dropdown.component.html @@ -2098,7 +2098,7 @@ src/app/components/admin/tasks/tasks.component.ts - 224 + 227 @@ -2109,7 +2109,7 @@ src/app/components/admin/tasks/tasks.component.ts - 236 + 239 @@ -2178,7 +2178,7 @@ src/app/components/admin/tasks/tasks.component.ts - 53 + 54 src/app/components/admin/trash/trash.component.html @@ -2471,15 +2471,15 @@ src/app/components/admin/tasks/tasks.component.ts - 326 + 340 src/app/components/admin/tasks/tasks.component.ts - 360 + 374 src/app/components/document-detail/document-detail.component.ts - 715 + 721 src/app/components/document-detail/document-version-dropdown/document-version-dropdown.component.html @@ -2563,56 +2563,63 @@ Result src/app/components/admin/tasks/tasks.component.ts - 54 + 55 + + + + Task ID + + src/app/components/admin/tasks/tasks.component.ts + 56 Needs attention src/app/components/admin/tasks/tasks.component.ts - 59 + 61 In progress src/app/components/admin/tasks/tasks.component.ts - 60 + 62 Recently completed src/app/components/admin/tasks/tasks.component.ts - 61 + 63 Consume File src/app/components/admin/tasks/tasks.component.ts - 70 + 72 Train Classifier src/app/components/admin/tasks/tasks.component.ts - 74 + 76 Sanity Check src/app/components/admin/tasks/tasks.component.ts - 78 + 80 Mail Fetch src/app/components/admin/tasks/tasks.component.ts - 80 + 82 src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.ts @@ -2623,63 +2630,63 @@ LLM Index src/app/components/admin/tasks/tasks.component.ts - 81 + 83 Empty Trash src/app/components/admin/tasks/tasks.component.ts - 84 + 86 Check Workflows src/app/components/admin/tasks/tasks.component.ts - 88 + 90 Bulk Update src/app/components/admin/tasks/tasks.component.ts - 92 + 94 Reprocess Document src/app/components/admin/tasks/tasks.component.ts - 96 + 98 Build Share Link src/app/components/admin/tasks/tasks.component.ts - 100 + 102 Bulk Delete src/app/components/admin/tasks/tasks.component.ts - 104 + 106 Apply AI Suggestions src/app/components/admin/tasks/tasks.component.ts - 108 + 110 Scheduled src/app/components/admin/tasks/tasks.component.ts - 118 + 120 src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.ts @@ -2690,7 +2697,7 @@ Web UI src/app/components/admin/tasks/tasks.component.ts - 120 + 122 src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.ts @@ -2701,7 +2708,7 @@ API Upload src/app/components/admin/tasks/tasks.component.ts - 123 + 125 src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.ts @@ -2712,106 +2719,110 @@ Folder Consume src/app/components/admin/tasks/tasks.component.ts - 127 + 129 Email Consume src/app/components/admin/tasks/tasks.component.ts - 131 + 133 System src/app/components/admin/tasks/tasks.component.ts - 133 + 135 Manual src/app/components/admin/tasks/tasks.component.ts - 134 + 136 + + + src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.ts + 128 Dismiss selected src/app/components/admin/tasks/tasks.component.ts - 248 + 251 Dismiss visible src/app/components/admin/tasks/tasks.component.ts - 249 + 252 Confirm Dismiss src/app/components/admin/tasks/tasks.component.ts - 323 + 337 Dismiss tasks? src/app/components/admin/tasks/tasks.component.ts - 324 + 338 Error dismissing tasks src/app/components/admin/tasks/tasks.component.ts - 335 + 349 src/app/components/admin/tasks/tasks.component.ts - 369 + 383 Error dismissing task src/app/components/admin/tasks/tasks.component.ts - 347 + 361 Confirm Dismiss All src/app/components/admin/tasks/tasks.component.ts - 357 + 371 Dismiss all tasks? src/app/components/admin/tasks/tasks.component.ts - 358 + 372 Success. New document id created src/app/components/admin/tasks/tasks.component.ts - 417 + 431 Duplicate of document # src/app/components/admin/tasks/tasks.component.ts - 427 + 441 src/app/components/admin/tasks/tasks.component.ts - 461 + 475 @@ -2954,7 +2965,7 @@ src/app/components/document-list/bulk-editor/bulk-editor.component.html - 179 + 184 src/app/components/manage/document-attributes/custom-fields/custom-fields.component.html @@ -3401,27 +3412,27 @@ src/app/components/document-detail/document-detail.component.ts - 1532 + 1552 src/app/components/document-detail/document-detail.component.ts - 1919 + 1972 src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 954 + 1019 src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 993 + 1058 src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 1016 + 1081 src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 1052 + 1117 src/app/components/manage/document-attributes/custom-fields/custom-fields.component.ts @@ -3764,25 +3775,46 @@ 418 + + Bulk operation completed. + + src/app/components/app-frame/app-frame.component.ts + 202 + + + + Bulk operation revoked. + + src/app/components/app-frame/app-frame.component.ts + 204 + + + + Bulk operation failed. Some changes may already have been applied. + + src/app/components/app-frame/app-frame.component.ts + 207 + + Sidebar views updated src/app/components/app-frame/app-frame.component.ts - 497 + 543 Error updating sidebar views src/app/components/app-frame/app-frame.component.ts - 500 + 546 An error occurred while saving update checking settings. src/app/components/app-frame/app-frame.component.ts - 521 + 567 @@ -3827,11 +3859,11 @@ src/app/components/document-list/bulk-editor/bulk-editor.component.html - 142 + 147 src/app/components/document-list/bulk-editor/bulk-editor.component.html - 151 + 156 src/app/components/document-list/document-card-large/document-card-large.component.html @@ -4074,19 +4106,19 @@ src/app/components/document-detail/document-detail.component.html - 73 + 79 src/app/components/document-detail/document-detail.component.html - 74 + 80 src/app/components/document-list/bulk-editor/bulk-editor.component.html - 111 + 116 src/app/components/document-list/bulk-editor/bulk-editor.component.html - 113 + 118 src/app/data/saved-view-icons.ts @@ -4159,31 +4191,31 @@ src/app/components/document-detail/document-detail.component.ts - 1481 + 1501 src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 572 + 637 src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 612 + 677 src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 650 + 715 src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 688 + 753 src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 750 + 815 src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 888 + 953 @@ -4303,7 +4335,7 @@ src/app/components/document-detail/document-detail.component.ts - 1972 + 2025 @@ -4314,7 +4346,7 @@ src/app/components/document-detail/document-detail.component.ts - 1973 + 2026 @@ -4325,7 +4357,7 @@ src/app/components/document-detail/document-detail.component.ts - 1974 + 2027 @@ -4363,6 +4395,34 @@ 25,27 + + Workflow + + src/app/components/common/confirm-dialog/run-workflow-confirm-dialog/run-workflow-confirm-dialog.component.html + 11,12 + + + + Select a workflow + + src/app/components/common/confirm-dialog/run-workflow-confirm-dialog/run-workflow-confirm-dialog.component.html + 13,14 + + + + Run on all selected documents + + src/app/components/common/confirm-dialog/run-workflow-confirm-dialog/run-workflow-confirm-dialog.component.html + 21,22 + + + + Ignore the workflow's trigger filters and run on every selected document. + + src/app/components/common/confirm-dialog/run-workflow-confirm-dialog/run-workflow-confirm-dialog.component.html + 22,23 + + View @@ -4564,7 +4624,7 @@ src/app/components/document-detail/document-detail.component.html - 97 + 103 src/app/guards/dirty-saved-view.guard.ts @@ -5701,7 +5761,7 @@ src/app/components/document-detail/document-detail.component.html - 352,353 + 358,359 @@ -5812,7 +5872,7 @@ src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.ts - 139 + 143 src/app/components/common/profile-edit-dialog/profile-edit-dialog.component.html @@ -5820,11 +5880,11 @@ src/app/components/document-detail/document-detail.component.html - 82,83 + 88,89 src/app/components/document-list/bulk-editor/bulk-editor.component.html - 136 + 141 @@ -6550,50 +6610,50 @@ Assignment src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.ts - 131 + 135 Removal src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.ts - 135 + 139 Webhook src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.ts - 143 + 147 Password removal src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.ts - 147 + 151 Move to trash src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.ts - 151 + 155 src/app/components/document-detail/document-detail.component.ts - 1485 + 1505 src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 892 + 957 Remote OCR src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.ts - 155 + 159 src/app/data/paperless-config.ts @@ -6604,18 +6664,18 @@ Apply AI suggestions src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.ts - 159 + 163 Title src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.ts - 166 + 170 src/app/components/document-detail/document-detail.component.html - 143 + 149 src/app/components/document-list/document-list.component.html @@ -6638,119 +6698,119 @@ Created date src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.ts - 186 + 190 Has any of these tags src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.ts - 255 + 259 Has all of these tags src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.ts - 262 + 266 Does not have these tags src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.ts - 269 + 273 Has any of these correspondents src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.ts - 276 + 280 Has correspondent src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.ts - 284 + 288 Does not have correspondents src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.ts - 292 + 296 Has document type src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.ts - 300 + 304 Has any of these document types src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.ts - 308 + 312 Does not have document types src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.ts - 316 + 320 Has storage path src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.ts - 324 + 328 Has any of these storage paths src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.ts - 332 + 336 Does not have storage paths src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.ts - 340 + 344 Matches custom field query src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.ts - 348 + 352 Some workflow options could not be loaded. src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.ts - 570 + 574 Create new workflow src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.ts - 592 + 596 Edit workflow src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.ts - 596 + 600 @@ -7903,7 +7963,7 @@ src/app/components/document-list/bulk-editor/bulk-editor.component.html - 124 + 129 @@ -8363,7 +8423,7 @@ src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 517 + 582 this string is used to separate processing, failed and added on the file upload widget @@ -8603,7 +8663,7 @@ src/app/components/document-detail/document-detail.component.html - 497 + 503 src/app/components/document-list/document-list.component.html @@ -8622,7 +8682,7 @@ src/app/components/document-detail/document-detail.component.html - 278,279 + 284,285 @@ -8644,7 +8704,7 @@ src/app/components/document-list/bulk-editor/bulk-editor.component.html - 154 + 159 @@ -8662,7 +8722,7 @@ src/app/components/document-list/bulk-editor/bulk-editor.component.html - 170,171 + 175,176 @@ -8676,18 +8736,37 @@ 90 + + Run workflow + + src/app/components/document-detail/document-detail.component.html + 54,55 + + + src/app/components/document-detail/document-detail.component.ts + 1586 + + + src/app/components/document-list/bulk-editor/bulk-editor.component.html + 103 + + + src/app/components/document-list/bulk-editor/bulk-editor.component.ts + 318 + + Print src/app/components/document-detail/document-detail.component.html - 53,54 + 59,60 More like this src/app/components/document-detail/document-detail.component.html - 57,58 + 63,64 src/app/components/document-list/document-card-large/document-card-large.component.html @@ -8698,21 +8777,21 @@ Remove Password src/app/components/document-detail/document-detail.component.html - 66 + 72 Previous src/app/components/document-detail/document-detail.component.html - 100 + 106 Next src/app/components/document-detail/document-detail.component.html - 103 + 109 src/main.ts @@ -8723,21 +8802,21 @@ Details src/app/components/document-detail/document-detail.component.html - 140,141 + 146,147 Date created src/app/components/document-detail/document-detail.component.html - 147 + 153 Default src/app/components/document-detail/document-detail.component.html - 159 + 165 src/app/components/manage/saved-views/saved-views.component.html @@ -8748,7 +8827,7 @@ Metadata src/app/components/document-detail/document-detail.component.html - 287,288 + 293,294 src/app/components/document-detail/metadata-collapse/metadata-collapse.component.ts @@ -8759,282 +8838,282 @@ Date modified src/app/components/document-detail/document-detail.component.html - 294,295 + 300,301 Date added src/app/components/document-detail/document-detail.component.html - 298,299 + 304,305 Media filename src/app/components/document-detail/document-detail.component.html - 302,303 + 308,309 Original filename src/app/components/document-detail/document-detail.component.html - 306,307 + 312,313 Original SHA256 checksum src/app/components/document-detail/document-detail.component.html - 310,311 + 316,317 Original file size src/app/components/document-detail/document-detail.component.html - 314,315 + 320,321 Original mime type src/app/components/document-detail/document-detail.component.html - 318,319 + 324,325 Archive SHA256 checksum src/app/components/document-detail/document-detail.component.html - 323,324 + 329,330 Archive file size src/app/components/document-detail/document-detail.component.html - 329,330 + 335,336 Barcodes src/app/components/document-detail/document-detail.component.html - 338,339 + 344,345 Original document metadata src/app/components/document-detail/document-detail.component.html - 342 + 348 Archived document metadata src/app/components/document-detail/document-detail.component.html - 345 + 351 Notes src/app/components/document-detail/document-detail.component.html - 364,367 + 370,373 History src/app/components/document-detail/document-detail.component.html - 375,376 + 381,382 Duplicates src/app/components/document-detail/document-detail.component.html - 398,401 + 404,407 Duplicate documents detected: src/app/components/document-detail/document-detail.component.html - 403,404 + 409,410 In trash src/app/components/document-detail/document-detail.component.html - 414,415 + 420,421 Save & next src/app/components/document-detail/document-detail.component.html - 446 + 452 src/app/components/document-detail/document-detail.component.html - 457 + 463 Save & close src/app/components/document-detail/document-detail.component.html - 448 + 454 src/app/components/document-detail/document-detail.component.html - 459 + 465 Discard src/app/components/document-detail/document-detail.component.html - 450 + 456 src/app/components/document-detail/document-detail.component.html - 451,452 + 457,458 More save options src/app/components/document-detail/document-detail.component.html - 454 + 460 Document loading... src/app/components/document-detail/document-detail.component.html - 469 + 475 of src/app/components/document-detail/document-detail.component.html - 498,499 + 504,505 Zoom out src/app/components/document-detail/document-detail.component.html - 502 + 508 Zoom src/app/components/document-detail/document-detail.component.html - 505 + 511 Zoom in src/app/components/document-detail/document-detail.component.html - 512 + 518 Enter Password src/app/components/document-detail/document-detail.component.html - 546 + 552 Error retrieving metadata src/app/components/document-detail/document-detail.component.ts - 465 + 471 An error occurred loading content: src/app/components/document-detail/document-detail.component.ts - 568,570 + 574,576 src/app/components/document-detail/document-detail.component.ts - 1049,1051 + 1069,1071 Document was updated src/app/components/document-detail/document-detail.component.ts - 710 + 716 Document was updated at . src/app/components/document-detail/document-detail.component.ts - 711 + 717 Reload to discard your local unsaved edits and load the latest remote version. src/app/components/document-detail/document-detail.component.ts - 712 + 718 Reload src/app/components/document-detail/document-detail.component.ts - 714 + 720 Document reloaded with latest changes. src/app/components/document-detail/document-detail.component.ts - 770 + 776 Document reloaded. src/app/components/document-detail/document-detail.component.ts - 781 + 787 Next document src/app/components/document-detail/document-detail.component.ts - 883 + 903 Previous document src/app/components/document-detail/document-detail.component.ts - 893 + 913 Close document src/app/components/document-detail/document-detail.component.ts - 901 + 921 src/app/services/open-documents.service.ts @@ -9045,28 +9124,28 @@ Save document src/app/components/document-detail/document-detail.component.ts - 908 + 928 Save and close / next src/app/components/document-detail/document-detail.component.ts - 917 + 937 Error retrieving version content src/app/components/document-detail/document-detail.component.ts - 1031 + 1051 Unsaved Changes src/app/components/document-detail/document-detail.component.ts - 1075 + 1095 src/app/guards/dirty-form.guard.ts @@ -9089,205 +9168,234 @@ You have unsaved changes to the content of this version. src/app/components/document-detail/document-detail.component.ts - 1076 + 1096 Switching versions will discard them. src/app/components/document-detail/document-detail.component.ts - 1077 + 1097 Discard and switch src/app/components/document-detail/document-detail.component.ts - 1079 + 1099 Save and switch src/app/components/document-detail/document-detail.component.ts - 1081 + 1101 Error retrieving suggestions. src/app/components/document-detail/document-detail.component.ts - 1124 + 1144 Document "" saved successfully. src/app/components/document-detail/document-detail.component.ts - 1355 + 1375 src/app/components/document-detail/document-detail.component.ts - 1383 + 1403 Error saving document "" src/app/components/document-detail/document-detail.component.ts - 1389 + 1409 Error saving document src/app/components/document-detail/document-detail.component.ts - 1444 + 1464 Do you really want to move the document "" to the trash? src/app/components/document-detail/document-detail.component.ts - 1482 + 1502 Documents can be restored prior to permanent deletion. src/app/components/document-detail/document-detail.component.ts - 1483 + 1503 src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 890 + 955 Moved "" to the trash src/app/components/document-detail/document-detail.component.ts - 1501 + 1521 Error deleting document src/app/components/document-detail/document-detail.component.ts - 1508 + 1528 Reprocess confirm src/app/components/document-detail/document-detail.component.ts - 1528 + 1548 src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 950 + 1015 This operation will permanently recreate the archive file for this document. src/app/components/document-detail/document-detail.component.ts - 1529 + 1549 The archive file will be re-generated with the current settings. src/app/components/document-detail/document-detail.component.ts - 1530 + 1550 Reprocess operation for "" will begin in the background. src/app/components/document-detail/document-detail.component.ts - 1543 + 1563 Error executing operation src/app/components/document-detail/document-detail.component.ts - 1554 + 1574 + + + src/app/components/document-detail/document-detail.component.ts + 1607 + + + + Run a workflow on "". + + src/app/components/document-detail/document-detail.component.ts + 1587 + + + + Run + + src/app/components/document-detail/document-detail.component.ts + 1588 + + + src/app/components/document-list/bulk-editor/bulk-editor.component.ts + 320 + + + + Workflow will run on "" in the background. + + src/app/components/document-detail/document-detail.component.ts + 1600 Error downloading document src/app/components/document-detail/document-detail.component.ts - 1618 + 1671 Page Fit src/app/components/document-detail/document-detail.component.ts - 1696 + 1749 PDF edit operation for "" will begin in the background. src/app/components/document-detail/document-detail.component.ts - 1939 + 1992 Error executing PDF edit operation src/app/components/document-detail/document-detail.component.ts - 1951 + 2004 Please enter the current password before attempting to remove it. src/app/components/document-detail/document-detail.component.ts - 1962 + 2015 Password removal operation for "" will begin in the background. src/app/components/document-detail/document-detail.component.ts - 1996 + 2049 Error executing password removal operation src/app/components/document-detail/document-detail.component.ts - 2010 + 2063 Print failed. src/app/components/document-detail/document-detail.component.ts - 2060 + 2113 Error loading document for printing. src/app/components/document-detail/document-detail.component.ts - 2069 + 2122 An error occurred loading tiff: src/app/components/document-detail/document-detail.component.ts - 2152 + 2205 src/app/components/document-detail/document-detail.component.ts - 2158 + 2211 @@ -9571,60 +9679,81 @@ src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 1050 + 1115 Create a share link bundle src/app/components/document-list/bulk-editor/bulk-editor.component.html - 119 + 124 Include: src/app/components/document-list/bulk-editor/bulk-editor.component.html - 157,158 + 162,163 Archived files src/app/components/document-list/bulk-editor/bulk-editor.component.html - 161,162 + 166,167 Original files src/app/components/document-list/bulk-editor/bulk-editor.component.html - 165,166 + 170,171 + + + + Run a workflow on selected document(s). + + src/app/components/document-list/bulk-editor/bulk-editor.component.ts + 319 + + + + Bulk operation queued. + + src/app/components/document-list/bulk-editor/bulk-editor.component.ts + 358 + + + + View task + + src/app/components/document-list/bulk-editor/bulk-editor.component.ts + 362 Error executing bulk operation src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 349 + 414 "" src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 509 + 574 src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 515 + 580 "" and "" src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 511 + 576 This is for messages like 'modify "tag1" and "tag2"' @@ -9632,7 +9761,7 @@ and "" src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 519,521 + 584,586 this is for messages like 'modify "tag1", "tag2" and "tag3"' @@ -9640,14 +9769,14 @@ Confirm tags assignment src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 536 + 601 This operation will add the tag "" to selected document(s). src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 542 + 607 @@ -9656,14 +9785,14 @@ )"/> to selected document(s). src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 547,549 + 612,614 This operation will remove the tag "" from selected document(s). src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 555 + 620 @@ -9672,7 +9801,7 @@ )"/> from selected document(s). src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 560,562 + 625,627 @@ -9683,84 +9812,84 @@ )"/> on selected document(s). src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 564,568 + 629,633 Confirm correspondent assignment src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 605 + 670 This operation will assign the correspondent "" to selected document(s). src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 607 + 672 This operation will remove the correspondent from selected document(s). src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 609 + 674 Confirm document type assignment src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 643 + 708 This operation will assign the document type "" to selected document(s). src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 645 + 710 This operation will remove the document type from selected document(s). src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 647 + 712 Confirm storage path assignment src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 681 + 746 This operation will assign the storage path "" to selected document(s). src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 683 + 748 This operation will remove the storage path from selected document(s). src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 685 + 750 Confirm custom field assignment src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 714 + 779 This operation will assign the custom field "" to selected document(s). src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 720 + 785 @@ -9769,14 +9898,14 @@ )"/> to selected document(s). src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 725,727 + 790,792 This operation will remove the custom field "" from selected document(s). src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 733 + 798 @@ -9785,7 +9914,7 @@ )"/> from selected document(s). src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 738,740 + 803,805 @@ -9796,112 +9925,105 @@ )"/> on selected document(s). src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 742,746 + 807,811 Move selected document(s) to the trash? src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 889 + 954 Moved document(s) to the trash src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 916 + 981 This operation will permanently recreate the archive files for selected document(s). src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 951 + 1016 The archive files will be re-generated with the current settings. src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 952 + 1017 Rotate confirm src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 990 + 1055 This operation will add rotated versions of the document(s). src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 991 + 1056 Merge confirm src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 1014 + 1079 This operation will merge selected documents into a new document. src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 1015 + 1080 Merged document will be queued for consumption. src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 1038 + 1103 The selected documents will become versions of the root document. src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 1051 + 1116 Documents merged as versions. src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 1066 - - - - Custom fields updated. - - src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 1092 + 1131 Error updating custom fields. src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 1101 + 1161 Share link bundle creation requested. src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 1149 + 1209 Share link bundle creation is not available yet. src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 1156 + 1216 @@ -13369,42 +13491,42 @@ Document already exists. src/app/services/websocket-status.service.ts - 27 + 29 Document already exists. Note: existing document is in the trash. src/app/services/websocket-status.service.ts - 28 + 30 Document with ASN already exists. src/app/services/websocket-status.service.ts - 29 + 31 Document with ASN already exists. Note: existing document is in the trash. src/app/services/websocket-status.service.ts - 30 + 32 File not found. src/app/services/websocket-status.service.ts - 31 + 33 Pre-consume script does not exist. src/app/services/websocket-status.service.ts - 32 + 34 Pre-Consume is a term that appears like that in the documentation as well and does not need a specific translation @@ -13412,7 +13534,7 @@ Error while executing pre-consume script. src/app/services/websocket-status.service.ts - 33 + 35 Pre-Consume is a term that appears like that in the documentation as well and does not need a specific translation @@ -13420,7 +13542,7 @@ Post-consume script does not exist. src/app/services/websocket-status.service.ts - 34 + 36 Post-Consume is a term that appears like that in the documentation as well and does not need a specific translation @@ -13428,7 +13550,7 @@ Error while executing post-consume script. src/app/services/websocket-status.service.ts - 35 + 37 Post-Consume is a term that appears like that in the documentation as well and does not need a specific translation @@ -13436,49 +13558,49 @@ Received new file. src/app/services/websocket-status.service.ts - 36 + 38 File type not supported. src/app/services/websocket-status.service.ts - 37 + 39 Processing document... src/app/services/websocket-status.service.ts - 38 + 40 Generating thumbnail... src/app/services/websocket-status.service.ts - 39 + 41 Retrieving date from document... src/app/services/websocket-status.service.ts - 40 + 42 Saving document... src/app/services/websocket-status.service.ts - 41 + 43 Finished. src/app/services/websocket-status.service.ts - 42 + 44 diff --git a/src-ui/src/app/components/admin/tasks/tasks.component.spec.ts b/src-ui/src/app/components/admin/tasks/tasks.component.spec.ts index 3b2c58f63e..887e690982 100644 --- a/src-ui/src/app/components/admin/tasks/tasks.component.spec.ts +++ b/src-ui/src/app/components/admin/tasks/tasks.component.spec.ts @@ -7,10 +7,15 @@ import { import { ComponentFixture, TestBed } from '@angular/core/testing' import { FormsModule } from '@angular/forms' import { By } from '@angular/platform-browser' -import { Router } from '@angular/router' +import { + ActivatedRoute, + convertToParamMap, + ParamMap, + Router, +} from '@angular/router' import { RouterTestingModule } from '@angular/router/testing' import { NgbModal, NgbModalRef, NgbModule } from '@ng-bootstrap/ng-bootstrap' -import { of, throwError } from 'rxjs' +import { BehaviorSubject, of, throwError } from 'rxjs' import { routes } from 'src/app/app-routing.module' import { PaperlessTask, @@ -159,6 +164,7 @@ const sectionCountResponse = { } describe('TasksComponent', () => { + let queryParams: BehaviorSubject let component: TasksComponent let fixture: ComponentFixture let tasksService: TasksService @@ -169,6 +175,7 @@ describe('TasksComponent', () => { let toastService: ToastService beforeEach(async () => { + queryParams = new BehaviorSubject(convertToParamMap({})) TestBed.configureTestingModule({ imports: [ NgbModule, @@ -181,6 +188,17 @@ describe('TasksComponent', () => { ConfirmDialogComponent, ], providers: [ + { + provide: ActivatedRoute, + useValue: { + queryParamMap: queryParams.asObservable(), + snapshot: { + get queryParamMap() { + return queryParams.value + }, + }, + }, + }, { provide: PermissionsService, useValue: { @@ -219,7 +237,11 @@ describe('TasksComponent', () => { }) // answers task list requests with the fixture tasks matching their status filter - function flushTaskLists(pageSize: number, count?: number) { + function flushTaskLists( + pageSize: number, + count?: number, + filteredTasks: PaperlessTask[] = tasks + ) { httpTestingController .match( (req) => @@ -228,7 +250,9 @@ describe('TasksComponent', () => { ) .forEach((req) => { const statuses = req.request.params.getAll('status') - const results = tasks.filter((task) => statuses.includes(task.status)) + const results = filteredTasks.filter((task) => + statuses.includes(task.status) + ) req.flush({ count: count ?? results.length, results }) }) } @@ -238,6 +262,71 @@ describe('TasksComponent', () => { flushTaskLists(25, count) } + it('consumes a task link on load into the normal resettable Task ID filter', () => { + jest + .spyOn(tasksService, 'list') + .mockReturnValue(of({ count: 0, results: [] })) + jest + .spyOn(tasksService, 'statusCounts') + .mockReturnValue(of(sectionCountResponse)) + jest.spyOn(router, 'navigate').mockResolvedValue(true) + queryParams.next(convertToParamMap({ task_id: 'linked-task' })) + fixture.destroy() + fixture = TestBed.createComponent(TasksComponent) + component = fixture.componentInstance + fixture.detectChanges() + expect(router.navigate).toHaveBeenCalledTimes(1) + expect(router.navigate).toHaveBeenCalledWith( + [], + expect.objectContaining({ + queryParams: { task_id: null }, + replaceUrl: true, + }) + ) + expect(component.filterTargetName).toBe('Task ID') + expect(component.filterText).toBe('linked-task') + expect(component.isFiltered).toBe(true) + component.setSection(TaskSection.InProgress) + expect(tasksService.list).toHaveBeenLastCalledWith(1, 25, { + task_id: 'linked-task', + status: [PaperlessTaskStatus.Pending, PaperlessTaskStatus.Started], + }) + component.resetFilters() + expect(component.filterText).toBe('') + expect(component.isFiltered).toBe(false) + expect(tasksService.list).toHaveBeenLastCalledWith(1, 25, { + acknowledged: false, + status: [PaperlessTaskStatus.Pending, PaperlessTaskStatus.Started], + }) + expect(router.navigate).toHaveBeenCalledTimes(1) + }) + + it('supports manually filtering by Task ID and clearing the text filter', () => { + jest + .spyOn(tasksService, 'list') + .mockReturnValue(of({ count: 0, results: [] })) + jest + .spyOn(tasksService, 'statusCounts') + .mockReturnValue(of(sectionCountResponse)) + component.setSection(TaskSection.InProgress) + component.setFilterTarget(TaskFilterTargetID.TaskId) + component.filterText = tasks[0].task_id + jest.advanceTimersByTime(150) + expect(tasksService.list).toHaveBeenLastCalledWith(1, 25, { + task_id: tasks[0].task_id, + status: [PaperlessTaskStatus.Pending, PaperlessTaskStatus.Started], + }) + component.pagedTasks.set(tasks) + expect(component.tasksForSection(TaskSection.NeedsAttention)).toEqual([ + tasks[0], + ]) + component.resetFilter() + expect(tasksService.list).toHaveBeenLastCalledWith(1, 25, { + acknowledged: false, + status: [PaperlessTaskStatus.Pending, PaperlessTaskStatus.Started], + }) + }) + it('should display task sections with counts', () => { expect(component.selectedSection).toBe(TaskSection.All) expect(component.selectedTaskType).toBeNull() @@ -771,6 +860,7 @@ describe('TasksComponent', () => { input.nativeElement.value = '191092' input.nativeElement.dispatchEvent(new Event('input')) jest.advanceTimersByTime(150) + flushTaskLists(10, undefined, [tasks[1]]) fixture.detectChanges() expect(component.filterText).toEqual('191092') expect(component.tasksForSection(TaskSection.NeedsAttention)).toHaveLength( @@ -782,6 +872,7 @@ describe('TasksComponent', () => { component.setSection(TaskSection.InProgress) component.filterText = 'system' jest.advanceTimersByTime(150) + flushTaskLists(25, undefined, [tasks[6]]) expect(component.tasksForSection(TaskSection.InProgress)).toHaveLength(1) expect(component.tasksForSection(TaskSection.InProgress)[0].task_type).toBe( @@ -815,6 +906,7 @@ describe('TasksComponent', () => { input.nativeElement.value = 'duplicate' input.nativeElement.dispatchEvent(new Event('input')) jest.advanceTimersByTime(150) + flushTaskLists(25, undefined, [tasks[0], tasks[1]]) fixture.detectChanges() expect(component.filterText).toEqual('duplicate') expect(component.tasksForSection(TaskSection.NeedsAttention)).toHaveLength( @@ -822,6 +914,53 @@ describe('TasksComponent', () => { ) }) + it('should show server-matched names when the displayed source is translated', () => { + component.setSection(TaskSection.InProgress) + flushTaskLists(25) + component.filterText = 'email' + jest.advanceTimersByTime(150) + + const request = httpTestingController.expectOne( + (req) => + req.url === `${environment.apiBaseUrl}tasks/` && + req.params.get('name') === 'email' && + req.params.get('page_size') === '25' + ) + const translatedTask = { + ...tasks[5], + trigger_source_display: 'E-Mail', + } + request.flush({ count: 1, results: [translatedTask] }) + fixture.detectChanges() + + expect(component.totalTasks()).toBe(1) + expect(component.visibleTasks).toEqual([translatedTask]) + }) + + it('should show server-matched duplicates when the displayed result is translated', () => { + component.setSection(TaskSection.NeedsAttention) + flushTaskLists(25) + jest + .spyOn(component, 'taskResultMessage') + .mockReturnValue('Duplikat von Document #311') + component.setFilterTarget(TaskFilterTargetID.Result) + component.filterText = 'duplicate' + jest.advanceTimersByTime(150) + + const request = httpTestingController.expectOne( + (req) => + req.url === `${environment.apiBaseUrl}tasks/` && + req.params.get('result') === 'duplicate' && + req.params.get('page_size') === '25' + ) + request.flush({ count: 1, results: [tasks[1]] }) + fixture.detectChanges() + + expect(component.totalTasks()).toBe(1) + expect(component.visibleTasks).toEqual([tasks[1]]) + expect(fixture.nativeElement.textContent).toContain('191092.pdf') + }) + it('should prefer explicit reason in the result message', () => { expect( component.taskResultMessage({ diff --git a/src-ui/src/app/components/admin/tasks/tasks.component.ts b/src-ui/src/app/components/admin/tasks/tasks.component.ts index 20f3107ca4..ad8793ef85 100644 --- a/src-ui/src/app/components/admin/tasks/tasks.component.ts +++ b/src-ui/src/app/components/admin/tasks/tasks.component.ts @@ -1,7 +1,7 @@ import { JsonPipe, NgTemplateOutlet } from '@angular/common' import { Component, inject, OnDestroy, OnInit, signal } from '@angular/core' import { FormsModule, ReactiveFormsModule } from '@angular/forms' -import { Router, RouterLink } from '@angular/router' +import { ActivatedRoute, Router, RouterLink } from '@angular/router' import { NgbCollapseModule, NgbDropdownModule, @@ -47,11 +47,13 @@ export enum TaskSection { export enum TaskFilterTargetID { Name, Result, + TaskId, } const FILTER_TARGETS = [ { id: TaskFilterTargetID.Name, name: $localize`Name` }, { id: TaskFilterTargetID.Result, name: $localize`Result` }, + { id: TaskFilterTargetID.TaskId, name: $localize`Task ID` }, ] const SECTION_LABELS = { @@ -161,6 +163,7 @@ export class TasksComponent tasksService = inject(TasksService) private modalService = inject(NgbModal) private readonly router = inject(Router) + private readonly route = inject(ActivatedRoute) private readonly toastService = inject(ToastService) readonly TaskSection = TaskSection @@ -275,6 +278,17 @@ export class TasksComponent } ngOnInit() { + const taskId = this.route.snapshot.queryParamMap.get('task_id') + if (taskId) { + this.filterTargetID = TaskFilterTargetID.TaskId + this._filterText = taskId + this.router.navigate([], { + relativeTo: this.route, + queryParams: { task_id: null }, + queryParamsHandling: 'merge', + replaceUrl: true, + }) + } this.tasksService.reload() this.reloadPage() timer(5000, 5000) @@ -636,17 +650,12 @@ export class TasksComponent const query = this._filterText.toLowerCase() - if (this.filterTargetID == TaskFilterTargetID.Name) { - return [ - this.taskDisplayName(task), - task.task_type_display, - task.trigger_source_display, - ] - .filter(Boolean) - .some((value) => value.toLowerCase().includes(query)) + if (this.filterTargetID === TaskFilterTargetID.TaskId) { + return task.task_id.toLowerCase() === query } - return this.taskResultMessage(task)?.toLowerCase().includes(query) ?? false + // Text filtering now handled API-side + return true } private tasksForOptionCounts({ @@ -706,9 +715,15 @@ export class TasksComponent } if (this._filterText.length) { - params[ - this.filterTargetID === TaskFilterTargetID.Name ? 'name' : 'result' - ] = this._filterText + const parameter = { + [TaskFilterTargetID.Name]: 'name', + [TaskFilterTargetID.Result]: 'result', + [TaskFilterTargetID.TaskId]: 'task_id', + }[this.filterTargetID] + params[parameter] = this._filterText + if (this.filterTargetID === TaskFilterTargetID.TaskId) { + delete params.acknowledged + } } return params diff --git a/src-ui/src/app/components/app-frame/app-frame.component.spec.ts b/src-ui/src/app/components/app-frame/app-frame.component.spec.ts index 9898e7c26e..85b16547c7 100644 --- a/src-ui/src/app/components/app-frame/app-frame.component.spec.ts +++ b/src-ui/src/app/components/app-frame/app-frame.component.spec.ts @@ -11,8 +11,10 @@ import { ActivatedRoute, Router } from '@angular/router' import { RouterTestingModule } from '@angular/router/testing' import { NgbModal, NgbModalModule, NgbModule } from '@ng-bootstrap/ng-bootstrap' import { provideUiTour } from 'ngx-ui-tour-ng-bootstrap' -import { of, throwError } from 'rxjs' +import { of, Subject, throwError } from 'rxjs' import { routes } from 'src/app/app-routing.module' +import { BulkOperationStatus } from 'src/app/data/bulk-operation' +import { PaperlessTaskStatus } from 'src/app/data/paperless-task' import { SavedView } from 'src/app/data/saved-view' import { HideableSidebarItemID, SETTINGS_KEYS } from 'src/app/data/ui-settings' import { IfPermissionsDirective } from 'src/app/directives/if-permissions.directive' @@ -21,10 +23,11 @@ import { DjangoMessageLevel, DjangoMessagesService, } from 'src/app/services/django-messages.service' +import { DocumentListViewService } from 'src/app/services/document-list-view.service' import { OpenDocumentsService } from 'src/app/services/open-documents.service' import { - PermissionType, PermissionsService, + PermissionType, } from 'src/app/services/permissions.service' import { RemoteVersionService } from 'src/app/services/rest/remote-version.service' import { SavedViewService } from 'src/app/services/rest/saved-view.service' @@ -95,6 +98,7 @@ describe('AppFrameComponent', () => { let savedViewSpy let modalService: NgbModal let maybeRefreshSpy + let bulkEvents: Subject let tasksService: TasksService beforeEach(async () => { @@ -182,6 +186,10 @@ describe('AppFrameComponent', () => { savedViewSpy = jest.spyOn(savedViewService, 'reload') maybeRefreshSpy = jest.spyOn(savedViewService, 'maybeRefreshDocumentCounts') + bulkEvents = new Subject() + jest + .spyOn(TestBed.inject(WebsocketStatusService), 'onBulkOperationStatus') + .mockReturnValue(bulkEvents.asObservable()) fixture = TestBed.createComponent(AppFrameComponent) component = fixture.componentInstance @@ -190,6 +198,78 @@ describe('AppFrameComponent', () => { fixture.detectChanges() }) + it('refreshes and notifies on completion without client-side task tracking', () => { + const list = TestBed.inject(DocumentListViewService) + const reload = jest.spyOn(list, 'reload').mockImplementation(() => {}) + jest.spyOn(list, 'reduceSelectionToFilter').mockImplementation(() => {}) + const tasksReload = jest + .spyOn(tasksService, 'reload') + .mockImplementation(() => {}) + const success = jest.spyOn(toastService, 'showSuccess') + const refresh = jest + .spyOn(openDocumentsService, 'refreshDocument') + .mockImplementation(() => {}) + jest + .spyOn(openDocumentsService, 'getOpenDocuments') + .mockReturnValue([document]) + tasksReload.mockClear() + maybeRefreshSpy.mockClear() + bulkEvents.next({ + task_id: 'bulk-task', + operation: 'set_permissions', + status: PaperlessTaskStatus.Started, + }) + expect(reload).not.toHaveBeenCalled() + bulkEvents.next({ + task_id: 'bulk-task', + operation: 'set_permissions', + status: PaperlessTaskStatus.Success, + }) + expect(reload).toHaveBeenCalledTimes(1) + expect(reload).toHaveBeenCalledWith(null, false) + expect(refresh).toHaveBeenCalledWith(document.id) + expect(maybeRefreshSpy).toHaveBeenCalledTimes(1) + expect(tasksReload).toHaveBeenCalledTimes(1) + expect(success).toHaveBeenCalledWith('Bulk operation completed.') + fixture.destroy() + bulkEvents.next({ + task_id: 'bulk-task', + operation: 'set_permissions', + status: PaperlessTaskStatus.Success, + }) + expect(reload).toHaveBeenCalledTimes(1) + }) + + it('refreshes and reports failed or revoked bulk operations', () => { + const list = TestBed.inject(DocumentListViewService) + const reload = jest.spyOn(list, 'reload').mockImplementation(() => {}) + jest.spyOn(list, 'reduceSelectionToFilter').mockImplementation(() => {}) + jest.spyOn(tasksService, 'reload').mockImplementation(() => {}) + const error = jest.spyOn(toastService, 'showError') + const success = jest.spyOn(toastService, 'showSuccess') + for (const status of [ + PaperlessTaskStatus.Failure, + PaperlessTaskStatus.Revoked, + ]) { + bulkEvents.next({ + task_id: 'bulk-task', + operation: 'set_permissions', + status, + error: + status === PaperlessTaskStatus.Revoked + ? 'Task expired before execution.' + : 'Could not update', + }) + } + expect(reload).toHaveBeenCalledTimes(2) + expect(error).toHaveBeenCalledWith(expect.any(String), 'Could not update') + expect(error).toHaveBeenCalledWith( + 'Bulk operation revoked.', + 'Task expired before execution.' + ) + expect(success).not.toHaveBeenCalled() + }) + it('should initialize the saved view service', () => { expect(savedViewSpy).toHaveBeenCalled() }) diff --git a/src-ui/src/app/components/app-frame/app-frame.component.ts b/src-ui/src/app/components/app-frame/app-frame.component.ts index 54caff0582..beae9bb4f6 100644 --- a/src-ui/src/app/components/app-frame/app-frame.component.ts +++ b/src-ui/src/app/components/app-frame/app-frame.component.ts @@ -8,12 +8,14 @@ import { import { NgClass } from '@angular/common' import { Component, + DestroyRef, HostListener, inject, OnInit, signal, viewChild, } from '@angular/core' +import { takeUntilDestroyed } from '@angular/core/rxjs-interop' import { FormsModule } from '@angular/forms' import { ActivatedRoute, Router, RouterModule } from '@angular/router' import { @@ -24,10 +26,11 @@ import { NgbPopoverModule, } from '@ng-bootstrap/ng-bootstrap' import { TourNgBootstrap } from 'ngx-ui-tour-ng-bootstrap' -import { Observable } from 'rxjs' +import { filter, Observable } from 'rxjs' import { first } from 'rxjs/operators' import { BootstrapIconComponent } from 'src/app/components/common/bootstrap-icon/bootstrap-icon.component' import { Document } from 'src/app/data/document' +import { PaperlessTaskStatus } from 'src/app/data/paperless-task' import { SavedView } from 'src/app/data/saved-view' import { CollapsibleSection, @@ -41,6 +44,7 @@ import { DjangoMessageLevel, DjangoMessagesService, } from 'src/app/services/django-messages.service' +import { DocumentListViewService } from 'src/app/services/document-list-view.service' import { OpenDocumentsService } from 'src/app/services/open-documents.service' import { PermissionAction, @@ -101,6 +105,8 @@ export class AppFrameComponent extends ComponentWithPermissions implements OnInit, ComponentCanDeactivate { + private destroyRef = inject(DestroyRef) + private documentList = inject(DocumentListViewService) router = inject(Router) private activatedRoute = inject(ActivatedRoute) private openDocumentsService = inject(OpenDocumentsService) @@ -164,6 +170,46 @@ export class AppFrameComponent } ngOnInit(): void { + this.websocketStatusService + .onBulkOperationStatus() + .pipe( + filter(({ status }) => + [ + PaperlessTaskStatus.Success, + PaperlessTaskStatus.Failure, + PaperlessTaskStatus.Revoked, + ].includes(status) + ), + takeUntilDestroyed(this.destroyRef) + ) + .subscribe(({ status, error }) => { + this.documentList.reload(null, false) + this.documentList.reduceSelectionToFilter() + // maybe someday we can optimize to only refresh affected documents + this.openDocumentsService.getOpenDocuments().forEach((doc) => { + this.openDocumentsService.refreshDocument(doc.id) + }) + this.savedViewService.maybeRefreshDocumentCounts() + if ( + this.permissionsService.currentUserCan( + PermissionAction.View, + PermissionType.PaperlessTask + ) + ) { + this.tasksService.reload() + } + if (status === PaperlessTaskStatus.Success) { + this.toastService.showSuccess($localize`Bulk operation completed.`) + } else if (status === PaperlessTaskStatus.Revoked) { + this.toastService.showError($localize`Bulk operation revoked.`, error) + } else { + this.toastService.showError( + $localize`Bulk operation failed. Some changes may already have been applied.`, + error + ) + } + }) + this.lastScrollY = window.scrollY this.detectClassicScrollbars() 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 d9a528dcca..f2de84ee19 100644 --- a/src-ui/src/app/components/common/bootstrap-icon/icons.ts +++ b/src-ui/src/app/components/common/bootstrap-icon/icons.ts @@ -120,6 +120,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' @@ -284,6 +285,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.spec.ts b/src-ui/src/app/components/common/confirm-dialog/run-workflow-confirm-dialog/run-workflow-confirm-dialog.component.spec.ts new file mode 100644 index 0000000000..0468cf64b3 --- /dev/null +++ b/src-ui/src/app/components/common/confirm-dialog/run-workflow-confirm-dialog/run-workflow-confirm-dialog.component.spec.ts @@ -0,0 +1,42 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing' +import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap' +import { RunWorkflowConfirmDialogComponent } from './run-workflow-confirm-dialog.component' + +describe('RunWorkflowConfirmDialogComponent', () => { + let component: RunWorkflowConfirmDialogComponent + let fixture: ComponentFixture + + beforeEach(async () => { + TestBed.configureTestingModule({ + providers: [NgbActiveModal], + imports: [RunWorkflowConfirmDialogComponent], + }).compileComponents() + + fixture = TestBed.createComponent(RunWorkflowConfirmDialogComponent) + component = fixture.componentInstance + component.workflows = [{ id: 5, name: 'Manual workflow' } as any] + fixture.detectChanges() + }) + + it('should disable confirm until a workflow is selected and not force by default', () => { + expect(component.confirmButtonEnabled).toBeFalsy() + expect(component.force).toBeFalsy() + + component.workflowId = 5 + component.workflowSelected() + expect(component.confirmButtonEnabled).toBeTruthy() + + component.workflowId = null + component.workflowSelected() + expect(component.confirmButtonEnabled).toBeFalsy() + }) + + it('should render an option per workflow', () => { + const options = fixture.nativeElement.querySelectorAll( + '#runWorkflowSelect option' + ) + // placeholder option + one per workflow + expect(options).toHaveLength(2) + expect(options[1].textContent).toContain('Manual workflow') + }) +}) 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/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.html b/src-ui/src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.html index f515754702..538aa1a76a 100644 --- a/src-ui/src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.html +++ b/src-ui/src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.html @@ -164,7 +164,7 @@ } - @if (formGroup.get('type').value === WorkflowTriggerType.DocumentAdded || formGroup.get('type').value === WorkflowTriggerType.DocumentUpdated || formGroup.get('type').value === WorkflowTriggerType.Scheduled) { + @if (formGroup.get('type').value === WorkflowTriggerType.DocumentAdded || formGroup.get('type').value === WorkflowTriggerType.DocumentUpdated || formGroup.get('type').value === WorkflowTriggerType.Scheduled || formGroup.get('type').value === WorkflowTriggerType.Manual) { @if (matchingPatternRequired(formGroup)) { @@ -175,7 +175,7 @@ } - @if (formGroup.get('type').value === WorkflowTriggerType.DocumentAdded || formGroup.get('type').value === WorkflowTriggerType.DocumentUpdated || formGroup.get('type').value === WorkflowTriggerType.Scheduled) { + @if (formGroup.get('type').value === WorkflowTriggerType.DocumentAdded || formGroup.get('type').value === WorkflowTriggerType.DocumentUpdated || formGroup.get('type').value === WorkflowTriggerType.Scheduled || formGroup.get('type').value === WorkflowTriggerType.Manual) {
diff --git a/src-ui/src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.ts b/src-ui/src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.ts index 4a89b22778..6b1b80bd03 100644 --- a/src-ui/src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.ts +++ b/src-ui/src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.ts @@ -123,6 +123,10 @@ export const WORKFLOW_TYPE_OPTIONS = [ id: WorkflowTriggerType.Scheduled, name: $localize`Scheduled`, }, + { + id: WorkflowTriggerType.Manual, + name: $localize`Manual`, + }, ] export const WORKFLOW_ACTION_OPTIONS = [ diff --git a/src-ui/src/app/components/document-detail/document-detail.component.html b/src-ui/src/app/components/document-detail/document-detail.component.html index 9dcd7ddd60..109947f570 100644 --- a/src-ui/src/app/components/document-detail/document-detail.component.html +++ b/src-ui/src/app/components/document-detail/document-detail.component.html @@ -49,6 +49,12 @@ Reprocess + @if (manualWorkflows().length > 0) { + + } + diff --git a/src-ui/src/app/components/document-detail/document-detail.component.spec.ts b/src-ui/src/app/components/document-detail/document-detail.component.spec.ts index 69a6e24fef..a3c59f60a3 100644 --- a/src-ui/src/app/components/document-detail/document-detail.component.spec.ts +++ b/src-ui/src/app/components/document-detail/document-detail.component.spec.ts @@ -1030,6 +1030,27 @@ describe('DocumentDetailComponent', () => { expect(modalCloseSpy).toHaveBeenCalled() }) + it('should run a workflow on the document, confirm and close modal', () => { + initNormally() + const bulkEditSpy = jest.spyOn(documentService, 'bulkEdit') + bulkEditSpy.mockReturnValue(of(true)) + let openModal: NgbModalRef + modalService.activeInstances.subscribe((modal) => (openModal = modal[0])) + const toastSpy = jest.spyOn(toastService, 'showInfo') + component.runWorkflow() + const modalCloseSpy = jest.spyOn(openModal, 'close') + openModal.componentInstance.workflowId = 5 + openModal.componentInstance.force = true + openModal.componentInstance.confirmClicked.next() + expect(bulkEditSpy).toHaveBeenCalledWith( + { documents: [doc.id] }, + 'run_workflow', + { workflow: 5, filter_documents: false } + ) + expect(toastSpy).toHaveBeenCalled() + expect(modalCloseSpy).toHaveBeenCalled() + }) + it('should pass remote OCR choice when reprocessing', () => { initNormally() const reprocessSpy = jest.spyOn(documentService, 'reprocessDocuments') diff --git a/src-ui/src/app/components/document-detail/document-detail.component.ts b/src-ui/src/app/components/document-detail/document-detail.component.ts index 698ddf2ee3..505a753cb9 100644 --- a/src-ui/src/app/components/document-detail/document-detail.component.ts +++ b/src-ui/src/app/components/document-detail/document-detail.component.ts @@ -69,6 +69,8 @@ import { StoragePath } from 'src/app/data/storage-path' import { Tag } from 'src/app/data/tag' import { SETTINGS_KEYS, SuggestionSource } from 'src/app/data/ui-settings' import { User } from 'src/app/data/user' +import { Workflow } from 'src/app/data/workflow' +import { WorkflowTriggerType } from 'src/app/data/workflow-trigger' import { IfPermissionsDirective } from 'src/app/directives/if-permissions.directive' import { CustomDatePipe } from 'src/app/pipes/custom-date.pipe' import { DocumentTitlePipe } from 'src/app/pipes/document-title.pipe' @@ -94,6 +96,7 @@ import { SavedViewService } from 'src/app/services/rest/saved-view.service' import { StoragePathService } from 'src/app/services/rest/storage-path.service' import { TagService } from 'src/app/services/rest/tag.service' import { UserService } from 'src/app/services/rest/user.service' +import { WorkflowService } from 'src/app/services/rest/workflow.service' import { SettingsService } from 'src/app/services/settings.service' import { ToastService } from 'src/app/services/toast.service' import { TrashService } from 'src/app/services/trash.service' @@ -105,6 +108,7 @@ import { DocumentDetailFieldID } from '../admin/settings/settings.component' import { ConfirmDialogComponent } from '../common/confirm-dialog/confirm-dialog.component' import { PasswordRemovalConfirmDialogComponent } from '../common/confirm-dialog/password-removal-confirm-dialog/password-removal-confirm-dialog.component' import { ReprocessConfirmDialogComponent } from '../common/confirm-dialog/reprocess-confirm-dialog/reprocess-confirm-dialog.component' +import { RunWorkflowConfirmDialogComponent } from '../common/confirm-dialog/run-workflow-confirm-dialog/run-workflow-confirm-dialog.component' import { ZoneOcrConfirmDialogComponent } from '../common/confirm-dialog/zone-ocr-confirm-dialog/zone-ocr-confirm-dialog.component' import { CustomFieldsDropdownComponent } from '../common/custom-fields-dropdown/custom-fields-dropdown.component' import { CorrespondentEditDialogComponent } from '../common/edit-dialog/correspondent-edit-dialog/correspondent-edit-dialog.component' @@ -235,6 +239,7 @@ export class DocumentDetailComponent private componentRouterService = inject(ComponentRouterService) private deviceDetectorService = inject(DeviceDetectorService) private savedViewService = inject(SavedViewService) + private readonly workflowService = inject(WorkflowService) private readonly websocketStatusService = inject(WebsocketStatusService) private readonly useNativePdfViewerSetting = this.settings.getSignal( SETTINGS_KEYS.USE_NATIVE_PDF_VIEWER @@ -298,6 +303,7 @@ export class DocumentDetailComponent readonly correspondents = signal(undefined) readonly documentTypes = signal(undefined) readonly storagePaths = signal(undefined) + readonly manualWorkflows = signal([]) documentForm: FormGroup = new FormGroup({ title: new FormControl(''), @@ -844,6 +850,20 @@ export class DocumentDetailComponent .pipe(first(), takeUntil(this.unsubscribeNotifier)) .subscribe((result) => this.users.set(result.results)) } + if ( + this.permissionsService.currentUserCan( + PermissionAction.View, + PermissionType.Workflow + ) + ) { + this.workflowService + .list(1, 100000, null, null, { + trigger_type: WorkflowTriggerType.Manual, + enabled: true, + }) + .pipe(first(), takeUntil(this.unsubscribeNotifier)) + .subscribe((result) => this.manualWorkflows.set(result.results)) + } this.getCustomFields() @@ -1568,6 +1588,39 @@ export class DocumentDetailComponent }) } + runWorkflow() { + const modal = this.modalService.open(RunWorkflowConfirmDialogComponent, { + backdrop: 'static', + }) + modal.componentInstance.title = $localize`Run workflow` + modal.componentInstance.message = $localize`Run a workflow on "${this.document().title}".` + modal.componentInstance.btnCaption = $localize`Run` + modal.componentInstance.workflows = this.manualWorkflows() + modal.componentInstance.confirmClicked.subscribe(() => { + modal.componentInstance.buttonsEnabled.set(false) + this.documentsService + .bulkEdit({ documents: [this.document().id] }, 'run_workflow', { + workflow: modal.componentInstance.workflowId, + filter_documents: !modal.componentInstance.force, + }) + .subscribe({ + next: () => { + this.toastService.showInfo( + $localize`Workflow will run on "${this.document().title}" in the background.` + ) + modal.close() + }, + error: (error) => { + modal.componentInstance.buttonsEnabled.set(true) + this.toastService.showError( + $localize`Error executing operation`, + error + ) + }, + }) + }) + } + /** Runs every template that matches, confirming only over unsaved changes. */ runZoneOcr() { if (this.networkActive()) return 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 680b64774c..8886790f82 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) { + + } @if (permissionService.currentUserCan(PermissionAction.View, PermissionType.OcrTemplate)) {

- @for (note of notes(); track note) { + @for (note of notes(); track note.id) {
-

{{note.note}}

+ @if (note.format === NoteFormat.Markdown) { +
+ } @else { +

{{note.note}}

+ }