mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-26 17:24:56 +00:00
emit success events on upload resume (#3824)
This commit is contained in:
parent
ef568679d5
commit
580cd3440f
@ -127,6 +127,26 @@ describe('UploadBase', () => {
|
||||
expect(uploadFilesInTheQueue).toHaveBeenCalled();
|
||||
}));
|
||||
|
||||
it('should emit callback events on resume', fakeAsync((done) => {
|
||||
spyOn(uploadService, 'addToQueue').and.stub();
|
||||
spyOn(uploadService, 'uploadFilesInTheQueue').and.stub();
|
||||
|
||||
let uploadEvent: UploadFilesEvent;
|
||||
component.beginUpload.subscribe(event => {
|
||||
uploadEvent = event;
|
||||
event.preventDefault();
|
||||
});
|
||||
const file = <File> { name: 'bigFile.png', size: 1000 };
|
||||
component.uploadFiles([file]);
|
||||
|
||||
tick();
|
||||
uploadEvent.resumeUpload();
|
||||
|
||||
component.success.subscribe(() => {
|
||||
done();
|
||||
});
|
||||
}));
|
||||
|
||||
});
|
||||
|
||||
describe('filesize', () => {
|
||||
|
@ -128,7 +128,8 @@ export abstract class UploadBase implements OnInit, OnDestroy {
|
||||
this.ngZone.run(() => {
|
||||
const event = new UploadFilesEvent(
|
||||
[...filteredFiles],
|
||||
this.uploadService
|
||||
this.uploadService,
|
||||
this.success
|
||||
);
|
||||
this.beginUpload.emit(event);
|
||||
|
||||
|
@ -16,9 +16,9 @@
|
||||
*/
|
||||
|
||||
import { FileModel, UploadService } from '@alfresco/adf-core';
|
||||
import { EventEmitter } from '@angular/core';
|
||||
|
||||
export class UploadFilesEvent {
|
||||
|
||||
private isDefaultPrevented: boolean = false;
|
||||
|
||||
get defaultPrevented() {
|
||||
@ -29,8 +29,11 @@ export class UploadFilesEvent {
|
||||
this.isDefaultPrevented = true;
|
||||
}
|
||||
|
||||
constructor(public files: Array<FileModel>, private uploadService: UploadService) {
|
||||
}
|
||||
constructor(
|
||||
public files: Array<FileModel>,
|
||||
private uploadService: UploadService,
|
||||
private callback: EventEmitter<any>
|
||||
) {}
|
||||
|
||||
pauseUpload() {
|
||||
this.preventDefault();
|
||||
@ -39,7 +42,7 @@ export class UploadFilesEvent {
|
||||
resumeUpload() {
|
||||
if (this.files && this.files.length > 0) {
|
||||
this.uploadService.addToQueue(...this.files);
|
||||
this.uploadService.uploadFilesInTheQueue();
|
||||
this.uploadService.uploadFilesInTheQueue(this.callback);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user