diff --git a/src-ui/src/app/components/admin/trash/trash.component.html b/src-ui/src/app/components/admin/trash/trash.component.html
index 87bb24d2c..08de0abd6 100644
--- a/src-ui/src/app/components/admin/trash/trash.component.html
+++ b/src-ui/src/app/components/admin/trash/trash.component.html
@@ -18,7 +18,7 @@ info="Manage trashed items."
@@ -85,13 +85,13 @@ info="Manage trashed items."
@if (!isLoading) {
- {documentsInTrash.length, plural, =1 {One object in trash} other {{{documentsInTrash.length || 0}} total documents in trash}}
+ {totalDocuments, plural, =1 {One object in trash} other {{{totalDocuments || 0}} total documents in trash}}
@if (selectedDocuments.size > 0) {
- ({{selectedDocuments.size}} selected)
+ ({{selectedDocuments.size}} selected)
}
@if (documentsInTrash.length > 20) {
-
+
}
}
diff --git a/src-ui/src/app/components/admin/trash/trash.component.spec.ts b/src-ui/src/app/components/admin/trash/trash.component.spec.ts
index 2f73c071a..063d4bb8f 100644
--- a/src-ui/src/app/components/admin/trash/trash.component.spec.ts
+++ b/src-ui/src/app/components/admin/trash/trash.component.spec.ts
@@ -62,7 +62,13 @@ describe('TrashComponent', () => {
it('should call correct service method on reload', () => {
const trashSpy = jest.spyOn(trashService, 'getTrash')
- trashSpy.mockReturnValue(of(documentsInTrash))
+ trashSpy.mockReturnValue(
+ of({
+ count: 2,
+ all: documentsInTrash.map((d) => d.id),
+ results: documentsInTrash,
+ })
+ )
component.reload()
expect(trashSpy).toHaveBeenCalled()
expect(component.documentsInTrash).toEqual(documentsInTrash)
diff --git a/src-ui/src/app/components/admin/trash/trash.component.ts b/src-ui/src/app/components/admin/trash/trash.component.ts
index a56445d4b..5a68dc1c5 100644
--- a/src-ui/src/app/components/admin/trash/trash.component.ts
+++ b/src-ui/src/app/components/admin/trash/trash.component.ts
@@ -18,6 +18,7 @@ export class TrashComponent implements OnDestroy {
public selectedDocuments: Set
= new Set()
public allToggled: boolean = false
public page: number = 1
+ public totalDocuments: number
public isLoading: boolean = false
unsubscribeNotifier: Subject = new Subject()
@@ -37,8 +38,9 @@ export class TrashComponent implements OnDestroy {
reload() {
this.isLoading = true
- this.trashService.getTrash().subscribe((documentsInTrash) => {
- this.documentsInTrash = documentsInTrash
+ this.trashService.getTrash(this.page).subscribe((r) => {
+ this.documentsInTrash = r.results
+ this.totalDocuments = r.count
this.isLoading = false
this.selectedDocuments.clear()
})
diff --git a/src-ui/src/app/services/trash.service.spec.ts b/src-ui/src/app/services/trash.service.spec.ts
index 8eeb76a76..c880f9361 100644
--- a/src-ui/src/app/services/trash.service.spec.ts
+++ b/src-ui/src/app/services/trash.service.spec.ts
@@ -22,7 +22,7 @@ describe('TrashServiceService', () => {
it('should call correct endpoint for getTrash', () => {
service.getTrash().subscribe()
const req = httpTestingController.expectOne(
- `${environment.apiBaseUrl}trash/`
+ `${environment.apiBaseUrl}trash/?page=1`
)
expect(req.request.method).toEqual('GET')
})
diff --git a/src-ui/src/app/services/trash.service.ts b/src-ui/src/app/services/trash.service.ts
index e1a310621..3b2eccdbd 100644
--- a/src-ui/src/app/services/trash.service.ts
+++ b/src-ui/src/app/services/trash.service.ts
@@ -1,8 +1,9 @@
-import { HttpClient } from '@angular/common/http'
+import { HttpClient, HttpParams } from '@angular/common/http'
import { Injectable } from '@angular/core'
import { Observable } from 'rxjs'
import { environment } from 'src/environments/environment'
import { Document } from '../data/document'
+import { Results } from '../data/results'
@Injectable({
providedIn: 'root',
@@ -10,8 +11,11 @@ import { Document } from '../data/document'
export class TrashService {
constructor(private http: HttpClient) {}
- public getTrash(): Observable {
- return this.http.get(`${environment.apiBaseUrl}trash/`)
+ public getTrash(page: number = 1): Observable> {
+ const httpParams = new HttpParams().set('page', page.toString())
+ return this.http.get>(`${environment.apiBaseUrl}trash/`, {
+ params: httpParams,
+ })
}
public emptyTrash(documents: number[] = []): Observable {
diff --git a/src/documents/views.py b/src/documents/views.py
index e9a099f81..a5ef50f44 100644
--- a/src/documents/views.py
+++ b/src/documents/views.py
@@ -2056,24 +2056,19 @@ class SystemStatusView(PassUserMixin):
)
-class TrashView(PassUserMixin):
- permission_classes = (IsAuthenticated,)
+class TrashView(ListModelMixin, PassUserMixin):
+ permission_classes = (IsAuthenticated, PaperlessObjectPermissions)
serializer_class = TrashSerializer
+ filter_backends = (ObjectOwnedOrGrantedPermissionsFilter,)
+ pagination_class = StandardPagination
+
+ model = Document
+
+ queryset = Document.deleted_objects.all()
def get(self, request, format=None):
- user = self.request.user
- documents = Document.deleted_objects.filter(
- owner=user,
- ) | Document.deleted_objects.filter(
- owner=None,
- )
-
- context = {
- "request": request,
- }
-
- serializer = DocumentSerializer(documents, many=True, context=context)
- return Response(serializer.data)
+ self.serializer_class = DocumentSerializer
+ return self.list(request, format)
def post(self, request, *args, **kwargs):
serializer = self.get_serializer(data=request.data)