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 67ffb9f3fc..9f2dd41bb4 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 @@ -54,6 +54,7 @@ define(function(require) { this.wizardTabId = WIZARD_TAB_ID + UniqueId.id(); this.icon = "fa-folder"; + this.type = "VM_TEMPLATE"; this.title = Locale.tr("Context"); this.classes = "hypervisor"; this.templateVcenterCustomizationSpec = ""; @@ -94,9 +95,12 @@ define(function(require) { function _onShow(context, panelForm) { } - function _setup(context) { - var that = this; + function _setup(context, type) { + if(type){ + this.type = type; + } + var that = this; $("input[name='context_type']", context).on("change", function() { $(".context_type", context).hide(); $("."+$(this).val(), context).show(); @@ -337,15 +341,38 @@ define(function(require) { OpenNebula.Image.list({ timeout: true, success: function(request, obj_files){ - - while (match = file_ds_regexp.exec(value.replace(/"/g, ""))) { - $.each(obj_files, function(key, value){ - if(value.IMAGE.NAME.replace(/"/g, "") == match[1] && value.IMAGE.UNAME == match[2]){ - files.push(value.IMAGE.ID); - return false; + if(that.type === "VM"){ + if(value){ + var pathFiles = value.split(" "); + if(Array.isArray(pathFiles)){ + pathFiles.forEach(function(pathFile){ + if(pathFile){ + var nameFile = pathFile.split(/:'(\w+)'$/gi); + if(nameFile && nameFile[1]){ + var find_id = obj_files.find( + function(element){ + return element && element.IMAGE && element.IMAGE.NAME && element.IMAGE.NAME === nameFile[1]; + } + ); + if(find_id && find_id.IMAGE && find_id.IMAGE.ID){ + files.push(find_id.IMAGE.ID); + } + } + } + }); } - }); + } + }else{ + while (match = file_ds_regexp.exec(value.replace(/"/g, ""))) { + $.each(obj_files, function(key, value){ + if(value.IMAGE.NAME.replace(/"/g, "") == match[1] && value.IMAGE.UNAME == match[2]){ + files.push(value.IMAGE.ID); + return false; + } + }); + } } + var selectedResources = { ids : files }; @@ -370,6 +397,7 @@ define(function(require) { } function _generateContextFiles(context) { + var that = this; var req_string=[]; var selected_files = this.contextFilesTable.retrieveResourceTableSelect(); if(selected_files.length != 0){ diff --git a/src/sunstone/public/app/tabs/vms-tab/form-panels/updateconf.js b/src/sunstone/public/app/tabs/vms-tab/form-panels/updateconf.js index 93fc89e162..44dad3ff41 100644 --- a/src/sunstone/public/app/tabs/vms-tab/form-panels/updateconf.js +++ b/src/sunstone/public/app/tabs/vms-tab/form-panels/updateconf.js @@ -19,25 +19,26 @@ define(function(require) { DEPENDENCIES */ - var BaseFormPanel = require('utils/form-panels/form-panel'); - var Locale = require('utils/locale'); - var Sunstone = require('sunstone'); - var TemplateUtils = require('utils/template-utils'); + var BaseFormPanel = require("utils/form-panels/form-panel"); + var Sunstone = require("sunstone"); + var Locale = require("utils/locale"); + var Tips = require("utils/tips"); + var TemplateUtils = require("utils/template-utils"); /* TEMPLATES */ - var TemplateWizardHTML = require('hbs!./updateconf/wizard'); - var TemplateAdvancedHTML = require('hbs!./updateconf/advanced'); + var TemplateWizardHTML = require("hbs!./updateconf/wizard"); + var TemplateAdvancedHTML = require("hbs!./updateconf/advanced"); /* CONSTANTS */ - var FORM_PANEL_ID = require('./updateconf/formPanelId'); - var TAB_ID = require('../tabId'); - var TEMPLATE_TAB_ID = require('tabs/templates-tab/tabId'); + var FORM_PANEL_ID = require("./updateconf/formPanelId"); + var TAB_ID = require("../tabId"); + var TEMPLATE_TAB_ID = require("tabs/templates-tab/tabId"); var WIZARD_TABS = [ require('tabs/templates-tab/form-panels/create/wizard-tabs/os'), require('tabs/templates-tab/form-panels/create/wizard-tabs/context'), @@ -52,10 +53,10 @@ define(function(require) { this.formPanelId = FORM_PANEL_ID; this.tabId = TAB_ID; this.actions = { - 'updateconf': { - 'title': Locale.tr("Update VM Configuration"), - 'buttonText': Locale.tr("Update"), - 'resetButton': false + "updateconf": { + "title": Locale.tr("Update VM Configuration"), + "buttonText": Locale.tr("Update"), + "resetButton": false } }; @@ -96,8 +97,8 @@ define(function(require) { function _htmlWizard() { return TemplateWizardHTML({ - 'formPanelId': this.formPanelId, - 'wizardTabs': this.wizardTabs + "formPanelId": this.formPanelId, + "wizardTabs": this.wizardTabs }); } @@ -107,21 +108,20 @@ define(function(require) { function _setup(context) { $.each(this.wizardTabs, function(index, wizardTab) { - wizardTab.setup($('#' + wizardTab.wizardTabId, context)); + wizardTab.setup($("#" + wizardTab.wizardTabId, context), "VM"); }); - $(".vm_updateconf_hide", context).remove(); - - Foundation.reflow(context, 'tabs'); - Foundation.reflow(context, 'tooltip'); + Foundation.reflow(context, "tabs"); + Foundation.reflow(context, "tooltip"); + Foundation.reflow(context, "tabs"); } function _onShow(context) { var that = this; - $('a[href="#'+ that.wizardTabs[0].wizardTabId +'"]', context).trigger("click"); + $("a[href=\"#"+ that.wizardTabs[0].wizardTabId +"\"]", context).trigger("click"); $.each(that.wizardTabs, function(index, wizardTab) { - wizardTab.onShow($('#' + wizardTab.wizardTabId, context), that); + wizardTab.onShow($("#" + wizardTab.wizardTabId, context), that); }); } @@ -130,10 +130,10 @@ define(function(require) { var templateJSON = this.template; $.each(this.wizardTabs, function(index, wizardTab) { $.extend( - true, - templateJSON, + true, + templateJSON, wizardTab.retrieve( - $('#' + wizardTab.wizardTabId, context) + $("#" + wizardTab.wizardTabId, context) ) ); }); @@ -143,7 +143,7 @@ define(function(require) { } function _submitAdvanced(context) { - var template = $('textarea#template', context).val(); + var template = $("textarea#template", context).val(); Sunstone.runAction("VM.updateconf", this.resourceId, template); return false; @@ -157,11 +157,11 @@ define(function(require) { var templateJSON = element.TEMPLATE; // Populates the Avanced mode Tab - $('#template', context).val( + $("#template", context).val( TemplateUtils.templateToString(templateJSON)); $.each(this.wizardTabs, function(index, wizardTab) { - wizardTab.fill($('#' + wizardTab.wizardTabId, context), templateJSON); + wizardTab.fill($("#" + wizardTab.wizardTabId, context), templateJSON); }); // After all tabs have been filled, perform a notify. @@ -169,7 +169,7 @@ define(function(require) { // the disks and nics $.each(this.wizardTabs, function(index, wizardTab) { if (wizardTab.notify != undefined){ - wizardTab.notify($('#' + wizardTab.wizardTabId, context), templateJSON); + wizardTab.notify($("#" + wizardTab.wizardTabId, context), templateJSON); } }); } diff --git a/src/sunstone/public/app/tabs/vms-tab/panels/conf.js b/src/sunstone/public/app/tabs/vms-tab/panels/conf.js index d51a9ae6f7..8951075fa6 100644 --- a/src/sunstone/public/app/tabs/vms-tab/panels/conf.js +++ b/src/sunstone/public/app/tabs/vms-tab/panels/conf.js @@ -19,28 +19,28 @@ define(function(require) { DEPENDENCIES */ - var Locale = require('utils/locale'); - var Sunstone = require('sunstone'); - var Config = require('sunstone-config'); - var TemplateUtils = require('utils/template-utils'); - var StateActions = require('../utils/state-actions'); + var Locale = require("utils/locale"); + var Sunstone = require("sunstone"); + var Config = require("sunstone-config"); + var TemplateUtils = require("utils/template-utils"); + var StateActions = require("../utils/state-actions"); /* TEMPLATES */ - var Template = require('hbs!./conf/html'); + var Template = require("hbs!./conf/html"); /* CONSTANTS */ - var TAB_ID = require('../tabId'); - var PANEL_ID = require('./conf/panelId'); + var TAB_ID = require("../tabId"); + var PANEL_ID = require("./conf/panelId"); var RESOURCE = "VM"; var XML_ROOT = "VM"; - var UPDATECONF_FORM_ID = require('../form-panels/updateconf/formPanelId'); + var UPDATECONF_FORM_ID = require("../form-panels/updateconf/formPanelId"); /* CONSTRUCTOR @@ -51,7 +51,12 @@ define(function(require) { this.title = Locale.tr("Conf"); this.icon = "fa-cog"; - this.element = info[XML_ROOT]; + this.element = $.extend( + true, + {}, + info[XML_ROOT] + ); + var conf = {}; var template = this.element.TEMPLATE; @@ -85,14 +90,13 @@ define(function(require) { function _setup(context) { var that = this; - if (Config.isTabActionEnabled("vms-tab", "VM.updateconf")) { if (!StateActions.enabledStateAction("VM.updateconf", that.element.STATE, that.element.LCM_STATE)){ - $('#vm_updateconf', context).attr("disabled", "disabled"); + $("#vm_updateconf", context).attr("disabled", "disabled"); } - context.off('click', '#vm_updateconf'); - context.on('click', '#vm_updateconf', function() { + context.off("click", "#vm_updateconf"); + context.on("click", "#vm_updateconf", function() { Sunstone.resetFormPanel(TAB_ID, UPDATECONF_FORM_ID); Sunstone.showFormPanel(TAB_ID, UPDATECONF_FORM_ID, "updateconf",