mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-10-24 08:38:55 +00:00
Enhancement: add upload count to button, link to tray, reduce notifications (#14501)
This commit is contained in:
1 parent
f8e93a535a
commit
3374debd6a
10 files changed
+125
-18
No files matched your search
@@ -66,6 +66,19 @@ describe('UploadDocumentsService', () => {
|
||||
.forEach((req) => req.flush('123-456'))
|
||||
})
|
||||
|
||||
it('emits when uploads start', () => {
|
||||
const startedSpy = jest.fn()
|
||||
uploadDocumentsService.onUploadsStarted().subscribe(startedSpy)
|
||||
uploadDocumentsService.uploadFiles([])
|
||||
expect(startedSpy).not.toHaveBeenCalled()
|
||||
const file = new File(['one'], 'one.pdf')
|
||||
uploadDocumentsService.uploadFiles([file])
|
||||
expect(startedSpy).toHaveBeenCalledWith([file])
|
||||
httpTestingController
|
||||
.match(`${environment.apiBaseUrl}documents/post_document/`)
|
||||
.forEach((req) => req.flush('123-456'))
|
||||
})
|
||||
|
||||
it('updates progress during upload and failure', () => {
|
||||
const file = new File(
|
||||
[new Blob(['testing'], { type: 'application/pdf' })],
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { HttpEventType } from '@angular/common/http'
|
||||
import { Injectable, inject } from '@angular/core'
|
||||
import { Subscription } from 'rxjs'
|
||||
import { Subject, Subscription } from 'rxjs'
|
||||
import { DocumentService } from './rest/document.service'
|
||||
import {
|
||||
FileStatusPhase,
|
||||
@@ -16,10 +16,19 @@ export class UploadDocumentsService {
|
||||
|
||||
private uploadSubscriptions: Array<Subscription> = []
|
||||
|
||||
private readonly uploadsStartedSubject = new Subject<File[]>()
|
||||
|
||||
public uploadFiles(files: Iterable<File>) {
|
||||
const started: File[] = []
|
||||
for (const file of files) {
|
||||
this.uploadFile(file)
|
||||
started.push(file)
|
||||
}
|
||||
if (started.length) this.uploadsStartedSubject.next(started)
|
||||
}
|
||||
|
||||
public onUploadsStarted() {
|
||||
return this.uploadsStartedSubject.asObservable()
|
||||
}
|
||||
|
||||
public uploadFile(file: File) {
|
||||
|
||||
Reference in new issue
Block a user