mirror of
https://github.com/portainer/portainer.git
synced 2025-07-22 23:09:41 +02:00
refactor(agent): refactor file-uploader to es6 (#4087)
* refactor(host): convert fileUploader to es6 * refactor(agent): rename main file
This commit is contained in:
parent
5abd35d4c1
commit
435f15ec6a
5 changed files with 39 additions and 30 deletions
29
app/agent/components/file-uploader/fileUploaderController.js
Normal file
29
app/agent/components/file-uploader/fileUploaderController.js
Normal file
|
@ -0,0 +1,29 @@
|
|||
export class FileUploaderController {
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue