-
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 - Add naviateEventInvolvedObjectURL filter for drawer & events - Update Events service to track read, cleared, namespace SessionStorage, etc - Animate w/a fade-out when a notification is cleared to ensure user notices the subtle change - Add BrowserStorage service - auto namespace openshift- on all Local & Session storage keys - Add links to objects in event-sidebar - Disabled in IE & Edge due to insufficient watches
- Loading branch information
1 parent
cf0278b
commit 03fac47
Showing
24 changed files
with
1,187 additions
and
42 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
114 changes: 114 additions & 0 deletions
114
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,114 @@ | ||
'use strict'; | ||
(function() { | ||
|
||
angular | ||
.module('openshiftConsole') | ||
.component('notificationCounter', { | ||
templateUrl: 'views/directives/notifications/notification-counter.html', | ||
bindings: {}, | ||
controller: [ | ||
'$filter', | ||
'$routeParams', | ||
'$rootScope', | ||
'AuthService', | ||
'Constants', | ||
NotificationCounter | ||
] | ||
}); | ||
|
||
function NotificationCounter($filter, $routeParams, $rootScope, AuthService, Constants) { | ||
|
||
var counter = this; | ||
var DISABLE_GLOBAL_EVENT_WATCH = _.get(Constants, 'DISABLE_GLOBAL_EVENT_WATCH'); | ||
var LIMIT_WATCHES = $filter('isIE')() || $filter('isEdge')(); | ||
|
||
counter.hide = 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 notificationListeners = []; | ||
|
||
var watchNotificationDrawerCount = function(projectName, cb) { | ||
if(!projectName) { | ||
return; | ||
} | ||
notificationListeners.push($rootScope.$on('NotificationDrawerWrapper.count', cb)); | ||
}; | ||
|
||
var deregisterNotificationListeners = function() { | ||
_.each(notificationListeners, function(listener) { | ||
listener && listener(); | ||
}); | ||
notificationListeners = []; | ||
}; | ||
|
||
var deregisterRootScopeWatches = function() { | ||
_.each(rootScopeWatches, function(deregister) { | ||
deregister(); | ||
}); | ||
rootScopeWatches = []; | ||
}; | ||
|
||
var hideIfNoProject = function(projectName) { | ||
if(!projectName) { | ||
counter.hide = true; | ||
} else { | ||
counter.hide = false; | ||
} | ||
}; | ||
|
||
counter.onClick = function() { | ||
$rootScope.$emit('NotificationDrawerWrapper.toggle'); | ||
}; | ||
|
||
var drawerCountCallback = function(event, newCount) { | ||
// NOTE: unread !== seen. We do not automatically mark | ||
// notifications unread when the drawer is closed. | ||
if(newCount) { | ||
counter.showUnreadNotificationsIndicator = true; | ||
} else { | ||
counter.showUnreadNotificationsIndicator = false; | ||
} | ||
}; | ||
|
||
var projectChanged = function(next, current) { | ||
return _.get(next, 'params.project') !== _.get(current, 'params.project'); | ||
}; | ||
|
||
var reset = function() { | ||
watchNotificationDrawerCount($routeParams.project, drawerCountCallback); | ||
hideIfNoProject($routeParams.project); | ||
}; | ||
|
||
var initWatches = function() { | ||
reset(); | ||
rootScopeWatches.push($rootScope.$on("$routeChangeSuccess", function (evt, next, current) { | ||
if(projectChanged(next, current)) { | ||
reset(); | ||
} | ||
})); | ||
|
||
rootScopeWatches.push($rootScope.$on('NotificationDrawerWrapper.onMarkAllRead', function() { | ||
counter.showUnreadNotificationsIndicator = false; | ||
})); | ||
}; | ||
|
||
counter.$onInit = function() { | ||
if(DISABLE_GLOBAL_EVENT_WATCH || LIMIT_WATCHES) { | ||
counter.hide = true; | ||
return; | ||
} | ||
if (AuthService.isLoggedIn()) { | ||
initWatches(); | ||
} else { | ||
AuthService.onUserChanged(initWatches); | ||
} | ||
}; | ||
|
||
counter.$onDestroy = function() { | ||
deregisterNotificationListeners(); | ||
deregisterRootScopeWatches(); | ||
}; | ||
} | ||
})(); |
Oops, something went wrong.