docker-registry-frontend/app/scripts/controllers/delete-repository-controller.js
Konrad Kleine 3c3a6f6f08 Revert "fixed deleting repositories doenst always work"
This reverts commit 81be538dfc.

The loop was ignored. See PR #54
2015-07-01 14:07:00 +02:00

52 lines
1.5 KiB
JavaScript

'use strict';
/**
* @ngdoc function
* @name docker-registry-frontend.controller:DeleteRepositoryController
* @description
* # DeleteRepositoryController
* Controller of the docker-registry-frontend
*/
angular.module('delete-repository-controller', ['registry-services'])
.controller('DeleteRepositoryController', ['$scope', '$route', '$modalInstance', '$window', 'Repository', 'items', 'information',
function($scope, $route, $modalInstance, $window, Repository, items, information){
$scope.items = items;
$scope.information = information;
// Callback that triggers deletion of tags and reloading of page
$scope.ok = function () {
angular.forEach($scope.items, function(value, key) {
var repoStr = value;
var repoUser = value.split("/")[0];
var repoName = value.split("/")[1];
var repo = {
repoUser: repoUser,
repoName: repoName
};
Repository.delete(repo,
// success
function(value, responseHeaders) {
toastr.success('Deleted repository: ' + repoStr);
},
// error
function(httpResponse) {
toastr.error('Failed to delete repository: ' + repoStr + ' Response: ' + httpResponse.statusText);
}
);
});
$modalInstance.close();
// Go to the repositories page
$window.location.href = '#/repositories';
$route.reload();
};
$scope.cancel = function () {
$modalInstance.dismiss('cancel');
};
}]);