2018-10-02 07:46:18 +00:00
|
|
|
angular.module('portainer.agent').controller('FileUploaderController', [
|
2018-10-07 08:30:22 +00:00
|
|
|
'$q',
|
|
|
|
function FileUploaderController($q) {
|
2018-10-02 07:46:18 +00:00
|
|
|
var ctrl = this;
|
|
|
|
|
|
|
|
ctrl.state = {
|
|
|
|
uploadInProgress: false
|
|
|
|
};
|
|
|
|
|
2018-10-07 08:30:22 +00:00
|
|
|
ctrl.onFileSelected = onFileSelected;
|
2018-10-02 07:46:18 +00:00
|
|
|
|
2018-10-07 08:30:22 +00:00
|
|
|
function onFileSelected(file) {
|
|
|
|
if (!file) {
|
|
|
|
return;
|
|
|
|
}
|
2018-10-07 08:37:27 +00:00
|
|
|
|
2018-10-02 07:46:18 +00:00
|
|
|
ctrl.state.uploadInProgress = true;
|
2018-10-07 08:30:22 +00:00
|
|
|
$q.when(ctrl.uploadFile(file)).finally(function toggleProgress() {
|
2018-10-07 08:37:27 +00:00
|
|
|
ctrl.state.uploadInProgress = false;
|
2018-10-07 08:30:22 +00:00
|
|
|
});
|
2018-10-02 07:46:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
]);
|