feat(image-details): add the ability to pull/update a tag (#421)

pull/705/head
Gábor Kovács 2017-03-20 11:45:04 +01:00 committed by Anthony Lapenna
parent b6627098c2
commit c2e63070e6
2 changed files with 54 additions and 20 deletions

View File

@ -11,24 +11,36 @@
<div class="col-lg-12 col-md-12 col-xs-12"> <div class="col-lg-12 col-md-12 col-xs-12">
<rd-widget> <rd-widget>
<rd-widget-header icon="fa fa-tags" title="Image tags"></rd-widget-header> <rd-widget-header icon="fa fa-tags" title="Image tags"></rd-widget-header>
<rd-widget-body classes="no-padding"> <rd-widget-body>
<div style="margin: 5px 10px;"> <form class="form-horizontal">
<span ng-repeat="tag in RepoTags" class="label label-primary image-tag space-right"> <div class="form-group">
<a data-toggle="tooltip" class="interactive" title="Push to registry" ng-click="pushImage(tag)"> <div class="row">
<i class="fa fa-upload white-icon" aria-hidden="true"></i> <div class="pull-left" ng-repeat="tag in RepoTags" style="display:table">
</a> <div class="input-group col-md-1" style="padding:0 15px">
{{ tag }} <span class="input-group-addon">{{ tag }}</span>
<a data-toggle="tooltip" class="interactive" title="Remove tag" ng-click="removeImage(tag)"> <span class="input-group-btn">
<i class="fa fa-trash-o white-icon" aria-hidden="true"></i> <a data-toggle="tooltip" class="btn btn-primary interactive" title="Push to registry" ng-click="pushImage(tag)">
</a> <span class="fa fa-upload white-icon" aria-hidden="true"></span>
</span> </a>
</div> <a data-toggle="tooltip" class="btn btn-primary interactive" title="Pull from registry" ng-click="pullImage(tag)">
<div style="margin: 5px 10px;"> <span class="fa fa-download white-icon" aria-hidden="true"></span>
<span class="small text-muted"> </a>
Note: you can click on the upload icon to push an image <a data-toggle="tooltip" class="btn btn-primary interactive" title="Remove tag" ng-click="removeImage(tag)">
and on the trash icon to delete a tag <span class="fa fa-trash-o white-icon" aria-hidden="true"></span>
</span> </a>
</div> </span>
</div>
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-12">
<span class="small text-muted">
Note: you can click on the upload icon to push or on the download icon to pull an image and on the trash icon to delete a tag
</span>
</div>
</div>
</form>
</rd-widget-body> </rd-widget-body>
</rd-widget> </rd-widget>
</div> </div>

View File

@ -1,6 +1,11 @@
angular.module('image', []) angular.module('image', [])
.controller('ImageController', ['$scope', '$stateParams', '$state', 'Image', 'ImageHelper', 'Messages', .filter('onlylabel', function(){
function ($scope, $stateParams, $state, Image, ImageHelper, Messages) { return function(tag){
return tag.substr(tag.indexOf(":")+1);
};
})
.controller('ImageController', ['$scope', '$stateParams', '$state', 'Image', 'ImageService', 'ImageHelper', 'Messages',
function ($scope, $stateParams, $state, Image, ImageService, ImageHelper, Messages) {
$scope.RepoTags = []; $scope.RepoTags = [];
$scope.config = { $scope.config = {
Image: '', Image: '',
@ -49,6 +54,23 @@ function ($scope, $stateParams, $state, Image, ImageHelper, Messages) {
}); });
}; };
$scope.pullImage = function(tag) {
var items = tag.split(":");
var image = items[0];
tag = items[1];
$('#loadingViewSpinner').show();
ImageService.pullImage({fromImage: image, tag: tag})
.then(function success(data) {
Messages.send('Image successfully pulled');
})
.catch(function error(error){
Messages.error("Failure", error, "Unable to pull image");
})
.finally(function final() {
$('#loadingViewSpinner').hide();
});
};
$scope.removeImage = function (id) { $scope.removeImage = function (id) {
$('#loadingViewSpinner').show(); $('#loadingViewSpinner').show();
Image.remove({id: id}, function (d) { Image.remove({id: id}, function (d) {