2020-04-10 21:54:53 +00:00
|
|
|
angular.module('portainer.docker').controller('ImportImageController', [
|
|
|
|
'$scope',
|
|
|
|
'$state',
|
|
|
|
'ImageService',
|
|
|
|
'Notifications',
|
|
|
|
'HttpRequestHelper',
|
|
|
|
function ($scope, $state, ImageService, Notifications, HttpRequestHelper) {
|
|
|
|
$scope.state = {
|
|
|
|
actionInProgress: false,
|
|
|
|
};
|
2018-07-26 13:09:48 +00:00
|
|
|
|
2020-04-10 21:54:53 +00:00
|
|
|
$scope.formValues = {
|
|
|
|
UploadFile: null,
|
|
|
|
NodeName: null,
|
|
|
|
};
|
2018-07-26 13:09:48 +00:00
|
|
|
|
2020-04-10 21:54:53 +00:00
|
|
|
$scope.uploadImage = function () {
|
|
|
|
$scope.state.actionInProgress = true;
|
2018-07-26 13:09:48 +00:00
|
|
|
|
2020-04-10 21:54:53 +00:00
|
|
|
var nodeName = $scope.formValues.NodeName;
|
|
|
|
HttpRequestHelper.setPortainerAgentTargetHeader(nodeName);
|
|
|
|
var file = $scope.formValues.UploadFile;
|
|
|
|
ImageService.uploadImage(file)
|
|
|
|
.then(function success() {
|
|
|
|
Notifications.success('Images successfully uploaded');
|
|
|
|
})
|
|
|
|
.catch(function error(err) {
|
2021-06-11 00:05:54 +00:00
|
|
|
Notifications.error('Failure', err, 'Unable to upload image');
|
2020-04-10 21:54:53 +00:00
|
|
|
})
|
|
|
|
.finally(function final() {
|
|
|
|
$scope.state.actionInProgress = false;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
},
|
|
|
|
]);
|