Abstract out an expiration status view into its own component
This commit is contained in:
parent
c5d8b5f86b
commit
977539bf08
7 changed files with 78 additions and 48 deletions
|
@ -80,32 +80,19 @@ angular.module('quay').directive('serviceKeysManager', function () {
|
|||
return moment(key.created_date).add(key.rotation_duration, 's').format('LLL');
|
||||
};
|
||||
|
||||
$scope.getExpirationInfo = function(key) {
|
||||
$scope.willRotate = function(key) {
|
||||
if (!key.expiration_date) {
|
||||
return '';
|
||||
return false;
|
||||
}
|
||||
|
||||
if (key.rotation_duration) {
|
||||
var rotate_date = moment(key.created_date).add(key.rotation_duration, 's')
|
||||
if (moment().isBefore(rotate_date)) {
|
||||
return {'className': 'rotation', 'icon': 'fa-refresh', 'willRotate': true};
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
expiration_date = moment(key.expiration_date);
|
||||
if (moment().isAfter(expiration_date)) {
|
||||
return {'className': 'expired', 'icon': 'fa-warning'};
|
||||
}
|
||||
|
||||
if (moment().add(1, 'week').isAfter(expiration_date)) {
|
||||
return {'className': 'critical', 'icon': 'fa-warning'};
|
||||
}
|
||||
|
||||
if (moment().add(1, 'month').isAfter(expiration_date)) {
|
||||
return {'className': 'warning', 'icon': 'fa-warning'};
|
||||
}
|
||||
|
||||
return {'className': 'info', 'icon': 'fa-check'};
|
||||
return false;
|
||||
};
|
||||
|
||||
$scope.showChangeName = function(key) {
|
||||
|
|
Reference in a new issue