diff --git a/src/sunstone/public/js/plugins/templates-tab.js b/src/sunstone/public/js/plugins/templates-tab.js index bcf222e5b2..d8e101e8ca 100644 --- a/src/sunstone/public/js/plugins/templates-tab.js +++ b/src/sunstone/public/js/plugins/templates-tab.js @@ -764,8 +764,8 @@ function generate_disk_tab_content(str_disk_tab_id, str_datatable_id){ '
'+ '
'+ '
'+ - '
' + - '' + + '
' + + '' + '
' + '
'+ ''+ @@ -918,23 +918,22 @@ function generate_disk_tab_content(str_disk_tab_id, str_datatable_id){ '
'+ '
'; - $("#refresh_template_images_table_div_class"+str_disk_tab_id).die(); + $("#refresh_template_images_table_button_class"+str_disk_tab_id).die(); - $("#refresh_template_images_table_div_class"+str_disk_tab_id).live('click', function(){ + $("#refresh_template_images_table_button_class"+str_disk_tab_id).live('click', function(){ // Retrieve the images to fill the datatable OpenNebula.Image.list({ timeout: true, success: function (request, images_list){ - var image_list_array = []; + var image_list_array = []; - $.each(images_list,function(){ - image_list_array.push(imageElementArray(this)); - }); - - var dataTable_template_images = $("#datatable_template_images" + str_disk_tab_id.substring(4,str_disk_tab_id.length)).dataTable(); - updateView(image_list_array, dataTable_template_images); - dataTable_template_images.fnFilter("OS|DATABLOCK|CDROM", 7, true); - } + $.each(images_list,function(){ + image_list_array.push(imageElementArray(this)); + }); + + var dataTable_template_images = $('table[id='+str_datatable_id+']').dataTable(); + updateView(image_list_array, dataTable_template_images); + } }); } ); @@ -1138,7 +1137,7 @@ function setup_disk_tab_content(disk_section, str_disk_tab_id, str_datatable_id) function generate_nic_tab_content(str_nic_tab_id, str_datatable_id){ var html = '
'+ '
' + - '' + + '' + '
' + '
'+ ''+ @@ -1269,6 +1268,25 @@ function generate_nic_tab_content(str_nic_tab_id, str_datatable_id){ '
'+ '
'; + $("#refresh_template_nic_table_button_class"+str_nic_tab_id).die(); + + $("#refresh_template_nic_table_button_class"+str_nic_tab_id).live('click', function(){ + // Retrieve the nics to fill the datatable + OpenNebula.Network.list({ + timeout: true, + success: function (request, networks_list){ + var network_list_array = []; + + $.each(networks_list,function(){ + network_list_array.push(vNetworkElementArray(this)); + }); + var dataTable_template_networks = $('table[id='+str_datatable_id+']').dataTable(); + updateView(network_list_array, dataTable_template_networks); + } + }); + } + ); + return html; } @@ -1309,7 +1327,6 @@ function setup_nic_tab_content(nic_section, str_nic_tab_id, str_datatable_id) { }); - $('#'+str_nic_tab_id+'_search', nic_section).keyup(function(){ dataTable_template_networks.fnFilter( $(this).val() ); }) @@ -1697,11 +1714,15 @@ function setupCreateTemplateDialog(){ $(html_tab_content).appendTo($("ul#template_create_storage_tabs_content")); var a = $("
\ - DISK \ + DISK \
").appendTo($("dl#template_create_storage_tabs")); $(document).foundationTabs("set_tab", a); + $("#disk_tab"+str_disk_tab_id).live('click', function(){ + $("#refresh_template_images_table_button_class"+str_disk_tab_id).click(); + }); + var disk_section = $('li#' +str_disk_tab_id+'Tab', dialog); setup_disk_tab_content(disk_section, str_disk_tab_id, str_datatable_id) @@ -1763,38 +1784,21 @@ function setupCreateTemplateDialog(){ '' // Append the new div containing the tab and add the tab to the list - var a = $("
NIC
").appendTo($("dl#template_create_network_tabs")); + var a = $("
NIC
").appendTo($("dl#template_create_network_tabs")); $(html_tab_content).appendTo($("ul#template_create_network_tabs_content")); $(document).foundationTabs("set_tab", a); + $('#nic_tab'+str_nic_tab_id).live('click', function(){ + $("#refresh_template_nic_table_button_class"+str_nic_tab_id).click(); + }); var nic_section = $('li#' + str_nic_tab_id + 'Tab', dialog); setup_nic_tab_content(nic_section, str_nic_tab_id, str_datatable_id) number_of_nics++; nics_index++; - - $("refresh_template_nic_table_button_class"+str_nic_tab_id).die(); - - $("refresh_template_nic_table_button_class"+str_nic_tab_id).live('click', function(){ - // Retrieve the images to fill the datatable - OpenNebula.Network.list({ - timeout: true, - success: function (request, images_list){ - var network_list_array = []; - - $.each(networks_list,function(){ - network_list_array.push(vNetworkElementArray(this)); - }); - - var dataTable_template_networks = $("#datatable_template_networks"+str_nic_tab_id.substring(3,str_nic_tab_id.length)).dataTable(); - updateView(network_list_array, dataTable_template_networks); - } - }); - } - ); } @@ -1896,6 +1900,9 @@ function setupCreateTemplateDialog(){ '
'+ '
'+ '
'+ + '
' + + '' + + '
' + '
'+ ''+ '
'+ @@ -1953,6 +1960,9 @@ function setupCreateTemplateDialog(){ '
'+ '
'+ '
'+ + '
' + + '' + + '
' + '
'+ ''+ '
'+ @@ -2002,6 +2012,52 @@ function setupCreateTemplateDialog(){ ''+ '' + $("#refresh_kernel_table").die(); + + $("#refresh_kernel_table").live('click', function(){ + + OpenNebula.Image.list({ + timeout: true, + success: function (request, images_list){ + var image_list_array = []; + + $.each(images_list,function(){ + var file = fileElementArray(this); + if (file) + image_list_array.push(file); + }); + + var dataTable_template_kernel = $('#datatable_kernel').dataTable(); + updateView(image_list_array, dataTable_template_kernel); + dataTable_template_kernel.fnFilter("KERNEL", 7) + }, + error: onError + }); + }); + + $("#refresh_ramdisk_table").die(); + + $("#refresh_ramdisk_table").live('click', function(){ + + OpenNebula.Image.list({ + timeout: true, + success: function (request, images_list){ + var image_list_array = []; + + $.each(images_list,function(){ + var file = fileElementArray(this); + if (file) + image_list_array.push(file); + }); + + var datTable_template_initrd = $('#datatable_initrd').dataTable(); + updateView(image_list_array, datTable_template_initrd); + datTable_template_initrd.fnFilter("RAMDISK", 7) + }, + error: onError + }); + }); + $("
OS Booting
").appendTo($("dl#template_create_tabs")); $(html_tab_content).appendTo($("ul#template_create_tabs_content")); @@ -2407,6 +2463,9 @@ function setupCreateTemplateDialog(){ ''+ '
  • '+ '
    '+ + '
    ' + + '' + + '
    ' + '
    '+ ''+ '
    '+ @@ -2474,6 +2533,26 @@ function setupCreateTemplateDialog(){ ''+ '
  • ' + $("#refresh_context_table").die(); + + $("#refresh_context_table").live('click', function(){ + // Retrieve the nics to fill the datatable + OpenNebula.Image.list({ + timeout: true, + success: function (request, files_list){ + var files_list_array = []; + + $.each(files_list,function(){ + var image = fileElementArray(this); + if (image) + files_list_array.push(image); + }); + var datTable_template_context = $('table[id="datatable_context"]').dataTable(); + updateView(files_list_array, datTable_template_context); + }, + error: onError + }); + }); $("
    Context
    ").appendTo($("dl#template_create_tabs")); $(html_tab_content).appendTo($("ul#template_create_tabs_content")); @@ -2657,6 +2736,9 @@ function setupCreateTemplateDialog(){ '
    '+ '
    '+ '
    '+ + '
    ' + + '' + + '
    ' + '
    '+ ''+ '
    '+ @@ -2691,6 +2773,9 @@ function setupCreateTemplateDialog(){ '
    '+ '