summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Vomacka <pvomacka@redhat.com>2016-04-22 10:34:06 +0200
committerPetr Vobornik <pvoborni@redhat.com>2016-06-29 15:41:58 +0200
commit044d3c25de6806b68b1f1627863873ecb1a87957 (patch)
tree0041694441e145db0d0186109eeddbddfcccb9c0
parent3d61aca6237852908e0857f9e28ed9c7243b7a3e (diff)
downloadfreeipa-044d3c25de6806b68b1f1627863873ecb1a87957.tar.gz
freeipa-044d3c25de6806b68b1f1627863873ecb1a87957.tar.xz
freeipa-044d3c25de6806b68b1f1627863873ecb1a87957.zip
Add ability to turn off activity icon
By specifying correct attribute when creating command it turn off showing activity icon when webui waits for response from the server. https://fedorahosted.org/freeipa/ticket/5381 Reviewed-By: Petr Vobornik <pvoborni@redhat.com>
-rw-r--r--install/ui/src/freeipa/rpc.js46
1 files changed, 42 insertions, 4 deletions
diff --git a/install/ui/src/freeipa/rpc.js b/install/ui/src/freeipa/rpc.js
index 9e684a7da..a185585f4 100644
--- a/install/ui/src/freeipa/rpc.js
+++ b/install/ui/src/freeipa/rpc.js
@@ -96,6 +96,29 @@ rpc.command = function(spec) {
*/
that.retry = typeof spec.retry == 'undefined' ? true : spec.retry;
+ /**
+ * Allow turning off the activity icon.
+ *
+ * @property {Boolean} show=true
+ */
+ that.hide_activity_icon = spec.hide_activity_icon || false;
+
+ /**
+ * Allow set function which will be called when the activity of the command
+ * starts. Works only when 'activity_icon' property is set to false
+ *
+ * @property {Function}
+ */
+ that.notify_activity_start = spec.notify_activity_start || null;
+
+ /**
+ * Allow set function which will be called when the activity of the command
+ * ends. Works only when 'activity_icon' property is set to false
+ *
+ * @property {Function}
+ */
+ that.notify_activity_end = spec.notify_activity_end || null;
+
/** @property {string} error_message Default error message */
that.error_message = text.get(spec.error_message || '@i18n:dialogs.batch_error_message', 'Some operations failed.');
@@ -198,6 +221,15 @@ rpc.command = function(spec) {
}
};
+ that.handle_notify_execution_end = function() {
+ if (that.hide_activity_icon) {
+ if (that.notify_activity_end) that.notify_activity_end();
+ }
+ else {
+ IPA.hide_activity_icon();
+ }
+ };
+
/**
* Execute the command.
*
@@ -280,7 +312,7 @@ rpc.command = function(spec) {
*/
function error_handler(xhr, text_status, error_thrown) {
- IPA.hide_activity_icon();
+ that.handle_notify_execution_end();
if (xhr.status === 401) {
error_handler_auth(xhr, text_status, error_thrown);
@@ -360,7 +392,7 @@ rpc.command = function(spec) {
});
} else {
- IPA.hide_activity_icon();
+ that.handle_notify_execution_end();
var ajax = this;
var failed = that.get_failed(that, data.result, text_status, xhr);
@@ -413,7 +445,13 @@ rpc.command = function(spec) {
error: error_handler_login
};
- IPA.display_activity_icon();
+ if (that.hide_activity_icon) {
+ if (that.notify_activity_start) that.notify_activity_start();
+ }
+ else {
+ IPA.display_activity_icon();
+ }
+
$.ajax(that.request);
return deferred.promise;
};
@@ -1005,4 +1043,4 @@ rpc.extract_objects = function(values) {
};
return rpc;
-}); \ No newline at end of file
+});