From e794bf7934127d85513f248e3da9afca9db415f9 Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Wed, 29 Dec 2010 11:21:38 -0800 Subject: [PATCH] add cluster page. --- ui/index.jsp | 3 +- ui/jsp/cluster.jsp | 81 ++++++++++++++++++++++++++++++ ui/scripts/cloud.core.cluster.js | 83 +++++++++++++++++++++++++++++++ ui/scripts/cloud.core.host.js | 24 +-------- ui/scripts/cloud.core.resource.js | 33 ++++++------ 5 files changed, 184 insertions(+), 40 deletions(-) create mode 100644 ui/jsp/cluster.jsp create mode 100644 ui/scripts/cloud.core.cluster.js diff --git a/ui/index.jsp b/ui/index.jsp index dd834f46a94..d1f06fee1ea 100644 --- a/ui/index.jsp +++ b/ui/index.jsp @@ -46,7 +46,8 @@ - + + diff --git a/ui/jsp/cluster.jsp b/ui/jsp/cluster.jsp new file mode 100644 index 00000000000..a29f02868d1 --- /dev/null +++ b/ui/jsp/cluster.jsp @@ -0,0 +1,81 @@ +<%@ page import="java.util.*" %> +<%@ page import="com.cloud.utils.*" %> + +<% + Locale browserLocale = request.getLocale(); + CloudResourceBundle t = CloudResourceBundle.getBundle("resources/resource", browserLocale); +%> + +
+ +
+
+ +

Cluster +

+
+
+ +
+
+ <%=t.t("Details")%>
+
+
+ +
+
+
+
+
+ <%=t.t("ID")%>:
+
+
+
+
+
+
+
+
+
+ <%=t.t("name")%>:
+
+
+
+
+
+
+
+
+
+ <%=t.t("zone")%>:
+
+
+
+
+
+
+
+
+
+ <%=t.t("pod")%>:
+
+
+
+
+
+
+
+
+
+
+ diff --git a/ui/scripts/cloud.core.cluster.js b/ui/scripts/cloud.core.cluster.js new file mode 100644 index 00000000000..79a4d2c62c9 --- /dev/null +++ b/ui/scripts/cloud.core.cluster.js @@ -0,0 +1,83 @@ + /** + * Copyright (C) 2010 Cloud.com, Inc. All rights reserved. + * + * This software is licensed under the GNU General Public License v3 or later. + * + * It is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or any later version. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +function afterLoadClusterJSP($midmenuItem1) { + /* + var objCluster = $midmenuItem1.data("jsonObj"); + listMidMenuItems(("listHosts&type=Routing&clusterid="+objCluster.id), hostGetSearchParams, "listhostsresponse", "host", "jsp/host.jsp", afterLoadHostJSP, hostToMidmenu, hostToRightPanel, getMidmenuId, false, ("cluster_"+objCluster.id)); + + + clearButtonsOnTop(); + + initDialog("dialog_add_host"); + initDialog("dialog_add_pool"); + bindEventHandlerToDialogAddPool($("#dialog_add_pool")); + + clusterToRightPanel($midmenuItem1); + */ +} + + +function clusterToRightPanel($midmenuItem1) { + $("#right_panel_content").data("$midmenuItem1", $midmenuItem1); + clusterJsonToDetailsTab(); + + /* + var objCluster = $midmenuItem1.data("jsonObj"); + + clearButtonsOnTop(); + initAddHostButton($("#midmenu_add_host_button"), "cluster_page", $midmenuItem1); + + initAddPrimaryStorageButton($("#midmenu_add_primarystorage_button"), "cluster_page", $midmenuItem1); + + listMidMenuItems(("listHosts&type=Routing&clusterid="+objCluster.id), hostGetSearchParams, "listhostsresponse", "host", "jsp/host.jsp", afterLoadHostJSP, hostToMidmenu, hostToRightPanel, getMidmenuId, false, ("cluster_"+objCluster.id)); + + $("#right_panel_content").data("$midmenuItem1", $midmenuItem1); + clusterJsonToDetailsTab(); + */ +} + +function clusterJsonToDetailsTab() { + var $midmenuItem1 = $("#right_panel_content").data("$midmenuItem1"); + if($midmenuItem1 == null) + return; + + var jsonObj = $midmenuItem1.data("jsonObj"); + if(jsonObj == null) + return; + + $.ajax({ + data: createURL("command=listClusters&id="+jsonObj.id), + dataType: "json", + async: false, + success: function(json) { + var items = json.listclustersresponse.cluster; + if(items != null && items.length > 0) { + jsonObj = items[0]; + $midmenuItem1.data("jsonObj", jsonObj); + } + } + }); + + var $detailsTab = $("#right_panel_content").find("#tab_content_details"); + $detailsTab.find("#id").text(fromdb(jsonObj.id)); + $detailsTab.find("#name").text(fromdb(jsonObj.name)); + $detailsTab.find("#zonename").text(fromdb(jsonObj.zonename)); + $detailsTab.find("#podname").text(fromdb(jsonObj.podname)); +} + diff --git a/ui/scripts/cloud.core.host.js b/ui/scripts/cloud.core.host.js index 6036ff613d6..f31125ade95 100644 --- a/ui/scripts/cloud.core.host.js +++ b/ui/scripts/cloud.core.host.js @@ -69,29 +69,7 @@ function hostToMidmenu(jsonObj, $midmenuItem1) { function hostToRightPanel($midmenuItem1) { $("#right_panel_content").data("$midmenuItem1", $midmenuItem1); - hostJsonToDetailsTab(); - /* - if(currentRightPanelJSP != "jsp/host.jsp") { - removeDialogs(); - $("#right_panel").load("jsp/host.jsp", function(){ - currentRightPanelJSP = "jsp/host.jsp"; - - $(this).data("onRefreshFn", function() { - hostJsonToDetailsTab(); - }); - afterLoadHostJSP($midmenuItem1); - - copyActionInfoFromMidMenuToRightPanel($midmenuItem1); - $("#right_panel_content").data("$midmenuItem1", $midmenuItem1); - $("#tab_details").click(); - - }); - } - else { - $("#right_panel_content").data("$midmenuItem1", $midmenuItem1); - hostJsonToDetailsTab(); - } - */ + hostJsonToDetailsTab(); } function afterLoadHostJSP() { diff --git a/ui/scripts/cloud.core.resource.js b/ui/scripts/cloud.core.resource.js index 4d982ec0534..74e005ecf14 100644 --- a/ui/scripts/cloud.core.resource.js +++ b/ui/scripts/cloud.core.resource.js @@ -211,17 +211,17 @@ function buildZoneTree() { */ $("#leftmenu_cluster_node_template").unbind("click").bind("click", function(event) { - var $clusterNode = $(this); + var $thisNode = $(this); var $target = $(event.target); var targetId = $target.attr("id"); switch (targetId) { case "cluster_arrow" : - var $loadingContainer = $clusterNode.find("#cluster_loading_container").show(); - var $clusterArrow = $clusterNode.find("#cluster_arrow").hide(); + var $loadingContainer = $thisNode.find("#cluster_loading_container").show(); + var $clusterArrow = $thisNode.find("#cluster_arrow").hide(); - var clusterObj = $clusterNode.data("jsonObj"); - var $clusterContent = $clusterNode.find("#cluster_content"); + var clusterObj = $thisNode.data("jsonObj"); + var $clusterContent = $thisNode.find("#cluster_content"); if($target.hasClass("expanded_close")) { $.ajax({ data: createURL("command=listHosts&type=Routing&clusterid="+clusterObj.id), @@ -253,28 +253,29 @@ function buildZoneTree() { break; - default: - /* - selectRowInZoneTree($(this).find("#cluster_header")); + default: + selectRowInZoneTree($thisNode.find("#cluster_header")); if(currentRightPanelJSP != "jsp/cluster.jsp") { removeDialogs(); - - var $thisNode = $(this); - $("#right_panel").load("jsp/cluster.jsp", function(){ + + $("#right_panel").load("jsp/cluster.jsp", function(){ currentRightPanelJSP = "jsp/cluster.jsp"; + + var $topButtonContainer = clearButtonsOnTop(); + $("#top_buttons").appendTo($topButtonContainer); - $(this).data("onRefreshFn", function() { + $thisNode.data("onRefreshFn", function() { clusterJsonToDetailsTab(); }); - afterLoadclusterJSP($thisNode); + afterLoadClusterJSP($thisNode); + clusterToRightPanel($thisNode); }); } else { - clusterJsonToRightPanel($(this)); - } - */ + clusterToRightPanel($thisNode); + } break; }