diff --git a/src/sunstone/public/js/plugins/vdcs-tab.js b/src/sunstone/public/js/plugins/vdcs-tab.js
index d174bdd3d5..f96d89f73c 100644
--- a/src/sunstone/public/js/plugins/vdcs-tab.js
+++ b/src/sunstone/public/js/plugins/vdcs-tab.js
@@ -56,17 +56,7 @@ var create_vdc_wizard_html =
'+generateGroupTableSelect("vdc_wizard_groups")+'\
\
\
-
\
-
\
-
' + tr("Zones") +'
\
- \
-
\
-
\
+ '+vdcResourceTabHeader()+'\
\
\
\
@@ -159,11 +149,16 @@ var vdc_actions = {
$.each(obj_list,function(){
zone_ids.push(this.ZONE.ID);
- addVdcResourceTab(this.ZONE.ID,
+ addVdcResourceTab(
+ "vdc_create_wizard",
+ this.ZONE.ID,
this.ZONE.NAME,
- context);
+ $("#vdcCreateResourcesTab",context));
});
+ setupVdcResourceTab("vdc_create_wizard",
+ $("#vdcCreateResourcesTab",context));
+
context.data("zone_ids", zone_ids);
},
error: onError
@@ -612,146 +607,24 @@ function setup_vdc_group_tab_content(vdc_info){
}
function vdc_resources_tab_content(vdc_info){
-
- var clusters_array = [];
- var hosts_array = [];
- var vnets_array = [];
- var datastores_array = [];
-
- if (vdc_info.CLUSTERS.CLUSTER){
- clusters_array = vdc_info.CLUSTERS.CLUSTER;
-
- if (!$.isArray(clusters_array)){
- clusters_array = [clusters_array];
- }
- }
-
- if (vdc_info.HOSTS.HOST){
- hosts_array = vdc_info.HOSTS.HOST;
-
- if (!$.isArray(hosts_array)){
- hosts_array = [hosts_array];
- }
- }
-
- if (vdc_info.VNETS.VNET){
- vnets_array = vdc_info.VNETS.VNET;
-
- if (!$.isArray(vnets_array)){
- vnets_array = [vnets_array];
- }
- }
-
- if (vdc_info.DATASTORES.DATASTORE){
- datastores_array = vdc_info.DATASTORES.DATASTORE;
-
- if (!$.isArray(datastores_array)){
- datastores_array = [datastores_array];
- }
- }
-
- var html =
- ''+
- generateVdcResourceTabContent(str_zone_tab_id, zone_id) +
+ var html_tab_content = '
'+
+ generateVdcResourceTabContent(unique_id, zone_id) +
'
'
- $(html_tab_content).appendTo($(".vdc_zones_tabs_content", dialog));
+ $(html_tab_content).appendTo($(".vdc_zones_tabs_content", context));
- var a = $("
\
- "+zone_name+"\
- ").appendTo($("dl#vdc_zones_tabs", dialog));
+ $("select.vdc_zones_select", context).append('
');
- var zone_section = $('#' +str_zone_tab_id+'Tab', dialog);
+ var zone_section = $('#' +unique_id+'Tab', context);
zone_section.foundation();
- $("dl#vdc_zones_tabs", dialog).children("dd").first().children("a").click();
-
- setupClusterTableSelect(zone_section, "vdc_wizard_clusters_zone_"+zone_id, {multiple_choice: true, zone_id: zone_id});
- setupHostTableSelect(zone_section, "vdc_wizard_hosts_zone_"+zone_id, {multiple_choice: true, zone_id: zone_id});
- setupVNetTableSelect(zone_section, "vdc_wizard_vnets_zone_"+zone_id, {multiple_choice: true, zone_id: zone_id});
- setupDatastoreTableSelect(zone_section, "vdc_wizard_datastores_zone_"+zone_id, {multiple_choice: true, zone_id: zone_id});
-
- refreshClusterTableSelect(zone_section, "vdc_wizard_clusters_zone_"+zone_id);
- refreshHostTableSelect(zone_section, "vdc_wizard_hosts_zone_"+zone_id);
- refreshVNetTableSelect(zone_section, "vdc_wizard_vnets_zone_"+zone_id);
- refreshDatastoreTableSelect(zone_section, "vdc_wizard_datastores_zone_"+zone_id);
-
- $("input[name='radio_cluster_"+zone_id+"']", zone_section).change(function(){
- if ($("input[name='radio_cluster_"+zone_id+"']:checked", zone_section).val() == "table") {
- $("div.vdc_cluster_select", zone_section).show();
- } else {
- $("div.vdc_cluster_select", zone_section).hide();
- }
+ $.each(["clusters", "hosts", "vnets", "datastores"], function(i,res_name){
+ $("input[name='all_"+res_name+"_"+unique_id+"']", zone_section).change(function(){
+ if ($(this).prop("checked")){
+ $("div.vdc_"+res_name+"_select", zone_section).hide();
+ } else {
+ $("div.vdc_"+res_name+"_select", zone_section).show();
+ }
+ });
});
- $("input[name='radio_host_"+zone_id+"']", zone_section).change(function(){
- if ($("input[name='radio_host_"+zone_id+"']:checked", zone_section).val() == "table") {
- $("div.vdc_host_select", zone_section).show();
- } else {
- $("div.vdc_host_select", zone_section).hide();
- }
- });
+ var opts = {};
- $("input[name='radio_vnet_"+zone_id+"']", zone_section).change(function(){
- if ($("input[name='radio_vnet_"+zone_id+"']:checked", zone_section).val() == "table") {
- $("div.vdc_vnet_select", zone_section).show();
- } else {
- $("div.vdc_vnet_select", zone_section).hide();
- }
- });
+ if(indexed_resources != undefined && indexed_resources[zone_id] != undefined){
+ var resources = indexed_resources[zone_id];
- $("input[name='radio_datastore_"+zone_id+"']", zone_section).change(function(){
- if ($("input[name='radio_datastore_"+zone_id+"']:checked", zone_section).val() == "table") {
- $("div.vdc_datastore_select", zone_section).show();
- } else {
- $("div.vdc_datastore_select", zone_section).hide();
- }
- });
+ $.each(["clusters", "hosts", "vnets", "datastores"], function(i,res_name){
+ opts[res_name] = { read_only: true, zone_id: zone_id };
+
+ if (resources[res_name].length == 1 && resources[res_name][0] == VDC_ALL_RESOURCES){
+ $("#all_"+res_name+"_"+unique_id).prop("checked", "checked");
+ } else {
+ opts[res_name].fixed_ids = resources[res_name];
+ }
+
+ $("#all_"+res_name+"_"+unique_id).prop("disabled", true);
+ });
+
+ } else {
+ $.each(["clusters", "hosts", "vnets", "datastores"], function(i,res_name){
+ opts[res_name] = {multiple_choice: true, zone_id: zone_id};
+ });
+ }
+
+ setupClusterTableSelect(zone_section, "vdc_clusters_"+unique_id, opts["clusters"]);
+ setupHostTableSelect(zone_section, "vdc_hosts_"+unique_id, opts["hosts"]);
+ setupVNetTableSelect(zone_section, "vdc_vnets_"+unique_id, opts["vnets"]);
+ setupDatastoreTableSelect(zone_section, "vdc_datastores_"+unique_id, opts["datastores"]);
+
+ refreshClusterTableSelect(zone_section, "vdc_clusters_"+unique_id);
+ refreshHostTableSelect(zone_section, "vdc_hosts_"+unique_id);
+ refreshVNetTableSelect(zone_section, "vdc_vnets_"+unique_id);
+ refreshDatastoreTableSelect(zone_section, "vdc_datastores_"+unique_id);
}
-function generateVdcResourceTabContent(str_zone_tab_id, zone_id){
- var html =
+function setupVdcResourceTab(unique_id_prefix, context){
+ $("select.vdc_zones_select", context).change(function(){
+ context.find(".vdc_zone_content").hide();
+ $('div#'+unique_id_prefix+'_'+$(this).val()+'Tab', context).show();
+ });
+
+ $("select.vdc_zones_select", context)[0].selectedIndex = 0;
+ $("select.vdc_zones_select", context).change();
+}
+
+function generateVdcResourceTabContent(unique_id, zone_id){
+ var html =
'
\
\
\
-
'+tr("Clusters")+' \
-
'+tr("Hosts")+' \
-
'+tr("VNets")+' \
-
'+tr("Datastores")+' \
+
'+tr("Clusters")+' \
+
'+tr("Hosts")+' \
+
'+tr("VNets")+' \
+
'+tr("Datastores")+' \
\
\
-
\
+
\
\
-
\
- '+generateClusterTableSelect("vdc_wizard_clusters_zone_"+zone_id)+'\
+
\
+ '+generateClusterTableSelect("vdc_clusters_"+unique_id)+'\
\
\
-
\
+
\
\
-
\
- '+generateHostTableSelect("vdc_wizard_hosts_zone_"+zone_id)+'\
+
\
+ '+generateHostTableSelect("vdc_hosts_"+unique_id)+'\
\
\
-
\
+
\
\
-
\
- '+generateVNetTableSelect("vdc_wizard_vnets_zone_"+zone_id)+'\
+
\
+ '+generateVNetTableSelect("vdc_vnets_"+unique_id)+'\
\
\
-
\
+
\
\
-
\
- '+generateDatastoreTableSelect("vdc_wizard_datastores_zone_"+zone_id)+'\
+
\
+ '+generateDatastoreTableSelect("vdc_datastores_"+unique_id)+'\
\
\
\
@@ -1354,6 +1195,64 @@ function generateVdcResourceTabContent(str_zone_tab_id, zone_id){
return html;
}
+/*
+Return an object with the selected VDC resources in the zone tab
+ { clusters : [],
+ hosts : [],
+ vnets : [],
+ datastores : []
+ }
+*/
+function retrieveVdcResourceTab(unique_id_prefix, zone_id, context) {
+ var clusters;
+ var hosts;
+ var vnets;
+ var datastores;
+
+ var unique_id = unique_id_prefix+'_'+zone_id;
+
+ if ( $("input[name='all_clusters_"+unique_id+"']", context).prop("checked") ){
+ clusters = [VDC_ALL_RESOURCES];
+ } else {
+ clusters = retrieveClusterTableSelect(
+ $("#vdcCreateResourcesTab",context),
+ "vdc_clusters_"+unique_id);
+ }
+
+ if ( $("input[name='all_hosts_"+unique_id+"']", context).prop("checked") ){
+ hosts = [VDC_ALL_RESOURCES];
+ } else {
+ hosts = retrieveHostTableSelect(
+ $("#vdcCreateResourcesTab",context),
+ "vdc_hosts_"+unique_id);
+ }
+
+ if ( $("input[name='all_vnets_"+unique_id+"']", context).prop("checked") ){
+ vnets = [VDC_ALL_RESOURCES];
+ } else {
+ vnets = retrieveVNetTableSelect(
+ $("#vdcCreateResourcesTab",context),
+ "vdc_vnets_"+unique_id);
+ }
+
+ if ( $("input[name='all_datastores_"+unique_id+"']", context).prop("checked") ){
+ datastores = [VDC_ALL_RESOURCES];
+ } else {
+ datastores = retrieveDatastoreTableSelect(
+ $("#vdcCreateResourcesTab",context),
+ "vdc_datastores_"+unique_id);
+ }
+
+ var resources = {
+ clusters : clusters,
+ hosts : hosts,
+ vnets : vnets,
+ datastores : datastores
+ }
+
+ return resources;
+}
+
//The DOM is ready and the ready() from sunstone.js
//has been executed at this point.
$(document).ready(function(){