Compare commits

...

12 Commits

Author SHA1 Message Date
shamoon
f20b224ef5 Basic show processing status in UI
[ci skip]
2025-08-26 01:44:58 -07:00
shamoon
8344a6e0e3 Set in_process during bulk operations
[ci skip]
2025-08-26 01:07:15 -07:00
shamoon
10a8a5da19 Add in_process field to DocumentSerializer
[ci skip]
2025-08-26 01:01:17 -07:00
shamoon
d190b50032 Set in_process flag during update_document_content_maybe_archive_file 2025-08-26 00:59:56 -07:00
shamoon
fda29f51c3 Add in_process field to Document model 2025-08-26 00:55:23 -07:00
shamoon
f2fabc81d4 Fix: include array items for pagination openapi schema (#10682) 2025-08-25 13:25:54 -07:00
shamoon
f94c3eeea8 Fix: prevent scroll for view name in sidebar (#10676) 2025-08-24 05:13:09 -07:00
shamoon
22064ed004 Chore: add test for navigation on document load error 2025-08-22 20:03:06 -07:00
shamoon
23daa0b974 Chore: add tests for previewText handling in DocumentDetail 2025-08-22 19:31:41 -07:00
shamoon
7b63f5a98c Merge branch 'main' into dev 2025-08-22 18:59:33 -07:00
shamoon
7c76377477 Fix: center document close button in app frame (#10661) 2025-08-22 18:58:09 -07:00
github-actions[bot]
56c70bf177 Documentation: Add v2.18.2 changelog (#10660)
* Changelog v2.18.2 - GHA

* Update changelog.md

---------

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: shamoon <4887959+shamoon@users.noreply.github.com>
2025-08-23 00:08:57 +00:00
15 changed files with 125 additions and 7 deletions

View File

@@ -1,5 +1,32 @@
# Changelog
## paperless-ngx 2.18.2
### Bug Fixes
- Fix: prevent loss of changes when switching between open docs [@shamoon](https://github.com/shamoon) ([#10659](https://github.com/paperless-ngx/paperless-ngx/pull/10659))
- Fix: ignore incomplete tasks for system status 'last run' [@shamoon](https://github.com/shamoon) ([#10641](https://github.com/paperless-ngx/paperless-ngx/pull/10641))
- Fix: increase legibility of date filter clear button in light mode [@shamoon](https://github.com/shamoon) ([#10649](https://github.com/paperless-ngx/paperless-ngx/pull/10649))
- Fix: ensure saved view count is visible with long names [@shamoon](https://github.com/shamoon) ([#10616](https://github.com/paperless-ngx/paperless-ngx/pull/10616))
- Tweak: improve dateparser auto-detection messages [@shamoon](https://github.com/shamoon) ([#10640](https://github.com/paperless-ngx/paperless-ngx/pull/10640))
### Dependencies
- Chore(deps): Bump the development group across 1 directory with 3 updates @[dependabot[bot]](https://github.com/apps/dependabot) ([#10578](https://github.com/paperless-ngx/paperless-ngx/pull/10578))
### All App Changes
<details>
<summary>6 changes</summary>
- Fix: prevent loss of changes when switching between open docs [@shamoon](https://github.com/shamoon) ([#10659](https://github.com/paperless-ngx/paperless-ngx/pull/10659))
- Fix: ignore incomplete tasks for system status 'last run' [@shamoon](https://github.com/shamoon) ([#10641](https://github.com/paperless-ngx/paperless-ngx/pull/10641))
- Tweak: improve dateparser auto-detection messages [@shamoon](https://github.com/shamoon) ([#10640](https://github.com/paperless-ngx/paperless-ngx/pull/10640))
- Fix: increase legibility of date filter clear button in light mode [@shamoon](https://github.com/shamoon) ([#10649](https://github.com/paperless-ngx/paperless-ngx/pull/10649))
- Fix: ensure saved view count is visible with long names [@shamoon](https://github.com/shamoon) ([#10616](https://github.com/paperless-ngx/paperless-ngx/pull/10616))
- Chore(deps): Bump the development group across 1 directory with 3 updates @[dependabot[bot]](https://github.com/apps/dependabot) ([#10578](https://github.com/paperless-ngx/paperless-ngx/pull/10578))
</details>
## paperless-ngx 2.18.1
### Features / Enhancements

View File

@@ -113,7 +113,7 @@
[disablePopover]="!slimSidebarEnabled" placement="end" container="body" triggers="mouseenter:mouseleave"
popoverClass="popover-slim">
<i-bs class="me-1" name="funnel"></i-bs>
<span>&nbsp;<div class="d-inline-flex view-name"><span [class.text-truncate]="!slimSidebarEnabled">{{view.name}}</span></div>
<span>&nbsp;<div class="d-inline-flex view-name"><span class="overflow-hidden" [class.text-truncate]="!slimSidebarEnabled">{{view.name}}</span></div>
@if (showSidebarCounts && !slimSidebarEnabled) {
<span class="badge bg-info text-dark ms-2 d-inline">{{ savedViewService.getDocumentCount(view) }}</span>
}
@@ -147,7 +147,7 @@
[disablePopover]="!slimSidebarEnabled" placement="end" container="body" triggers="mouseenter:mouseleave"
popoverClass="popover-slim">
<i-bs class="me-1" name="file-text"></i-bs><span>&nbsp;{{d.title | documentTitle}}</span>
<span class="close" (click)="closeDocument(d); $event.preventDefault()">
<span class="close flex-column justify-content-center" (click)="closeDocument(d); $event.preventDefault()">
<i-bs name="x"></i-bs>
</span>
</a>

View File

@@ -191,7 +191,7 @@ main {
list-style-type: none;
&:hover .close {
display: block;
display: flex;
}
.close {

View File

@@ -1,4 +1,9 @@
<pngx-page-header [(title)]="title">
@if (document?.in_process) {
<span class="badge bg-danger text-dark ms-2 d-flex align-items-center">
<div class="spinner-border spinner-border-sm me-1" role="status"></div><span i18n>Processing...</span>
</span>
}
@if (archiveContentRenderType === ContentRenderType.PDF && !useNativePdfViewer) {
@if (previewNumPages) {
<div class="input-group input-group-sm d-none d-md-flex">
@@ -50,7 +55,7 @@
<div class="d-none d-sm-inline">&nbsp;<ng-container i18n>Actions</ng-container></div>
</button>
<div ngbDropdownMenu aria-labelledby="actionsDropdown" class="shadow">
<button ngbDropdownItem (click)="reprocess()" [disabled]="!userCanEdit || !userIsOwner">
<button ngbDropdownItem (click)="reprocess()" [disabled]="!userCanEdit || !userIsOwner || document?.in_process">
<i-bs width="1em" height="1em" name="arrow-counterclockwise"></i-bs>&nbsp;<span i18n>Reprocess</span>
</button>
@@ -58,7 +63,7 @@
<i-bs width="1em" height="1em" name="diagram-3"></i-bs>&nbsp;<span i18n>More like this</span>
</button>
<button ngbDropdownItem (click)="editPdf()" [disabled]="!userIsOwner || !userCanEdit || originalContentRenderType !== ContentRenderType.PDF">
<button ngbDropdownItem (click)="editPdf()" [disabled]="!userIsOwner || !userCanEdit || originalContentRenderType !== ContentRenderType.PDF || document?.in_process">
<i-bs name="pencil"></i-bs>&nbsp;<ng-container i18n>PDF Editor</ng-container>
</button>
</div>
@@ -90,7 +95,6 @@
}
</div>
</div>
</pngx-page-header>
<div class="row">

View File

@@ -452,6 +452,18 @@ describe('DocumentDetailComponent', () => {
expect(navigateSpy).toHaveBeenCalledWith(['404'], { replaceUrl: true })
})
it('should navigate to 404 if error on load', () => {
jest
.spyOn(activatedRoute, 'paramMap', 'get')
.mockReturnValue(of(convertToParamMap({ id: 3, section: 'details' })))
const navigateSpy = jest.spyOn(router, 'navigate')
jest
.spyOn(documentService, 'get')
.mockReturnValue(throwError(() => new Error('not found')))
fixture.detectChanges()
expect(navigateSpy).toHaveBeenCalledWith(['404'], { replaceUrl: true })
})
it('should support save, close and show success toast', () => {
initNormally()
component.title = 'Foo Bar'
@@ -1388,4 +1400,19 @@ describe('DocumentDetailComponent', () => {
component.openEmailDocument()
expect(modalSpy).toHaveBeenCalled()
})
it('should set previewText', () => {
initNormally()
const previewText = 'Hello world, this is a test'
httpTestingController.expectOne(component.previewUrl).flush(previewText)
expect(component.previewText).toEqual(previewText)
})
it('should set previewText to error message if preview fails', () => {
initNormally()
httpTestingController
.expectOne(component.previewUrl)
.flush('fail', { status: 500, statusText: 'Server Error' })
expect(component.previewText).toContain('An error occurred loading content')
})
})

View File

@@ -17,6 +17,11 @@
</div>
<div class="col col-md-10">
<div class="card-body">
@if (document?.in_process) {
<span class="badge bg-secondary text-light mb-2">
<div class="spinner-border spinner-border-sm me-1" role="status"></div><span i18n>Processing...</span>
</span>
}
<div class="d-flex justify-content-between align-items-center">
<h5 class="card-title w-100">
@if (document) {

View File

@@ -37,6 +37,11 @@
}
<div class="card-body bg-light p-2">
@if (document?.in_process) {
<span class="badge bg-secondary text-light mb-2">
<div class="spinner-border spinner-border-sm me-1" role="status"></div><span i18n>Processing...</span>
</span>
}
<p class="card-text">
@if (document) {
@if (displayFields.includes(DisplayField.CORRESPONDENT) && document.correspondent) {

View File

@@ -301,6 +301,11 @@
}
@if (activeDisplayFields.includes(DisplayField.TITLE) || activeDisplayFields.includes(DisplayField.TAGS)) {
<td width="30%">
@if (d.in_process) {
<span class="badge bg-secondary text-light me-1">
<div class="spinner-border spinner-border-sm me-1" role="status"></div><span i18n>Processing...</span>
</span>
}
@if (activeDisplayFields.includes(DisplayField.TITLE)) {
<div class="d-inline-block" (mouseleave)="popupPreview.close()">
<a routerLink="/documents/{{d.id}}" title="Edit document" i18n-title style="overflow-wrap: anywhere;">{{d.title | documentTitle}}</a>

View File

@@ -159,6 +159,8 @@ export interface Document extends ObjectWithPermissions {
page_count?: number
in_process?: boolean
// Frontend only
__changedFields?: string[]
}

View File

@@ -283,6 +283,7 @@ def rotate(doc_ids: list[int], degrees: int) -> Literal["OK"]:
f"Attempting to rotate {len(doc_ids)} documents by {degrees} degrees.",
)
qs = Document.objects.filter(id__in=doc_ids)
Document.objects.filter(pk__in=doc_ids).update(in_process=True)
affected_docs: list[int] = []
import pikepdf
@@ -309,7 +310,9 @@ def rotate(doc_ids: list[int], degrees: int) -> Literal["OK"]:
f"Rotated document {doc.id} by {degrees} degrees",
)
affected_docs.append(doc.id)
Document.objects.filter(pk__in=doc_ids).update(in_process=False)
except Exception as e:
Document.objects.filter(pk__in=doc_ids).update(in_process=False)
logger.exception(f"Error rotating document {doc.id}: {e}")
if len(affected_docs) > 0:
@@ -474,6 +477,7 @@ def delete_pages(doc_ids: list[int], pages: list[int]) -> Literal["OK"]:
f"Attempting to delete pages {pages} from {len(doc_ids)} documents",
)
doc = Document.objects.get(id=doc_ids[0])
Document.objects.filter(pk=doc.id).update(in_process=True)
pages = sorted(pages) # sort pages to avoid index issues
import pikepdf
@@ -492,6 +496,7 @@ def delete_pages(doc_ids: list[int], pages: list[int]) -> Literal["OK"]:
update_document_content_maybe_archive_file.delay(document_id=doc.id)
logger.info(f"Deleted pages {pages} from document {doc.id}")
except Exception as e:
Document.objects.filter(pk=doc.id).update(in_process=False)
logger.exception(f"Error deleting pages from document {doc.id}: {e}")
return "OK"
@@ -518,6 +523,7 @@ def edit_pdf(
f"Editing PDF of document {doc_ids[0]} with {len(operations)} operations",
)
doc = Document.objects.get(id=doc_ids[0])
Document.objects.filter(pk=doc.id).update(in_process=True)
import pikepdf
pdf_docs: list[pikepdf.Pdf] = []
@@ -587,6 +593,7 @@ def edit_pdf(
except Exception as e:
logger.exception(f"Error editing document {doc.id}: {e}")
Document.objects.filter(pk=doc.id).update(in_process=False)
raise ValueError(
f"An error occurred while editing the document: {e}",
) from e

View File

@@ -0,0 +1,23 @@
# Generated by Django 5.2.5 on 2025-08-26 07:54
from django.db import migrations
from django.db import models
class Migration(migrations.Migration):
dependencies = [
("documents", "1068_alter_document_created"),
]
operations = [
migrations.AddField(
model_name="document",
name="in_process",
field=models.BooleanField(
db_index=True,
default=False,
help_text="Whether the document is currently being processed.",
verbose_name="in process",
),
),
]

View File

@@ -289,6 +289,13 @@ class Document(SoftDeleteModel, ModelWithOwner):
),
)
in_process = models.BooleanField(
_("in process"),
default=False,
db_index=True,
help_text=_("Whether the document is currently being processed."),
)
class Meta:
ordering = ("-created",)
verbose_name = _("document")

View File

@@ -935,6 +935,8 @@ class DocumentSerializer(
required=False,
)
in_process = serializers.BooleanField(read_only=True)
def get_page_count(self, obj) -> int | None:
return obj.page_count
@@ -1103,6 +1105,7 @@ class DocumentSerializer(
"remove_inbox_tags",
"page_count",
"mime_type",
"in_process",
)
list_serializer_class = OwnedObjectListSerializer

View File

@@ -250,6 +250,7 @@ def update_document_content_maybe_archive_file(document_id):
it exists.
"""
document = Document.objects.get(id=document_id)
Document.objects.filter(pk=document_id).update(in_process=True)
mime_type = document.mime_type
@@ -349,6 +350,7 @@ def update_document_content_maybe_archive_file(document_id):
)
finally:
parser.cleanup()
Document.objects.filter(pk=document_id).update(in_process=False)
@shared_task

View File

@@ -88,6 +88,7 @@ class StandardPagination(PageNumberPagination):
response_schema["properties"]["all"] = {
"type": "array",
"example": "[1, 2, 3]",
"items": {"type": "integer"},
}
return response_schema