mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-09-24 01:02:45 -05:00
Feature: documents trash aka soft delete (#6944)
This commit is contained in:
37
src-ui/src/app/services/trash.service.ts
Normal file
37
src-ui/src/app/services/trash.service.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
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',
|
||||
})
|
||||
export class TrashService {
|
||||
constructor(private http: HttpClient) {}
|
||||
|
||||
public getTrash(page: number = 1): Observable<Results<Document>> {
|
||||
const httpParams = new HttpParams().set('page', page.toString())
|
||||
return this.http.get<Results<Document>>(`${environment.apiBaseUrl}trash/`, {
|
||||
params: httpParams,
|
||||
})
|
||||
}
|
||||
|
||||
public emptyTrash(documents?: number[]): Observable<any> {
|
||||
const data = {
|
||||
action: 'empty',
|
||||
}
|
||||
if (documents?.length) {
|
||||
data['documents'] = documents
|
||||
}
|
||||
return this.http.post(`${environment.apiBaseUrl}trash/`, data)
|
||||
}
|
||||
|
||||
public restoreDocuments(documents: number[]): Observable<any> {
|
||||
return this.http.post(`${environment.apiBaseUrl}trash/`, {
|
||||
action: 'restore',
|
||||
documents,
|
||||
})
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user