2014-11-12 18:11:36 +00:00
|
|
|
angular.module('image', [])
|
2017-04-12 19:47:22 +00:00
|
|
|
.controller('ImageController', ['$scope', '$stateParams', '$state', 'ImageService', 'Notifications',
|
|
|
|
function ($scope, $stateParams, $state, ImageService, Notifications) {
|
2017-03-20 11:01:35 +00:00
|
|
|
$scope.config = {
|
|
|
|
Image: '',
|
|
|
|
Registry: ''
|
2017-03-20 10:45:04 +00:00
|
|
|
};
|
2016-08-17 06:05:17 +00:00
|
|
|
|
2017-03-20 11:01:35 +00:00
|
|
|
$scope.tagImage = function() {
|
|
|
|
$('#loadingViewSpinner').show();
|
|
|
|
var image = $scope.config.Image;
|
|
|
|
var registry = $scope.config.Registry;
|
2016-06-02 05:34:03 +00:00
|
|
|
|
2017-03-20 11:01:35 +00:00
|
|
|
ImageService.tagImage($stateParams.id, image, registry)
|
|
|
|
.then(function success(data) {
|
2017-04-12 19:47:22 +00:00
|
|
|
Notifications.success('Image successfully tagged');
|
2017-03-20 11:01:35 +00:00
|
|
|
$state.go('image', {id: $stateParams.id}, {reload: true});
|
|
|
|
})
|
|
|
|
.catch(function error(err) {
|
2017-05-23 18:25:56 +00:00
|
|
|
Notifications.error('Failure', err, 'Unable to tag image');
|
2017-03-20 11:01:35 +00:00
|
|
|
})
|
|
|
|
.finally(function final() {
|
|
|
|
$('#loadingViewSpinner').hide();
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2017-05-23 18:43:58 +00:00
|
|
|
$scope.pushTag = function(tag) {
|
2017-03-20 11:01:35 +00:00
|
|
|
$('#loadingViewSpinner').show();
|
|
|
|
ImageService.pushImage(tag)
|
|
|
|
.then(function success() {
|
2017-04-12 19:47:22 +00:00
|
|
|
Notifications.success('Image successfully pushed');
|
2017-03-20 11:01:35 +00:00
|
|
|
})
|
|
|
|
.catch(function error(err) {
|
2017-05-23 18:25:56 +00:00
|
|
|
Notifications.error('Failure', err, 'Unable to push image tag');
|
2017-03-20 11:01:35 +00:00
|
|
|
})
|
|
|
|
.finally(function final() {
|
|
|
|
$('#loadingViewSpinner').hide();
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2017-05-23 18:43:58 +00:00
|
|
|
$scope.pullTag = function(tag) {
|
2017-03-20 11:01:35 +00:00
|
|
|
$('#loadingViewSpinner').show();
|
2016-08-17 06:05:17 +00:00
|
|
|
|
2017-05-23 18:25:56 +00:00
|
|
|
ImageService.pullTag(tag)
|
2017-03-20 11:01:35 +00:00
|
|
|
.then(function success(data) {
|
2017-05-23 18:25:56 +00:00
|
|
|
Notifications.success('Image successfully pulled', tag);
|
2017-03-20 11:01:35 +00:00
|
|
|
})
|
|
|
|
.catch(function error(err){
|
2017-05-23 18:25:56 +00:00
|
|
|
Notifications.error('Failure', err, 'Unable to pull image');
|
2017-03-20 11:01:35 +00:00
|
|
|
})
|
|
|
|
.finally(function final() {
|
|
|
|
$('#loadingViewSpinner').hide();
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.removeTag = function(id) {
|
|
|
|
$('#loadingViewSpinner').show();
|
|
|
|
ImageService.deleteImage(id, false)
|
|
|
|
.then(function success() {
|
|
|
|
if ($scope.image.RepoTags.length === 1) {
|
2017-04-12 19:47:22 +00:00
|
|
|
Notifications.success('Image successfully deleted', id);
|
2017-03-20 11:01:35 +00:00
|
|
|
$state.go('images', {}, {reload: true});
|
|
|
|
} else {
|
2017-04-12 19:47:22 +00:00
|
|
|
Notifications.success('Tag successfully deleted', id);
|
2017-03-20 11:01:35 +00:00
|
|
|
$state.go('image', {id: $stateParams.id}, {reload: true});
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.catch(function error(err) {
|
2017-05-23 18:25:56 +00:00
|
|
|
Notifications.error('Failure', err, 'Unable to remove image');
|
2017-03-20 11:01:35 +00:00
|
|
|
})
|
|
|
|
.finally(function final() {
|
|
|
|
$('#loadingViewSpinner').hide();
|
|
|
|
});
|
|
|
|
};
|
2016-08-17 00:27:54 +00:00
|
|
|
|
2017-03-20 11:01:35 +00:00
|
|
|
$scope.removeImage = function (id) {
|
|
|
|
$('#loadingViewSpinner').show();
|
|
|
|
ImageService.deleteImage(id, false)
|
|
|
|
.then(function success() {
|
2017-04-12 19:47:22 +00:00
|
|
|
Notifications.success('Image successfully deleted', id);
|
2017-03-20 11:01:35 +00:00
|
|
|
$state.go('images', {}, {reload: true});
|
|
|
|
})
|
|
|
|
.catch(function error(err) {
|
2017-05-23 18:25:56 +00:00
|
|
|
Notifications.error('Failure', err, 'Unable to remove image');
|
2017-03-20 11:01:35 +00:00
|
|
|
})
|
|
|
|
.finally(function final() {
|
|
|
|
$('#loadingViewSpinner').hide();
|
|
|
|
});
|
|
|
|
};
|
2017-03-20 10:45:04 +00:00
|
|
|
|
2017-03-20 11:01:35 +00:00
|
|
|
function retrieveImageDetails() {
|
|
|
|
$('#loadingViewSpinner').show();
|
|
|
|
ImageService.image($stateParams.id)
|
|
|
|
.then(function success(data) {
|
|
|
|
$scope.image = data;
|
|
|
|
})
|
|
|
|
.catch(function error(err) {
|
2017-05-23 18:25:56 +00:00
|
|
|
Notifications.error('Failure', err, 'Unable to retrieve image details');
|
2017-03-20 11:01:35 +00:00
|
|
|
$state.go('images');
|
|
|
|
})
|
|
|
|
.finally(function final() {
|
|
|
|
$('#loadingViewSpinner').hide();
|
|
|
|
});
|
|
|
|
}
|
2016-08-10 03:14:10 +00:00
|
|
|
|
2017-03-20 11:01:35 +00:00
|
|
|
retrieveImageDetails();
|
2016-06-02 05:34:03 +00:00
|
|
|
}]);
|