parent
53ce4de6aa
commit
2cbdecb043
23 changed files with 584 additions and 116 deletions
|
@ -61,6 +61,10 @@ angular.module("core-config-setup", ['angularFileUpload'])
|
|||
|
||||
{'id': 'gitlab-trigger', 'title': 'GitLab Build Triggers', 'condition': function(config) {
|
||||
return config.FEATURE_GITLAB_BUILD;
|
||||
}},
|
||||
|
||||
{'id': 'security-scanner', 'title': 'Quay Security Scanner', 'condition': function(config) {
|
||||
return config.FEATURE_SECURITY_SCANNER;
|
||||
}}
|
||||
];
|
||||
|
||||
|
@ -1029,6 +1033,87 @@ angular.module("core-config-setup", ['angularFileUpload'])
|
|||
return directiveDefinitionObject;
|
||||
})
|
||||
|
||||
.directive('configServiceKeyField', function (ApiService) {
|
||||
var directiveDefinitionObject = {
|
||||
priority: 0,
|
||||
templateUrl: '/static/directives/config/config-service-key-field.html',
|
||||
replace: false,
|
||||
transclude: false,
|
||||
restrict: 'C',
|
||||
scope: {
|
||||
'serviceName': '@serviceName',
|
||||
},
|
||||
controller: function($scope, $element) {
|
||||
$scope.foundKeys = [];
|
||||
$scope.loading = false;
|
||||
$scope.loadError = false;
|
||||
$scope.hasValidKey = false;
|
||||
$scope.hasValidKeyStr = null;
|
||||
|
||||
$scope.updateKeys = function() {
|
||||
$scope.foundKeys = [];
|
||||
$scope.loading = true;
|
||||
|
||||
ApiService.listServiceKeys().then(function(resp) {
|
||||
$scope.loading = false;
|
||||
$scope.loadError = false;
|
||||
|
||||
resp['keys'].forEach(function(key) {
|
||||
if (key['service'] == $scope.serviceName) {
|
||||
$scope.foundKeys.push(key);
|
||||
}
|
||||
});
|
||||
|
||||
$scope.hasValidKey = checkValidKey($scope.foundKeys);
|
||||
$scope.hasValidKeyStr = $scope.hasValidKey ? 'true' : '';
|
||||
}, function() {
|
||||
$scope.loading = false;
|
||||
$scope.loadError = true;
|
||||
});
|
||||
};
|
||||
|
||||
// Perform initial loading of the keys.
|
||||
$scope.updateKeys();
|
||||
|
||||
$scope.isKeyExpired = function(key) {
|
||||
if (key.expiration_date != null) {
|
||||
var expiration_date = moment(key.expiration_date);
|
||||
return moment().isAfter(expiration_date);
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
$scope.showRequestServiceKey = function() {
|
||||
$scope.requestKeyInfo = {
|
||||
'service': $scope.serviceName
|
||||
};
|
||||
};
|
||||
|
||||
$scope.handleKeyCreated = function() {
|
||||
$scope.updateKeys();
|
||||
};
|
||||
|
||||
var checkValidKey = function(keys) {
|
||||
for (var i = 0; i < keys.length; ++i) {
|
||||
var key = keys[i];
|
||||
if (!key.approval) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($scope.isKeyExpired(key)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
}
|
||||
};
|
||||
return directiveDefinitionObject;
|
||||
})
|
||||
|
||||
.directive('configStringField', function () {
|
||||
var directiveDefinitionObject = {
|
||||
priority: 0,
|
||||
|
|
Reference in a new issue