initial import for Open Source 🎉
This commit is contained in:
parent
1898c361f3
commit
9c0dd3b722
2048 changed files with 218743 additions and 0 deletions
44
static/js/directives/ui/resource-view.js
Normal file
44
static/js/directives/ui/resource-view.js
Normal file
|
@ -0,0 +1,44 @@
|
|||
/**
|
||||
* An element which displays either a resource (if present) or an error message if the resource
|
||||
* failed to load.
|
||||
*/
|
||||
angular.module('quay').directive('resourceView', function () {
|
||||
var directiveDefinitionObject = {
|
||||
priority: 0,
|
||||
templateUrl: '/static/directives/resource-view.html',
|
||||
replace: false,
|
||||
transclude: true,
|
||||
restrict: 'C',
|
||||
scope: {
|
||||
'resource': '=resource',
|
||||
'resources': '=resources',
|
||||
'errorMessage': '=errorMessage'
|
||||
},
|
||||
controller: function($scope, $element) {
|
||||
$scope.getState = function() {
|
||||
if (!$scope.resources && !$scope.resource) {
|
||||
return 'loading';
|
||||
}
|
||||
|
||||
var resources = $scope.resources || [$scope.resource];
|
||||
if (!resources.length) {
|
||||
return 'loading';
|
||||
}
|
||||
|
||||
for (var i = 0; i < resources.length; ++i) {
|
||||
var current = resources[i];
|
||||
if (current.loading) {
|
||||
return 'loading';
|
||||
}
|
||||
|
||||
if (current.hasError) {
|
||||
return 'error';
|
||||
}
|
||||
}
|
||||
|
||||
return 'ready';
|
||||
};
|
||||
}
|
||||
};
|
||||
return directiveDefinitionObject;
|
||||
});
|
Reference in a new issue