2014-11-12 18:11:36 +00:00
|
|
|
angular.module('image', [])
|
2017-06-20 11:00:32 +00:00
|
|
|
.controller('ImageController', ['$scope', '$stateParams', '$state', '$timeout', 'ImageService', 'RegistryService', 'Notifications',
|
|
|
|
function ($scope, $stateParams, $state, $timeout, ImageService, RegistryService, Notifications) {
|
|
|
|
$scope.formValues = {
|
2017-03-20 11:01:35 +00:00
|
|
|
Image: '',
|
|
|
|
Registry: ''
|
2017-03-20 10:45:04 +00:00
|
|
|
};
|
2016-08-17 06:05:17 +00:00
|
|
|
|
2017-07-08 07:21:30 +00:00
|
|
|
$scope.sortType = 'Size';
|
|
|
|
$scope.sortReverse = true;
|
|
|
|
|
|
|
|
$scope.order = function(sortType) {
|
|
|
|
$scope.sortReverse = ($scope.sortType === sortType) ? !$scope.sortReverse : false;
|
|
|
|
$scope.sortType = sortType;
|
|
|
|
};
|
|
|
|
|
2017-07-08 06:59:32 +00:00
|
|
|
$scope.toggleLayerCommand = function(layerId) {
|
|
|
|
$('#layer-command-expander'+layerId+' span').toggleClass('glyphicon-plus-sign glyphicon-minus-sign');
|
|
|
|
$('#layer-command-'+layerId+'-short').toggle();
|
|
|
|
$('#layer-command-'+layerId+'-full').toggle();
|
|
|
|
};
|
|
|
|
|
2017-03-20 11:01:35 +00:00
|
|
|
$scope.tagImage = function() {
|
|
|
|
$('#loadingViewSpinner').show();
|
2017-06-20 11:00:32 +00:00
|
|
|
var image = $scope.formValues.Image;
|
|
|
|
var registry = $scope.formValues.Registry;
|
2016-06-02 05:34:03 +00:00
|
|
|
|
2017-06-20 11:00:32 +00:00
|
|
|
ImageService.tagImage($stateParams.id, image, registry.URL)
|
2017-03-20 11:01:35 +00:00
|
|
|
.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-06-20 11:00:32 +00:00
|
|
|
$scope.pushTag = function(repository) {
|
2017-03-20 11:01:35 +00:00
|
|
|
$('#loadingViewSpinner').show();
|
2017-06-20 11:00:32 +00:00
|
|
|
RegistryService.retrieveRegistryFromRepository(repository)
|
|
|
|
.then(function success(data) {
|
|
|
|
var registry = data;
|
|
|
|
return ImageService.pushImage(repository, registry);
|
|
|
|
})
|
|
|
|
.then(function success(data) {
|
|
|
|
Notifications.success('Image successfully pushed', repository);
|
2017-03-20 11:01:35 +00:00
|
|
|
})
|
|
|
|
.catch(function error(err) {
|
2017-06-20 11:00:32 +00:00
|
|
|
Notifications.error('Failure', err, 'Unable to push image to repository');
|
2017-03-20 11:01:35 +00:00
|
|
|
})
|
|
|
|
.finally(function final() {
|
|
|
|
$('#loadingViewSpinner').hide();
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2017-06-20 11:00:32 +00:00
|
|
|
$scope.pullTag = function(repository) {
|
2017-03-20 11:01:35 +00:00
|
|
|
$('#loadingViewSpinner').show();
|
2017-06-20 11:00:32 +00:00
|
|
|
RegistryService.retrieveRegistryFromRepository(repository)
|
|
|
|
.then(function success(data) {
|
|
|
|
var registry = data;
|
2017-06-29 14:05:39 +00:00
|
|
|
return ImageService.pullImage(repository, registry, false);
|
2017-06-20 11:00:32 +00:00
|
|
|
})
|
2017-03-20 11:01:35 +00:00
|
|
|
.then(function success(data) {
|
2017-06-20 11:00:32 +00:00
|
|
|
Notifications.success('Image successfully pulled', repository);
|
2017-03-20 11:01:35 +00:00
|
|
|
})
|
2017-06-20 11:00:32 +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();
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2017-06-20 11:00:32 +00:00
|
|
|
$scope.removeTag = function(repository) {
|
2017-03-20 11:01:35 +00:00
|
|
|
$('#loadingViewSpinner').show();
|
2017-06-20 11:00:32 +00:00
|
|
|
ImageService.deleteImage(repository, false)
|
2017-03-20 11:01:35 +00:00
|
|
|
.then(function success() {
|
|
|
|
if ($scope.image.RepoTags.length === 1) {
|
2017-06-20 11:00:32 +00:00
|
|
|
Notifications.success('Image successfully deleted', repository);
|
2017-03-20 11:01:35 +00:00
|
|
|
$state.go('images', {}, {reload: true});
|
|
|
|
} else {
|
2017-06-20 11:00:32 +00:00
|
|
|
Notifications.success('Tag successfully deleted', repository);
|
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();
|
|
|
|
});
|
2017-07-08 06:59:32 +00:00
|
|
|
|
|
|
|
$('#loadingViewSpinner').show();
|
|
|
|
ImageService.history($stateParams.id)
|
|
|
|
.then(function success(data) {
|
|
|
|
$scope.history = data;
|
|
|
|
})
|
|
|
|
.catch(function error(err) {
|
|
|
|
Notifications.error('Failure', err, 'Unable to retrieve image history');
|
|
|
|
})
|
|
|
|
.finally(function final() {
|
|
|
|
$('#loadingViewSpinner').hide();
|
|
|
|
});
|
2017-03-20 11:01:35 +00:00
|
|
|
}
|
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
|
|
|
}]);
|