\
+
\
+
\
+
\
+
\
+ \
+
\
+
\
+ \
+
\
+
\
+
\
+ \
+ \
+ | \
+ ' + tr("ID") + ' | \
+ ' + tr("Name") + ' | \
+ ' + tr("Hosts") + ' | \
+ ' + tr("VNets") + ' | \
+ ' + tr("Datastores") + ' | \
+
\
+ \
+ \
+ \
+
\
+
\
+
\
+ '+tr("Please select one or more clusters from the list")+' \
+ '+tr("You selected the following clusters:")+' \
+
\
+
\
+
\
+
';
+
+ $("#refresh_group_clusters_table_button_class"+str_zone_tab_id).die();
+ $("#refresh_group_clusters_table_button_class"+str_zone_tab_id).live('click', function(){
+ update_datatable_group_clusters($('table[id='+str_datatable_id+']').dataTable());
+ });
+
+ return html;
+}
+
// TODO: Refactor? same function in templates-tab.js
function update_datatable_group_clusters(datatable, fnDrawCallback) {
if (fnDrawCallback) {
@@ -799,101 +905,29 @@ function update_datatable_group_clusters(datatable, fnDrawCallback) {
});
};
+// TODO: one array per zone
var selected_group_clusters = {};
var group_clusters_row_hash = {};
-// TODO: Refactor? similar code in templates-tab.js
-function setupClusterDatatable(dialog){
- // Clusters TABLE
- var dataTable_group_clusters = $("#datatable_group_clusters", dialog).dataTable({
- "iDisplayLength": 4,
- "sDom" : '<"H">t<"F"p>',
- "bAutoWidth":false,
- "aoColumnDefs": [
- { "sWidth": "35px", "aTargets": [0,1] },
- { "bVisible": false, "aTargets": []}
- ]
- });
+var add_resource_tab = function(zone_id, dialog) {
+ var str_zone_tab_id = 'zone' + zone_id;
+ var str_datatable_id = 'datatable_group_clusters_zone' + zone_id;
- $("#refresh_group_clusters", dialog).die();
- $("#refresh_group_clusters", dialog).live('click', function(){
- update_datatable_group_clusters(dataTable_group_clusters);
- });
+ // Append the new div containing the tab and add the tab to the list
+ var html_tab_content = '
'+
+ generate_group_resource_tab_content(str_zone_tab_id, str_datatable_id) +
+ ''
+ $(html_tab_content).appendTo($("ul#group_zones_tabs_content"));
- update_datatable_group_clusters(dataTable_group_clusters);
+ var a = $("
\
+ "+tr("Zone")+" "+zone_id+"\
+ ").appendTo($("dl#group_zones_tabs"));
- $('#group_clusters_search', dialog).keyup(function(){
- dataTable_group_clusters.fnFilter( $(this).val() );
- })
+ $(document).foundationTabs("set_tab", a);
- dataTable_group_clusters.fnSort( [ [1,config['user_config']['table_order']] ] );
-
- $('#datatable_group_clusters', dialog).delegate("tr", "click", function(e){
- var aData = dataTable_group_clusters.fnGetData(this);
-
- if (!aData){
- return true;
- }
-
- var cluster_id = aData[1];
-
- if ($.isEmptyObject(selected_group_clusters)) {
- $('#you_selected_group_clusters', dialog).show();
- $('#select_group_clusters', dialog).hide();
- }
-
- if(!$("td:first", this).hasClass('markrowchecked'))
- {
- $('input.check_item', this).attr('checked','checked');
- selected_group_clusters[cluster_id]=1;
- group_clusters_row_hash[cluster_id]=this;
- $(this).children().each(function(){$(this).addClass('markrowchecked');});
- if ($('#tag_cluster_'+aData[1], $('div#selected_group_clusters', dialog)).length == 0 ) {
- $('div#selected_group_clusters', dialog).append('
'+aData[2]+' ');
- }
- }
- else
- {
- $('input.check_item', this).removeAttr('checked');
- delete selected_group_clusters[cluster_id];
- $(this).children().each(function(){$(this).removeClass('markrowchecked');});
- $('div#selected_group_clusters span#tag_cluster_'+cluster_id, dialog).remove();
- }
-
- if ($.isEmptyObject(selected_group_clusters)) {
- $('#you_selected_group_clusters', dialog).hide();
- $('#select_group_clusters', dialog).show();
- }
-
- $('.alert-box', $('.group_cluster_select')).hide();
-
- return true;
- });
-
- $( "#selected_group_clusters span.icon-remove", dialog ).live( "click", function() {
- $(this).parent().remove();
- var id = $(this).parent().attr("ID");
-
- var cluster_id=id.substring(12,id.length);
- delete selected_group_clusters[cluster_id];
- $('td', group_clusters_row_hash[cluster_id]).removeClass('markrowchecked');
- $('input.check_item', group_clusters_row_hash[cluster_id]).removeAttr('checked');
-
- if ($.isEmptyObject(selected_group_clusters)) {
- $('#you_selected_group_clusters', dialog).hide();
- $('#select_group_clusters', dialog).show();
- }
- });
-
- $("input[name='resources']", dialog).change(function(){
- if ($("input[name='resources']:checked").val() == "cluster") {
- $("div.group_cluster_select", dialog).show();
- }
- else {
- $("div.group_cluster_select", dialog).hide();
- }
- });
-}
+ var zone_section = $('li#' +str_zone_tab_id+'Tab', dialog);
+ setup_group_resource_tab_content(zone_section, str_zone_tab_id, str_datatable_id);
+};
function disableAdminUser(dialog){
$('#username',dialog).attr('disabled','disabled');
@@ -918,12 +952,10 @@ function setupCreateGroupDialog(){
dialog.html(create_group_tmpl);
dialog.addClass("reveal-modal large");
- setupTips($create_image_dialog);
+ setupTips($create_group_dialog);
setupCustomAuthDialog(dialog);
- $('#resources_all',dialog).click();
-
$('input#name', dialog).change(function(){
var val = $(this).val();
var dialog = $create_group_dialog;
@@ -961,23 +993,8 @@ function setupCreateGroupDialog(){
$('#admin_user',dialog).attr('disabled','disabled');
disableAdminUser(dialog);
- $('select#img_type',dialog).change(function(){
- var value = $(this).val();
- var context = $create_image_dialog;
- switch (value){
- case "DATABLOCK":
- $('#datablock_img',context).removeAttr("disabled");
- //$('#empty_datablock', context).show();
- break;
- default:
- $('#datablock_img',context).attr('disabled','disabled');
- //$('#empty_datablock', context).hide();
- $('#path_img',context).click();
-
- }
- });
-
- setupClusterDatatable(dialog);
+ // TODO: Retrieve list of zones and create a tab for each one
+ add_resource_tab(0, dialog);
$('#create_group_form',dialog).submit(function(){
var name = $('#name',this).val();
@@ -1014,7 +1031,11 @@ function setupCreateGroupDialog(){
var clusters = new Array();
- var resource_selection = $("input[name='resources']:checked").val();
+ // TODO: one zone hardcoded
+ var zone_id = 0;
+ var str_zone_tab_id = 'zone' + zone_id;
+
+ var resource_selection = $("input[name='"+str_zone_tab_id+"']:checked").val();
switch (resource_selection){
case "all":
// TODO