diff --git a/src/sunstone/public/js/opennebula.js b/src/sunstone/public/js/opennebula.js index 8c2bd5ef18..da5e35066a 100644 --- a/src/sunstone/public/js/opennebula.js +++ b/src/sunstone/public/js/opennebula.js @@ -299,6 +299,11 @@ var OpenNebula = { return(p_pool); } + }, + + "clear_cache" : function(cache_name){ + list_cache[cache_name] = null; + //console.log(cache_name+" cache cleaned"); } }, @@ -312,6 +317,7 @@ var OpenNebula = { var data = params.data; var request = OpenNebula.Helper.request(resource,"create", data); var req_path = path ? path : resource.toLowerCase(); + var cache_name = params.cache_name ? params.cache_name : resource; $.ajax({ url: req_path, @@ -319,6 +325,8 @@ var OpenNebula = { dataType: "json", data: JSON.stringify(data), success: function(response){ + OpenNebula.Helper.clear_cache(cache_name); + return callback ? callback(request, response) : null; }, error: function(response){ @@ -334,11 +342,14 @@ var OpenNebula = { var id = params.data.id; var request = OpenNebula.Helper.request(resource,"delete", id); var req_path = path ? path : resource.toLowerCase(); + var cache_name = params.cache_name ? params.cache_name : resource; $.ajax({ url: req_path + "/" + id, type: "DELETE", success: function(){ + OpenNebula.Helper.clear_cache(cache_name); + return callback ? callback(request) : null; }, error: function(response){ @@ -362,6 +373,10 @@ var OpenNebula = { force = options.force; } + if (force){ + OpenNebula.Helper.clear_cache(cache_name); + } + if( !force && list_cache[cache_name] && list_cache[cache_name]["timestamp"] + cache_expire > new Date().getTime()){ diff --git a/src/sunstone/public/js/plugins/oneflow-services.js b/src/sunstone/public/js/plugins/oneflow-services.js index b80b04b05d..7b46f0362f 100644 --- a/src/sunstone/public/js/plugins/oneflow-services.js +++ b/src/sunstone/public/js/plugins/oneflow-services.js @@ -29,6 +29,7 @@ var Service = { Service.path); }, "del": function(params){ + params.cache_name = "SERVICE"; OpenNebula.Action.del(params,Service.resource, Service.path); }, "list" : function(params){ diff --git a/src/sunstone/public/js/plugins/oneflow-templates.js b/src/sunstone/public/js/plugins/oneflow-templates.js index 3c49c79e7b..64170dfd52 100644 --- a/src/sunstone/public/js/plugins/oneflow-templates.js +++ b/src/sunstone/public/js/plugins/oneflow-templates.js @@ -20,6 +20,7 @@ var ServiceTemplate = { "resource" : 'DOCUMENT', "path" : 'service_template', "create": function(params){ + params.cache_name = "SERVICE_TEMPLATE"; OpenNebula.Action.create(params, ServiceTemplate.resource, ServiceTemplate.path); }, @@ -40,6 +41,7 @@ var ServiceTemplate = { ServiceTemplate.path); }, "del": function(params){ + params.cache_name = "SERVICE_TEMPLATE"; OpenNebula.Action.del(params,ServiceTemplate.resource, ServiceTemplate.path); }, "list" : function(params){ @@ -390,6 +392,9 @@ var service_template_actions = { "ServiceTemplate.instantiate" : { type: "multiple", call: ServiceTemplate.instantiate, + callback: function(req){ + OpenNebula.Helper.clear_cache("SERVICE"); + }, elements: serviceTemplateElements, error: onError, notify: true diff --git a/src/sunstone/public/js/plugins/templates-tab.js b/src/sunstone/public/js/plugins/templates-tab.js index d7e74cdabf..a689329f44 100644 --- a/src/sunstone/public/js/plugins/templates-tab.js +++ b/src/sunstone/public/js/plugins/templates-tab.js @@ -360,6 +360,9 @@ var template_actions = { "Template.instantiate" : { type: "multiple", call: OpenNebula.Template.instantiate, + callback: function(req){ + OpenNebula.Helper.clear_cache("VM"); + }, elements: templateElements, error: onError, notify: true @@ -368,6 +371,9 @@ var template_actions = { "Template.instantiate_quiet" : { type: "single", call: OpenNebula.Template.instantiate, + callback: function(req){ + OpenNebula.Helper.clear_cache("VM"); + }, error: onError, notify: false }, @@ -384,10 +390,9 @@ var template_actions = { { Sunstone.runAction("Template.instantiate", nodes); } - - Sunstone.runAction("VM.refresh"); } }, +/* "Template.instantiate_and_merge" : { type: "custom", call: function(){ @@ -400,10 +405,9 @@ var template_actions = { { notifyError(tr("Please select only one template in the table")) } - - Sunstone.runAction("VM.refresh"); } }, +*/ "Template.chown" : { type: "multiple", call: OpenNebula.Template.chown,