Work in progress: Show the diff information in the UI

This commit is contained in:
Joseph Schorr 2013-10-18 17:59:26 -04:00
parent 3d0b165de9
commit 262634555a
3 changed files with 139 additions and 6 deletions

View file

@ -360,8 +360,30 @@ function RepoCtrl($scope, Restangular, $routeParams, $rootScope, $location, $tim
});
};
$scope.loadImageChanges = function(image) {
$scope.currentImageChanges = null;
var changesFetch = Restangular.one('repository/' + namespace + '/' + name + '/image/' + image.id + '/changes');
changesFetch.get().then(function(changeInfo) {
$scope.currentImageChanges = changeInfo;
}, function() {
$scope.currentImageChanges = {};
});
};
$scope.getMoreCount = function(changes) {
if (!changes) { return 0; }
var addedDisplayed = Math.min(15, changes.added.length);
var removedDisplayed = Math.min(15, changes.removed.length);
var changedDisplayed = Math.min(15, changes.changed.length);
return (changes.added.length + changes.removed.length + changes.changed.length) -
addedDisplayed - removedDisplayed - changedDisplayed;
};
$scope.setImage = function(image) {
$scope.currentImage = image;
$scope.loadImageChanges(image);
if ($scope.tree) {
$scope.tree.setImage($scope.currentImage.id);
}
@ -382,6 +404,7 @@ function RepoCtrl($scope, Restangular, $routeParams, $rootScope, $location, $tim
if (proposedTag) {
$scope.currentTag = proposedTag;
$scope.currentImage = $scope.currentTag.image;
$scope.loadImageChanges($scope.currentImage);
if ($scope.tree) {
$scope.tree.setTag($scope.currentTag.name);
}