2020-07-23 07:44:32 +00:00
|
|
|
export class FileUploaderController {
|
2020-08-17 00:33:57 +00:00
|
|
|
/* @ngInject */
|
2020-07-23 07:44:32 +00:00
|
|
|
constructor($async) {
|
|
|
|
Object.assign(this, { $async });
|
|
|
|
|
|
|
|
this.state = {
|
|
|
|
uploadInProgress: false,
|
|
|
|
};
|
|
|
|
|
|
|
|
this.onFileSelected = this.onFileSelected.bind(this);
|
|
|
|
this.onFileSelectedAsync = this.onFileSelectedAsync.bind(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
onFileSelected(file) {
|
|
|
|
return this.$async(this.onFileSelectedAsync, file);
|
|
|
|
}
|
|
|
|
|
|
|
|
async onFileSelectedAsync(file) {
|
|
|
|
if (!file) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.state.uploadInProgress = true;
|
|
|
|
try {
|
|
|
|
await this.uploadFile(file);
|
|
|
|
} finally {
|
|
|
|
this.state.uploadInProgress = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|