mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-09-24 01:02:45 -05:00
Feature: processed mail UI (#10866)
This commit is contained in:
@@ -28,6 +28,7 @@ export enum PermissionType {
|
||||
ShareLink = '%s_sharelink',
|
||||
CustomField = '%s_customfield',
|
||||
Workflow = '%s_workflow',
|
||||
ProcessedMail = '%s_processedmail',
|
||||
}
|
||||
|
||||
@Injectable({
|
||||
|
39
src-ui/src/app/services/rest/processed-mail.service.spec.ts
Normal file
39
src-ui/src/app/services/rest/processed-mail.service.spec.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import { HttpTestingController } from '@angular/common/http/testing'
|
||||
import { TestBed } from '@angular/core/testing'
|
||||
import { Subscription } from 'rxjs'
|
||||
import { environment } from 'src/environments/environment'
|
||||
import { commonAbstractPaperlessServiceTests } from './abstract-paperless-service.spec'
|
||||
import { ProcessedMailService } from './processed-mail.service'
|
||||
|
||||
let httpTestingController: HttpTestingController
|
||||
let service: ProcessedMailService
|
||||
let subscription: Subscription
|
||||
const endpoint = 'processed_mail'
|
||||
|
||||
// run common tests
|
||||
commonAbstractPaperlessServiceTests(endpoint, ProcessedMailService)
|
||||
|
||||
describe('Additional service tests for ProcessedMailService', () => {
|
||||
beforeEach(() => {
|
||||
// Dont need to setup again
|
||||
|
||||
httpTestingController = TestBed.inject(HttpTestingController)
|
||||
service = TestBed.inject(ProcessedMailService)
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
subscription?.unsubscribe()
|
||||
httpTestingController.verify()
|
||||
})
|
||||
|
||||
it('should call appropriate api endpoint for bulk delete', () => {
|
||||
const ids = [1, 2, 3]
|
||||
subscription = service.bulk_delete(ids).subscribe()
|
||||
const req = httpTestingController.expectOne(
|
||||
`${environment.apiBaseUrl}${endpoint}/bulk_delete/`
|
||||
)
|
||||
expect(req.request.method).toEqual('POST')
|
||||
expect(req.request.body).toEqual({ mail_ids: ids })
|
||||
req.flush({})
|
||||
})
|
||||
})
|
19
src-ui/src/app/services/rest/processed-mail.service.ts
Normal file
19
src-ui/src/app/services/rest/processed-mail.service.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { Injectable } from '@angular/core'
|
||||
import { ProcessedMail } from 'src/app/data/processed-mail'
|
||||
import { AbstractPaperlessService } from './abstract-paperless-service'
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class ProcessedMailService extends AbstractPaperlessService<ProcessedMail> {
|
||||
constructor() {
|
||||
super()
|
||||
this.resourceName = 'processed_mail'
|
||||
}
|
||||
|
||||
public bulk_delete(mailIds: number[]) {
|
||||
return this.http.post(`${this.getResourceUrl()}bulk_delete/`, {
|
||||
mail_ids: mailIds,
|
||||
})
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user