mirror of https://github.com/portainer/portainer
31 lines
623 B
JavaScript
31 lines
623 B
JavaScript
export class FileUploaderController {
|
|
/* @ngInject */
|
|
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;
|
|
}
|
|
}
|
|
}
|