Notification Priority Constant
Added notification Priority constant to simplify declaring intercept priorities. Change-Id: Ie2556d41f9e4e5c3e588904aee5778ac46b0db14
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
|
||||
angular.module('sb.auth').run(
|
||||
function($log, $modal, Notification, RefreshManager, Session) {
|
||||
function($log, $modal, Notification, RefreshManager, Session, Priority) {
|
||||
'use strict';
|
||||
|
||||
function handle_401() {
|
||||
@@ -58,7 +58,7 @@ angular.module('sb.auth').run(
|
||||
|
||||
return true; // Stop processing this notifications.
|
||||
}
|
||||
}, -1);
|
||||
}, Priority.BEFORE);
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
27
src/app/notification/provider/priority.js
Normal file
27
src/app/notification/provider/priority.js
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License. You may obtain
|
||||
* a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Useful priority constants.
|
||||
*/
|
||||
|
||||
angular.module('sb.notification').constant('Priority', {
|
||||
BEFORE: -1,
|
||||
FIRST: 0,
|
||||
LAST: 999,
|
||||
AFTER: 1000
|
||||
});
|
||||
@@ -29,7 +29,7 @@
|
||||
* interceptors.
|
||||
*/
|
||||
angular.module('sb.notification').factory('Notification',
|
||||
function ($log, Severity) {
|
||||
function ($log, Severity, Priority) {
|
||||
'use strict';
|
||||
|
||||
var subscribers = [];
|
||||
@@ -100,7 +100,7 @@ angular.module('sb.notification').factory('Notification',
|
||||
intercept: function (interceptor, priority) {
|
||||
|
||||
var i = {
|
||||
'priority': priority || 999,
|
||||
'priority': priority || Priority.LAST,
|
||||
'method': interceptor
|
||||
};
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
* Notification interceptors for this library.
|
||||
*/
|
||||
angular.module('sb.services')
|
||||
.run(function (Notification) {
|
||||
.run(function (Notification, Priority) {
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
@@ -86,7 +86,7 @@ angular.module('sb.services')
|
||||
}
|
||||
|
||||
// Apply the interceptors.
|
||||
Notification.intercept(filterTemplateRequests, -1);
|
||||
Notification.intercept(filterSuccessful, 999);
|
||||
Notification.intercept(rewriteHttpStatus, 1000);
|
||||
Notification.intercept(filterTemplateRequests, Priority.BEFORE);
|
||||
Notification.intercept(filterSuccessful, Priority.LAST);
|
||||
Notification.intercept(rewriteHttpStatus, Priority.AFTER);
|
||||
});
|
||||
Reference in New Issue
Block a user