Commit 1db8e559 by Ben Petersen Committed by GitHub

Merge pull request #183 from benjaminapetersen/bpeterse/notification-config

Add ui config for notifications
parents 66dc55b0 37ed3693
...@@ -408,7 +408,9 @@ hawtioPluginLoader.addModule('openshiftCommonUI'); ...@@ -408,7 +408,9 @@ hawtioPluginLoader.addModule('openshiftCommonUI');
$templateCache.put('src/components/toast-notifications/toast-notifications.html', $templateCache.put('src/components/toast-notifications/toast-notifications.html',
"<div class=\"toast-notifications-list-pf\">\n" + "<div class=\"toast-notifications-list-pf\">\n" +
" <div ng-repeat=\"(notificationID, notification) in notifications track by notification.trackByID\" ng-if=\"!notification.hidden || notification.isHover\"\n" + " <div\n" +
" ng-repeat=\"(notificationID, notification) in notifications track by notification.trackByID\"\n" +
" ng-if=\"!notification.hidden || notification.isHover\"\n" +
" ng-mouseenter=\"setHover(notification, true)\" ng-mouseleave=\"setHover(notification, false)\">\n" + " ng-mouseenter=\"setHover(notification, true)\" ng-mouseleave=\"setHover(notification, false)\">\n" +
" <div class=\"toast-pf alert {{notification.type | alertStatus}}\" ng-class=\"{'alert-dismissable': !hideCloseButton}\">\n" + " <div class=\"toast-pf alert {{notification.type | alertStatus}}\" ng-class=\"{'alert-dismissable': !hideCloseButton}\">\n" +
" <button ng-if=\"!hideCloseButton\" type=\"button\" class=\"close\" ng-click=\"close(notification)\">\n" + " <button ng-if=\"!hideCloseButton\" type=\"button\" class=\"close\" ng-click=\"close(notification)\">\n" +
...@@ -1185,6 +1187,9 @@ angular.module('openshiftCommonUI') ...@@ -1185,6 +1187,9 @@ angular.module('openshiftCommonUI')
// Listen for updates from NotificationsService to show a notification. // Listen for updates from NotificationsService to show a notification.
var deregisterNotificationListener = $rootScope.$on('NotificationsService.onNotificationAdded', function(event, notification) { var deregisterNotificationListener = $rootScope.$on('NotificationsService.onNotificationAdded', function(event, notification) {
if (notification.skipToast) {
return;
}
$scope.$evalAsync(function() { $scope.$evalAsync(function() {
$scope.notifications.push(notification); $scope.notifications.push(notification);
if (NotificationsService.isAutoDismiss(notification)) { if (NotificationsService.isAutoDismiss(notification)) {
...@@ -2152,6 +2157,8 @@ angular.module('openshiftCommonUI').provider('NotificationsService', function() ...@@ -2152,6 +2157,8 @@ angular.module('openshiftCommonUI').provider('NotificationsService', function()
// notifications may already have an id that is not necessarily unique, // notifications may already have an id that is not necessarily unique,
// this is an explicitly unique id just for `track by` in templates // this is an explicitly unique id just for `track by` in templates
notification.trackByID = _.uniqueId('notification-') + Date.now(); notification.trackByID = _.uniqueId('notification-') + Date.now();
notification.skipToast = notification.skipToast || false;
notification.showInDrawer = notification.showInDrawer || false;
notification.timestamp = new Date().toISOString(); notification.timestamp = new Date().toISOString();
if (isNotificationPermanentlyHidden(notification) || isNotificationVisible(notification)) { if (isNotificationPermanentlyHidden(notification) || isNotificationVisible(notification)) {
return; return;
......
...@@ -579,7 +579,9 @@ hawtioPluginLoader.addModule('openshiftCommonUI'); ...@@ -579,7 +579,9 @@ hawtioPluginLoader.addModule('openshiftCommonUI');
$templateCache.put('src/components/toast-notifications/toast-notifications.html', $templateCache.put('src/components/toast-notifications/toast-notifications.html',
"<div class=\"toast-notifications-list-pf\">\n" + "<div class=\"toast-notifications-list-pf\">\n" +
" <div ng-repeat=\"(notificationID, notification) in notifications track by notification.trackByID\" ng-if=\"!notification.hidden || notification.isHover\"\n" + " <div\n" +
" ng-repeat=\"(notificationID, notification) in notifications track by notification.trackByID\"\n" +
" ng-if=\"!notification.hidden || notification.isHover\"\n" +
" ng-mouseenter=\"setHover(notification, true)\" ng-mouseleave=\"setHover(notification, false)\">\n" + " ng-mouseenter=\"setHover(notification, true)\" ng-mouseleave=\"setHover(notification, false)\">\n" +
" <div class=\"toast-pf alert {{notification.type | alertStatus}}\" ng-class=\"{'alert-dismissable': !hideCloseButton}\">\n" + " <div class=\"toast-pf alert {{notification.type | alertStatus}}\" ng-class=\"{'alert-dismissable': !hideCloseButton}\">\n" +
" <button ng-if=\"!hideCloseButton\" type=\"button\" class=\"close\" ng-click=\"close(notification)\">\n" + " <button ng-if=\"!hideCloseButton\" type=\"button\" class=\"close\" ng-click=\"close(notification)\">\n" +
...@@ -1356,6 +1358,9 @@ angular.module('openshiftCommonUI') ...@@ -1356,6 +1358,9 @@ angular.module('openshiftCommonUI')
// Listen for updates from NotificationsService to show a notification. // Listen for updates from NotificationsService to show a notification.
var deregisterNotificationListener = $rootScope.$on('NotificationsService.onNotificationAdded', function(event, notification) { var deregisterNotificationListener = $rootScope.$on('NotificationsService.onNotificationAdded', function(event, notification) {
if (notification.skipToast) {
return;
}
$scope.$evalAsync(function() { $scope.$evalAsync(function() {
$scope.notifications.push(notification); $scope.notifications.push(notification);
if (NotificationsService.isAutoDismiss(notification)) { if (NotificationsService.isAutoDismiss(notification)) {
...@@ -5763,6 +5768,8 @@ angular.module('openshiftCommonUI').provider('NotificationsService', function() ...@@ -5763,6 +5768,8 @@ angular.module('openshiftCommonUI').provider('NotificationsService', function()
// notifications may already have an id that is not necessarily unique, // notifications may already have an id that is not necessarily unique,
// this is an explicitly unique id just for `track by` in templates // this is an explicitly unique id just for `track by` in templates
notification.trackByID = _.uniqueId('notification-') + Date.now(); notification.trackByID = _.uniqueId('notification-') + Date.now();
notification.skipToast = notification.skipToast || false;
notification.showInDrawer = notification.showInDrawer || false;
notification.timestamp = new Date().toISOString(); notification.timestamp = new Date().toISOString();
if (isNotificationPermanentlyHidden(notification) || isNotificationVisible(notification)) { if (isNotificationPermanentlyHidden(notification) || isNotificationVisible(notification)) {
return; return;
......
...@@ -379,7 +379,9 @@ angular.module('openshiftCommonUI').run(['$templateCache', function($templateCac ...@@ -379,7 +379,9 @@ angular.module('openshiftCommonUI').run(['$templateCache', function($templateCac
$templateCache.put('src/components/toast-notifications/toast-notifications.html', $templateCache.put('src/components/toast-notifications/toast-notifications.html',
"<div class=\"toast-notifications-list-pf\">\n" + "<div class=\"toast-notifications-list-pf\">\n" +
" <div ng-repeat=\"(notificationID, notification) in notifications track by notification.trackByID\" ng-if=\"!notification.hidden || notification.isHover\"\n" + " <div\n" +
" ng-repeat=\"(notificationID, notification) in notifications track by notification.trackByID\"\n" +
" ng-if=\"!notification.hidden || notification.isHover\"\n" +
" ng-mouseenter=\"setHover(notification, true)\" ng-mouseleave=\"setHover(notification, false)\">\n" + " ng-mouseenter=\"setHover(notification, true)\" ng-mouseleave=\"setHover(notification, false)\">\n" +
" <div class=\"toast-pf alert {{notification.type | alertStatus}}\" ng-class=\"{'alert-dismissable': !hideCloseButton}\">\n" + " <div class=\"toast-pf alert {{notification.type | alertStatus}}\" ng-class=\"{'alert-dismissable': !hideCloseButton}\">\n" +
" <button ng-if=\"!hideCloseButton\" type=\"button\" class=\"close\" ng-click=\"close(notification)\">\n" + " <button ng-if=\"!hideCloseButton\" type=\"button\" class=\"close\" ng-click=\"close(notification)\">\n" +
......
<div class="toast-notifications-list-pf"> <div class="toast-notifications-list-pf">
<div ng-repeat="(notificationID, notification) in notifications track by notification.trackByID" ng-if="!notification.hidden || notification.isHover" <div
ng-repeat="(notificationID, notification) in notifications track by notification.trackByID"
ng-if="!notification.hidden || notification.isHover"
ng-mouseenter="setHover(notification, true)" ng-mouseleave="setHover(notification, false)"> ng-mouseenter="setHover(notification, true)" ng-mouseleave="setHover(notification, false)">
<div class="toast-pf alert {{notification.type | alertStatus}}" ng-class="{'alert-dismissable': !hideCloseButton}"> <div class="toast-pf alert {{notification.type | alertStatus}}" ng-class="{'alert-dismissable': !hideCloseButton}">
<button ng-if="!hideCloseButton" type="button" class="close" ng-click="close(notification)"> <button ng-if="!hideCloseButton" type="button" class="close" ng-click="close(notification)">
......
...@@ -56,6 +56,9 @@ angular.module('openshiftCommonUI') ...@@ -56,6 +56,9 @@ angular.module('openshiftCommonUI')
// Listen for updates from NotificationsService to show a notification. // Listen for updates from NotificationsService to show a notification.
var deregisterNotificationListener = $rootScope.$on('NotificationsService.onNotificationAdded', function(event, notification) { var deregisterNotificationListener = $rootScope.$on('NotificationsService.onNotificationAdded', function(event, notification) {
if (notification.skipToast) {
return;
}
$scope.$evalAsync(function() { $scope.$evalAsync(function() {
$scope.notifications.push(notification); $scope.notifications.push(notification);
if (NotificationsService.isAutoDismiss(notification)) { if (NotificationsService.isAutoDismiss(notification)) {
......
...@@ -21,6 +21,8 @@ angular.module('openshiftCommonUI').provider('NotificationsService', function() ...@@ -21,6 +21,8 @@ angular.module('openshiftCommonUI').provider('NotificationsService', function()
// notifications may already have an id that is not necessarily unique, // notifications may already have an id that is not necessarily unique,
// this is an explicitly unique id just for `track by` in templates // this is an explicitly unique id just for `track by` in templates
notification.trackByID = _.uniqueId('notification-') + Date.now(); notification.trackByID = _.uniqueId('notification-') + Date.now();
notification.skipToast = notification.skipToast || false;
notification.showInDrawer = notification.showInDrawer || false;
notification.timestamp = new Date().toISOString(); notification.timestamp = new Date().toISOString();
if (isNotificationPermanentlyHidden(notification) || isNotificationVisible(notification)) { if (isNotificationPermanentlyHidden(notification) || isNotificationVisible(notification)) {
return; return;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment