Finish basic notifications system and verify it works for the "password_required" notification.
This commit is contained in:
parent
f186fa2888
commit
578add3b9e
7 changed files with 128 additions and 12 deletions
|
@ -494,10 +494,26 @@ quayApp = angular.module('quay', ['ngRoute', 'chieffancypants.loadingBar', 'angu
|
|||
'test_notification': {
|
||||
'level': 'primary',
|
||||
'summary': 'This is a test notification',
|
||||
'message': 'This notification is a long message for testing'
|
||||
'message': 'This notification is a long message for testing',
|
||||
'page': '/about/'
|
||||
},
|
||||
'password_required': {
|
||||
'level': 'error',
|
||||
'summary': 'A password is needed for your account',
|
||||
'message': 'In order to begin pushing and pulling repositories to Quay.io, a password must be set for your account',
|
||||
'page': '/user?tab=password'
|
||||
}
|
||||
};
|
||||
|
||||
notificationService.getPage = function(notification) {
|
||||
return notificationKinds[notification['kind']]['page'];
|
||||
};
|
||||
|
||||
notificationService.getMessage = function(notification) {
|
||||
var kindInfo = notificationKinds[notification['kind']];
|
||||
return StringBuilderService.buildString(kindInfo['message'], notification['metadata']);
|
||||
};
|
||||
|
||||
notificationService.getSummary = function(notification) {
|
||||
var kindInfo = notificationKinds[notification['kind']];
|
||||
return StringBuilderService.buildString(kindInfo['summary'], notification['metadata']);
|
||||
|
@ -512,16 +528,25 @@ quayApp = angular.module('quay', ['ngRoute', 'chieffancypants.loadingBar', 'angu
|
|||
return summaries.join('<br>');
|
||||
};
|
||||
|
||||
notificationService.getClass = function(notification) {
|
||||
return 'notification-' + notificationKinds[notification['kind']]['level'];
|
||||
};
|
||||
|
||||
notificationService.getClasses = function(notifications) {
|
||||
var classes = [];
|
||||
for (var i = 0; i < notifications.length; ++i) {
|
||||
var notification = notifications[i];
|
||||
classes.push('notification-' + notificationKinds[notification['kind']]['level']);
|
||||
classes.push(notificationService.getClass(notification));
|
||||
}
|
||||
return classes.join(' ');
|
||||
};
|
||||
|
||||
notificationService.update = function() {
|
||||
var user = UserService.currentUser();
|
||||
if (!user || user.anonymous) {
|
||||
return;
|
||||
}
|
||||
|
||||
ApiService.listUserNotifications().then(function(resp) {
|
||||
notificationService.notifications = resp['notifications'];
|
||||
notificationService.notificationClasses = notificationService.getClasses(notificationService.notifications);
|
||||
|
@ -3320,6 +3345,49 @@ quayApp.directive('buildProgress', function () {
|
|||
});
|
||||
|
||||
|
||||
quayApp.directive('notificationView', function () {
|
||||
var directiveDefinitionObject = {
|
||||
priority: 0,
|
||||
templateUrl: '/static/directives/notification-view.html',
|
||||
replace: false,
|
||||
transclude: false,
|
||||
restrict: 'C',
|
||||
scope: {
|
||||
'notification': '=notification',
|
||||
'parent': '=parent'
|
||||
},
|
||||
controller: function($scope, $element, $location, NotificationService) {
|
||||
$scope.getMessage = function(notification) {
|
||||
return NotificationService.getMessage(notification);
|
||||
};
|
||||
|
||||
$scope.parseDate = function(dateString) {
|
||||
return Date.parse(dateString);
|
||||
};
|
||||
|
||||
$scope.showNotification = function() {
|
||||
var url = NotificationService.getPage($scope.notification);
|
||||
if (url) {
|
||||
var parts = url.split('?')
|
||||
$location.path(parts[0]);
|
||||
|
||||
if (parts.length > 1) {
|
||||
$location.search(parts[1]);
|
||||
}
|
||||
|
||||
$scope.parent.$hide();
|
||||
}
|
||||
};
|
||||
|
||||
$scope.getClass = function(notification) {
|
||||
return NotificationService.getClass(notification);
|
||||
};
|
||||
}
|
||||
};
|
||||
return directiveDefinitionObject;
|
||||
});
|
||||
|
||||
|
||||
quayApp.directive('dockerfileBuildDialog', function () {
|
||||
var directiveDefinitionObject = {
|
||||
priority: 0,
|
||||
|
|
Reference in a new issue