Add a banner to the Quay UI when an app specific token is about to expire
This commit is contained in:
parent
5b4f5f9859
commit
888b564a9b
9 changed files with 60 additions and 9 deletions
|
@ -1,4 +1,11 @@
|
|||
<div class="announcement inline quay-message-bar-element" ng-show="messages.length">
|
||||
<div ng-repeat="token in NotificationService.expiringAppTokens">
|
||||
<div class="quay-service-status-description warning">
|
||||
Your external application token <strong style="display: inline-block; padding: 4px;">{{ token.title }}</strong>
|
||||
will be expiring <strong style="display: inline-block; padding: 4px;"><time-ago datetime="token.expiration"></time-ago></strong>.
|
||||
Please create a new token and revoke this token in user settings.
|
||||
</div>
|
||||
</div>
|
||||
<div ng-repeat="message in messages">
|
||||
<div class="quay-service-status-description" ng-class="message.severity">
|
||||
<span ng-switch on="message.media_type">
|
||||
|
|
|
@ -9,8 +9,10 @@ angular.module('quay').directive('quayMessageBar', function () {
|
|||
transclude: false,
|
||||
restrict: 'C',
|
||||
scope: {},
|
||||
controller: function ($scope, $element, ApiService) {
|
||||
controller: function ($scope, $element, ApiService, NotificationService) {
|
||||
$scope.messages = [];
|
||||
$scope.NotificationService = NotificationService;
|
||||
|
||||
ApiService.getGlobalMessages().then(function (data) {
|
||||
$scope.messages = data['messages'] || [];
|
||||
}, function (resp) {
|
||||
|
|
|
@ -14,7 +14,8 @@ export class AppSpecificTokenManagerComponent {
|
|||
private tokenCredentials: any;
|
||||
private revokeTokenInfo: any;
|
||||
|
||||
constructor(@Inject('ApiService') private ApiService: any, @Inject('UserService') private UserService: any) {
|
||||
constructor(@Inject('ApiService') private ApiService: any, @Inject('UserService') private UserService: any,
|
||||
@Inject('NotificationService') private NotificationService: any) {
|
||||
this.loadTokens();
|
||||
}
|
||||
|
||||
|
@ -49,6 +50,9 @@ export class AppSpecificTokenManagerComponent {
|
|||
|
||||
this.ApiService.revokeAppToken(null, params).then((resp) => {
|
||||
this.loadTokens();
|
||||
|
||||
// Update the notification service so it hides any banners if we revoked an expiring token.
|
||||
this.NotificationService.update();
|
||||
callback(true);
|
||||
}, errorHandler);
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ function($rootScope, $interval, UserService, ApiService, StringBuilderService, P
|
|||
'notifications': [],
|
||||
'notificationClasses': [],
|
||||
'notificationSummaries': [],
|
||||
'expiringAppTokens': [],
|
||||
'additionalNotifications': false
|
||||
};
|
||||
|
||||
|
@ -272,6 +273,13 @@ function($rootScope, $interval, UserService, ApiService, StringBuilderService, P
|
|||
notificationService.additionalNotifications = resp['additional'];
|
||||
notificationService.notificationClasses = notificationService.getClasses(notificationService.notifications);
|
||||
});
|
||||
|
||||
var params = {
|
||||
'expiring': true
|
||||
};
|
||||
ApiService.listAppTokens(null, params).then(function(resp) {
|
||||
notificationService.expiringAppTokens = resp['tokens'];
|
||||
});
|
||||
};
|
||||
|
||||
notificationService.reset = function() {
|
||||
|
|
Reference in a new issue