1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-23 07:19:41 +02:00

feat(registries): add registry management (#930)

This commit is contained in:
Anthony Lapenna 2017-06-20 13:00:32 +02:00 committed by GitHub
parent 9360f24d89
commit 08c5a5a4f6
75 changed files with 2317 additions and 621 deletions

View file

@ -1,17 +1,17 @@
angular.module('image', [])
.controller('ImageController', ['$scope', '$stateParams', '$state', 'ImageService', 'Notifications',
function ($scope, $stateParams, $state, ImageService, Notifications) {
$scope.config = {
.controller('ImageController', ['$scope', '$stateParams', '$state', '$timeout', 'ImageService', 'RegistryService', 'Notifications',
function ($scope, $stateParams, $state, $timeout, ImageService, RegistryService, Notifications) {
$scope.formValues = {
Image: '',
Registry: ''
};
$scope.tagImage = function() {
$('#loadingViewSpinner').show();
var image = $scope.config.Image;
var registry = $scope.config.Registry;
var image = $scope.formValues.Image;
var registry = $scope.formValues.Registry;
ImageService.tagImage($stateParams.id, image, registry)
ImageService.tagImage($stateParams.id, image, registry.URL)
.then(function success(data) {
Notifications.success('Image successfully tagged');
$state.go('image', {id: $stateParams.id}, {reload: true});
@ -24,28 +24,35 @@ function ($scope, $stateParams, $state, ImageService, Notifications) {
});
};
$scope.pushTag = function(tag) {
$scope.pushTag = function(repository) {
$('#loadingViewSpinner').show();
ImageService.pushImage(tag)
.then(function success() {
Notifications.success('Image successfully pushed');
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);
})
.catch(function error(err) {
Notifications.error('Failure', err, 'Unable to push image tag');
Notifications.error('Failure', err, 'Unable to push image to repository');
})
.finally(function final() {
$('#loadingViewSpinner').hide();
});
};
$scope.pullTag = function(tag) {
$scope.pullTag = function(repository) {
$('#loadingViewSpinner').show();
ImageService.pullTag(tag)
RegistryService.retrieveRegistryFromRepository(repository)
.then(function success(data) {
Notifications.success('Image successfully pulled', tag);
var registry = data;
return ImageService.pullImage(repository, registry);
})
.catch(function error(err){
.then(function success(data) {
Notifications.success('Image successfully pulled', repository);
})
.catch(function error(err) {
Notifications.error('Failure', err, 'Unable to pull image');
})
.finally(function final() {
@ -53,15 +60,15 @@ function ($scope, $stateParams, $state, ImageService, Notifications) {
});
};
$scope.removeTag = function(id) {
$scope.removeTag = function(repository) {
$('#loadingViewSpinner').show();
ImageService.deleteImage(id, false)
ImageService.deleteImage(repository, false)
.then(function success() {
if ($scope.image.RepoTags.length === 1) {
Notifications.success('Image successfully deleted', id);
Notifications.success('Image successfully deleted', repository);
$state.go('images', {}, {reload: true});
} else {
Notifications.success('Tag successfully deleted', id);
Notifications.success('Tag successfully deleted', repository);
$state.go('image', {id: $stateParams.id}, {reload: true});
}
})