mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-07 05:31:22 +00:00
GUACAMOLE-526: Add convenience function for displaying modal notifications for REST errors.
This commit is contained in:
@@ -37,6 +37,19 @@ angular.module('notification').factory('guacNotification', ['$injector',
|
|||||||
*/
|
*/
|
||||||
var storedStatus = sessionStorageFactory.create(false);
|
var storedStatus = sessionStorageFactory.create(false);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An action to be provided along with the object sent to showStatus which
|
||||||
|
* closes the currently-shown status dialog.
|
||||||
|
*
|
||||||
|
* @type NotificationAction
|
||||||
|
*/
|
||||||
|
service.ACKNOWLEDGE_ACTION = {
|
||||||
|
name : 'APP.ACTION_ACKNOWLEDGE',
|
||||||
|
callback : function acknowledgeCallback() {
|
||||||
|
service.showStatus(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the current status notification, which may simply be false if
|
* Retrieves the current status notification, which may simply be false if
|
||||||
* no status is currently shown.
|
* no status is currently shown.
|
||||||
@@ -79,6 +92,28 @@ angular.module('notification').factory('guacNotification', ['$injector',
|
|||||||
storedStatus(status);
|
storedStatus(status);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shows the given REST error response as a modal status. If a status
|
||||||
|
* notification is already currently shown, this function will have no
|
||||||
|
* effect.
|
||||||
|
*
|
||||||
|
* @param {Error} error
|
||||||
|
* The error object returned from the failed REST request.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
*
|
||||||
|
* someService.updateObject(object)
|
||||||
|
* ['catch'](guacNotification.showRequestError);
|
||||||
|
*/
|
||||||
|
service.showRequestError = function showRequestError(error) {
|
||||||
|
service.showStatus({
|
||||||
|
className : 'error',
|
||||||
|
title : 'APP.DIALOG_HEADER_ERROR',
|
||||||
|
text : error.translatableMessage,
|
||||||
|
actions : [ service.ACKNOWLEDGE_ACTION ]
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
// Hide status upon navigation
|
// Hide status upon navigation
|
||||||
$rootScope.$on('$routeChangeSuccess', function() {
|
$rootScope.$on('$routeChangeSuccess', function() {
|
||||||
service.showStatus(false);
|
service.showStatus(false);
|
||||||
|
Reference in New Issue
Block a user