-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
76 additions
and
12 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
(function () { | ||
'use strict'; | ||
var m = angular.module('nflowExplorer.config.notificationFilter', ['toastr']); | ||
|
||
m.service('httpNotificationInterceptor', ['$q', '$injector', function($q, $injector) { | ||
return { | ||
responseError: function(rejection) { | ||
var toastr = $injector.get('toastr'); | ||
var toastrConfig = { | ||
timeOut: 0 | ||
}; | ||
if (rejection.status === -1) { | ||
toastr.error('Check network connection, CORS settings and ensure that nFlow REST API is running', | ||
'REST API request aborted by browser', toastrConfig); | ||
} else if (rejection.status === 401 || rejection.status === 403) { | ||
toastr.error('Authentication failed', toastrConfig); | ||
} else if (rejection.status === 404) { | ||
toastr.error('Check that your URL is valid', 'Page not found', toastrConfig); | ||
} else if (rejection.status >= 500) { | ||
toastr.error('Internal server error', toastrConfig); | ||
} | ||
return $q.reject(rejection); | ||
} | ||
}; | ||
}]); | ||
|
||
m.config(function($httpProvider) { | ||
$httpProvider.interceptors.push('httpNotificationInterceptor'); | ||
}); | ||
})(); |
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
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