mirror of https://github.com/portainer/portainer
feat(image): add the ability to push an image tag
parent
722dc0b3af
commit
f0e4cdc13e
|
@ -13,14 +13,21 @@
|
|||
<rd-widget-header icon="fa fa-tags" title="Image tags"></rd-widget-header>
|
||||
<rd-widget-body classes="no-padding">
|
||||
<div style="margin: 5px 10px;">
|
||||
<span ng-repeat="tag in RepoTags" class="label label-primary image-tag">{{ tag }}
|
||||
<span ng-repeat="tag in RepoTags" class="label label-primary image-tag">
|
||||
<a data-toggle="tooltip" class="interactive" title="Push to registry" ng-click="pushImage(tag)">
|
||||
<i class="fa fa-upload white-icon" aria-hidden="true"></i>
|
||||
</a>
|
||||
{{ tag }}
|
||||
<a data-toggle="tooltip" class="interactive" title="Remove tag" ng-click="removeImage(tag)">
|
||||
<i class="fa fa-trash-o white-icon" aria-hidden="true"></i>
|
||||
</a>
|
||||
</span>
|
||||
</div>
|
||||
<div style="margin: 5px 10px;">
|
||||
<span class="small text-muted">Note: you can click on the trash icon to delete a tag</span>
|
||||
<span class="small text-muted">
|
||||
Note: you can click on the upload icon to push an image
|
||||
and on the trash icon to delete a tag
|
||||
</span>
|
||||
</div>
|
||||
</rd-widget-body>
|
||||
</rd-widget>
|
||||
|
|
|
@ -15,6 +15,21 @@ function ($scope, $stateParams, $state, Image, Messages) {
|
|||
});
|
||||
}
|
||||
|
||||
$scope.pushImage = function(tag) {
|
||||
$('#loadingViewSpinner').show();
|
||||
Image.push({tag: tag}, function (d) {
|
||||
if (d[d.length-1].error) {
|
||||
Messages.error("Unable to push image", d[d.length-1].error);
|
||||
} else {
|
||||
Messages.send('Image successfully pushed');
|
||||
}
|
||||
$('#loadingViewSpinner').hide();
|
||||
}, function (e) {
|
||||
$('#loadingViewSpinner').hide();
|
||||
Messages.error("Unable to push image", e.data);
|
||||
});
|
||||
};
|
||||
|
||||
$scope.removeImage = function (id) {
|
||||
$('#loadingViewSpinner').show();
|
||||
Image.remove({id: id}, function (d) {
|
||||
|
|
|
@ -12,6 +12,13 @@ function createImageHandler(data) {
|
|||
return angular.fromJson(str);
|
||||
}
|
||||
|
||||
// Image push API return a list of JSON object.
|
||||
// This handler wrap the JSON objects in an array.
|
||||
function pushImageHandler(data) {
|
||||
var str = "[" + data.replace(/\n/g, " ").replace(/\}\s*\{/g, "}, {") + "]";
|
||||
return angular.fromJson(str);
|
||||
}
|
||||
|
||||
// Image delete API returns an array on success and an object on error.
|
||||
// This handler creates an array from an object in case of error.
|
||||
function deleteImageHandler(data) {
|
||||
|
|
|
@ -93,9 +93,12 @@ angular.module('uifordocker.services', ['ngResource', 'ngSanitize'])
|
|||
search: {method: 'GET', params: {action: 'search'}},
|
||||
history: {method: 'GET', params: {action: 'history'}, isArray: true},
|
||||
insert: {method: 'POST', params: {id: '@id', action: 'insert'}},
|
||||
push: {method: 'POST', params: {id: '@id', action: 'push'}},
|
||||
tag: {method: 'POST', params: {id: '@id', action: 'tag', force: 0, repo: '@repo', tag: '@tag'}},
|
||||
inspect: {method: 'GET', params: {id: '@id', action: 'json'}},
|
||||
push: {
|
||||
method: 'POST', params: {action: 'push', id: '@tag'},
|
||||
isArray: true, transformResponse: pushImageHandler
|
||||
},
|
||||
create: {
|
||||
method: 'POST', params: {action: 'create', fromImage: '@fromImage', tag: '@tag'},
|
||||
isArray: true, transformResponse: createImageHandler
|
||||
|
|
Loading…
Reference in New Issue