Fix to make edit guest network details async

This commit is contained in:
Brian Federle 2011-11-29 19:33:03 -08:00
parent ed854ba221
commit f253be7715
2 changed files with 15 additions and 38 deletions

View File

@ -258,36 +258,11 @@
dataType: "json", dataType: "json",
success: function(json) { success: function(json) {
var jobId = json.updatephysicalnetworkresponse.jobid; var jobId = json.updatephysicalnetworkresponse.jobid;
var timerKey = "updatePhysicalNetworkJob_"+jobId; args.response.success({ _custom: { jobId: jobId }});
$("body").everyTime(2000, timerKey, function() {
$.ajax({
url: createURL("queryAsyncJobResult&jobId="+jobId),
dataType: "json",
success: function(json) {
var result = json.queryasyncjobresultresponse;
if (result.jobstatus == 0) {
return; //Job has not completed
}
else {
$("body").stopTime(timerKey);
if (result.jobstatus == 1) {
var item = json.queryasyncjobresultresponse.jobresult.physicalnetwork;
args.response.success({data:item});
}
else if (result.jobstatus == 2) {
alert("updatePhysicalNetwork failed. Error: " + fromdb(result.jobresult.errortext));
}
}
},
error: function(XMLHttpResponse) {
var errorMsg = parseXMLHttpResponse(XMLHttpResponse);
alert("updatePhysicalNetwork failed. Error: " + errorMsg);
}
});
});
} }
}); });
} },
notification: { poll: pollAsyncJobResult }
} }
}, },

View File

@ -26,6 +26,7 @@
_custom: notification._custom, _custom: notification._custom,
poll: function(args) { poll: function(args) {
var complete = args.complete; var complete = args.complete;
var notificationError = args.error;
notification.poll({ notification.poll({
_custom: args._custom, _custom: args._custom,
@ -34,14 +35,10 @@
complete(args); complete(args);
}, },
error: function(args) { error: function(args) {
if (args.message) { error($.extend(errorArgs, args));
if (args.message) { notificationError(args);
cloudStack.dialog.notice({ message: args.message });
}
error($.extend(errorArgs, args)); return cloudStack.dialog.error;
complete(args);
}
} }
}); });
} }
@ -337,10 +334,11 @@
_custom: $detailView.data('_custom'), _custom: $detailView.data('_custom'),
context: $detailView.data('view-args').context, context: $detailView.data('view-args').context,
response: { response: {
success: function() { success: function(args) {
var notificationArgs = { var notificationArgs = {
section: id, section: id,
desc: 'Changed item properties' desc: 'Changed item properties',
_custom: args._custom
}; };
if (!action.notification) { if (!action.notification) {
@ -358,6 +356,10 @@
convertInputs($inputs); convertInputs($inputs);
$loading.remove(); $loading.remove();
}, [],
function() {
$loading.remove();
$inputs.closest('.detail-view').find('.toolbar .refresh').click();
}, [] }, []
); );
} }