From fe5d825d337146668593216a2fdd86c66262951e Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Wed, 15 Sep 2010 14:29:53 -0700 Subject: [PATCH 01/86] new UI - implement updateTemplate and updateTemplatePermission. --- ui/new/jsp/template.jsp | 34 +++-- ui/new/scripts/cloud.core2.js | 9 +- ui/new/scripts/cloud.core2.router.js | 10 +- ui/new/scripts/cloud.core2.template.js | 188 +++++++++++++++++++++---- 4 files changed, 193 insertions(+), 48 deletions(-) diff --git a/ui/new/jsp/template.jsp b/ui/new/jsp/template.jsp index 5d1b92a84fa..46714582eef 100644 --- a/ui/new/jsp/template.jsp +++ b/ui/new/jsp/template.jsp @@ -25,8 +25,8 @@
- -
+
+ +
+ + +
diff --git a/ui/new/scripts/cloud.core2.iso.js b/ui/new/scripts/cloud.core2.iso.js index 3a7402a33b1..29d8aa643d9 100644 --- a/ui/new/scripts/cloud.core2.iso.js +++ b/ui/new/scripts/cloud.core2.iso.js @@ -4,6 +4,28 @@ var g_zoneNames = []; function afterLoadIsoJSP() { var $detailsTab = $("#right_panel_content #tab_content_details"); + //edit button *** + var $readonlyFields = $detailsTab.find("#name, #displaytext"); + var $editFields = $detailsTab.find("#name_edit, #displaytext_edit"); + $("#edit_button").bind("click", function(event){ + $readonlyFields.hide(); + $editFields.show(); + $("#cancel_button, #save_button").show() + return false; + }); + $("#cancel_button").bind("click", function(event){ + $editFields.hide(); + $readonlyFields.show(); + $("#save_button, #cancel_button").hide(); + return false; + }); + $("#save_button").bind("click", function(event){ + doUpdateIso(); + $editFields.hide(); + $readonlyFields.show(); + $("#save_button, #cancel_button").hide(); + return false; + }); //populate dropdown *** $.ajax({ @@ -107,8 +129,13 @@ function isoJsonToDetailsTab(jsonObj) { $detailsTab.data("jsonObj", jsonObj); $detailsTab.find("#id").text(fromdb(jsonObj.id)); $detailsTab.find("#zonename").text(fromdb(jsonObj.zonename)); + $detailsTab.find("#name").text(fromdb(jsonObj.name)); + $detailsTab.find("#name_edit").val(fromdb(jsonObj.name)); + $detailsTab.find("#displaytext").text(fromdb(jsonObj.displaytext)); + $detailsTab.find("#displaytext_edit").val(fromdb(jsonObj.displaytext)); + $detailsTab.find("#account").text(fromdb(jsonObj.account)); if(jsonObj.size != null) @@ -197,6 +224,33 @@ var isoListAPIMap = { listAPIResponseObj: "iso" }; +function doUpdateIso() { + var $detailsTab = $("#right_panel_content #tab_content_details"); + + // validate values + var isValid = true; + isValid &= validateString("Name", $detailsTab.find("#name_edit"), $detailsTab.find("#name_edit_errormsg")); + isValid &= validateString("Display Text", $detailsTab.find("#displaytext_edit"), $detailsTab.find("#displaytext_edit_errormsg")); + if (!isValid) + return; + + var jsonObj = $detailsTab.data("jsonObj"); + var id = jsonObj.id; + + var name = trim($detailsTab.find("#name_edit").val()); + var displaytext = trim($detailsTab.find("#displaytext_edit").val()); + + $.ajax({ + data: createURL("command=updateIso&id="+id+"&name="+todb(name)+"&displayText="+todb(displaytext)), + dataType: "json", + success: function(json) { + var jsonObj = json.updateisoresponse; + isoToMidmenu(jsonObj, $("#midmenuItem_"+jsonObj.id)); + isoJsonToDetailsTab(jsonObj); + } + }); +} + function populateZoneFieldExcludeSourceZone(zoneField, excludeZoneId) { zoneField.empty(); if (g_zoneIds != null && g_zoneIds.length > 0) { From 7aa2053df29503bf77f84543fc309b72434c33b4 Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Thu, 16 Sep 2010 16:06:05 -0700 Subject: [PATCH 22/86] new UI - ISO page - implement deleteISO action. --- ui/new/scripts/cloud.core2.iso.js | 21 +- ui/new/scripts/cloud.core2.js | 318 +++++++++++++------------ ui/new/scripts/cloud.core2.template.js | 8 +- 3 files changed, 182 insertions(+), 165 deletions(-) diff --git a/ui/new/scripts/cloud.core2.iso.js b/ui/new/scripts/cloud.core2.iso.js index 29d8aa643d9..58686de9e63 100644 --- a/ui/new/scripts/cloud.core2.iso.js +++ b/ui/new/scripts/cloud.core2.iso.js @@ -185,7 +185,22 @@ function isoJsonToDetailsTab(jsonObj) { } function isoClearRightPanel() { - + var $detailsTab = $("#right_panel_content #tab_content_details"); + + $detailsTab.find("#id").text(""); + $detailsTab.find("#zonename").text(""); + + $detailsTab.find("#name").text(""); + $detailsTab.find("#name_edit").val(""); + + $detailsTab.find("#displaytext").text(""); + $detailsTab.find("#displaytext_edit").val(""); + + $detailsTab.find("#account").text(""); + $detailsTab.find("#size").text(""); + $detailsTab.find("#status").text(""); + $detailsTab.find("#bootable").text(""); + $detailsTab.find("#created").text(""); } var isoActionMap = { @@ -194,7 +209,7 @@ var isoActionMap = { isAsyncJob: true, asyncJobResponse: "deleteisosresponse", inProcessText: "Deleting ISO....", - afterActionSeccessFn: function(jsonObj) { + afterActionSeccessFn: function(jsonObj) { var $midmenuItem1 = $("#midmenuItem_"+jsonObj.id); $midmenuItem1.remove(); clearRightPanel(); @@ -219,7 +234,7 @@ var isoActionMap = { } var isoListAPIMap = { - listAPI: "listisos&isofilter=self", + listAPI: "listIsos&isofilter=self", listAPIResponse: "listisosresponse", listAPIResponseObj: "iso" }; diff --git a/ui/new/scripts/cloud.core2.js b/ui/new/scripts/cloud.core2.js index f591494b98a..c5484890d10 100644 --- a/ui/new/scripts/cloud.core2.js +++ b/ui/new/scripts/cloud.core2.js @@ -20,6 +20,166 @@ // Version: @VERSION@ + +//***** actions for details tab in right panel (begin) ************************************************************************ +function buildActionLinkForDetailsTab(label, actionMap, $actionMenu, listAPIMap) { + var apiInfo = actionMap[label]; + var $listItem = $("#action_list_item").clone(); + $actionMenu.find("#action_list").append($listItem.show()); + var $link = $listItem.find("#link").text(label); + $link.data("label", label); + $link.data("inProcessText", apiInfo.inProcessText); + $link.data("api", apiInfo.api); + $link.data("isAsyncJob", apiInfo.isAsyncJob); + $link.data("asyncJobResponse", apiInfo.asyncJobResponse); + $link.data("afterActionSeccessFn", apiInfo.afterActionSeccessFn); + $link.data("dialogBeforeActionFn", apiInfo.dialogBeforeActionFn); + + var $detailsTab = $("#right_panel_content #tab_content_details"); + var id = $detailsTab.data("jsonObj").id; + + $link.bind("click", function(event) { + $actionMenu.hide(); + var $actionLink = $(this); + var dialogBeforeActionFn = $actionLink.data("dialogBeforeActionFn"); + if(dialogBeforeActionFn == null) { + var apiCommand = "command="+$actionLink.data("api")+"&id="+id; + doActionToDetailsTab(id, $actionLink, apiCommand, listAPIMap); + } + else { + dialogBeforeActionFn($actionLink, listAPIMap, $detailsTab); + } + return false; + }); +} + +function doActionToDetailsTab(id, $actionLink, apiCommand, listAPIMap) { + var label = $actionLink.data("label"); + var inProcessText = $actionLink.data("inProcessText"); + var isAsyncJob = $actionLink.data("isAsyncJob"); + var asyncJobResponse = $actionLink.data("asyncJobResponse"); + var afterActionSeccessFn = $actionLink.data("afterActionSeccessFn"); + var listAPI = listAPIMap["listAPI"]; + var listAPIResponse = listAPIMap["listAPIResponse"]; + var listAPIResponseObj = listAPIMap["listAPIResponseObj"]; + + var $detailsTab = $("#right_panel_content #tab_content_details"); + var $spinningWheel = $detailsTab.find("#spinning_wheel"); + $spinningWheel.find("#description").text(inProcessText); + $spinningWheel.show(); + + //Async job (begin) ***** + if(isAsyncJob == true) { + $.ajax({ + data: createURL(apiCommand), + dataType: "json", + success: function(json) { + var jobId = json[asyncJobResponse].jobid; + var timerKey = "asyncJob_" + jobId; + $("body").everyTime( + 10000, + timerKey, + function() { + $.ajax({ + data: createURL("command=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); + $spinningWheel.hide(); + if (result.jobstatus == 1) { // Succeeded + $detailsTab.find("#action_message_box #description").text(label + " action succeeded."); + $detailsTab.find("#action_message_box").removeClass("error").show(); + + //DestroyVirtualMachine API doesn't return an embedded object on success (Bug 6041) + //Before Bug 6041 get fixed, use the temporary solution below. + $.ajax({ + cache: false, + data: createURL("command="+listAPI+"&id="+id), + dataType: "json", + success: function(json) { + afterActionSeccessFn(json[listAPIResponse][listAPIResponseObj][0]); + } + }); + //After Bug 6037 is fixed, remove temporary solution above and uncomment the line below + //afterActionSeccessFn(json[listAPIResponse][listAPIResponseObj][0]); + + } else if (result.jobstatus == 2) { // Failed + $detailsTab.find("#action_message_box #description").text(label + " action failed. Reason: " + sanitizeXSS(result.jobresult)); + $detailsTab.find("#action_message_box").addClass("error").show(); + } + } + }, + error: function(XMLHttpResponse) { + $("body").stopTime(timerKey); + handleErrorInDetailsTab(XMLHttpResponse, $detailsTab, label); + } + }); + }, + 0 + ); + }, + error: function(XMLHttpResponse) { + handleErrorInDetailsTab(XMLHttpResponse, $detailsTab, label); + } + }); + } + //Async job (end) ***** + + //Sync job (begin) ***** + else { + $.ajax({ + data: createURL(apiCommand), + dataType: "json", + async: false, + success: function(json) { + $spinningWheel.hide(); + + //RecoverVirtualMachine API doesn't return an embedded object on success (Bug 6037) + //Before Bug 6037 get fixed, use the temporary solution below. + $.ajax({ + cache: false, + data: createURL("command="+listAPI+"&id="+id), + dataType: "json", + async: false, + success: function(json) { + $detailsTab.find("#action_message_box #description").text(label + " action succeeded."); + $detailsTab.find("#action_message_box").removeClass("error").show(); + + afterActionSeccessFn(json[listAPIResponse][listAPIResponseObj][0]); + } + }); + //After Bug 6037 is fixed, remove temporary solution above and uncomment the line below + //afterActionSeccessFn(json[listAPIResponse][listAPIResponseObj][0]); + }, + error: function(XMLHttpResponse) { + handleErrorInDetailsTab(XMLHttpResponse, $detailsTab, label); + } + }); + } + //Sync job (end) ***** +} + +function handleErrorInDetailsTab(XMLHttpResponse, $detailsTab, label) { + $detailsTab.find("#spinning_wheel").hide(); + + var errorMsg = ""; + if(XMLHttpResponse.responseText != null & XMLHttpResponse.responseText.length > 0) { + var start = XMLHttpResponse.responseText.indexOf("h1") + 3; + var end = XMLHttpResponse.responseText.indexOf(" 0) + $detailsTab.find("#action_message_box #description").text(label + " action failed. Reason: " + sanitizeXSS(unescape(errorMsg))); + else + $detailsTab.find("#action_message_box #description").text(label + " action failed."); + $detailsTab.find("#action_message_box").addClass("error").show(); +} +//***** actions for details tab in right panel (end) ************************************************************************** + //***** actions for middle menu (begin) ************************************************************************ var selectedItemsInMidMenu = {}; @@ -180,164 +340,6 @@ function handleErrorInMidMenu(XMLHttpResponse, $midmenuItem) { } //***** actions for middle menu (end) ************************************************************************** -//***** actions for details tab in right panel (begin) ************************************************************************ -function buildActionLinkForDetailsTab(label, actionMap, $actionMenu, listAPIMap) { - var apiInfo = actionMap[label]; - var $listItem = $("#action_list_item").clone(); - $actionMenu.find("#action_list").append($listItem.show()); - var $link = $listItem.find("#link").text(label); - $link.data("label", label); - $link.data("inProcessText", apiInfo.inProcessText); - $link.data("api", apiInfo.api); - $link.data("isAsyncJob", apiInfo.isAsyncJob); - $link.data("asyncJobResponse", apiInfo.asyncJobResponse); - $link.data("afterActionSeccessFn", apiInfo.afterActionSeccessFn); - $link.data("dialogBeforeActionFn", apiInfo.dialogBeforeActionFn); - - var $detailsTab = $("#right_panel_content #tab_content_details"); - var id = $detailsTab.data("jsonObj").id; - - $link.bind("click", function(event) { - $actionMenu.hide(); - var $actionLink = $(this); - var dialogBeforeActionFn = $actionLink.data("dialogBeforeActionFn"); - if(dialogBeforeActionFn == null) { - var apiCommand = "command="+$actionLink.data("api")+"&id="+id; - doActionToDetailsTab(id, $actionLink, apiCommand, listAPIMap); - } - else { - dialogBeforeActionFn($actionLink, listAPIMap, $detailsTab); - } - return false; - }); -} - -function doActionToDetailsTab(id, $actionLink, apiCommand, listAPIMap) { - var label = $actionLink.data("label"); - var inProcessText = $actionLink.data("inProcessText"); - var isAsyncJob = $actionLink.data("isAsyncJob"); - var asyncJobResponse = $actionLink.data("asyncJobResponse"); - var afterActionSeccessFn = $actionLink.data("afterActionSeccessFn"); - var listAPI = listAPIMap["listAPI"]; - var listAPIResponse = listAPIMap["listAPIResponse"]; - var listAPIResponseObj = listAPIMap["listAPIResponseObj"]; - - var $detailsTab = $("#right_panel_content #tab_content_details"); - var $spinningWheel = $detailsTab.find("#spinning_wheel"); - $spinningWheel.find("#description").text(inProcessText); - $spinningWheel.show(); - - //Async job (begin) ***** - if(isAsyncJob == true) { - $.ajax({ - data: createURL(apiCommand), - dataType: "json", - success: function(json) { - var jobId = json[asyncJobResponse].jobid; - var timerKey = "asyncJob_" + jobId; - $("body").everyTime( - 10000, - timerKey, - function() { - $.ajax({ - data: createURL("command=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); - $spinningWheel.hide(); - if (result.jobstatus == 1) { // Succeeded - $detailsTab.find("#action_message_box #description").text(label + " action succeeded."); - $detailsTab.find("#action_message_box").removeClass("error").show(); - - //DestroyVirtualMachine API doesn't return an embedded object on success (Bug 6041) - //Before Bug 6041 get fixed, use the temporary solution below. - $.ajax({ - cache: false, - data: createURL("command="+listAPI+"&id="+id), - dataType: "json", - success: function(json) { - afterActionSeccessFn(json[listAPIResponse][listAPIResponseObj][0]); - } - }); - //After Bug 6037 is fixed, remove temporary solution above and uncomment the line below - //afterActionSeccessFn(json[listAPIResponse][listAPIResponseObj][0]); - - } else if (result.jobstatus == 2) { // Failed - $detailsTab.find("#action_message_box #description").text(label + " action failed. Reason: " + sanitizeXSS(result.jobresult)); - $detailsTab.find("#action_message_box").addClass("error").show(); - } - } - }, - error: function(XMLHttpResponse) { - $("body").stopTime(timerKey); - handleErrorInDetailsTab(XMLHttpResponse, $detailsTab, label); - } - }); - }, - 0 - ); - }, - error: function(XMLHttpResponse) { - handleErrorInDetailsTab(XMLHttpResponse, $detailsTab, label); - } - }); - } - //Async job (end) ***** - - //Sync job (begin) ***** - else { - $.ajax({ - data: createURL(apiCommand), - dataType: "json", - async: false, - success: function(json) { - $spinningWheel.hide(); - - //RecoverVirtualMachine API doesn't return an embedded object on success (Bug 6037) - //Before Bug 6037 get fixed, use the temporary solution below. - $.ajax({ - cache: false, - data: createURL("command="+listAPI+"&id="+id), - dataType: "json", - async: false, - success: function(json) { - $detailsTab.find("#action_message_box #description").text(label + " action succeeded."); - $detailsTab.find("#action_message_box").removeClass("error").show(); - - afterActionSeccessFn(json[listAPIResponse][listAPIResponseObj][0]); - } - }); - //After Bug 6037 is fixed, remove temporary solution above and uncomment the line below - //afterActionSeccessFn(json[listAPIResponse][listAPIResponseObj][0]); - }, - error: function(XMLHttpResponse) { - handleErrorInDetailsTab(XMLHttpResponse, $detailsTab, label); - } - }); - } - //Sync job (end) ***** -} - -function handleErrorInDetailsTab(XMLHttpResponse, $detailsTab, label) { - $detailsTab.find("#spinning_wheel").hide(); - - var errorMsg = ""; - if(XMLHttpResponse.responseText != null & XMLHttpResponse.responseText.length > 0) { - var start = XMLHttpResponse.responseText.indexOf("h1") + 3; - var end = XMLHttpResponse.responseText.indexOf(" 0) - $detailsTab.find("#action_message_box #description").text(label + " action failed. Reason: " + sanitizeXSS(unescape(errorMsg))); - else - $detailsTab.find("#action_message_box #description").text(label + " action failed."); - $detailsTab.find("#action_message_box").addClass("error").show(); -} -//***** actions for details tab in right panel (end) ************************************************************************** //***** actions for a subgrid item in right panel (begin) ************************************************************************ function buildActionLinkForSubgridItem(label, actionMap, $actionMenu, listAPIMap, $subgridItem) { diff --git a/ui/new/scripts/cloud.core2.template.js b/ui/new/scripts/cloud.core2.template.js index f8f36b89fbb..819d4cd918d 100644 --- a/ui/new/scripts/cloud.core2.template.js +++ b/ui/new/scripts/cloud.core2.template.js @@ -220,16 +220,16 @@ function templateClearRightPanel() { $detailsTab.find("#status").text(""); - setBooleanField(null, $detailsTab.find("#passwordenabled")); + $detailsTab.find("#passwordenabled").text(""); $detailsTab.find("#passwordenabled_edit").val(null); - setBooleanField(null, $detailsTab.find("#ispublic")); + $detailsTab.find("#ispublic").text(""); $detailsTab.find("#ispublic_edit").val(null); - setBooleanField(null, $detailsTab.find("#isfeatured")); + $detailsTab.find("#isfeatured").text(""); $detailsTab.find("#isfeatured_edit").val(null); - setBooleanField(null, $detailsTab.find("#crossZones")); + $detailsTab.find("#crossZones").text(""); $detailsTab.find("#ostypename").text(""); $detailsTab.find("#ostypename_edit").val(null); From b87c5e0222c3ecb1e4261102ca775a1ba23c9f5c Mon Sep 17 00:00:00 2001 From: NIKITA Date: Thu, 16 Sep 2010 16:16:02 -0700 Subject: [PATCH 23/86] New Ui for Dashboard --- ui/new/css/main.css | 90 +++++++++++++++++++++++++++++++++++ ui/new/images/db_usedbox.gif | Bin 0 -> 529 bytes ui/new/images/dbrow_even.gif | Bin 0 -> 124 bytes ui/new/images/dbrow_odd.gif | Bin 0 -> 133 bytes ui/new/jsp/dashboard.jsp | 53 +++++++++++++++++++++ 5 files changed, 143 insertions(+) create mode 100644 ui/new/images/db_usedbox.gif create mode 100644 ui/new/images/dbrow_even.gif create mode 100644 ui/new/images/dbrow_odd.gif create mode 100644 ui/new/jsp/dashboard.jsp diff --git a/ui/new/css/main.css b/ui/new/css/main.css index 872d7cc4068..7f40c2bfe23 100644 --- a/ui/new/css/main.css +++ b/ui/new/css/main.css @@ -2158,6 +2158,26 @@ a:visited { border-right:1px solid #CCC; } +.grid_header_formbox { + width:auto; + height:auto; + float:right; + margin:0; + padding:0; +} + +.grid_header_cell .select { + height:15px; + float:left; + margin:2px 10px 0 0; + display:inline; + padding:0; + border:1px solid #999; + background:#e7e7e7; + color:#333; + font-size:11px; +} + .grid_header_title { width:auto; height:auto; @@ -2389,4 +2409,74 @@ a:visited { margin:0; padding:0; z-index:1002; +} + +.dbrow { + width:100%; + height:44px; + float:left; + border-bottom:1px solid #e2e2e2; + margin:0; + padding:0; +} + +.dbrow.even { + background:url(../images/dbrow_even.gif) repeat-x top left; +} + +.dbrow.odd { + background:url(../images/dbrow_odd.gif) repeat-x top left; +} + +.dbrow_cell { + height:44px; + float:left; + border-right:1px solid #e2e2e2; + margin:0; + padding:0; +} + +.dbgraph_titlebox { + width:95%; + height:auto; + float:left; + margin:5px 0 0 10px; + padding:0; +} + +.dbgraph_titlebox h2{ + width:80%; + height:auto; + float:left; + color:#333; + font-size:11px; + font-weight:normal; + text-align:left; + margin:0; + padding:0; +} + +.dbgraph_title_usedbox { + width:170px; + height:16px; + float:left; + background:url(../images/db_usedbox.gif) no-repeat top left; + margin:3px 0 0 0; + padding:0; +} + +.dbgraph_title_usedbox p { + width: auto; + height:auto; + float:left; + color:#FFF; + font-size:11px; + font-weight:normal; + text-align:left; + margin:2px 0 0 5px; + padding:0; +} + +.dbgraph_title_usedbox span { + font-weight:bold; } \ No newline at end of file diff --git a/ui/new/images/db_usedbox.gif b/ui/new/images/db_usedbox.gif new file mode 100644 index 0000000000000000000000000000000000000000..4370792940fbf245e222601ba2af3ad799555fb2 GIT binary patch literal 529 zcmZ?wbhEHbT*V;3aFu}}GBVQL-90QUEFd7j+S=OR-`~f_Cpb9R)zvjLG}O$@EFvPp z$;s*c`}elCw&CI7&z?QAw6xUI({pxq*3r><{`|RvgM*Qgk*=<;wzhV9dU}3-eo9Kp zlqpksdU`xPJ!j0Av1`{Z6BCnz2M$IM{rS;hu8GhK0`U4C_;Gf7`Igwf5<`sR0I!)7N(^I9E+} z%RR*CH_zc@)X7atPfs@pzqsjXlB>b(}P&+h*3q|v96G%sVpx*Y301wLm=a_>~cy{Vc1=fHzR K4;?oK25SJ7pf?Nv literal 0 HcmV?d00001 diff --git a/ui/new/images/dbrow_odd.gif b/ui/new/images/dbrow_odd.gif new file mode 100644 index 0000000000000000000000000000000000000000..6936525f9d65dd8901a48f5c9f2655dc5e21ec28 GIT binary patch literal 133 zcmV;00DAvNNk%w1VFdsz0J8u9@9*#C=H~0`>*M3&?d|RE?(XdD?CI(0=;-L-;o;=u z%L1IA9QUaINt1g;Qv5}P^c&t2gsz7!DJ?$&j +<%@ page import="com.cloud.utils.*" %> + +<% + Locale browserLocale = request.getLocale(); + CloudResourceBundle t = CloudResourceBundle.getBundle("resources/resource", browserLocale); +%> + + +
+ +
+ Event
+ +

Dashboard +

+
+ + +
+ + +
+
+
+
System Wide Capacity
+
+
+
+ + +
+
+
+
+
+
+

Public IP Addresses

+
+

Used: 2 / 11

+
+
+
+
+
+
+
+
+
+ + From f1cab0525c1c1ed5a1197149269ee841b310e288 Mon Sep 17 00:00:00 2001 From: abhishek Date: Thu, 16 Sep 2010 16:46:55 -0700 Subject: [PATCH 24/86] bug 6021: blocking the deletion of private disk offering from the back end api --- .../src/com/cloud/api/commands/DeleteDiskOfferingCmd.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/server/src/com/cloud/api/commands/DeleteDiskOfferingCmd.java b/server/src/com/cloud/api/commands/DeleteDiskOfferingCmd.java index 5c00750146f..8c38a24857b 100644 --- a/server/src/com/cloud/api/commands/DeleteDiskOfferingCmd.java +++ b/server/src/com/cloud/api/commands/DeleteDiskOfferingCmd.java @@ -26,6 +26,7 @@ import org.apache.log4j.Logger; import com.cloud.api.BaseCmd; import com.cloud.api.ServerApiException; +import com.cloud.offering.DiskOffering; import com.cloud.storage.DiskOfferingVO; import com.cloud.user.User; import com.cloud.utils.Pair; @@ -62,7 +63,12 @@ public class DeleteDiskOfferingCmd extends BaseCmd { if (disk == null) { throw new ServerApiException(BaseCmd.PARAM_ERROR, "unable to find a disk offering with id " + id); } - + + if(disk.getName().equals("Private") && disk.getDisplayText().equals("Private Disk")){ + //block deletion of these disks + throw new ServerApiException(BaseCmd.INTERNAL_ERROR,"Cannot delete this diskoffering as it is private"); + } + boolean result = getManagementServer().deleteDiskOffering(userId, id); List> returnValues = new ArrayList>(); From bcfbfa628e95fa2d61cd7a7db98f898fa897d74b Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Thu, 16 Sep 2010 16:52:24 -0700 Subject: [PATCH 25/86] new UI - add dashboard link. --- ui/new/index.jsp | 4 ++-- ui/new/scripts/cloud.core2.init.js | 14 ++++++++++---- ui/new/scripts/cloud.core2.js | 12 ++++++++++-- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/ui/new/index.jsp b/ui/new/index.jsp index 14abb69651d..0afb8418fbe 100644 --- a/ui/new/index.jsp +++ b/ui/new/index.jsp @@ -83,7 +83,7 @@ long milliseconds = new Date().getTime();
-
+
  1. @@ -261,7 +261,7 @@ long milliseconds = new Date().getTime();
-
+
-
+
diff --git a/ui/new/scripts/cloud.core2.instance.js b/ui/new/scripts/cloud.core2.instance.js index 7d1ce21df9e..1ceedf983d6 100644 --- a/ui/new/scripts/cloud.core2.instance.js +++ b/ui/new/scripts/cloud.core2.instance.js @@ -377,31 +377,33 @@ function clickInstanceGroupHeader($arrowIcon) { } function vmToRightPanel($midmenuItem) { - var json = $midmenuItem.data("jsonObj"); - vmJsonToDetailsTab(json, $midmenuItem); + var jsonObj = $midmenuItem.data("jsonObj"); + + var vmName = getVmName(jsonObj.name, jsonObj.displayname); + $("right_panel_header").find("#vm_name").text(fromdb(vmName)); + + var $rightPanelContent = $("#right_panel_content"); + if($midmenuItem.find("#info_icon").css("display") != "none") { + $rightPanelContent.find("#after_action_info").text($midmenuItem.data("afterActionInfo")); + if($midmenuItem.find("#info_icon").hasClass("error")) + $rightPanelContent.find("#after_action_info_container").addClass("errorbox"); + else + $rightPanelContent.find("#after_action_info_container").removeClass("errorbox"); + $rightPanelContent.find("#after_action_info_container").show(); + } + else { + $rightPanelContent.find("#after_action_info").text(""); + $rightPanelContent.find("#after_action_info_container").hide(); + } + + vmJsonToDetailsTab(jsonObj, $midmenuItem); } function vmJsonToDetailsTab(jsonObj, $midmenuItem){ var $detailsTab = $("#right_panel_content #tab_content_details"); $detailsTab.data("jsonObj", jsonObj); - //details tab - if($midmenuItem.find("#info_icon").css("display") != "none") { - $detailsTab.find("#after_action_info").text($midmenuItem.data("afterActionInfo")); - if($midmenuItem.find("#info_icon").hasClass("error")) - $detailsTab.find("#after_action_info_container").addClass("errorbox"); - else - $detailsTab.find("#after_action_info_container").removeClass("errorbox"); - $detailsTab.find("#after_action_info_container").show(); - } - else { - $detailsTab.find("#after_action_info").text(""); - $detailsTab.find("#after_action_info_container").hide(); - } - - - var vmName = getVmName(jsonObj.name, jsonObj.displayname); - $rightPanelHeader.find("#vm_name").text(fromdb(vmName)); + //details tab updateVirtualMachineStateInRightPanel(jsonObj.state); $detailsTab.find("#ipAddress").text(jsonObj.ipaddress); $detailsTab.find("#zoneName").text(fromdb(jsonObj.zonename)); @@ -569,13 +571,15 @@ function clickInstanceGroupHeader($arrowIcon) { data: createURL("command=listVirtualMachines&group="+group1+"&pagesize="+midmenuItemCount), dataType: "json", success: function(json) { - var instances = json.listvirtualmachinesresponse.virtualmachine; - for(var i=0; i 0) { + for(var i=0; i Date: Thu, 16 Sep 2010 18:52:02 -0700 Subject: [PATCH 27/86] new UI - error handling when adding VM fails. --- ui/new/jsp/template.jsp | 79 ++++++++++++++++ ui/new/scripts/cloud.core2.instance.js | 45 +++------ ui/new/scripts/cloud.core2.js | 24 ++++- ui/new/scripts/cloud.core2.template.js | 122 +++++++++++++++++++------ 4 files changed, 206 insertions(+), 64 deletions(-) diff --git a/ui/new/jsp/template.jsp b/ui/new/jsp/template.jsp index c62233ec905..0c3e9538a40 100644 --- a/ui/new/jsp/template.jsp +++ b/ui/new/jsp/template.jsp @@ -259,3 +259,82 @@
+ + + + diff --git a/ui/new/scripts/cloud.core2.instance.js b/ui/new/scripts/cloud.core2.instance.js index 1ceedf983d6..1dcfbeddd1e 100644 --- a/ui/new/scripts/cloud.core2.instance.js +++ b/ui/new/scripts/cloud.core2.instance.js @@ -1186,19 +1186,14 @@ function clickInstanceGroupHeader($arrowIcon) { moreCriteria.push("&group="+todb(group)); vmWizardClose(); - - var $t = $("#midmenu_item").clone(); - $t.find("#first_row").text("Adding...."); - $t.find("#content").addClass("inaction"); - $t.find("#spinning_wheel").show(); - $("#midmenu_container").append($t.show()); - + + var $midmenuItem1 = beforeAddingMidMenuItem() ; + $.ajax({ data: createURL("command=deployVirtualMachine"+moreCriteria.join("")), dataType: "json", success: function(json) { - var jobId = json.deployvirtualmachineresponse.jobid; - $t.attr("id","vmNew"+jobId).data("jobId", jobId); + var jobId = json.deployvirtualmachineresponse.jobid; var timerKey = "vmNew"+jobId; // Process the async job @@ -1214,35 +1209,23 @@ function clickInstanceGroupHeader($arrowIcon) { if (result.jobstatus == 0) { return; //Job has not completed } else { - $("body").stopTime(timerKey); - $t.find("#content").removeClass("inaction"); - $t.find("#spinning_wheel").hide(); + $("body").stopTime(timerKey); if (result.jobstatus == 1) { // Succeeded - $t.find("#info_icon").removeClass("error").show(); - $t.data("afterActionInfo", ("Adding succeeded.")); + afterAddingMidMenuItem($midmenuItem1, true); if("virtualmachine" in result) vmToMidmenu(result.virtualmachine[0], $t); } else if (result.jobstatus == 2) { // Failed - $t.find("#first_row").text("Adding failed"); - $t.find("#info_icon").addClass("error").show(); - $t.data("afterActionInfo", ("Adding failed. Reason: " + fromdb(result.jobresult))); - $t.bind("click", function(event) { - $rightPanelContent.find("#after_action_info").text($(this).data("afterActionInfo")); - $rightPanelContent.find("#after_action_info_container").addClass("errorbox"); - $rightPanelContent.find("#after_action_info_container").show(); - vmClearRightPanel(); - return false; - }); + afterAddingMidMenuItem($midmenuItem1, false); + $("#dialog_error").html("

Adding Instance failed


"+fromdb(result.jobresult)+"

").dialog("open"); } } }, error: function(XMLHttpResponse) { - $("body").stopTime(timerKey); - $t.find("#info_icon").addClass("error").show(); - $t.find("#first_row").text("Adding failed"); + $("body").stopTime(timerKey); + afterAddingMidMenuItem($midmenuItem1, false); handleError(XMLHttpResponse); } }); @@ -1250,9 +1233,8 @@ function clickInstanceGroupHeader($arrowIcon) { 0 ); }, - error: function(XMLHttpResponse) { - $t.find("#info_icon").addClass("error").show(); - $t.find("#first_row").text("Adding failed"); + error: function(XMLHttpResponse) { + afterAddingMidMenuItem($midmenuItem1, false); handleError(XMLHttpResponse); } }); @@ -1312,8 +1294,7 @@ function doCreateTemplateFromVmVolume($actionLink, listAPIMap, $subgridItem) { $("#dialog_create_template") .dialog('option', 'buttons', { - "Create": function() { - //debugger; + "Create": function() { var thisDialog = $(this); thisDialog.dialog("close"); diff --git a/ui/new/scripts/cloud.core2.js b/ui/new/scripts/cloud.core2.js index e105eba3c66..1b53ff4f131 100644 --- a/ui/new/scripts/cloud.core2.js +++ b/ui/new/scripts/cloud.core2.js @@ -548,14 +548,34 @@ function hideMiddleMenu() { $("#middle_menu, #search_panel, #middle_menu_pagination").hide(); $("#right_panel").removeClass("main_contentarea").addClass("main_contentarea_dashboard"); } - function showMiddleMenu() { $("#middle_menu, #search_panel, #middle_menu_pagination").show(); $("#right_panel").removeClass("main_contentarea_dashboard").addClass("main_contentarea"); } - +// adding middle menu item *** +function beforeAddingMidMenuItem() { + var $midmenuItem1 = $("#midmenu_item").clone(); + $midmenuItem1.find("#first_row").text("Adding...."); + $midmenuItem1.find("#content").addClass("inaction"); + $midmenuItem1.find("#spinning_wheel").show(); + $("#midmenu_container").append($midmenuItem1.show()); + return $midmenuItem1; +} +function afterAddingMidMenuItem($midmenuItem1, isSuccessful) { + $midmenuItem1.find("#content").removeClass("inaction"); + $midmenuItem1.find("#spinning_wheel").hide(); + + if(isSuccessful == true) { + $midmenuItem1.find("#info_icon").removeClass("error").show(); + $midmenuItem1.data("afterActionInfo", ("Adding succeeded.")); + } + else { + $midmenuItem1.find("#info_icon").addClass("error").show(); + $midmenuItem1.find("#first_row").text("Adding failed"); + } +} diff --git a/ui/new/scripts/cloud.core2.template.js b/ui/new/scripts/cloud.core2.template.js index 819d4cd918d..bb4ebef3427 100644 --- a/ui/new/scripts/cloud.core2.template.js +++ b/ui/new/scripts/cloud.core2.template.js @@ -1,8 +1,63 @@ var g_zoneIds = []; var g_zoneNames = []; -function afterLoadTemplateJSP() { - var $detailsTab = $("#right_panel_content #tab_content_details"); +function afterLoadTemplateJSP() { + var $detailsTab = $("#right_panel_content #tab_content_details"); + + //add button *** + $("#midmenu_add_link").show(); + $("#midmenu_add_link").bind("click", function(event) { + $("#dialog_add_template") + .dialog('option', 'buttons', { + "Create": function() { + var thisDialog = $(this); + thisDialog.dialog("close"); + + debugger; + // validate values + var isValid = true; + isValid &= validateString("Name", thisDialog.find("#add_template_name"), thisDialog.find("#add_template_name_errormsg")); + isValid &= validateString("Display Text", thisDialog.find("#add_template_display_text"), thisDialog.find("#add_template_display_text_errormsg")); + isValid &= validateString("URL", thisDialog.find("#add_template_url"), thisDialog.find("#add_template_url_errormsg")); + if (!isValid) return; + + var name = trim(thisDialog.find("#add_template_name").val()); + var desc = trim(thisDialog.find("#add_template_display_text").val()); + var url = trim(thisDialog.find("#add_template_url").val()); + var zoneId = thisDialog.find("#add_template_zone").val(); + var format = thisDialog.find("#add_template_format").val(); + var password = thisDialog.find("#add_template_password").val(); + var isPublic = thisDialog.find("#add_template_public").val(); + var osType = thisDialog.find("#add_template_os_type").val(); + + var moreCriteria = []; + if(thisDialog.find("#add_template_featured_container").css("display")!="none") { + var isFeatured = thisDialog.find("#add_template_featured").val(); + moreCriteria.push("&isfeatured="+isFeatured); + } + + //middle menu spinning wheel.... + + $.ajax({ + data: createURL("command=registerTemplate&name="+encodeURIComponent(name)+"&displayText="+encodeURIComponent(desc)+"&url="+encodeURIComponent(url)+"&zoneid="+zoneId+"&ispublic="+isPublic+moreCriteria.join("")+"&format="+format+"&passwordEnabled="+password+"&osTypeId="+osType+"&response=json"), + dataType: "json", + success: function(json) { + var result = json.registertemplateresponse; + debugger; + //spinning wheel disappear + }, + error: function(XMLHttpResponse) { + debugger; + + } + }); + }, + "Cancel": function() { + $(this).dialog("close"); + } + }).dialog("open"); + return false; + }); //edit button *** var $readonlyFields = $detailsTab.find("#name, #displaytext, #passwordenabled, #ispublic, #isfeatured, #ostypename"); @@ -28,17 +83,39 @@ function afterLoadTemplateJSP() { }); - //populate dropdown *** + //populate dropdown *** + var addTemplateZoneField = $("#dialog_add_template #add_template_zone"); + if (isAdmin()) + addTemplateZoneField.append(""); + $.ajax({ + data: createURL("command=listZones&available=true"+maxPageSize), + dataType: "json", + success: function(json) { + var zones = json.listzonesresponse.zone; + if (zones != null && zones.length > 0) { + for (var i = 0; i < zones.length; i++) { + addTemplateZoneField.append(""); + g_zoneIds.push(zones[i].id); + g_zoneNames.push(zones[i].name); + } + } + } + }); + $.ajax({ data: createURL("command=listOsTypes&response=json"+maxPageSize), dataType: "json", success: function(json) { types = json.listostypesresponse.ostype; - if (types != null && types.length > 0) { - var osTypeDropdown = $detailsTab.find("#ostypename_edit").empty(); - for (var i = 0; i < types.length; i++) { - var html = ""; - osTypeDropdown.append(html); + if (types != null && types.length > 0) { + var osTypeDropdownAdd = $("#dialog_add_template #add_template_os_type"); + var osTypeDropdownEdit = $detailsTab.find("#ostypename_edit").empty(); + if(types != null && types.length > 0) { + for(var i = 0; i < types.length; i++) { + var html = ""; + osTypeDropdownAdd.append(html); + osTypeDropdownEdit.append(html); + } } } } @@ -72,6 +149,13 @@ function afterLoadTemplateJSP() { }); //initialize dialog box *** + activateDialog($("#dialog_add_template").dialog({ + width:450, + autoOpen: false, + modal: true, + zIndex: 2000 + })); + activateDialog($("#dialog_copy_template").dialog({ width:300, autoOpen: false, @@ -85,28 +169,6 @@ function afterLoadTemplateJSP() { modal: true, zIndex: 2000 })); - - //populate zone dropdown excluding source zone *** - var addTemplateZoneField = $("#dialog_add_template #add_template_zone"); - - // Add default zone - if (isAdmin()) { - addTemplateZoneField.append(""); - } - $.ajax({ - data: createURL("command=listZones&available=true"+maxPageSize), - dataType: "json", - success: function(json) { - var zones = json.listzonesresponse.zone; - if (zones != null && zones.length > 0) { - for (var i = 0; i < zones.length; i++) { - addTemplateZoneField.append(""); - g_zoneIds.push(zones[i].id); - g_zoneNames.push(zones[i].name); - } - } - } - }); } function templateToMidmenu(jsonObj, $midmenuItem1) { From 221c8fb05932e4ce1ad21b8badd946f5144e7829 Mon Sep 17 00:00:00 2001 From: anthony Date: Thu, 16 Sep 2010 19:31:12 -0700 Subject: [PATCH 28/86] add more log --- .../xen/resource/XenServerConnectionPool.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/core/src/com/cloud/hypervisor/xen/resource/XenServerConnectionPool.java b/core/src/com/cloud/hypervisor/xen/resource/XenServerConnectionPool.java index 22401671c00..d4ef72350a8 100644 --- a/core/src/com/cloud/hypervisor/xen/resource/XenServerConnectionPool.java +++ b/core/src/com/cloud/hypervisor/xen/resource/XenServerConnectionPool.java @@ -159,6 +159,9 @@ public class XenServerConnectionPool { } protected synchronized void cleanup(String poolUuid) { + if( poolUuid == null ) { + return; + } ConnectionInfo info = _infos.remove(poolUuid); if (info == null) { return; @@ -187,8 +190,10 @@ public class XenServerConnectionPool { protected synchronized void cleanup(String poolUuid, ConnectionInfo info) { ConnectionInfo info2 = _infos.get(poolUuid); - s_logger - .debug("Cleanup for Session " + info.conn.getSessionReference()); + if( info2 == null ) { + return; + } + s_logger.debug("Cleanup for Session " + info.conn.getSessionReference()); if (info != info2) { s_logger.debug("Session " + info.conn.getSessionReference() + " is already logged out."); @@ -796,18 +801,20 @@ public class XenServerConnectionPool { try { return super.dispatch(method_call, method_params); } catch (Types.SessionInvalid e) { + s_logger.debug("Session is invalid for method: " + method_call + " due to " + e.getMessage() + ". Reconnecting...retry=" + + retries); if (retries >= _retries) { if (_poolUuid != null) { cleanup(_poolUuid, _info); } throw e; } - s_logger.debug("Session is invalid. Reconnecting...retry=" - + retries); Session.loginWithPassword(this, _username, _password, APIVersion.latest().toString()); method_params[0] = getSessionReference(); } catch (XmlRpcException e) { + s_logger.debug("XmlRpcException for method: " + method_call + " due to " + e.getMessage() + ". Reconnecting...retry=" + + retries); if (retries >= _retries) { if (_poolUuid != null) { cleanup(_poolUuid, _info); @@ -821,9 +828,9 @@ public class XenServerConnectionPool { } throw e; } - s_logger.debug("Connection couldn't be made for method " + method_call - + " Reconnecting....retry=" + retries); } catch (Types.HostIsSlave e) { + s_logger.debug("HostIsSlave Exception for method: " + method_call + " due to " + e.getMessage() + ". Reconnecting...retry=" + + retries); if (_poolUuid != null) { cleanup(_poolUuid, _info); } From 135f13127099045ccb06c709c2a6e42b6f6c6b06 Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Thu, 16 Sep 2010 20:13:07 -0700 Subject: [PATCH 29/86] new UI - template page - implement add template --- ui/new/scripts/cloud.core2.init.js | 15 ++------- ui/new/scripts/cloud.core2.instance.js | 3 +- ui/new/scripts/cloud.core2.js | 33 ++++++++++++++++++- ui/new/scripts/cloud.core2.template.js | 45 ++++++++++++++++++-------- 4 files changed, 67 insertions(+), 29 deletions(-) diff --git a/ui/new/scripts/cloud.core2.init.js b/ui/new/scripts/cloud.core2.init.js index 854c184897e..d2d69e6729c 100644 --- a/ui/new/scripts/cloud.core2.init.js +++ b/ui/new/scripts/cloud.core2.init.js @@ -59,19 +59,8 @@ $(document).ready(function() { for(var i=0; i 0) - $("#"+selected_midmenu_id).find("#content").removeClass("selected"); - selected_midmenu_id = ("midmenuItem_"+thisMidmenuItem.data("jsonObj").id); - - thisMidmenuItem.find("#content").addClass("selected"); - clearRightPanel(); - toRightPanel(thisMidmenuItem); - return false; - }); + toMidmenu(items[i], $midmenuItem1); + bindClickToMidMenu($midmenuItem1, toRightPanel); $("#midmenu_container").append($midmenuItem1.show()); } } diff --git a/ui/new/scripts/cloud.core2.instance.js b/ui/new/scripts/cloud.core2.instance.js index 1dcfbeddd1e..a7acb16f9df 100644 --- a/ui/new/scripts/cloud.core2.instance.js +++ b/ui/new/scripts/cloud.core2.instance.js @@ -1218,8 +1218,7 @@ function clickInstanceGroupHeader($arrowIcon) { } else if (result.jobstatus == 2) { // Failed - afterAddingMidMenuItem($midmenuItem1, false); - $("#dialog_error").html("

Adding Instance failed


"+fromdb(result.jobresult)+"

").dialog("open"); + afterAddingMidMenuItem($midmenuItem1, false, fromdb(result.jobresult)); } } }, diff --git a/ui/new/scripts/cloud.core2.js b/ui/new/scripts/cloud.core2.js index 1b53ff4f131..2f3306b749f 100644 --- a/ui/new/scripts/cloud.core2.js +++ b/ui/new/scripts/cloud.core2.js @@ -563,7 +563,7 @@ function beforeAddingMidMenuItem() { $("#midmenu_container").append($midmenuItem1.show()); return $midmenuItem1; } -function afterAddingMidMenuItem($midmenuItem1, isSuccessful) { +function afterAddingMidMenuItem($midmenuItem1, isSuccessful, extraMessage) { $midmenuItem1.find("#content").removeClass("inaction"); $midmenuItem1.find("#spinning_wheel").hide(); @@ -574,9 +574,40 @@ function afterAddingMidMenuItem($midmenuItem1, isSuccessful) { else { $midmenuItem1.find("#info_icon").addClass("error").show(); $midmenuItem1.find("#first_row").text("Adding failed"); + if(extraMessage != null) + $midmenuItem1.find("#second_row").text(extraMessage); } } +function bindClickToMidMenu($midmenuItem1, toRightPanel) { + $midmenuItem1.bind("click", function(event){ + var thisMidmenuItem = $(this); + + if(selected_midmenu_id != null && selected_midmenu_id.length > 0) + $("#"+selected_midmenu_id).find("#content").removeClass("selected"); + selected_midmenu_id = ("midmenuItem_"+thisMidmenuItem.data("jsonObj").id); + + thisMidmenuItem.find("#content").addClass("selected"); + clearRightPanel(); + toRightPanel(thisMidmenuItem); + return false; + }); +} + + + + + + + + + + + + + + + diff --git a/ui/new/scripts/cloud.core2.template.js b/ui/new/scripts/cloud.core2.template.js index bb4ebef3427..19317db8c09 100644 --- a/ui/new/scripts/cloud.core2.template.js +++ b/ui/new/scripts/cloud.core2.template.js @@ -4,16 +4,27 @@ var g_zoneNames = []; function afterLoadTemplateJSP() { var $detailsTab = $("#right_panel_content #tab_content_details"); - //add button *** + //add button *** + var formatSelect = $("#dialog_add_template #add_template_format").empty(); + if (getHypervisorType() == "kvm") + formatSelect.append(""); + else if (getHypervisorType() == "xenserver") + formatSelect.append(""); + + if(isAdmin()) + $("#dialog_add_template #add_template_featured_container, #dialog_edit_template #edit_template_featured_container").show(); + else + $("#dialog_add_template #add_template_featured_container, #dialog_edit_template #edit_template_featured_container").hide(); + $("#midmenu_add_link").show(); + $("#midmenu_add_link").bind("click", function(event) { $("#dialog_add_template") .dialog('option', 'buttons', { "Create": function() { var thisDialog = $(this); thisDialog.dialog("close"); - - debugger; + // validate values var isValid = true; isValid &= validateString("Name", thisDialog.find("#add_template_name"), thisDialog.find("#add_template_name_errormsg")); @@ -36,20 +47,28 @@ function afterLoadTemplateJSP() { moreCriteria.push("&isfeatured="+isFeatured); } - //middle menu spinning wheel.... + var $midmenuItem1 = beforeAddingMidMenuItem() ; $.ajax({ data: createURL("command=registerTemplate&name="+encodeURIComponent(name)+"&displayText="+encodeURIComponent(desc)+"&url="+encodeURIComponent(url)+"&zoneid="+zoneId+"&ispublic="+isPublic+moreCriteria.join("")+"&format="+format+"&passwordEnabled="+password+"&osTypeId="+osType+"&response=json"), dataType: "json", - success: function(json) { - var result = json.registertemplateresponse; - debugger; - //spinning wheel disappear - }, - error: function(XMLHttpResponse) { - debugger; - - } + success: function(json) { + var result = json.registertemplateresponse; + templateToMidmenu(result.template[0], $midmenuItem1); + bindClickToMidMenu($midmenuItem1, templateToRigntPanel); + /* + if(result.template.length > 1) { + for(var i=1; i Date: Thu, 16 Sep 2010 20:37:58 -0700 Subject: [PATCH 30/86] new UI - ISO page - implement adding ISO. --- ui/new/jsp/iso.jsp | 53 ++++++++++++++ ui/new/scripts/cloud.core2.iso.js | 116 +++++++++++++++++++++++------- 2 files changed, 142 insertions(+), 27 deletions(-) diff --git a/ui/new/jsp/iso.jsp b/ui/new/jsp/iso.jsp index b7d6ab38876..f6fcd0d4b48 100644 --- a/ui/new/jsp/iso.jsp +++ b/ui/new/jsp/iso.jsp @@ -154,6 +154,59 @@
+ + + + From 263bfe13bda0b6d0720288c36fe02e33ce07421a Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Fri, 17 Sep 2010 16:25:17 -0700 Subject: [PATCH 48/86] new UI - IP address page - implement details tab. --- ui/new/jsp/ip_address.jsp | 50 ++++++++++--------------- ui/new/scripts/cloud.core2.init.js | 2 +- ui/new/scripts/cloud.core2.ipaddress.js | 45 ++++++++++++++++++++-- 3 files changed, 62 insertions(+), 35 deletions(-) diff --git a/ui/new/jsp/ip_address.jsp b/ui/new/jsp/ip_address.jsp index ec5a18072e5..ddd96927e52 100644 --- a/ui/new/jsp/ip_address.jsp +++ b/ui/new/jsp/ip_address.jsp @@ -61,7 +61,7 @@ IP:
-
+
@@ -71,7 +71,7 @@ Zone:
-
+
@@ -81,67 +81,57 @@ VLAN:
-
+
-
+
-
-
- <%=t.t("Level")%>:
-
-
-
-
-
-
-
Source NAT:
-
+
-
+
Network Type:
-
-
-
-
-
-
-
- Domain:
-
-
-
+
- Account:
+ Domain:
-
+
+
+
+ Account:
+
+
+
+
+
+
+
Allocated:
-
+
diff --git a/ui/new/scripts/cloud.core2.init.js b/ui/new/scripts/cloud.core2.init.js index 5e2f3af7572..3d261233901 100644 --- a/ui/new/scripts/cloud.core2.init.js +++ b/ui/new/scripts/cloud.core2.init.js @@ -75,7 +75,7 @@ $(document).ready(function() { listMidMenuItems("leftmenu_account", "listAccounts", "listaccountsresponse", "account", "jsp/account.jsp", afterLoadAccountJSP, accountToMidmenu, accountToRigntPanel); listMidMenuItems("leftmenu_volume", "listVolumes", "listvolumesresponse", "volume", "jsp/volume.jsp", afterLoadVolumeJSP, volumeToMidmenu, volumeToRigntPanel); listMidMenuItems("leftmenu_snapshot", "listSnapshots", "listsnapshotsresponse", "snapshot", "jsp/snapshot.jsp", afterLoadSnapshotJSP, snapshotToMidmenu, snapshotToRigntPanel); - listMidMenuItems("leftmenu_ip", "listPublicIpAddresses", "listpublicipaddressesresponse", "publicipaddress", "jsp/ip_address.jsp", afterLoadIpJSP, ipToMidmenu, ipToRigntPanel); + listMidMenuItems("leftmenu_ip", "listPublicIpAddresses", "listpublicipaddressesresponse", "publicipaddress", "jsp/ip_address.jsp", afterLoadIpJSP, ipToMidmenu, ipToRigntPanel, ipGetMidmenuId); listMidMenuItems("leftmenu_router", "listRouters", "listroutersresponse", "router", "jsp/router.jsp", afterLoadRouterJSP, routerToMidmenu, routerToRigntPanel); listMidMenuItems("leftmenu_submenu_my_template", "listTemplates&templatefilter=self", "listtemplatesresponse", "template", "jsp/template.jsp", afterLoadTemplateJSP, templateToMidmenu, templateToRigntPanel, templateGetMidmenuId); diff --git a/ui/new/scripts/cloud.core2.ipaddress.js b/ui/new/scripts/cloud.core2.ipaddress.js index 37d40bf076a..98d43fe3e3e 100644 --- a/ui/new/scripts/cloud.core2.ipaddress.js +++ b/ui/new/scripts/cloud.core2.ipaddress.js @@ -2,8 +2,13 @@ function afterLoadIpJSP() { } +function ipGetMidmenuId(jsonObj) { + return "midmenuItem_" + jsonObj.ipaddress.replace(/\./g, "_"); //e.g. "192.168.33.108" => "192_168_33_108" +} + function ipToMidmenu(jsonObj, $midmenuItem1) { - $midmenuItem1.attr("id", ("midmenuItem_"+jsonObj.id)); + var id = ipGetMidmenuId(jsonObj); + $midmenuItem1.attr("id", id); $midmenuItem1.data("jsonObj", jsonObj); var $iconContainer = $midmenuItem1.find("#icon_container").show(); @@ -13,8 +18,40 @@ function ipToMidmenu(jsonObj, $midmenuItem1) { $midmenuItem1.find("#second_row").text(fromdb(jsonObj.account).substring(0,25)); } -function ipToRigntPanel($midmenuItem) { - var jsonObj = $midmenuItem.data("jsonObj"); +function ipToRigntPanel($midmenuItem1) { + var jsonObj = $midmenuItem1.data("jsonObj"); + ipJsonToDetailsTab(jsonObj); +} + +function ipJsonToDetailsTab(jsonObj) { + var $detailsTab = $("#right_panel_content #tab_content_details"); + $detailsTab.data("jsonObj", jsonObj); - var $rightPanelContent = $("#right_panel_content"); + $detailsTab.find("#ipaddress").text(fromdb(jsonObj.ipaddress)); + $detailsTab.find("#zonename").text(fromdb(jsonObj.zonename)); + $detailsTab.find("#vlanname").text(fromdb(jsonObj.vlanname)); + setSourceNatField(jsonObj.issourcenat, $detailsTab.find("#source_nat")); + setNetworkTypeField(jsonObj.forvirtualnetwork, $detailsTab.find("#network_type")); + + $detailsTab.find("#domain").text(fromdb(jsonObj.domain)); + $detailsTab.find("#account").text(fromdb(jsonObj.account)); + $detailsTab.find("#allocated").text(fromdb(jsonObj.allocated)); +} + +function setSourceNatField(value, $field) { + if(value == "true") + $field.text("Yes"); + else if(value == "false") + $field.text("No"); + else + $field.text(""); +} + +function setNetworkTypeField(value, $field) { + if(value == "true") + $field.text("Public"); + else if(value == "false") + $field.text("Direct"); + else + $field.text(""); } \ No newline at end of file From a016aa27cd17104cdcf4e8e08b24e21ed92ebd09 Mon Sep 17 00:00:00 2001 From: abhishek Date: Fri, 17 Sep 2010 15:19:21 -0700 Subject: [PATCH 49/86] bug 6203: incremental fix --- .../com/cloud/server/ManagementServer.java | 3 +- .../api/commands/CreateDiskOfferingCmd.java | 5 +++- .../api/commands/DeleteDiskOfferingCmd.java | 2 +- .../cloud/server/ConfigurationServerImpl.java | 2 +- .../cloud/server/ManagementServerImpl.java | 28 +++++++++++++------ 5 files changed, 27 insertions(+), 13 deletions(-) diff --git a/core/src/com/cloud/server/ManagementServer.java b/core/src/com/cloud/server/ManagementServer.java index 157c3685ba8..9b85f40c31e 100755 --- a/core/src/com/cloud/server/ManagementServer.java +++ b/core/src/com/cloud/server/ManagementServer.java @@ -1836,8 +1836,9 @@ public interface ManagementServer { * @param mirrored boolean value of whether or not the offering provides disk mirroring * @param tags Comma separated string to indicate special tags for the disk offering. * @return the created disk offering, null if failed to create + * @throws InternalErrorException */ - DiskOfferingVO createDiskOffering(long userId, long domainId, String name, String description, int numGibibytes, String tags) throws InvalidParameterValueException; + DiskOfferingVO createDiskOffering(long userId, long domainId, String name, String description, int numGibibytes, String tags) throws InvalidParameterValueException, InternalErrorException; /** * Delete a disk offering diff --git a/server/src/com/cloud/api/commands/CreateDiskOfferingCmd.java b/server/src/com/cloud/api/commands/CreateDiskOfferingCmd.java index b77c51ba7bb..64a458e78a1 100644 --- a/server/src/com/cloud/api/commands/CreateDiskOfferingCmd.java +++ b/server/src/com/cloud/api/commands/CreateDiskOfferingCmd.java @@ -27,6 +27,7 @@ import org.apache.log4j.Logger; import com.cloud.api.BaseCmd; import com.cloud.api.ServerApiException; import com.cloud.domain.DomainVO; +import com.cloud.exception.InternalErrorException; import com.cloud.exception.InvalidParameterValueException; import com.cloud.storage.DiskOfferingVO; import com.cloud.user.User; @@ -86,7 +87,9 @@ public class CreateDiskOfferingCmd extends BaseCmd { diskOffering = getManagementServer().createDiskOffering(userId, domainId.longValue(), name, displayText, numGB.intValue(),tags); } catch (InvalidParameterValueException ex) { throw new ServerApiException (BaseCmd.VM_INVALID_PARAM_ERROR, ex.getMessage()); - } + } catch (InternalErrorException e) { + throw new ServerApiException (BaseCmd.INTERNAL_ERROR, e.getMessage()); + } if (diskOffering == null) { throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create disk offering"); diff --git a/server/src/com/cloud/api/commands/DeleteDiskOfferingCmd.java b/server/src/com/cloud/api/commands/DeleteDiskOfferingCmd.java index 8c38a24857b..12a448fade8 100644 --- a/server/src/com/cloud/api/commands/DeleteDiskOfferingCmd.java +++ b/server/src/com/cloud/api/commands/DeleteDiskOfferingCmd.java @@ -64,7 +64,7 @@ public class DeleteDiskOfferingCmd extends BaseCmd { throw new ServerApiException(BaseCmd.PARAM_ERROR, "unable to find a disk offering with id " + id); } - if(disk.getName().equals("Private") && disk.getDisplayText().equals("Private Disk")){ + if(disk.getDiskSize()==0){ //block deletion of these disks throw new ServerApiException(BaseCmd.INTERNAL_ERROR,"Cannot delete this diskoffering as it is private"); } diff --git a/server/src/com/cloud/server/ConfigurationServerImpl.java b/server/src/com/cloud/server/ConfigurationServerImpl.java index 35a63ae5bc2..a678f157817 100644 --- a/server/src/com/cloud/server/ConfigurationServerImpl.java +++ b/server/src/com/cloud/server/ConfigurationServerImpl.java @@ -145,7 +145,7 @@ public class ConfigurationServerImpl implements ConfigurationServer { _configMgr.createDiskOffering(User.UID_SYSTEM, DomainVO.ROOT_DOMAIN, "Small", "Small Disk, 5 GB", 5, null); _configMgr.createDiskOffering(User.UID_SYSTEM, DomainVO.ROOT_DOMAIN, "Medium", "Medium Disk, 20 GB", 20, null); _configMgr.createDiskOffering(User.UID_SYSTEM, DomainVO.ROOT_DOMAIN, "Large", "Large Disk, 100 GB", 100, null); - _configMgr.createDiskOffering(User.UID_SYSTEM, DomainVO.ROOT_DOMAIN, "Private", "Private Disk", 0, null); + //_configMgr.createDiskOffering(User.UID_SYSTEM, DomainVO.ROOT_DOMAIN, "Private", "Private Disk", 0, null); //Add default manual snapshot policy SnapshotPolicyVO snapPolicy = new SnapshotPolicyVO(0L, "00", "GMT", (short)4, 0); diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java index 93198b7fe63..3a5e02187d3 100755 --- a/server/src/com/cloud/server/ManagementServerImpl.java +++ b/server/src/com/cloud/server/ManagementServerImpl.java @@ -368,7 +368,7 @@ public class ManagementServerImpl implements ManagementServer { private final int _proxyRamSize; private final int _ssRamSize; - private final long _maxVolumeSizeInTb; + private final long _maxVolumeSizeInGb; private final Map _availableIdsMap; private boolean _networkGroupsEnabled = false; @@ -465,9 +465,9 @@ public class ManagementServerImpl implements ManagementServer { // and set them in the right places String maxVolumeSizeInTbString = _configs.get("max.volume.size.gb"); - long maxVolumeSizeTb = NumbersUtil.parseLong(maxVolumeSizeInTbString, new Long("2093049000000")); + long maxVolumeSizeBytes = NumbersUtil.parseLong(maxVolumeSizeInTbString, new Long("2093049000000")); - _maxVolumeSizeInTb = maxVolumeSizeTb; + _maxVolumeSizeInGb = maxVolumeSizeBytes/1000000000; _routerRamSize = NumbersUtil.parseInt(_configs.get("router.ram.size"),NetworkManager.DEFAULT_ROUTER_VM_RAMSIZE); _proxyRamSize = NumbersUtil.parseInt(_configs.get("consoleproxy.ram.size"), ConsoleProxyManager.DEFAULT_PROXY_VM_RAMSIZE); @@ -7091,12 +7091,22 @@ public class ManagementServerImpl implements ManagementServer { } @Override - public DiskOfferingVO createDiskOffering(long userId, long domainId, String name, String description, int numGibibytes, String tags) throws InvalidParameterValueException { - if (numGibibytes!=0 && numGibibytes < 1) { - throw new InvalidParameterValueException("Please specify a disk size of at least 1 Gb."); - } else if (numGibibytes > _maxVolumeSizeInTb) { - throw new InvalidParameterValueException("The maximum size for a disk is " + _maxVolumeSizeInTb + " Gb."); + public DiskOfferingVO createDiskOffering(long userId, long domainId, String name, String description, int numGibibytes, String tags) throws InvalidParameterValueException, InternalErrorException { + + if(numGibibytes!=0 && numGibibytes<1){ + throw new InvalidParameterValueException("The minimum disk offering size is 1 GB"); + } + + if (numGibibytes > _maxVolumeSizeInGb) { + throw new InvalidParameterValueException("The maximum allowed size for a disk is " + _maxVolumeSizeInGb + " Gb."); } + + if(numGibibytes==0){ + List existingOffering = _diskOfferingDao.findPrivateDiskOffering(); + + if(existingOffering!=null && existingOffering.size()>0) + throw new InternalErrorException("There already exists a private disk offering"); + } return _configMgr.createDiskOffering(userId, domainId, name, description, numGibibytes, tags); } @@ -8820,7 +8830,7 @@ public class ManagementServerImpl implements ManagementServer { public boolean validateCustomVolumeSizeRange(long size) throws InvalidParameterValueException { if (size<0 || (size>0 && size < 2097152)) { throw new InvalidParameterValueException("Please specify a size (in bytes) of at least 2 MB or above."); - } else if (size > _maxVolumeSizeInTb) { + } else if (size > (_maxVolumeSizeInGb*1000000000)) { throw new InvalidParameterValueException("The maximum size allowed is 2 TB"); } From 573885c61571e0e94731af1ef4bb9069c4454925 Mon Sep 17 00:00:00 2001 From: abhishek Date: Fri, 17 Sep 2010 16:58:59 -0700 Subject: [PATCH 50/86] bug 6203: changed the functionality for custom volume and disk offering creation status 6203: resolved fixed --- server/src/com/cloud/api/commands/CreateVolumeCmd.java | 2 +- server/src/com/cloud/server/ManagementServerImpl.java | 9 +-------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/server/src/com/cloud/api/commands/CreateVolumeCmd.java b/server/src/com/cloud/api/commands/CreateVolumeCmd.java index 75f76d238ec..9e63a551ee4 100644 --- a/server/src/com/cloud/api/commands/CreateVolumeCmd.java +++ b/server/src/com/cloud/api/commands/CreateVolumeCmd.java @@ -155,7 +155,7 @@ public class CreateVolumeCmd extends BaseCmd { //this is the case of creating var size vol with private disk offering List privateTemplateList = getManagementServer().findPrivateDiskOffering(); - diskOfferingId = privateTemplateList.get(0).getId(); //we use this id for creating volume + diskOfferingId = privateTemplateList.get(0).getId(); //we use this id for creating volume, randomly tagging it to a pool with an offering } } else diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java index 3a5e02187d3..01f4b41724b 100755 --- a/server/src/com/cloud/server/ManagementServerImpl.java +++ b/server/src/com/cloud/server/ManagementServerImpl.java @@ -7100,14 +7100,7 @@ public class ManagementServerImpl implements ManagementServer { if (numGibibytes > _maxVolumeSizeInGb) { throw new InvalidParameterValueException("The maximum allowed size for a disk is " + _maxVolumeSizeInGb + " Gb."); } - - if(numGibibytes==0){ - List existingOffering = _diskOfferingDao.findPrivateDiskOffering(); - - if(existingOffering!=null && existingOffering.size()>0) - throw new InternalErrorException("There already exists a private disk offering"); - } - + return _configMgr.createDiskOffering(userId, domainId, name, description, numGibibytes, tags); } From 1a37b661c7c6fa1c04d6bd1da111c593a910dc44 Mon Sep 17 00:00:00 2001 From: abhishek Date: Fri, 17 Sep 2010 17:06:19 -0700 Subject: [PATCH 51/86] code cleanup --- server/src/com/cloud/api/commands/DeleteDiskOfferingCmd.java | 1 - 1 file changed, 1 deletion(-) diff --git a/server/src/com/cloud/api/commands/DeleteDiskOfferingCmd.java b/server/src/com/cloud/api/commands/DeleteDiskOfferingCmd.java index 12a448fade8..05d12a0ea00 100644 --- a/server/src/com/cloud/api/commands/DeleteDiskOfferingCmd.java +++ b/server/src/com/cloud/api/commands/DeleteDiskOfferingCmd.java @@ -26,7 +26,6 @@ import org.apache.log4j.Logger; import com.cloud.api.BaseCmd; import com.cloud.api.ServerApiException; -import com.cloud.offering.DiskOffering; import com.cloud.storage.DiskOfferingVO; import com.cloud.user.User; import com.cloud.utils.Pair; From 48d7ab1907add560fa0c2e22f6a250734e9199f0 Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Fri, 17 Sep 2010 17:27:22 -0700 Subject: [PATCH 52/86] new UI - IP address tab - switch between tabs. --- ui/new/jsp/ip_address.jsp | 20 +++++++++---------- ui/new/scripts/cloud.core2.ipaddress.js | 26 ++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 11 deletions(-) diff --git a/ui/new/jsp/ip_address.jsp b/ui/new/jsp/ip_address.jsp index ddd96927e52..fd4e0d51194 100644 --- a/ui/new/jsp/ip_address.jsp +++ b/ui/new/jsp/ip_address.jsp @@ -20,11 +20,11 @@

-
+
<%=t.t("Details")%>
-
+
<%=t.t("Port Forwarding")%>
-
+
<%=t.t("Load Balancer")%>
@@ -201,7 +201,7 @@

- Creating …

+ Adding …

@@ -221,11 +221,11 @@
Instance Name
-
@@ -301,8 +301,8 @@
@@ -358,11 +358,11 @@
Source
-
diff --git a/ui/new/scripts/cloud.core2.ipaddress.js b/ui/new/scripts/cloud.core2.ipaddress.js index 98d43fe3e3e..189e9126551 100644 --- a/ui/new/scripts/cloud.core2.ipaddress.js +++ b/ui/new/scripts/cloud.core2.ipaddress.js @@ -1,5 +1,29 @@ function afterLoadIpJSP() { - + //***** switch to different tab (begin) ******************************************************************** + $("#tab_details").bind("click", function(event){ + $(this).removeClass("off").addClass("on"); + $("#tab_port_forwarding, #tab_load_balancer").removeClass("on").addClass("off"); + $("#tab_content_details").show(); + $("#tab_content_port_forwarding, #tab_content_load_balancer").hide(); + return false; + }); + + $("#tab_port_forwarding").bind("click", function(event){ + $(this).removeClass("off").addClass("on"); + $("#tab_details, #tab_load_balancer").removeClass("on").addClass("off"); + $("#tab_content_port_forwarding").show(); + $("#tab_content_details, #tab_content_load_balancer").hide(); + return false; + }); + + $("#tab_load_balancer").bind("click", function(event){ + $(this).removeClass("off").addClass("on"); + $("#tab_details, #tab_port_forwarding").removeClass("on").addClass("off"); + $("#tab_content_load_balancer").show(); + $("#tab_content_details, #tab_content_port_forwarding").hide(); + return false; + }); + //***** switch to different tab (end) ********************************************************************** } function ipGetMidmenuId(jsonObj) { From ae2bf6df38681ce2aaf0809bdb7fa1046587cafd Mon Sep 17 00:00:00 2001 From: NIKITA Date: Fri, 17 Sep 2010 17:29:51 -0700 Subject: [PATCH 53/86] added new css for grid error msg --- ui/new/css/main.css | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ui/new/css/main.css b/ui/new/css/main.css index 099ef696c7d..fbd10eef625 100644 --- a/ui/new/css/main.css +++ b/ui/new/css/main.css @@ -1841,6 +1841,14 @@ a:visited { background:#FFF repeat top left; } +.grid_rows.success { + background:#fffbe6 url(../images/infomsg_bg.gif) repeat-x top left; +} + +.grid_rows.error { + background:#ffe5e5 url(../images/errormsg_bg.gif) repeat-x top left; +} + .grid_rows.odd { background:#f3f3f3 repeat top left; } From 439872fe6bf969293a9a7688f396891bba24b5a9 Mon Sep 17 00:00:00 2001 From: NIKITA Date: Fri, 17 Sep 2010 17:40:07 -0700 Subject: [PATCH 54/86] Loading for Load Balancer - Manage --- ui/new/css/main.css | 1 + ui/new/jsp/ip_address.jsp | 762 +++++++++++++++++++------------------- 2 files changed, 391 insertions(+), 372 deletions(-) diff --git a/ui/new/css/main.css b/ui/new/css/main.css index fbd10eef625..dab70890c0e 100644 --- a/ui/new/css/main.css +++ b/ui/new/css/main.css @@ -2443,6 +2443,7 @@ a:visited { border-bottom:1px dashed #a2bcce; background:#e3eaef repeat top left; float:left; + position:relative; margin:0; padding:4px 0 4px 0; } diff --git a/ui/new/jsp/ip_address.jsp b/ui/new/jsp/ip_address.jsp index fd4e0d51194..179cecb540e 100644 --- a/ui/new/jsp/ip_address.jsp +++ b/ui/new/jsp/ip_address.jsp @@ -1,372 +1,390 @@ -<%@ page import="java.util.*" %> - -<%@ page import="com.cloud.utils.*" %> - -<% - Locale browserLocale = request.getLocale(); - CloudResourceBundle t = CloudResourceBundle.getBundle("resources/resource", browserLocale); -%> - -
-
- IP Address
-

- IP Address -

-
-
- -
-
- <%=t.t("Details")%>
-
- <%=t.t("Port Forwarding")%>
-
- <%=t.t("Load Balancer")%>
-
-
-
- -
-
-
-
-
-

- Detaching Disk …

-
- -
-
-
-
-
- IP:
-
-
-
-
-
-
-
-
-
- Zone:
-
-
-
-
-
-
-
-
-
- VLAN:
-
-
-
-
-
-
-
-
-
- Source NAT:
-
-
-
-
-
-
-
-
-
- Network Type:
-
-
-
-
-
-
-
-
-
- Domain:
-
-
-
-
-
-
-
-
-
- Account:
-
-
-
-
-
-
-
-
-
- Allocated:
-
-
-
-
-
-
-
-
- - - - - - - -
- +<%@ page import="java.util.*" %> + +<%@ page import="com.cloud.utils.*" %> + +<% + Locale browserLocale = request.getLocale(); + CloudResourceBundle t = CloudResourceBundle.getBundle("resources/resource", browserLocale); +%> + +
+
+ IP Address
+

+ IP Address +

+
+
+ +
+
+ <%=t.t("Details")%>
+
+ <%=t.t("Port Forwarding")%>
+
+ <%=t.t("Load Balancer")%>
+
+
+
+ +
+
+
+
+
+

+ Detaching Disk …

+
+ +
+
+
+
+
+ IP:
+
+
+
+
+
+
+
+
+
+ Zone:
+
+
+
+
+
+
+
+
+
+ VLAN:
+
+
+
+
+
+
+
+
+
+ Source NAT:
+
+
+
+
+
+
+
+
+
+ Network Type:
+
+
+
+
+
+
+
+
+
+ Domain:
+
+
+
+
+
+
+
+
+
+ Account:
+
+
+
+
+
+
+
+
+
+ Allocated:
+
+
+
+
+
+
+
+
+ + + + + + + +
+ From f004981dc132787e8c227cd44fc08e12755bd8c2 Mon Sep 17 00:00:00 2001 From: NIKITA Date: Fri, 17 Sep 2010 17:59:13 -0700 Subject: [PATCH 55/86] Template for Error msg in Volume --- ui/new/jsp/instance.jsp | 1820 ++++++++++++++++++++------------------- 1 file changed, 916 insertions(+), 904 deletions(-) diff --git a/ui/new/jsp/instance.jsp b/ui/new/jsp/instance.jsp index e8944b43877..eabf476cf81 100644 --- a/ui/new/jsp/instance.jsp +++ b/ui/new/jsp/instance.jsp @@ -1,904 +1,916 @@ -<%@ page import="java.util.*" %> - -<%@ page import="com.cloud.utils.*" %> - -<% - Locale browserLocale = request.getLocale(); - CloudResourceBundle t = CloudResourceBundle.getBundle("resources/resource", browserLocale); -%> - -
-
- Instance
-

- Instance -

-
-
- -
-
- <%=t.t("Details")%>
-
- <%=t.t("Volume")%>
-
- <%=t.t("Statistics")%>
-
- -
-
-
-
-
-
-
-
-
-

-

-
-
-
-
-
-
- <%=t.t("Zone")%>:
-
-
-
-
-
-
-
-
-
- <%=t.t("Template")%>:
-
-
-
-
-
-
-
-
-
- <%=t.t("Service")%>:
-
-
-
-
-
-
-
-
-
- <%=t.t("HA.Enabled")%>:
-
-
-
-
-
-
-
-
-
- <%=t.t("Created")%>:
-
-
-
-
-
-
-
-
-
- <%=t.t("Account")%>:
-
-
-
-
-
-
-
-
-
- <%=t.t("Domain")%>:
-
-
-
-
-
-
-
-
-
- <%=t.t("Host")%>:
-
-
-
-
-
-
-
-
-
- <%=t.t("ISO.attached")%>:
-
-
-
-
-
-
-
-
-
- <%=t.t("Group")%>:
-
-
-
-
-
-
-
- - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - +<%@ page import="java.util.*" %> + +<%@ page import="com.cloud.utils.*" %> + +<% + Locale browserLocale = request.getLocale(); + CloudResourceBundle t = CloudResourceBundle.getBundle("resources/resource", browserLocale); +%> + +
+
+ Instance
+

+ Instance +

+
+
+ +
+
+ <%=t.t("Details")%>
+
+ <%=t.t("Volume")%>
+
+ <%=t.t("Statistics")%>
+
+ +
+
+
+
+
+
+
+
+
+

+

+
+
+
+
+
+
+ <%=t.t("Zone")%>:
+
+
+
+
+
+
+
+
+
+ <%=t.t("Template")%>:
+
+
+
+
+
+
+
+
+
+ <%=t.t("Service")%>:
+
+
+
+
+
+
+
+
+
+ <%=t.t("HA.Enabled")%>:
+
+
+
+
+
+
+
+
+
+ <%=t.t("Created")%>:
+
+
+
+
+
+
+
+
+
+ <%=t.t("Account")%>:
+
+
+
+
+
+
+
+
+
+ <%=t.t("Domain")%>:
+
+
+
+
+
+
+
+
+
+ <%=t.t("Host")%>:
+
+
+
+
+
+
+
+
+
+ <%=t.t("ISO.attached")%>:
+
+
+
+
+
+
+
+
+
+ <%=t.t("Group")%>:
+
+
+
+
+
+
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + From 06e7789a63152d2b257c6d70e72a7a82b0f9ac01 Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Fri, 17 Sep 2010 19:37:31 -0700 Subject: [PATCH 56/86] new UI - implement add port forwarding rule. --- ui/new/jsp/ip_address.jsp | 145 ++++++++------ ui/new/scripts/cloud.core2.ipaddress.js | 254 +++++++++++++++++++++++- 2 files changed, 325 insertions(+), 74 deletions(-) diff --git a/ui/new/jsp/ip_address.jsp b/ui/new/jsp/ip_address.jsp index 179cecb540e..5e179b43f81 100644 --- a/ui/new/jsp/ip_address.jsp +++ b/ui/new/jsp/ip_address.jsp @@ -140,7 +140,7 @@ -
@@ -333,7 +288,7 @@

- Deleting …

+ Removing instance from load balancer policy …

@@ -349,11 +304,11 @@
-
@@ -380,7 +335,7 @@

- Adding …

+ Adding load balancer policy …

@@ -388,3 +343,61 @@ + + + + diff --git a/ui/new/scripts/cloud.core2.ipaddress.js b/ui/new/scripts/cloud.core2.ipaddress.js index 189e9126551..eddc8adff0a 100644 --- a/ui/new/scripts/cloud.core2.ipaddress.js +++ b/ui/new/scripts/cloud.core2.ipaddress.js @@ -1,29 +1,229 @@ +//***** baseline (begin) ******************************************************************************************************************* function afterLoadIpJSP() { - //***** switch to different tab (begin) ******************************************************************** + //switch to different tab $("#tab_details").bind("click", function(event){ $(this).removeClass("off").addClass("on"); $("#tab_port_forwarding, #tab_load_balancer").removeClass("on").addClass("off"); $("#tab_content_details").show(); $("#tab_content_port_forwarding, #tab_content_load_balancer").hide(); return false; - }); - + }); $("#tab_port_forwarding").bind("click", function(event){ $(this).removeClass("off").addClass("on"); $("#tab_details, #tab_load_balancer").removeClass("on").addClass("off"); $("#tab_content_port_forwarding").show(); $("#tab_content_details, #tab_content_load_balancer").hide(); return false; - }); - + }); $("#tab_load_balancer").bind("click", function(event){ $(this).removeClass("off").addClass("on"); $("#tab_details, #tab_port_forwarding").removeClass("on").addClass("off"); $("#tab_content_load_balancer").show(); $("#tab_content_details, #tab_content_port_forwarding").hide(); return false; - }); - //***** switch to different tab (end) ********************************************************************** + }); + + + //Port Fowording tab + var $createPortForwardingRow = $("#create_port_forwarding_row"); + + //var portForwardingIndex = 0; + function portForwardingJsonToTemplate(jsonObj, template) { + //(portForwardingIndex++ % 2 == 0)? template.find("#row_container").addClass("smallrow_even"): template.find("#row_container").addClass("smallrow_odd"); + template.attr("id", "portForwarding_" + jsonObj.id).data("portForwardingId", jsonObj.id); + + template.find("#row_container #public_port").text(jsonObj.publicport); + template.find("#row_container_edit #public_port").val(jsonObj.publicport); + + template.find("#row_container #private_port").text(jsonObj.privateport); + template.find("#row_container_edit #private_port").val(jsonObj.privateport); + + template.find("#row_container #protocol").text(jsonObj.protocol); + template.find("#row_container_edit #protocol").val(jsonObj.protocol); + + template.find("#row_container #vm_name").text(jsonObj.vmname); + var virtualMachineId = jsonObj.virtualmachineid; + + var $detailsTab = $("#right_panel_content #tab_content_details"); + var jsonObj = $detailsTab.data("jsonObj"); + var IpDomainid = jsonObj.domainid; + var IpAccount = jsonObj.account; + + $.ajax({ + data: createURL("command=listVirtualMachines&response=json&domainid="+IpDomainid+"&account="+IpAccount+maxPageSize), + dataType: "json", + success: function(json) { + var instances = json.listvirtualmachinesresponse.virtualmachine; + var vmSelect = template.find("#row_container_edit #vm").empty(); + if (instances != null && instances.length > 0) { + for (var i = 0; i < instances.length; i++) { + var html = $(""); + vmSelect.append(html); + } + vmSelect.val(virtualMachineId); + } + } + }); + + /* + var loadingImg = template.find(".adding_loading"); + var rowContainer = template.find("#row_container"); + var rowContainerEdit = template.find("#row_container_edit"); + + template.find("#delete_link").unbind("click").bind("click", function(event){ + loadingImg.find(".adding_text").text("Deleting...."); + loadingImg.show(); + rowContainer.hide(); + + $.ajax({ + data: createURL("command=deletePortForwardingRule&response=json&id="+json.id), + dataType: "json", + success: function(json) { + template.slideUp("slow", function(){ + $(this).remove(); + }); + }, + error: function(XMLHttpResponse) { + handleError(XMLHttpResponse); + loadingImg.hide(); + rowContainer.show(); + } + }); + return false; + }); + + template.find("#edit_link").unbind("click").bind("click", function(event){ + rowContainer.hide(); + rowContainerEdit.show(); + }); + + template.find("#cancel_link").unbind("click").bind("click", function(event){ + rowContainer.show(); + rowContainerEdit.hide(); + }); + + template.find("#save_link").unbind("click").bind("click", function(event){ + // validate values + var isValid = true; + isValid &= validateNumber("Private Port", rowContainerEdit.find("#private_port"), rowContainerEdit.find("#private_port_errormsg"), 1, 65535); + if (!isValid) return; + + var loadingImg = template.find(".adding_loading"); + loadingImg.find(".adding_text").text("Saving...."); + loadingImg.show(); + rowContainerEdit.hide(); + + var ipAddress = $("#submenu_content_network #ip_select").val(); + if (!isUser()) { + ipAddress = ipPanel.data("ip_address"); + } + var publicPort = rowContainerEdit.find("#public_port").text(); + var privatePort = rowContainerEdit.find("#private_port").val(); + var protocol = rowContainerEdit.find("#protocol").text(); + var virtualMachineId = rowContainerEdit.find("#vm").val(); + + var array1 = []; + array1.push("&publicip="+ipAddress); + array1.push("&privateport="+privatePort); + array1.push("&publicport="+publicPort); + array1.push("&protocol="+protocol); + array1.push("&virtualmachineid=" + virtualMachineId); + + $.ajax({ + data: createURL("command=updatePortForwardingRule&response=json"+array1.join("")), + dataType: "json", + success: function(json) { + var jobId = json.updateportforwardingruleresponse.jobid; + var timerKey = "updateportforwardingruleJob"+jobId; + + $("body").everyTime(2000, timerKey, function() { + $.ajax({ + data: createURL("command=queryAsyncJobResult&jobId="+jobId+"&response=json"), + 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) { // Succeeded + var items = result.portforwardingrule; + portForwardingJsonToTemplate(items[0],template); + loadingImg.hide(); + rowContainer.show(); + } else if (result.jobstatus == 2) { //Fail + loadingImg.hide(); + rowContainer.show(); + $("#dialog_alert").html("

" + sanitizeXSS(result.jobresult) + "

").dialog("open"); + } + } + }, + error: function(XMLHttpResponse) { + handleError(XMLHttpResponse); + $("body").stopTime(timerKey); + loadingImg.hide(); + rowContainer.show(); + } + }); + }, 0); + }, + error: function(XMLHttpResponse) { + handleError(XMLHttpResponse); + loadingImg.hide(); + rowContainer.show(); + } + }); + }); + */ + } + + $createPortForwardingRow.find("#add_link").bind("click", function(event){ + var isValid = true; + isValid &= validateNumber("Public Port", $createPortForwardingRow.find("#public_port"), $createPortForwardingRow.find("#public_port_errormsg"), 1, 65535); + isValid &= validateNumber("Private Port", $createPortForwardingRow.find("#private_port"), $createPortForwardingRow.find("#private_port_errormsg"), 1, 65535); + if (!isValid) return; + + var $template = $("#port_forwarding_template").clone(); + $("#tab_content_port_forwarding #grid_container").append($template.show()); + + var $spinningWheel = $template.find("#spinning_wheel"); + $spinningWheel.show(); + + var $detailsTab = $("#right_panel_content #tab_content_details"); + var jsonObj = $detailsTab.data("jsonObj"); + var ipAddress = jsonObj.ipaddress; + var publicPort = $createPortForwardingRow.find("#public_port").val(); + var privatePort = $createPortForwardingRow.find("#private_port").val(); + var protocol = $createPortForwardingRow.find("#protocol").val(); + var virtualMachineId = $createPortForwardingRow.find("#vm").val(); + + var array1 = []; + array1.push("&ipaddress="+ipAddress); + array1.push("&privateport="+privatePort); + array1.push("&publicport="+publicPort); + array1.push("&protocol="+protocol); + array1.push("&virtualmachineid=" + virtualMachineId); + $.ajax({ + data: createURL("command=createPortForwardingRule"+array1.join("")), + dataType: "json", + success: function(json) { + var items = json.createportforwardingruleresponse.portforwardingrule; + portForwardingJsonToTemplate(items[0],$template); + $spinningWheel.hide(); + refreshCreatePortForwardingRow(); + }, + error: function(XMLHttpResponse) { + handleError(XMLHttpResponse); + $template.slideUp("slow", function() { + $(this).remove(); + }); + } + }); + + return false; + }); + + } function ipGetMidmenuId(jsonObj) { @@ -44,7 +244,12 @@ function ipToMidmenu(jsonObj, $midmenuItem1) { function ipToRigntPanel($midmenuItem1) { var jsonObj = $midmenuItem1.data("jsonObj"); + + //Details tab ipJsonToDetailsTab(jsonObj); + + //Port Forwarding tab + refreshCreatePortForwardingRow(); } function ipJsonToDetailsTab(jsonObj) { @@ -61,7 +266,9 @@ function ipJsonToDetailsTab(jsonObj) { $detailsTab.find("#account").text(fromdb(jsonObj.account)); $detailsTab.find("#allocated").text(fromdb(jsonObj.allocated)); } +//***** baseline (end) ********************************************************************************************************************* +//***** Details tab (begin) **************************************************************************************************************** function setSourceNatField(value, $field) { if(value == "true") $field.text("Yes"); @@ -78,4 +285,35 @@ function setNetworkTypeField(value, $field) { $field.text("Direct"); else $field.text(""); -} \ No newline at end of file +} +//***** Details tab (end) ****************************************************************************************************************** + +//***** Port Forwarding tab (begin) ******************************************************************************************************** +function refreshCreatePortForwardingRow() { + var $createPortForwardingRow = $("#create_port_forwarding_row"); + $createPortForwardingRow.find("#public_port").val(""); + $createPortForwardingRow.find("#private_port").val(""); + $createPortForwardingRow.find("#protocol").val("TCP"); + + var $detailsTab = $("#right_panel_content #tab_content_details"); + var jsonObj = $detailsTab.data("jsonObj"); + var IpDomainid = jsonObj.domainid; + var IpAccount = jsonObj.account; + + $.ajax({ + data: createURL("command=listVirtualMachines&domainid="+IpDomainid+"&account="+IpAccount+maxPageSize), + dataType: "json", + success: function(json) { + var instances = json.listvirtualmachinesresponse.virtualmachine; + var vmSelect = $createPortForwardingRow.find("#vm").empty(); + if (instances != null && instances.length > 0) { + for (var i = 0; i < instances.length; i++) { + var html = $(""); + vmSelect.append(html); + } + } + } + }); +} + +//***** Port Forwarding tab (end) ********************************************************************************************************** \ No newline at end of file From 854af0766aabebeef40948a012294d962fd9a68b Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Fri, 17 Sep 2010 20:04:22 -0700 Subject: [PATCH 57/86] new UI - IP address page - implement listPortForwardingRules. --- ui/new/jsp/ip_address.jsp | 4 +- ui/new/scripts/cloud.core2.ipaddress.js | 327 +++++++++++++----------- 2 files changed, 179 insertions(+), 152 deletions(-) diff --git a/ui/new/jsp/ip_address.jsp b/ui/new/jsp/ip_address.jsp index 5e179b43f81..6f8f2c606aa 100644 --- a/ui/new/jsp/ip_address.jsp +++ b/ui/new/jsp/ip_address.jsp @@ -182,7 +182,9 @@ - + +
+
diff --git a/ui/new/scripts/cloud.core2.ipaddress.js b/ui/new/scripts/cloud.core2.ipaddress.js index eddc8adff0a..cd1ab4cb879 100644 --- a/ui/new/scripts/cloud.core2.ipaddress.js +++ b/ui/new/scripts/cloud.core2.ipaddress.js @@ -25,157 +25,7 @@ function afterLoadIpJSP() { //Port Fowording tab - var $createPortForwardingRow = $("#create_port_forwarding_row"); - - //var portForwardingIndex = 0; - function portForwardingJsonToTemplate(jsonObj, template) { - //(portForwardingIndex++ % 2 == 0)? template.find("#row_container").addClass("smallrow_even"): template.find("#row_container").addClass("smallrow_odd"); - template.attr("id", "portForwarding_" + jsonObj.id).data("portForwardingId", jsonObj.id); - - template.find("#row_container #public_port").text(jsonObj.publicport); - template.find("#row_container_edit #public_port").val(jsonObj.publicport); - - template.find("#row_container #private_port").text(jsonObj.privateport); - template.find("#row_container_edit #private_port").val(jsonObj.privateport); - - template.find("#row_container #protocol").text(jsonObj.protocol); - template.find("#row_container_edit #protocol").val(jsonObj.protocol); - - template.find("#row_container #vm_name").text(jsonObj.vmname); - var virtualMachineId = jsonObj.virtualmachineid; - - var $detailsTab = $("#right_panel_content #tab_content_details"); - var jsonObj = $detailsTab.data("jsonObj"); - var IpDomainid = jsonObj.domainid; - var IpAccount = jsonObj.account; - - $.ajax({ - data: createURL("command=listVirtualMachines&response=json&domainid="+IpDomainid+"&account="+IpAccount+maxPageSize), - dataType: "json", - success: function(json) { - var instances = json.listvirtualmachinesresponse.virtualmachine; - var vmSelect = template.find("#row_container_edit #vm").empty(); - if (instances != null && instances.length > 0) { - for (var i = 0; i < instances.length; i++) { - var html = $(""); - vmSelect.append(html); - } - vmSelect.val(virtualMachineId); - } - } - }); - - /* - var loadingImg = template.find(".adding_loading"); - var rowContainer = template.find("#row_container"); - var rowContainerEdit = template.find("#row_container_edit"); - - template.find("#delete_link").unbind("click").bind("click", function(event){ - loadingImg.find(".adding_text").text("Deleting...."); - loadingImg.show(); - rowContainer.hide(); - - $.ajax({ - data: createURL("command=deletePortForwardingRule&response=json&id="+json.id), - dataType: "json", - success: function(json) { - template.slideUp("slow", function(){ - $(this).remove(); - }); - }, - error: function(XMLHttpResponse) { - handleError(XMLHttpResponse); - loadingImg.hide(); - rowContainer.show(); - } - }); - return false; - }); - - template.find("#edit_link").unbind("click").bind("click", function(event){ - rowContainer.hide(); - rowContainerEdit.show(); - }); - - template.find("#cancel_link").unbind("click").bind("click", function(event){ - rowContainer.show(); - rowContainerEdit.hide(); - }); - - template.find("#save_link").unbind("click").bind("click", function(event){ - // validate values - var isValid = true; - isValid &= validateNumber("Private Port", rowContainerEdit.find("#private_port"), rowContainerEdit.find("#private_port_errormsg"), 1, 65535); - if (!isValid) return; - - var loadingImg = template.find(".adding_loading"); - loadingImg.find(".adding_text").text("Saving...."); - loadingImg.show(); - rowContainerEdit.hide(); - - var ipAddress = $("#submenu_content_network #ip_select").val(); - if (!isUser()) { - ipAddress = ipPanel.data("ip_address"); - } - var publicPort = rowContainerEdit.find("#public_port").text(); - var privatePort = rowContainerEdit.find("#private_port").val(); - var protocol = rowContainerEdit.find("#protocol").text(); - var virtualMachineId = rowContainerEdit.find("#vm").val(); - - var array1 = []; - array1.push("&publicip="+ipAddress); - array1.push("&privateport="+privatePort); - array1.push("&publicport="+publicPort); - array1.push("&protocol="+protocol); - array1.push("&virtualmachineid=" + virtualMachineId); - - $.ajax({ - data: createURL("command=updatePortForwardingRule&response=json"+array1.join("")), - dataType: "json", - success: function(json) { - var jobId = json.updateportforwardingruleresponse.jobid; - var timerKey = "updateportforwardingruleJob"+jobId; - - $("body").everyTime(2000, timerKey, function() { - $.ajax({ - data: createURL("command=queryAsyncJobResult&jobId="+jobId+"&response=json"), - 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) { // Succeeded - var items = result.portforwardingrule; - portForwardingJsonToTemplate(items[0],template); - loadingImg.hide(); - rowContainer.show(); - } else if (result.jobstatus == 2) { //Fail - loadingImg.hide(); - rowContainer.show(); - $("#dialog_alert").html("

" + sanitizeXSS(result.jobresult) + "

").dialog("open"); - } - } - }, - error: function(XMLHttpResponse) { - handleError(XMLHttpResponse); - $("body").stopTime(timerKey); - loadingImg.hide(); - rowContainer.show(); - } - }); - }, 0); - }, - error: function(XMLHttpResponse) { - handleError(XMLHttpResponse); - loadingImg.hide(); - rowContainer.show(); - } - }); - }); - */ - } + var $createPortForwardingRow = $("#create_port_forwarding_row"); $createPortForwardingRow.find("#add_link").bind("click", function(event){ var isValid = true; @@ -249,6 +99,7 @@ function ipToRigntPanel($midmenuItem1) { ipJsonToDetailsTab(jsonObj); //Port Forwarding tab + listPortForwardingRules(); refreshCreatePortForwardingRow(); } @@ -289,6 +140,180 @@ function setNetworkTypeField(value, $field) { //***** Details tab (end) ****************************************************************************************************************** //***** Port Forwarding tab (begin) ******************************************************************************************************** + +//var portForwardingIndex = 0; +function portForwardingJsonToTemplate(jsonObj, template) { + //(portForwardingIndex++ % 2 == 0)? template.find("#row_container").addClass("smallrow_even"): template.find("#row_container").addClass("smallrow_odd"); + template.attr("id", "portForwarding_" + jsonObj.id).data("portForwardingId", jsonObj.id); + + template.find("#row_container #public_port").text(jsonObj.publicport); + template.find("#row_container_edit #public_port").val(jsonObj.publicport); + + template.find("#row_container #private_port").text(jsonObj.privateport); + template.find("#row_container_edit #private_port").val(jsonObj.privateport); + + template.find("#row_container #protocol").text(jsonObj.protocol); + template.find("#row_container_edit #protocol").val(jsonObj.protocol); + + template.find("#row_container #vm_name").text(jsonObj.vmname); + var virtualMachineId = jsonObj.virtualmachineid; + + var $detailsTab = $("#right_panel_content #tab_content_details"); + var jsonObj = $detailsTab.data("jsonObj"); + var IpDomainid = jsonObj.domainid; + var IpAccount = jsonObj.account; + + $.ajax({ + data: createURL("command=listVirtualMachines&response=json&domainid="+IpDomainid+"&account="+IpAccount+maxPageSize), + dataType: "json", + success: function(json) { + var instances = json.listvirtualmachinesresponse.virtualmachine; + var vmSelect = template.find("#row_container_edit #vm").empty(); + if (instances != null && instances.length > 0) { + for (var i = 0; i < instances.length; i++) { + var html = $(""); + vmSelect.append(html); + } + vmSelect.val(virtualMachineId); + } + } + }); + + /* + var loadingImg = template.find(".adding_loading"); + var rowContainer = template.find("#row_container"); + var rowContainerEdit = template.find("#row_container_edit"); + + template.find("#delete_link").unbind("click").bind("click", function(event){ + loadingImg.find(".adding_text").text("Deleting...."); + loadingImg.show(); + rowContainer.hide(); + + $.ajax({ + data: createURL("command=deletePortForwardingRule&response=json&id="+json.id), + dataType: "json", + success: function(json) { + template.slideUp("slow", function(){ + $(this).remove(); + }); + }, + error: function(XMLHttpResponse) { + handleError(XMLHttpResponse); + loadingImg.hide(); + rowContainer.show(); + } + }); + return false; + }); + + template.find("#edit_link").unbind("click").bind("click", function(event){ + rowContainer.hide(); + rowContainerEdit.show(); + }); + + template.find("#cancel_link").unbind("click").bind("click", function(event){ + rowContainer.show(); + rowContainerEdit.hide(); + }); + + template.find("#save_link").unbind("click").bind("click", function(event){ + // validate values + var isValid = true; + isValid &= validateNumber("Private Port", rowContainerEdit.find("#private_port"), rowContainerEdit.find("#private_port_errormsg"), 1, 65535); + if (!isValid) return; + + var loadingImg = template.find(".adding_loading"); + loadingImg.find(".adding_text").text("Saving...."); + loadingImg.show(); + rowContainerEdit.hide(); + + var ipAddress = $("#submenu_content_network #ip_select").val(); + if (!isUser()) { + ipAddress = ipPanel.data("ip_address"); + } + var publicPort = rowContainerEdit.find("#public_port").text(); + var privatePort = rowContainerEdit.find("#private_port").val(); + var protocol = rowContainerEdit.find("#protocol").text(); + var virtualMachineId = rowContainerEdit.find("#vm").val(); + + var array1 = []; + array1.push("&publicip="+ipAddress); + array1.push("&privateport="+privatePort); + array1.push("&publicport="+publicPort); + array1.push("&protocol="+protocol); + array1.push("&virtualmachineid=" + virtualMachineId); + + $.ajax({ + data: createURL("command=updatePortForwardingRule&response=json"+array1.join("")), + dataType: "json", + success: function(json) { + var jobId = json.updateportforwardingruleresponse.jobid; + var timerKey = "updateportforwardingruleJob"+jobId; + + $("body").everyTime(2000, timerKey, function() { + $.ajax({ + data: createURL("command=queryAsyncJobResult&jobId="+jobId+"&response=json"), + 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) { // Succeeded + var items = result.portforwardingrule; + portForwardingJsonToTemplate(items[0],template); + loadingImg.hide(); + rowContainer.show(); + } else if (result.jobstatus == 2) { //Fail + loadingImg.hide(); + rowContainer.show(); + $("#dialog_alert").html("

" + sanitizeXSS(result.jobresult) + "

").dialog("open"); + } + } + }, + error: function(XMLHttpResponse) { + handleError(XMLHttpResponse); + $("body").stopTime(timerKey); + loadingImg.hide(); + rowContainer.show(); + } + }); + }, 0); + }, + error: function(XMLHttpResponse) { + handleError(XMLHttpResponse); + loadingImg.hide(); + rowContainer.show(); + } + }); + }); + */ +} + +function listPortForwardingRules() { + var jsonObj = $("#right_panel_content #tab_content_details").data("jsonObj"); + var ipAddress = jsonObj.ipaddress; + if(ipAddress == null || ipAddress.length == 0) + return; + $.ajax({ + data: createURL("command=listPortForwardingRules&ipaddress=" + ipAddress), + dataType: "json", + success: function(json) { + var items = json.listportforwardingrulesresponse.portforwardingrule; + var $portForwardingGrid = $("#tab_content_port_forwarding #grid_container #grid_content"); + $portForwardingGrid.empty(); + if (items != null && items.length > 0) { + for (var i = 0; i < items.length; i++) { + var $template = $("#port_forwarding_template").clone(true); + portForwardingJsonToTemplate(items[i], $template); //??? + $portForwardingGrid.append($template.show()); + } + } + } + }); +} + function refreshCreatePortForwardingRow() { var $createPortForwardingRow = $("#create_port_forwarding_row"); $createPortForwardingRow.find("#public_port").val(""); From 6ee817db62ae39cffbb3bd11f0ca6c0aa9962b6b Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Fri, 17 Sep 2010 20:47:37 -0700 Subject: [PATCH 58/86] new UI - IP address page - port forwarding tab - implement updatePortForwardingRule. --- ui/new/jsp/ip_address.jsp | 71 ++++++++++++--------- ui/new/scripts/cloud.core2.ipaddress.js | 84 ++++++++++++------------- 2 files changed, 79 insertions(+), 76 deletions(-) diff --git a/ui/new/jsp/ip_address.jsp b/ui/new/jsp/ip_address.jsp index 6f8f2c606aa..4280dff999d 100644 --- a/ui/new/jsp/ip_address.jsp +++ b/ui/new/jsp/ip_address.jsp @@ -142,43 +142,47 @@