mirror of
https://github.com/kwk/docker-registry-frontend.git
synced 2024-11-10 08:52:47 +08:00
3f988e7309
Now all files dealing with repositories reside in app/repository and all dealing with tag reside in app/tag. That's far more easy to maintain than having tag files spread across multiple folders.
47 lines
1.4 KiB
JavaScript
47 lines
1.4 KiB
JavaScript
'use strict';
|
|
|
|
/**
|
|
* @ngdoc function
|
|
* @name docker-registry-frontend.controller:TagItemController
|
|
* @description
|
|
* # TagItemController
|
|
* Every item in the tag list is associated with a TagItemController
|
|
*/
|
|
angular.module('tag-item-controller', ['registry-services'])
|
|
.controller('TagItemController', ['$scope', 'Image', 'Ancestry',
|
|
function($scope, Image, Ancestry){
|
|
|
|
// Assign details to "tag" variable in the parent scope
|
|
|
|
$scope.tag.details = Image.query( {imageId: $scope.tag.imageId} );
|
|
|
|
/**
|
|
* Calculates the total download size for the image based on
|
|
* it's ancestry.
|
|
*/
|
|
$scope.totalImageSize = null;
|
|
$scope.calculateTotalImageSize = function() {
|
|
|
|
/* Fetch the image's ancestry and when complete, fetch the size of each image */
|
|
|
|
Ancestry.query( {imageId: $scope.tag.imageId} ).$promise.then(function (result) {
|
|
|
|
$scope.totalImageSize = 0;
|
|
|
|
angular.forEach(result, function (id, key) {
|
|
|
|
/* We have to use the $promise object here to be sure the result is accessible */
|
|
|
|
Image.get( {imageId: id} ).$promise.then(function (result) {
|
|
if (!isNaN(result.Size-0)) {
|
|
$scope.totalImageSize += result.Size;
|
|
}
|
|
});
|
|
|
|
});
|
|
|
|
|
|
});
|
|
};
|
|
|
|
}]);
|