From 8b68fb2373ddfd20a241ec70c17fa711781a8a97 Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Mon, 7 Apr 2014 18:19:53 +0200 Subject: [PATCH] feature #2798: Remove template and image --- .../public/js/plugins/provision-tab.js | 41 ++++++++++++++----- src/sunstone/public/js/sunstone.js | 5 +++ 2 files changed, 35 insertions(+), 11 deletions(-) diff --git a/src/sunstone/public/js/plugins/provision-tab.js b/src/sunstone/public/js/plugins/provision-tab.js index 23c1b6391a..8a224fd1e3 100644 --- a/src/sunstone/public/js/plugins/provision-tab.js +++ b/src/sunstone/public/js/plugins/provision-tab.js @@ -1664,6 +1664,11 @@ $(document).ready(function(){ '
  • '+ (data.TEMPLATE.DESCRIPTION || '...')+ '
  • '+ + '
  • '+ + ''+ + _format_date(data.REGTIME)+ + " " + tr("from VM") + ": " + (data.TEMPLATE.SAVED_TEMPLATE_ID||'-') + + '
  • '+ ''+ ''); @@ -1929,7 +1934,7 @@ $(document).ready(function(){ ''+ ''); } else { - $("#provision_templates_table").html(''); + $("#provision_templates_table").html(''); } return true; }, @@ -1938,8 +1943,8 @@ $(document).ready(function(){ //var state = get_provision_image_state(data); $("#provision_templates_ul").append('
  • '+ - '
      '+ - '
    • '+ + '
    • '+ data.NAME + ''+ '
    • '+ '
    • '+ @@ -1960,10 +1965,6 @@ $(document).ready(function(){ ''+ _format_date(data.REGTIME)+ " " + tr("from VM") + ": " + (data.TEMPLATE.SAVED_TEMPLATE_ID||'-') + - //''+ - // ' '+ - // state.str+ - //''+ '
    • '+ '
    '+ '
  • '); @@ -1997,6 +1998,7 @@ $(document).ready(function(){ $("#provision_list_templates").on("click", ".provision_confirm_delete_template_button", function(){ var context = $(this).parents(".provision-pricing-table"); var template_id = context.attr("opennebula_id"); + var image_id = context.attr("saved_to_image_id"); var template_name = $(".provision-title", context).text(); $("#provision_confirm_delete_template_div").html( @@ -2006,11 +2008,11 @@ $(document).ready(function(){ ''+ tr("This action will inmediately destroy the template")+ ' "' + template_name + '" ' + - tr("and all the information will be lost.") + + tr("and the image associated.") + ''+ ''+ ''+ ''+ '×'+ @@ -2018,8 +2020,25 @@ $(document).ready(function(){ }); $("#provision_confirm_delete_template_div").on("click", "#provision_delete_template_button", function(){ - var template_id = $(this).attr("value"); - Sunstone.runAction('Provision.Template.delete', template_id); + var template_id = $(this).attr("template_id"); + var image_id = $(this).attr("image_id"); + + OpenNebula.Image.del({ + timeout: true, + data : { + id : image_id + }, + success: function (){ + Sunstone.runAction('Provision.Template.delete', template_id); + }, + error: function (request,error_json, container) { + if (error_json.error.http_status=="404") { + Sunstone.runAction('Provision.Template.delete', template_id); + } else { + onError(request, error_json, container); + } + } + }) }); // diff --git a/src/sunstone/public/js/sunstone.js b/src/sunstone/public/js/sunstone.js index 4c2ced0591..2da57d36fc 100644 --- a/src/sunstone/public/js/sunstone.js +++ b/src/sunstone/public/js/sunstone.js @@ -1502,6 +1502,11 @@ function onError(request,error_json, container) { return false; }; + if (error_json.error.http_status=="404") { + notifyError(message); + return false; + } + if (container) { container.show(); return false;