You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@guacamole.apache.org by vn...@apache.org on 2018/04/29 20:58:54 UTC

[12/19] guacamole-client git commit: GUACAMOLE-526: Add convenience function for displaying modal notifications for REST errors.

GUACAMOLE-526: Add convenience function for displaying modal notifications for REST errors.

Project: http://git-wip-us.apache.org/repos/asf/guacamole-client/repo
Commit: http://git-wip-us.apache.org/repos/asf/guacamole-client/commit/1e5e9b60
Tree: http://git-wip-us.apache.org/repos/asf/guacamole-client/tree/1e5e9b60
Diff: http://git-wip-us.apache.org/repos/asf/guacamole-client/diff/1e5e9b60

Branch: refs/heads/master
Commit: 1e5e9b607b56e8cf0fd15b9b58337baa6c0652aa
Parents: cc6ade4
Author: Michael Jumper <mj...@apache.org>
Authored: Thu Apr 26 21:20:05 2018 -0700
Committer: Michael Jumper <mj...@apache.org>
Committed: Thu Apr 26 21:20:05 2018 -0700

----------------------------------------------------------------------
 .../notification/services/guacNotification.js   | 35 ++++++++++++++++++++
 1 file changed, 35 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/guacamole-client/blob/1e5e9b60/guacamole/src/main/webapp/app/notification/services/guacNotification.js
----------------------------------------------------------------------
diff --git a/guacamole/src/main/webapp/app/notification/services/guacNotification.js b/guacamole/src/main/webapp/app/notification/services/guacNotification.js
index c3d4a2b..a1b8d10 100644
--- a/guacamole/src/main/webapp/app/notification/services/guacNotification.js
+++ b/guacamole/src/main/webapp/app/notification/services/guacNotification.js
@@ -38,6 +38,19 @@ angular.module('notification').factory('guacNotification', ['$injector',
     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
      * no status is currently shown.
      * 
@@ -79,6 +92,28 @@ angular.module('notification').factory('guacNotification', ['$injector',
             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
     $rootScope.$on('$routeChangeSuccess', function() {
         service.showStatus(false);