diff --git a/src/sunstone/models/OpenNebulaJSON/MarketPlaceAppJSON.rb b/src/sunstone/models/OpenNebulaJSON/MarketPlaceAppJSON.rb index 7bf34ee133..b7e88085ed 100644 --- a/src/sunstone/models/OpenNebulaJSON/MarketPlaceAppJSON.rb +++ b/src/sunstone/models/OpenNebulaJSON/MarketPlaceAppJSON.rb @@ -172,6 +172,7 @@ module OpenNebulaJSON name = params['name'] vmtemplate_name = params['vmtemplate_name'] notemplate = [true, 'true'].include?(params['notemplate']) + template = params['vcenter_template'] != "" ? params['vcenter_template'].to_i : nil tag ="tag=#{params['tag']}" if params['tag'] && !params['tag'].empty? rc = export({ @@ -179,7 +180,8 @@ module OpenNebulaJSON :name => name, :vmtemplate_name => vmtemplate_name, :notemplate => notemplate, - :url_args => tag + :url_args => tag, + :template => template }) if OpenNebula.is_error?(rc) diff --git a/src/sunstone/public/app/tabs/marketplaceapps-tab/form-panels/export.js b/src/sunstone/public/app/tabs/marketplaceapps-tab/form-panels/export.js index 277b7f1944..d29f845b1c 100644 --- a/src/sunstone/public/app/tabs/marketplaceapps-tab/form-panels/export.js +++ b/src/sunstone/public/app/tabs/marketplaceapps-tab/form-panels/export.js @@ -24,8 +24,10 @@ define(function(require) { var Locale = require("utils/locale"); var Tips = require("utils/tips"); var DataStoresTable = require("tabs/datastores-tab/datatable"); + var TemplatesTable = require("tabs/templates-tab/datatable"); var DockerTagsTable = require("./docker-tags"); var DataStore = require("opennebula/datastore"); + var Template = require("opennebula/template"); /* TEMPLATES @@ -59,6 +61,18 @@ define(function(require) { return r; } + function getTemplates(formPanelId){ + var r = null; + if(formPanelId){ + r = new TemplatesTable( + formPanelId + "templatesTable", { + "select": true + } + ); + } + return r; + } + function _getDockerTagsTable(formPanelId, resourceId){ return (formPanelId) ? new DockerTagsTable( @@ -79,6 +93,7 @@ define(function(require) { }; this.datastoresTable = getDataStore(FORM_PANEL_ID); + this.vCenterTemplatesTable = getTemplates(FORM_PANEL_ID); BaseFormPanel.call(this); } @@ -102,7 +117,8 @@ define(function(require) { function _htmlWizard() { return TemplateWizardHTML({ "formPanelId": this.formPanelId, - "datastoresTableHTML": this.datastoresTable.dataTableHTML + "datastoresTableHTML": this.datastoresTable.dataTableHTML, + "vCenterTemplatesTableHTML": this.vCenterTemplatesTable.dataTableHTML }); } @@ -121,8 +137,10 @@ define(function(require) { } this.datastoresTable.resetResourceTableSelect(); + this.vCenterTemplatesTable.resetResourceTableSelect(); } $("#NAME", context).focus(); + $("#placeDatatablevCenterTemplate", context).hide(); return false; } @@ -131,6 +149,7 @@ define(function(require) { Tips.setup(context); this.datastoresTable.initialize(); this.datastoresTable.idInput().attr("required", ""); + this.vCenterTemplatesTable.initialize(); $("input#NAME", context).on("input", function(){ var vmname = $("#VMNAME", context).val(); if (vmname == "" || vmname == $(this).data("prev")){ @@ -138,6 +157,23 @@ define(function(require) { } $(this).data("prev", $(this).val()); }); + + var that = this; + var section = $("#" + that.datastoresTable.dataTableId + "Container"); + $("#" + that.datastoresTable.dataTableId + " tbody", section).delegate("tr", "click", function(e) { + var wasChecked = $("td.markrow", this).hasClass("markrow"); + console.log({"dsTable": that.datastoresTable}) + var aData = that.datastoresTable.dataTable.fnGetData(this); + var check = aData != undefined && !wasChecked; + + if (aData[9] == "vcenter"){ + $("#placeDatatablevCenterTemplate", context).show(); + } + else{ + $("#placeDatatablevCenterTemplate", context).hide(); + } + return true; + }); } function _setResourceId(context, appJson, type) { @@ -150,7 +186,12 @@ define(function(require) { ? ds.TYPE == DataStore.TYPES.FILE_DS : ds.TYPE == DataStore.TYPES.IMAGE_DS; } - this.datastoresTable.updateFn() + this.datastoresTable.updateFn(); + + this.vCenterTemplatesTable.selectOptions.filter_fn = function(template) { + return template.TEMPLATE.HYPERVISOR === "vcenter"; + } + this.vCenterTemplatesTable.updateFn() $("input#NAME", context).val(appJson.MARKETPLACEAPP.NAME).trigger("input"); @@ -182,7 +223,8 @@ define(function(require) { "name" : $("#NAME", context).val(), "vmtemplate_name" : $("#VMNAME", context).val(), "dsid" : this.datastoresTable.idInput().val(), - "notemplate" : $("#NOTEMPLATE", context).is(':checked') + "notemplate" : $("#NOTEMPLATE", context).is(':checked'), + "vcenter_template" : this.vCenterTemplatesTable.idInput().val() }; if (this.dockertagsTable) { @@ -193,4 +235,3 @@ define(function(require) { return false; } }); - diff --git a/src/sunstone/public/app/tabs/marketplaceapps-tab/form-panels/export/wizard.hbs b/src/sunstone/public/app/tabs/marketplaceapps-tab/form-panels/export/wizard.hbs index ebcec45971..43478a3468 100644 --- a/src/sunstone/public/app/tabs/marketplaceapps-tab/form-panels/export/wizard.hbs +++ b/src/sunstone/public/app/tabs/marketplaceapps-tab/form-panels/export/wizard.hbs @@ -48,6 +48,10 @@ {{{ datastoresTableHTML }}} +