From cd549d309c8b9b97a6e9b6f84c5c34eb9575552d Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Sun, 17 Oct 2010 09:52:42 -0700 Subject: [PATCH] new UI - resources page - zone page - fill secondary storage tab. --- ui/new/jsp/resource.jsp | 283 ++++++++++++------------- ui/new/scripts/cloud.core2.resource.js | 41 +++- 2 files changed, 175 insertions(+), 149 deletions(-) diff --git a/ui/new/jsp/resource.jsp b/ui/new/jsp/resource.jsp index f92e7dbe88e..ee9535294db 100644 --- a/ui/new/jsp/resource.jsp +++ b/ui/new/jsp/resource.jsp @@ -816,153 +816,33 @@ + + + + - - - - - - - - - - - - - - - - - - - - - + + + + + diff --git a/ui/new/scripts/cloud.core2.resource.js b/ui/new/scripts/cloud.core2.resource.js index 7b2cbbf3b4b..602410d34c4 100644 --- a/ui/new/scripts/cloud.core2.resource.js +++ b/ui/new/scripts/cloud.core2.resource.js @@ -58,7 +58,8 @@ function buildZoneTree() { var jsonObj = target.data("jsonObj"); showPage($("#zone_page"), jsonObj); zoneJsonToDetailsTab(jsonObj); - zoneJsonToNetworkTab(jsonObj); + zoneJsonToNetworkTab(jsonObj); + zoneJsonToSecondaryStorageTab(jsonObj); break; case "pod_name" : @@ -195,7 +196,7 @@ function showPage($pageToShow, jsonObj) { if($pageToShow.attr("id") == "zone_page") { initAddPodButton($("#midmenu_add_link"), jsonObj); - $("#midmenu_add2_link").unbind("click").hide(); + $("#tab_details").click(); } else if($pageToShow.attr("id") == "pod_page") { initAddHostButton($("#midmenu_add_link"), jsonObj); @@ -222,7 +223,7 @@ function zoneJsonToDetailsTab(jsonObj) { } function zoneJsonToNetworkTab(jsonObj) { - var $networkTab = $("#zone_page").find("#tab_content_network"); + var $networkTab = $("#zone_page").find("#tab_content_network"); $networkTab.find("#zone_cloud").find("#zone_name").text(fromdb(jsonObj.name)); $networkTab.find("#zone_vlan").text(jsonObj.vlan); @@ -250,6 +251,27 @@ function zoneJsonToNetworkTab(jsonObj) { }); } +function zoneJsonToSecondaryStorageTab(jsonObj) { + var zoneObj = $("#zone_page").find("#tab_content_details").data("jsonObj"); + $.ajax({ + cache: false, + data: createURL("command=listHosts&type=SecondaryStorage&zoneid="+zoneObj.id+maxPageSize), + dataType: "json", + success: function(json) { + var items = json.listhostsresponse.host; + var container = $("#zone_page").find("#tab_content_secondary_storage").empty(); + if (items != null && items.length > 0) { + var template = $("#secondary_storage_tab_template"); + for (var i = 0; i < items.length; i++) { + var newTemplate = template.clone(true); + secondaryStorageJSONToTemplate(items[i], newTemplate); + container.append(newTemplate.show()); + } + } + } + }); +} + function vlanJsonToTemplate(jsonObj, $template1) { $template1.data("jsonObj", jsonObj); $template1.find("#vlan_id").text(jsonObj.vlan); @@ -412,6 +434,7 @@ function afterLoadResourceJSP() { initDialog("dialog_add_pod", 320); initDialog("dialog_add_host"); initDialog("dialog_add_pool"); + initDialog("dialog_add_secondarystorage"); // if hypervisor is KVM, limit the server option to NFS for now if (getHypervisorType() == 'kvm') { @@ -846,3 +869,15 @@ function initAddPrimaryStorageButton($midmenuAddLink2, jsonObj) { return false; }); } + +function secondaryStorageJSONToTemplate(json, template) { + template.attr("id", "secondaryStorage_"+json.id).data("secondaryStorageId", json.id); + template.find("#id").text(json.id); + template.find("#name").text(json.name); + template.find("#zonename").text(json.zonename); + template.find("#type").text(json.type); + template.find("#ipaddress").text(json.ipaddress); + template.find("#state").text(json.state); + template.find("#version").text(json.version); + setDateField(json.disconnected, template.find("#disconnected")); +} \ No newline at end of file