GUACAMOLE-526: Move handling of request error notification to guacNotification, resolving circular dependency.

This commit is contained in:
Michael Jumper
2018-04-26 22:28:18 -07:00
parent 266b445c21
commit ae6b5fc8bb
10 changed files with 26 additions and 41 deletions

View File

@@ -21,5 +21,6 @@
* The module for code used to display arbitrary notifications.
*/
angular.module('notification', [
'rest',
'storage'
]);

View File

@@ -25,6 +25,7 @@ angular.module('notification').factory('guacNotification', ['$injector',
// Required services
var $rootScope = $injector.get('$rootScope');
var requestService = $injector.get('requestService');
var sessionStorageFactory = $injector.get('sessionStorageFactory');
var service = {};
@@ -93,26 +94,24 @@ angular.module('notification').factory('guacNotification', ['$injector',
};
/**
* Shows the given REST error response as a modal status. If a status
* notification is already currently shown, this function will have no
* effect.
* Promise error callback which displays a modal notification for all
* rejections due to REST errors. The message displayed to the user within
* the notification is provided by the contents of the @link{Error} object
* within the REST response. All other rejections, such as those due to
* JavaScript errors, are logged to the browser console without displaying
* any notification.
*
* @param {Error} error
* The error object returned from the failed REST request.
*
* @example
*
* someService.updateObject(object)
* ['catch'](guacNotification.showRequestError);
* @constant
* @type Function
*/
service.showRequestError = function showRequestError(error) {
service.SHOW_REQUEST_ERROR = requestService.createErrorCallback(function showRequestError(error) {
service.showStatus({
className : 'error',
title : 'APP.DIALOG_HEADER_ERROR',
text : error.translatableMessage,
actions : [ service.ACKNOWLEDGE_ACTION ]
});
};
});
// Hide status upon navigation
$rootScope.$on('$routeChangeSuccess', function() {