WIP: UI for QuaySec
This commit is contained in:
parent
75dfec7875
commit
8c144397e9
5 changed files with 177 additions and 1 deletions
|
@ -18,7 +18,7 @@ angular.module('quay').directive('repoPanelTags', function () {
|
|||
|
||||
'getImages': '&getImages'
|
||||
},
|
||||
controller: function($scope, $element, $filter, $location, ApiService, UIService) {
|
||||
controller: function($scope, $element, $filter, $location, ApiService, UIService, VulnerabilityService) {
|
||||
var orderBy = $filter('orderBy');
|
||||
|
||||
$scope.checkedTags = UIService.createCheckStateController([], 'name');
|
||||
|
@ -35,6 +35,7 @@ angular.module('quay').directive('repoPanelTags', function () {
|
|||
$scope.tagActionHandler = null;
|
||||
$scope.showingHistory = false;
|
||||
$scope.tagsPerPage = 50;
|
||||
$scope.tagVulnerabilities = {};
|
||||
|
||||
var setTagState = function() {
|
||||
if (!$scope.repository || !$scope.selectedTags) { return; }
|
||||
|
@ -149,6 +150,53 @@ angular.module('quay').directive('repoPanelTags', function () {
|
|||
setTagState();
|
||||
});
|
||||
|
||||
$scope.loadTagVulnerabilities = function(tag, tagData) {
|
||||
var params = {
|
||||
'tag': tag.name,
|
||||
'repository': $scope.repository.namespace + '/' + $scope.repository.name,
|
||||
};
|
||||
|
||||
ApiService.getRepoTagVulnerabilities(null, params).then(function(resp) {
|
||||
tagData.indexed = resp.security_indexed;
|
||||
tagData.loading = false;
|
||||
|
||||
if (resp.security_indexed) {
|
||||
tagData.hasVulnerabilities = !!resp.data.Vulnerabilities.length;
|
||||
tagData.vulnerabilities = resp.data.Vulnerabilities;
|
||||
|
||||
var highest = null;
|
||||
resp.data.Vulnerabilities.forEach(function(v) {
|
||||
if (highest == null ||
|
||||
VulnerabilityService.LEVELS[v.Priority].index < VulnerabilityService.LEVELS[highest.Priority].index) {
|
||||
highest = v;
|
||||
}
|
||||
});
|
||||
|
||||
tagData.highestVulnerability = highest;
|
||||
}
|
||||
}, function() {
|
||||
tagData.loading = false;
|
||||
tagData.hasError = true;
|
||||
});
|
||||
};
|
||||
|
||||
$scope.getTagVulnerabilities = function(tag) {
|
||||
if (!$scope.repository) {
|
||||
return
|
||||
}
|
||||
|
||||
var tagName = tag.name;
|
||||
if (!$scope.tagVulnerabilities[tagName]) {
|
||||
$scope.tagVulnerabilities[tagName] = {
|
||||
'loading': true
|
||||
};
|
||||
|
||||
$scope.loadTagVulnerabilities(tag, $scope.tagVulnerabilities[tagName]);
|
||||
}
|
||||
|
||||
return $scope.tagVulnerabilities[tagName];
|
||||
};
|
||||
|
||||
$scope.clearSelectedTags = function() {
|
||||
$scope.checkedTags.setChecked([]);
|
||||
};
|
||||
|
|
Reference in a new issue