This repository has been archived on 2020-03-24. You can view files and clone it, but cannot push or open issues or pull requests.
quay/static/js/directives/ui/image-changes-view.js
2015-03-11 17:46:50 -07:00

34 lines
1.1 KiB
JavaScript

/**
* An element which loads and displays UI representing the changes made in an image.
*/
angular.module('quay').directive('imageChangesView', function () {
var directiveDefinitionObject = {
priority: 0,
templateUrl: '/static/directives/image-changes-view.html',
replace: false,
transclude: false,
restrict: 'C',
scope: {
'repository': '=repository',
'image': '=image',
'hasChanges': '=hasChanges'
},
controller: function($scope, $element, ApiService) {
$scope.$watch('image', function() {
if (!$scope.image || !$scope.repository) { return; }
var params = {
'repository': $scope.repository.namespace + '/' + $scope.repository.name,
'image_id': $scope.image
};
$scope.hasChanges = true;
$scope.imageChangesResource = ApiService.getImageChangesAsResource(params).get(function(resp) {
$scope.changeData = resp;
$scope.hasChanges = resp.added.length || resp.removed.length || resp.changed.length;
});
});
}
};
return directiveDefinitionObject;
});