From d15e3899bb7e5daef667cd7111aa3fcf320302fc Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Fri, 3 Sep 2010 11:02:29 -0700 Subject: [PATCH] new UI - implement enable HA action, implement disable HA action. --- ui/new/scripts/cloud.core.instance.js | 56 ++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/ui/new/scripts/cloud.core.instance.js b/ui/new/scripts/cloud.core.instance.js index 1de7e8eb0d1..4fea2cf728f 100755 --- a/ui/new/scripts/cloud.core.instance.js +++ b/ui/new/scripts/cloud.core.instance.js @@ -84,7 +84,17 @@ function clickInstanceGroupHeader($arrowIcon) { isAsyncJob: false, dialogBeforeActionFn : doChangeGroup, afterActionSeccessFn: setMidmenuItemVm - } + }, + "Enable HA": { + isAsyncJob: false, + dialogBeforeActionFn : doEnableHA, + afterActionSeccessFn: setMidmenuItemVm + }, + "Disable HA": { + isAsyncJob: false, + dialogBeforeActionFn : doDisableHA, + afterActionSeccessFn: setMidmenuItemVm + } } function doAttachISO($t, selectedItemIds, listAPIMap) { @@ -264,6 +274,50 @@ function clickInstanceGroupHeader($arrowIcon) { }).dialog("open"); } + function doEnableHA($t, selectedItemIds, listAPIMap) { + var message = "

Please confirm you want to enable HA for your virtual machine. Once HA is enabled, your Virtual Instance will be automatically restarted in the event it is detected to have failed.

"; + + $("#dialog_confirmation") + .html(message) + .dialog('option', 'buttons', { + "Confirm": function() { + $(this).dialog("close"); + for(var id in selectedItemIds) { + var $midMenuItem = selectedItemIds[id]; + var jsonObj = $midMenuItem.data("jsonObj"); + var apiCommand = "command=updateVirtualMachine&id="+id+"&haenable=true"; + doAction(id, $t, apiCommand, listAPIMap); + } + }, + "Cancel": function() { + $(this).dialog("close"); + } + }).dialog("open"); + } + + function doDisableHA($t, selectedItemIds, listAPIMap) { + var message = "

Please confirm you want to disable HA for your virtual machine. Once HA is disabled, your Virtual Instance will no longer be be automatically restarted in the event of a failure.

"; + + $("#dialog_confirmation") + .html(message) + .dialog('option', 'buttons', { + "Confirm": function() { + $(this).dialog("close"); + for(var id in selectedItemIds) { + var $midMenuItem = selectedItemIds[id]; + var jsonObj = $midMenuItem.data("jsonObj"); + var apiCommand = "command=updateVirtualMachine&id="+id+"&haenable=false"; + doAction(id, $t, apiCommand, listAPIMap); + } + }, + "Cancel": function() { + $(this).dialog("close"); + } + }).dialog("open"); + } + + + function updateVirtualMachineStateInRightPanel(state) { if(state == "Running") $rightPanelContent.find("#state").text(state).removeClass("red gray").addClass("green");