summaryrefslogtreecommitdiffstats
path: root/install/static/ipa.js
diff options
context:
space:
mode:
authorAdam Young <ayoung@redhat.com>2011-01-10 21:14:51 -0500
committerEndi S. Dewata <edewata@redhat.com>2011-01-14 11:42:27 -0500
commitc385db4fc017f3319ff4d57bc19efe81585bc5dd (patch)
treeae3a03c9816d4616adbbe7e3896c6c29e77dd159 /install/static/ipa.js
parent74d8a3c487d1fd8854a66a741cc06daf924d3838 (diff)
downloadfreeipa-c385db4fc017f3319ff4d57bc19efe81585bc5dd.tar.gz
freeipa-c385db4fc017f3319ff4d57bc19efe81585bc5dd.tar.xz
freeipa-c385db4fc017f3319ff4d57bc19efe81585bc5dd.zip
spinning wheel display a spinning icon gif during network traffic. Fixes the following from first patch: 1 primary key set in span as opposed to appended, so it only appears once. 2. call hide for the network activity icon only in success or failure functions, not multiple times
Diffstat (limited to 'install/static/ipa.js')
-rw-r--r--install/static/ipa.js38
1 files changed, 33 insertions, 5 deletions
diff --git a/install/static/ipa.js b/install/static/ipa.js
index f84028b89..ed43d550a 100644
--- a/install/static/ipa.js
+++ b/install/static/ipa.js
@@ -229,6 +229,7 @@ IPA.batch_command = function (spec) {
that.args,
that.options,
function(data, text_status, xhr) {
+
for (var i=0; i<that.commands.length; i++) {
var command = that.commands[i];
var result = data.result.results[i];
@@ -283,6 +284,20 @@ IPA.cmd = function (name, args, options, win_callback, fail_callback, objname, c
{
var default_json_url = '/ipa/json';
+ var network_call_count = 0;
+ function display_activity_icon(){
+ network_call_count += 1;
+ $('.network-activity-indicator').css('display','inline');
+ }
+
+ function hide_activity_icon(){
+ network_call_count -= 1;
+
+ if (0 === network_call_count){
+ $('.network-activity-indicator').css('display','none');
+ }
+ }
+
function dialog_open(xhr, text_status, error_thrown) {
var that = this;
@@ -292,11 +307,15 @@ IPA.cmd = function (name, args, options, win_callback, fail_callback, objname, c
buttons: {
'Retry': function () {
IPA.error_dialog.dialog('close');
- IPA.cmd(name, args, options, win_callback, fail_callback, objname, command_name);
+ IPA.cmd(name, args, options, win_callback, fail_callback,
+ objname, command_name);
},
'Cancel': function () {
IPA.error_dialog.dialog('close');
- if (fail_callback) fail_callback.call(that, xhr, text_status, error_thrown);
+ if (fail_callback) {
+ fail_callback.call(that, xhr, text_status,
+ error_thrown);
+ }
}
}
});
@@ -312,7 +331,7 @@ IPA.cmd = function (name, args, options, win_callback, fail_callback, objname, c
}
function error_handler(xhr, text_status, error_thrown) {
-
+ hide_activity_icon();
if (!error_thrown) {
error_thrown = {
name: xhr.responseText || 'Unknown Error',
@@ -349,7 +368,9 @@ IPA.cmd = function (name, args, options, win_callback, fail_callback, objname, c
dialog_open.call(this, xhr, text_status, error_thrown);
}
- function error_handler(xhr, text_status, error_thrown) {
+ //Think this should be removed
+ function alt_error_handler(xhr, text_status, error_thrown) {
+ hide_activity_icon();
IPA.error_dialog.empty();
IPA.error_dialog.attr('title', error_thrown.title);
@@ -360,6 +381,7 @@ IPA.cmd = function (name, args, options, win_callback, fail_callback, objname, c
function success_handler(data, text_status, xhr) {
+ hide_activity_icon();
if (!data) {
var error_thrown = {
title: 'HTTP Error '+xhr.status,
@@ -408,7 +430,7 @@ IPA.cmd = function (name, args, options, win_callback, fail_callback, objname, c
success: success_handler,
error: error_handler
};
-
+ display_activity_icon();
$.ajax(request);
return (id);
@@ -455,3 +477,9 @@ IPA.get_member_attribute = function (obj_name, member)
}
return null;
}
+
+IPA.create_network_spinner = function(){
+ return $('<span />',{
+ 'class':'network-activity-indicator',
+ html: '<img src="spinner_small.gif" />'});
+}