diff --git a/ui/scripts/cloud.core.diskoffering.js b/ui/scripts/cloud.core.diskoffering.js index 5bafb70b261..5993ae42ea7 100644 --- a/ui/scripts/cloud.core.diskoffering.js +++ b/ui/scripts/cloud.core.diskoffering.js @@ -95,8 +95,10 @@ function initAddDiskOfferingButton($midmenuAddLink1) { bindClickToMidMenu($midmenuItem1, diskOfferingToRightPanel, getMidmenuId); afterAddingMidMenuItem($midmenuItem1, true); }, - error: function(XMLHttpResponse) { - handleErrorInMidMenu(XMLHttpResponse, $midmenuItem1); + error: function(XMLHttpResponse) { + handleError(XMLHttpResponse, function() { + handleErrorInMidMenu(XMLHttpResponse, $midmenuItem1); + }); } }); }, diff --git a/ui/scripts/cloud.core.host.js b/ui/scripts/cloud.core.host.js index 6370ae26277..462482a0471 100644 --- a/ui/scripts/cloud.core.host.js +++ b/ui/scripts/cloud.core.host.js @@ -201,9 +201,8 @@ var hostActionMap = { asyncJobResponse: "preparehostformaintenanceresponse", dialogBeforeActionFn: doEnableMaintenanceMode, inProcessText: "Enabling Maintenance Mode....", - afterActionSeccessFn: function(json, $midmenuItem1, id) { - var item = json.queryasyncjobresultresponse.jobresult.host; - hostToMidmenu(item, $midmenuItem1); + afterActionSeccessFn: function(json, $midmenuItem1, id) { + hostToMidmenu(json.queryasyncjobresultresponse.host[0], $midmenuItem1); hostToRightPanel($midmenuItem1); $("#right_panel_content #after_action_info").text("We are actively enabling maintenance on your host. Please refresh periodically for an updated status."); } @@ -213,9 +212,8 @@ var hostActionMap = { asyncJobResponse: "cancelhostmaintenanceresponse", dialogBeforeActionFn: doCancelMaintenanceMode, inProcessText: "Cancelling Maintenance Mode....", - afterActionSeccessFn: function(json, $midmenuItem1, id) { - var item = json.queryasyncjobresultresponse.jobresult.host; - hostToMidmenu(item, $midmenuItem1); + afterActionSeccessFn: function(json, $midmenuItem1, id) { + hostToMidmenu(json.queryasyncjobresultresponse.host[0], $midmenuItem1); hostToRightPanel($midmenuItem1); $("#right_panel_content #after_action_info").text("We are actively cancelling your scheduled maintenance. Please refresh periodically for an updated status."); } @@ -226,8 +224,7 @@ var hostActionMap = { dialogBeforeActionFn: doForceReconnect, inProcessText: "Reconnecting....", afterActionSeccessFn: function(json, $midmenuItem1, id) { - var item = json.queryasyncjobresultresponse.jobresult.host; - hostToMidmenu(item, $midmenuItem1); + hostToMidmenu(json.queryasyncjobresultresponse.jobresult.host, $midmenuItem1); hostToRightPanel($midmenuItem1); $("#right_panel_content #after_action_info").text("We are actively reconnecting your host. Please refresh periodically for an updated status."); } @@ -236,10 +233,8 @@ var hostActionMap = { isAsyncJob: false, dialogBeforeActionFn: doRemoveHost, inProcessText: "Removing Host....", - afterActionSeccessFn: function(json, $midmenuItem1, id) { - $midmenuItem1.slideUp("slow", function() { - $(this).remove(); - }); + afterActionSeccessFn: function(json, $midmenuItem1, id) { + $midmenuItem1.remove(); clearRightPanel(); hostClearRightPanel(); } @@ -248,10 +243,16 @@ var hostActionMap = { isAsyncJob: false, dialogBeforeActionFn: doUpdateOSPreference, inProcessText: "Updating OS Preference....", - afterActionSeccessFn: function(json, $midmenuItem1, id) { - var item = json.updatehostresponse.host; - hostToMidmenu(item, $midmenuItem1); - hostToRightPanel($midmenuItem1); + afterActionSeccessFn: function(json, $midmenuItem1, id) { + //call listHosts API before bug 6650 ("updateHost API should return an embedded object like what listHosts API does") is fixed. + $.ajax({ + data: createURL("command=listHosts&id="+id), + dataType: "json", + success: function(json) { + hostToMidmenu(json.listhostsresponse.host[0], $midmenuItem1); + hostToRightPanel($midmenuItem1); + } + }); } } } diff --git a/ui/scripts/cloud.core.instance.js b/ui/scripts/cloud.core.instance.js index 1933764cc77..3cecc1ba81f 100644 --- a/ui/scripts/cloud.core.instance.js +++ b/ui/scripts/cloud.core.instance.js @@ -856,18 +856,20 @@ function initVMWizard() { } }, error: function(XMLHttpResponse) { - $("body").stopTime(timerKey); - afterAddingMidMenuItem($midmenuItem1, false); - handleError(XMLHttpResponse); + $("body").stopTime(timerKey); + handleError(XMLHttpResponse, function() { + afterAddingMidMenuItem($midmenuItem1, false); + }); } }); }, 0 ); }, - error: function(XMLHttpResponse) { - afterAddingMidMenuItem($midmenuItem1, false); - handleError(XMLHttpResponse); + error: function(XMLHttpResponse) { + handleError(XMLHttpResponse, function() { + afterAddingMidMenuItem($midmenuItem1, false); + }); } }); } diff --git a/ui/scripts/cloud.core.ipaddress.js b/ui/scripts/cloud.core.ipaddress.js index df975cb27cc..3e018790e51 100644 --- a/ui/scripts/cloud.core.ipaddress.js +++ b/ui/scripts/cloud.core.ipaddress.js @@ -70,8 +70,10 @@ function afterLoadIpJSP() { afterAddingMidMenuItem($midmenuItem1, true); }, - error: function(XMLHttpResponse) { - handleErrorInMidMenu(XMLHttpResponse, $midmenuItem1); + error: function(XMLHttpResponse) { + handleError(XMLHttpResponse, function() { + handleErrorInMidMenu(XMLHttpResponse, $midmenuItem1); + }); } }); }, @@ -123,9 +125,10 @@ function afterLoadIpJSP() { refreshCreatePortForwardingRow(); }, error: function(XMLHttpResponse) { - handleError(XMLHttpResponse); - $template.slideUp("slow", function() { - $(this).remove(); + handleError(XMLHttpResponse, function() { + $template.slideUp("slow", function() { + $(this).remove(); + }); }); } }); @@ -176,9 +179,10 @@ function afterLoadIpJSP() { refreshCreateLoadBalancerRow(); }, error: function(XMLHttpResponse) { - handleError(XMLHttpResponse); - $template.slideUp("slow", function() { - $(this).remove(); + handleError(XMLHttpResponse, function() { + $template.slideUp("slow", function() { + $(this).remove(); + }); }); } }); @@ -352,8 +356,10 @@ function showEnableVPNDialog($thisTab) { } }, error: function(XMLHttpResponse) { - $("body").stopTime(timerKey); - handleErrorInDialog(XMLHttpResponse, $thisDialog); + $("body").stopTime(timerKey); + handleError(XMLHttpResponse, function() { + handleErrorInDialog(XMLHttpResponse, $thisDialog); + }); } }); }, @@ -361,7 +367,9 @@ function showEnableVPNDialog($thisTab) { ); }, error: function(XMLHttpResponse) { - handleErrorInDialog(XMLHttpResponse, $thisDialog); + handleError(XMLHttpResponse, function() { + handleErrorInDialog(XMLHttpResponse, $thisDialog); + }); } }); }, @@ -454,8 +462,10 @@ function showVpnUsers(presharedkey, publicip) { } }, error: function(XMLHttpResponse) { - $("body").stopTime(timerKey); - handleErrorInDialog(XMLHttpResponse, $thisDialog); + $("body").stopTime(timerKey); + handleError(XMLHttpResponse, function() { + handleErrorInDialog(XMLHttpResponse, $thisDialog); + }); } }); }, @@ -463,7 +473,9 @@ function showVpnUsers(presharedkey, publicip) { ); }, error: function(XMLHttpResponse) { - handleErrorInDialog(XMLHttpResponse, $thisDialog); + handleError(XMLHttpResponse, function() { + handleErrorInDialog(XMLHttpResponse, $thisDialog); + }); } }); }, @@ -527,8 +539,10 @@ function showVpnUsers(presharedkey, publicip) { } }, error: function(XMLHttpResponse) { - $("body").stopTime(timerKey); - handleErrorInDialog(XMLHttpResponse, $thisDialog); + $("body").stopTime(timerKey); + handleError(XMLHttpResponse, function() { + handleErrorInDialog(XMLHttpResponse, $thisDialog); + }); } }); }, @@ -536,7 +550,9 @@ function showVpnUsers(presharedkey, publicip) { ); }, error: function(XMLHttpResponse) { - handleErrorInDialog(XMLHttpResponse, $thisDialog); + handleError(XMLHttpResponse, function() { + handleErrorInDialog(XMLHttpResponse, $thisDialog); + }); } }); }, @@ -632,8 +648,10 @@ function enableDeleteUser() { } }, error: function(XMLHttpResponse) { - $("body").stopTime(timerKey); - handleErrorInDialog(XMLHttpResponse, $thisDialog); + $("body").stopTime(timerKey); + handleError(XMLHttpResponse, function() { + handleErrorInDialog(XMLHttpResponse, $thisDialog); + }); } }); }, @@ -641,7 +659,9 @@ function enableDeleteUser() { ); }, error: function(XMLHttpResponse) { - handleErrorInDialog(XMLHttpResponse, $thisDialog); + handleError(XMLHttpResponse, function() { + handleErrorInDialog(XMLHttpResponse, $thisDialog); + }); } }); }, diff --git a/ui/scripts/cloud.core.iso.js b/ui/scripts/cloud.core.iso.js index 1c1e6e54602..41d9ba291f6 100644 --- a/ui/scripts/cloud.core.iso.js +++ b/ui/scripts/cloud.core.iso.js @@ -84,8 +84,10 @@ function afterLoadIsoJSP() { } } }, - error: function(XMLHttpResponse) { - handleErrorInMidMenu(XMLHttpResponse, $midmenuItem1); + error: function(XMLHttpResponse) { + handleError(XMLHttpResponse, function() { + handleErrorInMidMenu(XMLHttpResponse, $midmenuItem1); + }); } }); }, @@ -194,9 +196,34 @@ function isoJsonToDetailsTab() { $thisTab.find("#tab_container").hide(); $thisTab.find("#tab_spinning_wheel").show(); - var $midmenuItem1 = $("#right_panel_content").data("$midmenuItem1"); - var jsonObj = $midmenuItem1.data("jsonObj"); - + var $midmenuItem1 = $("#right_panel_content").data("$midmenuItem1"); + + + var jsonObj = $midmenuItem1.data("jsonObj"); + + //listIsos API has a bug => it returns nothing when id is 200(xs-tools.iso) and zoneid is specified. So, comment the following code before the bug is fixed. + /* + var array1 = []; + var id = $midmenuItem1.data("jsonObj").id; + array1.push("&id="+id); + + var zoneid = $midmenuItem1.data("jsonObj").zoneid; + if(zoneid != null) + array1.push("&zoneid="+zoneid); + + var jsonObj; + $.ajax({ + data: createURL("command=listIsos&isofilter=self"+array1.join("")), + dataType: "json", + async: false, + success: function(json) { + var items = json.listisosresponse.iso; + if(items != null && items.length > 0) + jsonObj = items[0]; + } + }); + */ + $thisTab.data("jsonObj", jsonObj); $midmenuItem1.data("jsonObj", jsonObj); diff --git a/ui/scripts/cloud.core.js b/ui/scripts/cloud.core.js index 48fea8747ba..ef80f914533 100644 --- a/ui/scripts/cloud.core.js +++ b/ui/scripts/cloud.core.js @@ -100,16 +100,20 @@ function doActionToTab(id, $actionLink, apiCommand, $midmenuItem1, $thisTab) { } }, error: function(XMLHttpResponse) { - $("body").stopTime(timerKey); - handleErrorInDetailsTab(XMLHttpResponse, $thisTab, label, $afterActionInfoContainer, $midmenuItem1); + $("body").stopTime(timerKey); + handleError(XMLHttpResponse, function() { + handleErrorInDetailsTab(XMLHttpResponse, $thisTab, label, $afterActionInfoContainer, $midmenuItem1); + }); } }); }, 0 ); }, - error: function(XMLHttpResponse) { - handleErrorInDetailsTab(XMLHttpResponse, $thisTab, label, $afterActionInfoContainer, $midmenuItem1); + error: function(XMLHttpResponse) { + handleError(XMLHttpResponse, function() { + handleErrorInDetailsTab(XMLHttpResponse, $thisTab, label, $afterActionInfoContainer, $midmenuItem1); + }); } }); } @@ -130,8 +134,10 @@ function doActionToTab(id, $actionLink, apiCommand, $midmenuItem1, $thisTab) { afterActionSeccessFn(json, $midmenuItem1, id); }, - error: function(XMLHttpResponse) { - handleErrorInDetailsTab(XMLHttpResponse, $thisTab, label, $afterActionInfoContainer, $midmenuItem1); + error: function(XMLHttpResponse) { + handleError(XMLHttpResponse, function() { + handleErrorInDetailsTab(XMLHttpResponse, $thisTab, label, $afterActionInfoContainer, $midmenuItem1); + }); } }); } @@ -248,16 +254,20 @@ function doActionToSubgridItem(id, $actionLink, apiCommand, $subgridItem) { } }, error: function(XMLHttpResponse) { - $("body").stopTime(timerKey); - handleErrorInSubgridItem(XMLHttpResponse, $subgridItem, label); + $("body").stopTime(timerKey); + handleError(XMLHttpResponse, function() { + handleErrorInSubgridItem(XMLHttpResponse, $subgridItem, label); + }); } }); }, 0 ); }, - error: function(XMLHttpResponse) { - handleErrorInSubgridItem(XMLHttpResponse, $subgridItem, label); + error: function(XMLHttpResponse) { + handleError(XMLHttpResponse, function() { + handleErrorInSubgridItem(XMLHttpResponse, $subgridItem, label); + }); } }); } @@ -275,8 +285,10 @@ function doActionToSubgridItem(id, $actionLink, apiCommand, $subgridItem) { $subgridItem.find("#after_action_info_container").removeClass("error").addClass("success").show(); afterActionSeccessFn(json, id, $subgridItem); }, - error: function(XMLHttpResponse) { - handleErrorInSubgridItem(XMLHttpResponse, $subgridItem, label); + error: function(XMLHttpResponse) { + handleError(XMLHttpResponse, function() { + handleErrorInSubgridItem(XMLHttpResponse, $subgridItem, label); + }); } }); } @@ -410,8 +422,9 @@ function doActionToMidMenu(id, apiInfo, apiCommand) { 0 ); }, - error: function(XMLHttpResponse) { - handleErrorInMidMenu(XMLHttpResponse, $midmenuItem1, id, inProcessText); + error: function(XMLHttpResponse) { + handleError(XMLHttpResponse); + handleErrorInMidMenu(XMLHttpResponse, $midmenuItem1, id, inProcessText); } }); } @@ -985,7 +998,8 @@ function bindAndListMidMenuItems($leftmenu, commandString, jsonResponse1, jsonRe }); } -function handleErrorInDialog(XMLHttpResponse, $thisDialog) { +function handleErrorInDialog(XMLHttpResponse, $thisDialog) { + handleError(XMLHttpResponse); var start = XMLHttpResponse.responseText.indexOf("h1") + 3; var end = XMLHttpResponse.responseText.indexOf(" 0) { + item = items[0]; + } + } + }); + $leftmenuItem1.data("jsonObj", item); systemvmJsonToRightPanel($leftmenuItem1); } @@ -113,7 +126,20 @@ var systemVmActionMap = { inProcessText: "Rebooting System VM....", dialogBeforeActionFn : doRebootSystemVM, afterActionSeccessFn: function(json, $leftmenuItem1, id) { - var item = json.queryasyncjobresultresponse.jobresult.systemvm; + //var item = json.queryasyncjobresultresponse.jobresult.rebootsystemvmresponse; //waiting for Bug 6860 to be fixed ("RebootSystemVM should return an embedded object on success") + var item; + $.ajax({ + data: createURL("command=listSystemVms&id="+id), + dataType: "json", + async: false, + success: function(json) { + var items = json.listsystemvmsresponse.systemvm; + if (items != null && items.length > 0) { + item = items[0]; + } + } + }); + $leftmenuItem1.data("jsonObj", item); systemvmJsonToRightPanel($leftmenuItem1); } diff --git a/ui/scripts/cloud.core.template.js b/ui/scripts/cloud.core.template.js index 962709d04c1..fd60fbe5557 100644 --- a/ui/scripts/cloud.core.template.js +++ b/ui/scripts/cloud.core.template.js @@ -105,8 +105,10 @@ function afterLoadTemplateJSP() { } } }, - error: function(XMLHttpResponse) { - handleErrorInMidMenu(XMLHttpResponse, $midmenuItem1); + error: function(XMLHttpResponse) { + handleError(XMLHttpResponse, function() { + handleErrorInMidMenu(XMLHttpResponse, $midmenuItem1); + }); } }); }, @@ -218,8 +220,21 @@ function templateJsonToDetailsTab() { $thisTab.find("#tab_container").hide(); $thisTab.find("#tab_spinning_wheel").show(); - var $midmenuItem1 = $("#right_panel_content").data("$midmenuItem1"); - var jsonObj = $midmenuItem1.data("jsonObj"); + var $midmenuItem1 = $("#right_panel_content").data("$midmenuItem1"); + var id = $midmenuItem1.data("jsonObj").id; + var zoneid = $midmenuItem1.data("jsonObj").zoneid; + + var jsonObj; + $.ajax({ + data: createURL("command=listTemplates&templatefilter=self&id="+id+"&zoneid="+zoneid), + dataType: "json", + async: false, + success: function(json) { + var items = json.listtemplatesresponse.template; + if(items != null && items.length > 0) + jsonObj = items[0]; + } + }); $thisTab.data("jsonObj", jsonObj); $midmenuItem1.data("jsonObj", jsonObj); @@ -245,13 +260,16 @@ function templateJsonToDetailsTab() { setBooleanReadField(jsonObj.passwordenabled, $thisTab.find("#passwordenabled")); setBooleanEditField(jsonObj.passwordenabled, $thisTab.find("#passwordenabled_edit")); - + //$thisTab.find("#passwordenabled_edit").val(jsonObj.passwordenabled); + setBooleanReadField(jsonObj.ispublic, $thisTab.find("#ispublic")); setBooleanEditField(jsonObj.ispublic, $thisTab.find("#ispublic_edit")); - + //$thisTab.find("#ispublic_edit").val(jsonObj.ispublic); + setBooleanReadField(jsonObj.isfeatured, $thisTab.find("#isfeatured")); setBooleanEditField(jsonObj.isfeatured, $thisTab.find("#isfeatured_edit")); - + //$thisTab.find("#isfeatured_edit").val(jsonObj.isfeatured); + setBooleanReadField(jsonObj.crossZones, $thisTab.find("#crossZones")); $thisTab.find("#ostypename").text(fromdb(jsonObj.ostypename)); diff --git a/ui/scripts/cloud.core.volume.js b/ui/scripts/cloud.core.volume.js index 647d6c1fb33..773c552d303 100644 --- a/ui/scripts/cloud.core.volume.js +++ b/ui/scripts/cloud.core.volume.js @@ -121,14 +121,18 @@ function afterLoadVolumeJSP() { } }, error: function(XMLHttpResponse) { - $("body").stopTime(timerKey); - afterAddingMidMenuItem($midmenuItem1, false); + $("body").stopTime(timerKey); + handleError(XMLHttpResponse, function() { + afterAddingMidMenuItem($midmenuItem1, false); + }); } }); }, 0); }, - error: function(XMLHttpResponse) { - afterAddingMidMenuItem($midmenuItem1, false); + error: function(XMLHttpResponse) { + handleError(XMLHttpResponse, function() { + afterAddingMidMenuItem($midmenuItem1, false); + }); } }); }, diff --git a/ui/scripts/cloud.core.zone.js b/ui/scripts/cloud.core.zone.js index 072e7f0cd90..437fc124dd8 100644 --- a/ui/scripts/cloud.core.zone.js +++ b/ui/scripts/cloud.core.zone.js @@ -417,14 +417,15 @@ function initAddVLANButton($addButton) { $template1.find("#vlan_type_icon").removeClass("virtual").addClass("direct"); else //virtual $template1.find("#vlan_type_icon").removeClass("direct").addClass("virtual"); - - var item = json.createvlaniprangeresponse.vlan; - vlanJsonToTemplate(item, $template1); + + vlanJsonToTemplate(json.createvlaniprangeresponse.vlaniprange, $template1); $vlanContainer.prepend($template1); $template1.fadeIn("slow"); }, error: function(XMLHttpResponse) { - handleErrorInDialog(XMLHttpResponse, $thisDialog); + handleError(XMLHttpResponse, function() { + handleErrorInDialog(XMLHttpResponse, $thisDialog); + }); } }); @@ -479,8 +480,10 @@ function initAddSecondaryStorageButton($addButton) { $subgridItem.find("#after_action_info_container").removeClass("error").addClass("success").show(); $("#tab_content_secondarystorage").append($subgridItem.show()); }, - error: function(XMLHttpResponse) { - handleErrorInDialog(XMLHttpResponse, $thisDialog); + error: function(XMLHttpResponse) { + handleError(XMLHttpResponse, function() { + handleErrorInDialog(XMLHttpResponse, $thisDialog); + }); } }); }, @@ -562,7 +565,9 @@ function initAddPodButton($midmenuAddLink1) { } }, error: function(XMLHttpResponse) { - handleErrorInDialog(XMLHttpResponse, $thisDialog); + handleError(XMLHttpResponse, function() { + handleErrorInDialog(XMLHttpResponse, $thisDialog); + }); } }); },