initial import for Open Source 🎉
This commit is contained in:
parent
1898c361f3
commit
9c0dd3b722
2048 changed files with 218743 additions and 0 deletions
60
static/js/directives/ui/manifest-label-list.js
Normal file
60
static/js/directives/ui/manifest-label-list.js
Normal file
|
@ -0,0 +1,60 @@
|
|||
/**
|
||||
* An element which displays the labels on a repository manifest.
|
||||
*/
|
||||
angular.module('quay').directive('manifestLabelList', function () {
|
||||
var directiveDefinitionObject = {
|
||||
priority: 0,
|
||||
templateUrl: '/static/directives/manifest-label-list.html',
|
||||
replace: false,
|
||||
transclude: true,
|
||||
restrict: 'C',
|
||||
scope: {
|
||||
'repository': '=repository',
|
||||
'manifestDigest': '=manifestDigest',
|
||||
'cache': '=cache'
|
||||
},
|
||||
controller: function($scope, $element, ApiService) {
|
||||
$scope.labels = null;
|
||||
|
||||
var loadLabels = function() {
|
||||
if (!$scope.repository) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$scope.manifestDigest) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($scope.cache[$scope.manifestDigest]) {
|
||||
$scope.labels = $scope.cache[$scope.manifestDigest];
|
||||
return;
|
||||
}
|
||||
|
||||
$scope.labels = null;
|
||||
$scope.loadError = false;
|
||||
|
||||
var params = {
|
||||
'repository': $scope.repository.namespace + '/' + $scope.repository.name,
|
||||
'manifestref': $scope.manifestDigest
|
||||
};
|
||||
|
||||
ApiService.listManifestLabels(null, params).then(function(resp) {
|
||||
$scope.labels = resp['labels'];
|
||||
$scope.cache[$scope.manifestDigest] = resp['labels'];
|
||||
}, function() {
|
||||
$scope.loadError = true;
|
||||
});
|
||||
};
|
||||
|
||||
$scope.$watch('cache', function(cache) {
|
||||
if (cache && $scope.manifestDigest && $scope.labels && !cache[$scope.manifestDigest]) {
|
||||
loadLabels();
|
||||
}
|
||||
}, true);
|
||||
|
||||
$scope.$watch('repository', loadLabels);
|
||||
$scope.$watch('manifestDigest', loadLabels);
|
||||
}
|
||||
};
|
||||
return directiveDefinitionObject;
|
||||
});
|
Reference in a new issue