Commit d5ae6b45 by Sam Padgett Committed by GitHub

Merge pull request #170 from benjaminapetersen/bpeterse/notification-update

Update notifications with id and timestamp
parents 722e481c 284898a5
...@@ -1250,7 +1250,9 @@ angular.module('openshiftCommonUI') ...@@ -1250,7 +1250,9 @@ angular.module('openshiftCommonUI')
return function (type) { return function (type) {
var status; var status;
switch(type) { // API events have just two types: Normal, Warning
// our notifications have four: info, success, error, and warning
switch(type.toLowerCase()) {
case 'error': case 'error':
status = 'alert-danger'; status = 'alert-danger';
break; break;
...@@ -1260,6 +1262,9 @@ angular.module('openshiftCommonUI') ...@@ -1260,6 +1262,9 @@ angular.module('openshiftCommonUI')
case 'success': case 'success':
status = 'alert-success'; status = 'alert-success';
break; break;
case 'normal':
status = 'alert-info';
break;
default: default:
status = 'alert-info'; status = 'alert-info';
} }
...@@ -1271,7 +1276,9 @@ angular.module('openshiftCommonUI') ...@@ -1271,7 +1276,9 @@ angular.module('openshiftCommonUI')
return function (type) { return function (type) {
var icon; var icon;
switch(type) { // API events have just two types: Normal, Warning
// our notifications have four: info, success, error, and warning
switch(type.toLowerCase()) {
case 'error': case 'error':
icon = 'pficon pficon-error-circle-o'; icon = 'pficon pficon-error-circle-o';
break; break;
...@@ -1281,6 +1288,9 @@ angular.module('openshiftCommonUI') ...@@ -1281,6 +1288,9 @@ angular.module('openshiftCommonUI')
case 'success': case 'success':
icon = 'pficon pficon-ok'; icon = 'pficon pficon-ok';
break; break;
case 'normal':
icon = 'pficon pficon-info';
break;
default: default:
icon = 'pficon pficon-info'; icon = 'pficon pficon-info';
} }
...@@ -2139,6 +2149,8 @@ angular.module('openshiftCommonUI').provider('NotificationsService', function() ...@@ -2139,6 +2149,8 @@ angular.module('openshiftCommonUI').provider('NotificationsService', function()
}; };
var addNotification = function (notification) { var addNotification = function (notification) {
notification.id = notification.id || _.uniqueId('notification-');
notification.timestamp = new Date().toISOString();
if (isNotificationPermanentlyHidden(notification) || isNotificationVisible(notification)) { if (isNotificationPermanentlyHidden(notification) || isNotificationVisible(notification)) {
return; return;
} }
......
...@@ -1421,7 +1421,9 @@ angular.module('openshiftCommonUI') ...@@ -1421,7 +1421,9 @@ angular.module('openshiftCommonUI')
return function (type) { return function (type) {
var status; var status;
switch(type) { // API events have just two types: Normal, Warning
// our notifications have four: info, success, error, and warning
switch(type.toLowerCase()) {
case 'error': case 'error':
status = 'alert-danger'; status = 'alert-danger';
break; break;
...@@ -1431,6 +1433,9 @@ angular.module('openshiftCommonUI') ...@@ -1431,6 +1433,9 @@ angular.module('openshiftCommonUI')
case 'success': case 'success':
status = 'alert-success'; status = 'alert-success';
break; break;
case 'normal':
status = 'alert-info';
break;
default: default:
status = 'alert-info'; status = 'alert-info';
} }
...@@ -1442,7 +1447,9 @@ angular.module('openshiftCommonUI') ...@@ -1442,7 +1447,9 @@ angular.module('openshiftCommonUI')
return function (type) { return function (type) {
var icon; var icon;
switch(type) { // API events have just two types: Normal, Warning
// our notifications have four: info, success, error, and warning
switch(type.toLowerCase()) {
case 'error': case 'error':
icon = 'pficon pficon-error-circle-o'; icon = 'pficon pficon-error-circle-o';
break; break;
...@@ -1452,6 +1459,9 @@ angular.module('openshiftCommonUI') ...@@ -1452,6 +1459,9 @@ angular.module('openshiftCommonUI')
case 'success': case 'success':
icon = 'pficon pficon-ok'; icon = 'pficon pficon-ok';
break; break;
case 'normal':
icon = 'pficon pficon-info';
break;
default: default:
icon = 'pficon pficon-info'; icon = 'pficon pficon-info';
} }
...@@ -5660,6 +5670,8 @@ angular.module('openshiftCommonUI').provider('NotificationsService', function() ...@@ -5660,6 +5670,8 @@ angular.module('openshiftCommonUI').provider('NotificationsService', function()
}; };
var addNotification = function (notification) { var addNotification = function (notification) {
notification.id = notification.id || _.uniqueId('notification-');
notification.timestamp = new Date().toISOString();
if (isNotificationPermanentlyHidden(notification) || isNotificationVisible(notification)) { if (isNotificationPermanentlyHidden(notification) || isNotificationVisible(notification)) {
return; return;
} }
......
...@@ -488,7 +488,7 @@ content ? (scope.truncatedContent = truncateFilter(content, scope.limit, scope.u ...@@ -488,7 +488,7 @@ content ? (scope.truncatedContent = truncateFilter(content, scope.limit, scope.u
} ]), angular.module("openshiftCommonUI").filter("alertStatus", function() { } ]), angular.module("openshiftCommonUI").filter("alertStatus", function() {
return function(type) { return function(type) {
var status; var status;
switch (type) { switch (type.toLowerCase()) {
case "error": case "error":
status = "alert-danger"; status = "alert-danger";
break; break;
...@@ -501,6 +501,10 @@ case "success": ...@@ -501,6 +501,10 @@ case "success":
status = "alert-success"; status = "alert-success";
break; break;
case "normal":
status = "alert-info";
break;
default: default:
status = "alert-info"; status = "alert-info";
} }
...@@ -509,7 +513,7 @@ return status; ...@@ -509,7 +513,7 @@ return status;
}).filter("alertIcon", function() { }).filter("alertIcon", function() {
return function(type) { return function(type) {
var icon; var icon;
switch (type) { switch (type.toLowerCase()) {
case "error": case "error":
icon = "pficon pficon-error-circle-o"; icon = "pficon pficon-error-circle-o";
break; break;
...@@ -522,6 +526,10 @@ case "success": ...@@ -522,6 +526,10 @@ case "success":
icon = "pficon pficon-ok"; icon = "pficon pficon-ok";
break; break;
case "normal":
icon = "pficon pficon-info";
break;
default: default:
icon = "pficon pficon-info"; icon = "pficon pficon-info";
} }
...@@ -2378,7 +2386,7 @@ this.dismissDelay = 8e3, this.autoDismissTypes = [ "info", "success" ], this.$ge ...@@ -2378,7 +2386,7 @@ this.dismissDelay = 8e3, this.autoDismissTypes = [ "info", "success" ], this.$ge
var notifications = [], dismissDelay = this.dismissDelay, autoDismissTypes = this.autoDismissTypes, notificationHiddenKey = function(notificationID, namespace) { var notifications = [], dismissDelay = this.dismissDelay, autoDismissTypes = this.autoDismissTypes, notificationHiddenKey = function(notificationID, namespace) {
return namespace ? "hide/notification/" + namespace + "/" + notificationID :"hide/notification/" + notificationID; return namespace ? "hide/notification/" + namespace + "/" + notificationID :"hide/notification/" + notificationID;
}, addNotification = function(notification) { }, addNotification = function(notification) {
isNotificationPermanentlyHidden(notification) || isNotificationVisible(notification) || (notifications.push(notification), $rootScope.$emit("NotificationsService.onNotificationAdded", notification)); notification.id = notification.id || _.uniqueId("notification-"), notification.timestamp = new Date().toISOString(), isNotificationPermanentlyHidden(notification) || isNotificationVisible(notification) || (notifications.push(notification), $rootScope.$emit("NotificationsService.onNotificationAdded", notification));
}, hideNotification = function(notificationID) { }, hideNotification = function(notificationID) {
notificationID && _.each(notifications, function(notification) { notificationID && _.each(notifications, function(notification) {
notification.id === notificationID && (notification.hidden = !0); notification.id === notificationID && (notification.hidden = !0);
......
...@@ -5,7 +5,9 @@ angular.module('openshiftCommonUI') ...@@ -5,7 +5,9 @@ angular.module('openshiftCommonUI')
return function (type) { return function (type) {
var status; var status;
switch(type) { // API events have just two types: Normal, Warning
// our notifications have four: info, success, error, and warning
switch(type.toLowerCase()) {
case 'error': case 'error':
status = 'alert-danger'; status = 'alert-danger';
break; break;
...@@ -15,6 +17,9 @@ angular.module('openshiftCommonUI') ...@@ -15,6 +17,9 @@ angular.module('openshiftCommonUI')
case 'success': case 'success':
status = 'alert-success'; status = 'alert-success';
break; break;
case 'normal':
status = 'alert-info';
break;
default: default:
status = 'alert-info'; status = 'alert-info';
} }
...@@ -26,7 +31,9 @@ angular.module('openshiftCommonUI') ...@@ -26,7 +31,9 @@ angular.module('openshiftCommonUI')
return function (type) { return function (type) {
var icon; var icon;
switch(type) { // API events have just two types: Normal, Warning
// our notifications have four: info, success, error, and warning
switch(type.toLowerCase()) {
case 'error': case 'error':
icon = 'pficon pficon-error-circle-o'; icon = 'pficon pficon-error-circle-o';
break; break;
...@@ -36,6 +43,9 @@ angular.module('openshiftCommonUI') ...@@ -36,6 +43,9 @@ angular.module('openshiftCommonUI')
case 'success': case 'success':
icon = 'pficon pficon-ok'; icon = 'pficon pficon-ok';
break; break;
case 'normal':
icon = 'pficon pficon-info';
break;
default: default:
icon = 'pficon pficon-info'; icon = 'pficon pficon-info';
} }
......
...@@ -18,6 +18,8 @@ angular.module('openshiftCommonUI').provider('NotificationsService', function() ...@@ -18,6 +18,8 @@ angular.module('openshiftCommonUI').provider('NotificationsService', function()
}; };
var addNotification = function (notification) { var addNotification = function (notification) {
notification.id = notification.id || _.uniqueId('notification-');
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