-
Notifications
You must be signed in to change notification settings - Fork 231
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add notification-drawer to show curated list of events to user
- Show events that pass the white list in OPENSHIFT_CONSTANTS.EVENTS_TO_SHOW - Internal Notifications coming in next iteration - Add patternfly.notifications - add notification counter to top bar - add notification event service - add drawer-wrapper as a proxy to pf-notification-drawer - need our own controller for filtering, etc - Update event system to use $rootScope.$emit rather than a custom service - add sessionStorage cache to keep track of read/unread state - Debounce watch in notification service based on work recently done in DataService to support - Update web-common to 0.0.43, includes DataService.watch() flag - Add FEATURE_FLAG.global_event_watch_for_notification_drawer - kill switch in case watching events is too expensive - would still allow internal notifications to appear in drawer - Add link to events page, update index.html - Migrate EVENTS_TO_SHOW map out of EventsService into Constants
- Loading branch information
1 parent
3130e60
commit 52a0764
Showing
15 changed files
with
647 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 98 additions & 0 deletions
98
app/scripts/directives/notifications/notificationCounter.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
'use strict'; | ||
|
||
angular | ||
.module('openshiftConsole') | ||
.component('notificationCounter', { | ||
templateUrl: 'views/directives/notifications/notification-counter.html', | ||
bindings: {}, | ||
controller: [ | ||
'$routeParams', | ||
'$rootScope', | ||
'Constants', | ||
'DataService', | ||
function($routeParams, $rootScope, Constants, DataService) { | ||
var ENABLE_EVENT_WATCH = _.get(Constants, 'FEATURE_FLAGS.global_event_watch_for_notification_drawer'); | ||
var counter = this; | ||
var drawerHidden = true; | ||
|
||
var rootScopeWatches = []; | ||
// this one is treated separately from the rootScopeWatches as | ||
// it may need to be updated outside of the lifecycle of init/destroy | ||
var notificationListener; | ||
|
||
var eventsWatcher; | ||
|
||
var deregisterEventsWatch = function() { | ||
if(eventsWatcher) { | ||
DataService.unwatch(eventsWatcher); | ||
} | ||
}; | ||
|
||
var watchEvents = function(projectName, cb) { | ||
if(projectName && ENABLE_EVENT_WATCH) { | ||
eventsWatcher = DataService.watch('events', {namespace: projectName}, _.debounce(cb, 50), { skipDigest: true }); | ||
} | ||
}; | ||
|
||
var watchNotifications = function(projectName, cb) { | ||
if(!projectName) { | ||
return; | ||
} | ||
notificationListener = $rootScope.$on('NotificationsService.onNotificationAdded', cb); | ||
}; | ||
|
||
var deregisterNotificationListener = function() { | ||
notificationListener && notificationListener(); | ||
}; | ||
|
||
var deregisterRootScopeWatches = function() { | ||
_.each(rootScopeWatches, function(deregister) { | ||
deregister(); | ||
}); | ||
}; | ||
|
||
// TODO: since the current IMPL of the drawer doesn't support a "global" | ||
// empty state, need to hide the bell icon entirely if there are no messages | ||
// for a project. Otherwise, you open to get a blank panel. Thats not ideal. | ||
var toggleVisibility = function(projectName) { | ||
if(!projectName) { | ||
counter.hide = true; | ||
} | ||
counter.showNewNotificationIndicator = true; | ||
}; | ||
|
||
counter.onClick = function() { | ||
drawerHidden = !drawerHidden; | ||
counter.showNewNotificationIndicator = false; | ||
$rootScope.$emit('notification-drawer:show', { | ||
drawerHidden: drawerHidden | ||
}); | ||
}; | ||
|
||
var genericEventCallback = function() { | ||
counter.showNewNotificationIndicator = true; | ||
}; | ||
|
||
var reset = function() { | ||
deregisterEventsWatch(); | ||
deregisterNotificationListener(); | ||
watchEvents($routeParams.project, genericEventCallback); | ||
watchNotifications($routeParams.project, genericEventCallback); | ||
toggleVisibility($routeParams.project); | ||
}; | ||
|
||
counter.$onInit = function() { | ||
reset(); | ||
rootScopeWatches.push($rootScope.$on("$routeChangeSuccess", function () { | ||
reset(); | ||
})); | ||
}; | ||
|
||
counter.$onDestroy = function() { | ||
deregisterEventsWatch(); | ||
deregisterNotificationListener(); | ||
deregisterRootScopeWatches(); | ||
}; | ||
} | ||
] | ||
}); |
Oops, something went wrong.