diff --git a/src/sunstone/public/js/plugins/provision-tab.js b/src/sunstone/public/js/plugins/provision-tab.js index 315695c079..a8f9e3489b 100644 --- a/src/sunstone/public/js/plugins/provision-tab.js +++ b/src/sunstone/public/js/plugins/provision-tab.js @@ -5873,6 +5873,59 @@ $(document).ready(function(){ // Create VM // + function appendTemplateCard(aData, tableID) { + var data = aData.VMTEMPLATE; + var logo; + + if (data.TEMPLATE.LOGO) { + logo = ''; + } else { + logo = ''+ + ''+ + ''; + } + + var li = $('
  • '+ + ''+ + '
  • ').appendTo($("#"+tableID+'_ul')); + + $(".provision-pricing-table", li).data("opennebula", aData); + } + + function initializeTemplateCards(context, tableID) { + // create a thumbs container if it doesn't exist. put it in the dataTables_scrollbody div + if (context.$('tr', {"filter": "applied"} ).length == 0) { + context.html('
    '+ + ''+ + ''+ + ''+ + ''+ + '
    '+ + '
    '+ + ''+ + tr("There are no templates available")+ + ''+ + '
    '); + } else { + $('#'+tableID+'_table').html( + ''); + } + + return true; + } + provision_system_templates_datatable = $('#provision_system_templates_table').dataTable({ "iDisplayLength": 6, "sDom" : '<"H">t<"F"lp>', @@ -5886,55 +5939,10 @@ $(document).ready(function(){ { "mDataProp": "VMTEMPLATE.TEMPLATE.SAVED_TEMPLATE_ID", "sDefaultContent" : "-" } ], "fnPreDrawCallback": function (oSettings) { - // create a thumbs container if it doesn't exist. put it in the dataTables_scrollbody div - if (this.$('tr', {"filter": "applied"} ).length == 0) { - this.html('
    '+ - ''+ - ''+ - ''+ - ''+ - '
    '+ - '
    '+ - ''+ - tr("There are no templates available")+ - ''+ - '
    '); - } else { - $("#provision_system_templates_table").html(''); - } - - return true; + initializeTemplateCards(this, "provision_system_templates") }, "fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) { - var data = aData.VMTEMPLATE; - var logo; - - if (data.TEMPLATE.LOGO) { - logo = ''; - } else { - logo = ''+ - ''+ - ''; - } - - var li = $('
  • '+ - '
      '+ - '
    • '+ - data.NAME+ - '
    • '+ - '
    • '+ - logo + - '
    • '+ - '
    • '+ - (data.TEMPLATE.DESCRIPTION || '...')+ - '
    • '+ - '
    '+ - '
  • ').appendTo($("#provision_system_templates_ul")); - - $(".provision-pricing-table", li).data("opennebula", aData); - + appendTemplateCard(aData, "provision_system_templates"); return nRow; } }); @@ -5954,55 +5962,10 @@ $(document).ready(function(){ { "mDataProp": "VMTEMPLATE.PERMISSIONS.GROUP_U" } ], "fnPreDrawCallback": function (oSettings) { - // create a thumbs container if it doesn't exist. put it in the dataTables_scrollbody div - if (this.$('tr', {"filter": "applied"} ).length == 0) { - this.html('
    '+ - ''+ - ''+ - ''+ - ''+ - '
    '+ - '
    '+ - ''+ - tr("There are no templates available. Please contact your cloud administrator")+ - ''+ - '
    '); - } else { - $("#provision_vdc_templates_table").html(''); - } - - return true; + initializeTemplateCards(this, "provision_vdc_templates") }, "fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) { - var data = aData.VMTEMPLATE; - var logo; - - if (data.TEMPLATE.LOGO) { - logo = ''; - } else { - logo = ''+ - ''+ - ''; - } - - var li = ('
  • '+ - '
      '+ - '
    • '+ - data.NAME+ - '
    • '+ - '
    • '+ - logo + - '
    • '+ - '
    • '+ - (data.TEMPLATE.DESCRIPTION || '...')+ - '
    • '+ - '
    '+ - '
  • ').appendTo($("#provision_vdc_templates_ul")); - - $(".provision-pricing-table", li).data("opennebula", aData); - + appendTemplateCard(aData, "provision_vdc_templates"); return nRow; } }); @@ -6022,56 +5985,10 @@ $(document).ready(function(){ { "mDataProp": "VMTEMPLATE.PERMISSIONS.GROUP_U" } ], "fnPreDrawCallback": function (oSettings) { - // create a thumbs container if it doesn't exist. put it in the dataTables_scrollbody div - if (this.$('tr', {"filter": "applied"} ).length == 0) { - this.html('
    '+ - ''+ - ''+ - ''+ - ''+ - '
    '+ - '
    '+ - ''+ - tr("There are no templates available. Please contact your cloud administrator")+ - ''+ - '
    '); - } else { - $("#provision_saved_templates_table").html('
      '); - } - - return true; + initializeTemplateCards(this, "provision_saved_templates") }, "fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) { - var data = aData.VMTEMPLATE; - - var logo; - - if (data.TEMPLATE.LOGO) { - logo = ''; - } else { - logo = ''+ - ''+ - ''; - } - - var li = $('
    • '+ - '
        '+ - '
      • '+ - data.NAME+ - '
      • '+ - '
      • '+ - logo + - '
      • '+ - '
      • '+ - (data.TEMPLATE.DESCRIPTION || '...')+ - '
      • '+ - '
      '+ - '
    • ').appendTo($("#provision_saved_templates_ul")); - - $(".provision-pricing-table", li).data("opennebula", aData); - + appendTemplateCard(aData, "provision_saved_templates"); return nRow; } });