From 09851f95fb9881133f133795c8fab79bd319a5b2 Mon Sep 17 00:00:00 2001 From: Abel Coronado Date: Thu, 27 Jul 2017 16:40:11 +0200 Subject: [PATCH] B #5290 Solved bug filenames datastore in VM Template (#421) --- .../form-panels/create/wizard-tabs/context.js | 32 +++++++++++-------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/context.js b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/context.js index d8789dfb1a..664f7eb47d 100644 --- a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/context.js +++ b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/context.js @@ -323,9 +323,10 @@ define(function(require) { OpenNebula.Image.list({ timeout: true, success: function(request, obj_files){ - while (match = file_ds_regexp.exec(value)) { + + while (match = file_ds_regexp.exec(value.replace(/"/g, ""))) { $.each(obj_files, function(key, value){ - if(value.IMAGE.NAME == match[1] && value.IMAGE.UNAME == match[2]){ + if(value.IMAGE.NAME.replace(/"/g, "") == match[1] && value.IMAGE.UNAME == match[2]){ files.push(value.IMAGE.ID); return false; } @@ -357,18 +358,21 @@ define(function(require) { function _generateContextFiles(context) { var req_string=[]; var selected_files = this.contextFilesTable.retrieveResourceTableSelect(); - - $.each(selected_files, function(index, fileId) { - OpenNebula.Image.show({ - timeout: true, - data : { - id: fileId - }, - success: function(request, obj_file){ - req_string.push("$FILE[IMAGE=" + obj_file.IMAGE.NAME + ", IMAGE_UNAME=" + obj_file.IMAGE.UNAME + "]"); - $('.FILES_DS', context).val(req_string.join(" ")); - } + if(selected_files.length != 0){ + $.each(selected_files, function(index, fileId) { + OpenNebula.Image.show({ + timeout: true, + data : { + id: fileId + }, + success: function(request, obj_file){ + req_string.push("$FILE[IMAGE=" + '"' + obj_file.IMAGE.NAME + '"' + ", IMAGE_UNAME=" + obj_file.IMAGE.UNAME + "]"); + $('.FILES_DS', context).val(req_string.join(" ")); + } + }); }); - }); + } else { + $('.FILES_DS', context).val(""); + } }; });