FileUploadItem is added
This commit is contained in:
parent
a4ee7cc83e
commit
8da169a144
|
@ -0,0 +1,38 @@
|
|||
import { Observable, Subject } from 'rxjs';
|
||||
import { share } from 'rxjs/operators';
|
||||
|
||||
export class FileUploadItem {
|
||||
file: File;
|
||||
uploadTime: number;
|
||||
uploadingProgress$: Observable<number>;
|
||||
|
||||
private uploadingProgress: Subject<number>;
|
||||
private uploadStartTime: number;
|
||||
|
||||
private constructor(file: File) {
|
||||
this.file = file;
|
||||
}
|
||||
|
||||
static fromFiles(files: File[]): FileUploadItem[] {
|
||||
const fileItems: FileUploadItem[] = [];
|
||||
for (const file of files) {
|
||||
fileItems.push(new FileUploadItem(file));
|
||||
}
|
||||
return fileItems;
|
||||
}
|
||||
|
||||
uploadStart(): Subject<number> {
|
||||
this.uploadStartTime = new Date().getTime();
|
||||
this.uploadingProgress = new Subject<number>();
|
||||
this.uploadingProgress$ = this.uploadingProgress
|
||||
.asObservable()
|
||||
.pipe(share());
|
||||
return this.uploadingProgress;
|
||||
}
|
||||
|
||||
uploadComplete() {
|
||||
const endTime = new Date().getTime();
|
||||
this.uploadTime = endTime - this.uploadStartTime;
|
||||
this.uploadingProgress.complete();
|
||||
}
|
||||
}
|
|
@ -15,6 +15,8 @@ export * from './lib/apis/trans-mass-talk-save';
|
|||
export * from './lib/apis/translation-req';
|
||||
export * from './lib/apis/translation-save';
|
||||
|
||||
export * from './lib/models/file-upload-item';
|
||||
|
||||
export * from './lib/services/common-api.service';
|
||||
|
||||
export * from './lib/ucap-common-api.module';
|
||||
|
|
Loading…
Reference in New Issue
Block a user