mirror of
https://github.com/portainer/portainer.git
synced 2025-08-05 13:55:21 +02:00
Merge branch 'develop' into oath-poc
This commit is contained in:
commit
508352f4ea
53 changed files with 626 additions and 452 deletions
|
@ -1,11 +1,13 @@
|
|||
angular.module('portainer.extensions.registrymanagement')
|
||||
.factory('RegistryCatalog', ['$resource', 'API_ENDPOINT_REGISTRIES', function RegistryCatalogFactory($resource, API_ENDPOINT_REGISTRIES) {
|
||||
.factory('RegistryCatalog', ['$resource', 'API_ENDPOINT_REGISTRIES',
|
||||
function RegistryCatalogFactory($resource, API_ENDPOINT_REGISTRIES) {
|
||||
'use strict';
|
||||
return $resource(API_ENDPOINT_REGISTRIES + '/:id/v2/:action', {},
|
||||
{
|
||||
get: {
|
||||
method: 'GET',
|
||||
params: { id: '@id', action: '_catalog' }
|
||||
params: { id: '@id', action: '_catalog' },
|
||||
transformResponse: linkGetResponse
|
||||
},
|
||||
ping: {
|
||||
method: 'GET',
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
function linkGetResponse(data, headers) {
|
||||
var response = angular.fromJson(data);
|
||||
var link = headers('link');
|
||||
if (link) {
|
||||
var queryString = link.substring(link.indexOf('?') + 1).split('>;')[0];
|
||||
var queries = queryString.split('&');
|
||||
for (var i = 0; i < queries.length; i++) {
|
||||
var kv = queries[i].split('=');
|
||||
response[kv[0]] = kv[1];
|
||||
}
|
||||
}
|
||||
return response;
|
||||
}
|
|
@ -11,16 +11,33 @@ function RegistryV2ServiceFactory($q, RegistryCatalog, RegistryTags, RegistryMan
|
|||
return RegistryCatalog.ping({ id: id }).$promise;
|
||||
};
|
||||
|
||||
function getCatalog(id) {
|
||||
var deferred = $q.defer();
|
||||
var repositories = [];
|
||||
|
||||
_getCatalogPage({id: id}, deferred, repositories);
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
function _getCatalogPage(params, deferred, repositories) {
|
||||
RegistryCatalog.get(params).$promise.then(function(data) {
|
||||
repositories = _.concat(repositories, data.repositories);
|
||||
if (data.last && data.n) {
|
||||
_getCatalogPage({id: params.id, n: data.n, last: data.last}, deferred, repositories);
|
||||
} else {
|
||||
deferred.resolve(repositories);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
service.repositories = function (id) {
|
||||
var deferred = $q.defer();
|
||||
|
||||
RegistryCatalog.get({
|
||||
id: id
|
||||
}).$promise
|
||||
.then(function success(data) {
|
||||
getCatalog(id).then(function success(data) {
|
||||
var promises = [];
|
||||
for (var i = 0; i < data.repositories.length; i++) {
|
||||
var repository = data.repositories[i];
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var repository = data[i];
|
||||
promises.push(RegistryTags.get({
|
||||
id: id,
|
||||
repository: repository
|
||||
|
|
|
@ -81,9 +81,17 @@ angular.module('portainer.app')
|
|||
});
|
||||
return $q.all(promises);
|
||||
})
|
||||
.then(function success() {
|
||||
.then(function success(data) {
|
||||
Notifications.success('Success', 'Tags successfully deleted');
|
||||
$state.reload();
|
||||
if (data.length === 0) {
|
||||
$state.go('portainer.registries.registry.repositories', {
|
||||
id: $scope.registryId
|
||||
}, {
|
||||
reload: true
|
||||
});
|
||||
} else {
|
||||
$state.reload();
|
||||
}
|
||||
})
|
||||
.catch(function error(err) {
|
||||
Notifications.error('Failure', err, 'Unable to delete tags');
|
||||
|
@ -127,9 +135,9 @@ angular.module('portainer.app')
|
|||
})
|
||||
.then(function success(data) {
|
||||
$scope.registry = data.registry;
|
||||
$scope.repository.Tags = data.tags;
|
||||
$scope.repository.Tags = [].concat(data.tags || []);
|
||||
$scope.tags = [];
|
||||
for (var i = 0; i < data.tags.length; i++) {
|
||||
for (var i = 0; i < $scope.repository.Tags.length; i++) {
|
||||
var tag = data.tags[i];
|
||||
RegistryV2Service.tag(registryId, repository, tag)
|
||||
.then(function success(data) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue