diff --git a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/general.js b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/general.js index 3c962776e55..7231b080acb 100644 --- a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/general.js +++ b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/general.js @@ -27,6 +27,8 @@ define(function(require) { var UserInputs = require('utils/user-inputs'); var UniqueId = require('utils/unique-id'); var OpenNebula = require('opennebula'); + var UsersTable = require("tabs/users-tab/datatable"); + var GroupTable = require("tabs/groups-tab/datatable"); /* TEMPLATES @@ -53,9 +55,19 @@ define(function(require) { this.icon = 'fa-laptop'; this.title = Locale.tr("General"); - if(opts.listener != undefined){ + if (opts.listener != undefined){ this.listener = opts.listener; } + + var opts = { + "select": true, + "selectOptions": { + "multiple_choice": false + } + }; + + this.usersTable = new UsersTable("UsersTable" + UniqueId.id(), opts); + this.groupTable = new GroupTable("GroupTable" + UniqueId.id(), opts); } WizardTab.prototype.constructor = WizardTab; @@ -74,7 +86,9 @@ define(function(require) { function _html() { return TemplateHTML({ 'capacityCreateHTML': CapacityCreate.html(), - 'logos': Config.vmLogos + 'logos': Config.vmLogos, + 'usersDatatable': this.usersTable.dataTableHTML, + 'groupDatatable': this.groupTable.dataTableHTML }); } @@ -121,6 +135,11 @@ define(function(require) { function _setup(context) { var that = this; + this.usersTable.initialize(); + this.usersTable.refreshResourceTableSelect(); + this.groupTable.initialize(); + this.groupTable.refreshResourceTableSelect(); + $(document).on('click', "[href='#" + this.wizardTabId + "']", function(){ //context.foundation('slider', 'reflow'); }); @@ -281,6 +300,16 @@ define(function(require) { if (templateJSON['DISK_COST']) { templateJSON['DISK_COST'] = templateJSON['DISK_COST']/1024; } + + var as_uid = this.usersTable.retrieveResourceTableSelect(); + if (as_uid){ + templateJSON["AS_UID"] = as_uid; + } + + var as_gid = this.groupTable.retrieveResourceTableSelect(); + if (as_gid){ + templateJSON["AS_GID"] = as_gid; + } return templateJSON; } @@ -350,7 +379,6 @@ define(function(require) { } } - if (templateJSON["VCENTER_RESOURCE_POOL"]) { $('.modify_rp', context).val('fixed'); WizardFields.fillInput($('.initial_rp', context), templateJSON["VCENTER_RESOURCE_POOL"]); @@ -358,23 +386,41 @@ define(function(require) { delete templateJSON["VCENTER_RESOURCE_POOL"]; } - if(templateJSON["VCENTER_TEMPLATE_REF"]){ + if (templateJSON["VCENTER_TEMPLATE_REF"]){ WizardFields.fillInput($("#vcenter_template_ref", context), templateJSON["VCENTER_TEMPLATE_REF"]); delete templateJSON["VCENTER_TEMPLATE_REF"]; } - if(templateJSON["VCENTER_CCR_REF"]){ + if (templateJSON["VCENTER_CCR_REF"]){ WizardFields.fillInput($("#vcenter_ccr_ref", context), templateJSON["VCENTER_CCR_REF"]); delete templateJSON["VCENTER_CCR_REF"]; } - if(templateJSON["VCENTER_INSTANCE_ID"]){ + if (templateJSON["VCENTER_INSTANCE_ID"]){ WizardFields.fillInput($("#vcenter_instance_id", context), templateJSON["VCENTER_INSTANCE_ID"]); delete templateJSON["VCENTER_INSTANCE_ID"]; } CapacityCreate.fill($("div.capacityCreate", context), templateJSON); + if (templateJSON["AS_UID"]){ + var asuidJSON = templateJSON["AS_UID"]; + var selectedResources = { + ids : asuidJSON + }; + this.usersTable.selectResourceTableSelect(selectedResources); + delete templateJSON["AS_UID"]; + } + + if (templateJSON["AS_GID"]){ + var asgidJSON = templateJSON["AS_GID"]; + var selectedResources = { + ids : asgidJSON + }; + this.groupTable.selectResourceTableSelect(selectedResources); + delete templateJSON["AS_GID"]; + } + WizardFields.fill(context, templateJSON); } }); diff --git a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/general/html.hbs b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/general/html.hbs index 55cddbeaec0..054ef6313e3 100644 --- a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/general/html.hbs +++ b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/general/html.hbs @@ -190,4 +190,30 @@ {{{tip (tr "Virtual Routers create Virtual Machines from a source Template. This checkbox makes this template available to be selected in the New Virtual Router wizard")}}} +

+{{#advancedSection (tr "User / Group") }} +{{#isFeatureEnabled "show_as_uid_instantiate"}} +
+
+
+ + {{tr "Instantiate as a different user"}} + +
{{{usersDatatable}}}
+
+
+{{/isFeatureEnabled}} +{{#isFeatureEnabled "show_as_gid_instantiate"}} +
+
+
+ + {{tr "Instantiate as a different group"}} + +
{{{groupDatatable}}}
+
+
+
+{{/isFeatureEnabled}} +{{/advancedSection}} diff --git a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/io.js b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/io.js index 40cb38fc90d..f4234518ca5 100644 --- a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/io.js +++ b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/io.js @@ -24,6 +24,7 @@ define(function(require) { var Tips = require('utils/tips'); var WizardFields = require('utils/wizard-fields'); var UniqueId = require('utils/unique-id'); + var CreateUtils = require('./utils'); /* TEMPLATES @@ -115,6 +116,15 @@ define(function(require) { context.on('click', "i.remove-tab", function() { $(this).closest("tr").remove() }); + + context.off("click", ".add_pci"); + context.on("click", ".add_pci", function(){ + var tr = $(CreateUtils.pciRowHTML()).appendTo( $(".pci_devices tbody", context) ); + + CreateUtils.fillPCIRow({tr: tr, remove: true}); + }); + + CreateUtils.setupPCIRows($(".pci_devices", context)); } function _retrieve(context) { @@ -139,6 +149,18 @@ define(function(require) { if (!$.isEmptyObject(inputsJSON)) { templateJSON['INPUT'] = inputsJSON; }; + $('.pci_devices tbody tr', context).each(function(i,row){ + var pci = WizardFields.retrieve(row); + + if (!$.isEmptyObject(pci)){ + if (templateJSON['PCI'] == undefined){ + templateJSON['PCI'] = []; + } + + templateJSON['PCI'].push(pci); + } + }); + return templateJSON; } @@ -191,7 +213,28 @@ define(function(require) { cell3.innerHTML = ""; }); - delete templateJSON['INPUT'] + delete templateJSON['INPUT']; } + + $(".pci_devices i.remove-tab", context).trigger("click"); + + var pcis = templateJSON['PCI']; + + if (pcis == undefined){ + pcis = []; + } + + if (!$.isArray(pcis)){ // If only 1 convert to array + pcis = [pcis]; + } + + $.each(pcis, function(i, pci){ + $(".add_pci", context).trigger("click"); + var tr = $('.pci_devices tbody tr', context).last(); + + WizardFields.fill(tr, pci); + }); + + delete templateJSON.PCI; } }); diff --git a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/io/html.hbs b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/io/html.hbs index 1439d610376..2ef6b490643 100644 --- a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/io/html.hbs +++ b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/io/html.hbs @@ -111,4 +111,42 @@ +
+
+ {{tr "PCI Devices"}} +
+
+ + {{tr "PCI passthrough of network devices is configured per NIC, in the \"Network\" tab. Do not add network devices here"}} + +
+
+
+
+ + + + + + + + + + + + + + + + + +
{{tr "Device name"}}{{tr "Vendor"}}{{tr "Device"}}{{tr "Class"}}
+ + + +
+
+
+
+
diff --git a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/other.js b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/other.js index 5bc349b62f4..0f7bf5d3e58 100644 --- a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/other.js +++ b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/other.js @@ -27,7 +27,6 @@ define(function(require) { var CustomTagsTable = require('utils/custom-tags-table'); var OpenNebulaHost = require('opennebula/host'); var UniqueId = require('utils/unique-id'); - var CreateUtils = require('./utils'); /* TEMPLATES @@ -51,8 +50,8 @@ define(function(require) { } this.wizardTabId = WIZARD_TAB_ID + UniqueId.id(); - this.icon = 'fa-ellipsis-h'; - this.title = Locale.tr("Other"); + this.icon = 'fa-tag'; + this.title = Locale.tr("Tags"); } WizardTab.prototype.constructor = WizardTab; @@ -79,21 +78,12 @@ define(function(require) { function _setup(context) { CustomTagsTable.setup(context); - - context.off("click", ".add_pci"); - context.on("click", ".add_pci", function(){ - var tr = $(CreateUtils.pciRowHTML()).appendTo( $(".pci_devices tbody", context) ); - - CreateUtils.fillPCIRow({tr: tr, remove: true}); - }); - - CreateUtils.setupPCIRows($(".pci_devices", context)); } function _retrieve(context) { var templateJSON = CustomTagsTable.retrieve(context); - var rawJSON = {} + var rawJSON = {}; var rawData = WizardFields.retrieveInput($('.raw_data', context)); if (rawData != "") { rawJSON['DATA'] = rawData; @@ -106,18 +96,6 @@ define(function(require) { if (!$.isEmptyObject(rawJSON)) { templateJSON['RAW'] = rawJSON; }; - $('.pci_devices tbody tr', context).each(function(i,row){ - var pci = WizardFields.retrieve(row); - - if (!$.isEmptyObject(pci)){ - if (templateJSON['PCI'] == undefined){ - templateJSON['PCI'] = []; - } - - templateJSON['PCI'].push(pci); - } - }); - return templateJSON; } @@ -128,30 +106,9 @@ define(function(require) { $('.raw_type', context).change(); WizardFields.fillInput($('.raw_data', context), rawJSON['DATA']); - delete templateJSON.RAW + delete templateJSON.RAW; } - $(".pci_devices i.remove-tab", context).trigger("click"); - - var pcis = templateJSON['PCI']; - - if (pcis == undefined){ - pcis = []; - } - - if (!$.isArray(pcis)){ // If only 1 convert to array - pcis = [pcis]; - } - - $.each(pcis, function(i, pci){ - $(".add_pci", context).trigger("click"); - var tr = $('.pci_devices tbody tr', context).last(); - - WizardFields.fill(tr, pci); - }); - - delete templateJSON.PCI; - CustomTagsTable.fill(context, templateJSON); } }); diff --git a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/other/html.hbs b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/other/html.hbs index bd2485892bb..cb01de7b9d4 100644 --- a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/other/html.hbs +++ b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/other/html.hbs @@ -36,42 +36,6 @@ -
- {{tr "PCI Devices"}} -
-
- - {{tr "PCI passthrough of network devices is configured per NIC, in the \"Network\" tab. Do not add network devices here"}} - -
-
-
-
- - - - - - - - - - - - - - - - - -
{{tr "Device name"}}{{tr "Vendor"}}{{tr "Device"}}{{tr "Class"}}
- - - -
-
-
-
{{tr "Custom Tags"}} {{{customTagsTableHTML}}} diff --git a/src/sunstone/public/app/tabs/templates-tab/form-panels/instantiate/templateRow.hbs b/src/sunstone/public/app/tabs/templates-tab/form-panels/instantiate/templateRow.hbs index c0b9a0187ae..974802b6b55 100644 --- a/src/sunstone/public/app/tabs/templates-tab/form-panels/instantiate/templateRow.hbs +++ b/src/sunstone/public/app/tabs/templates-tab/form-panels/instantiate/templateRow.hbs @@ -48,6 +48,7 @@
+ {{#advancedSection (tr "Network") }} {{#isFeatureEnabled "show_vnet_instantiate"}}
@@ -56,7 +57,8 @@
{{/isFeatureEnabled}} - {{#advancedSection (tr "Advanced options") }} + {{/advancedSection}} + {{#advancedSection (tr "User / Group") }} {{#isFeatureEnabled "show_as_uid_instantiate"}}
@@ -81,6 +83,8 @@
{{/isFeatureEnabled}} + {{/advancedSection}} + {{#advancedSection (tr "Host") }} {{#isFeatureEnabled "show_host_instantiate"}}
@@ -102,6 +106,8 @@
{{/isFeatureEnabled}} + {{/advancedSection}} + {{#advancedSection (tr "Datastore") }} {{#isFeatureEnabled "show_ds_instantiate"}}
@@ -123,11 +129,13 @@
{{/isFeatureEnabled}} + {{/advancedSection}} + {{#advancedSection (tr "Actions") }}
- {{tr "Actions"}} + {{tr "Schedule Actions for VM"}} @@ -143,12 +151,14 @@ + {{/advancedSection}} + {{#advancedSection (tr "VM Group") }} {{#isFeatureEnabled "show_vmgroup_instantiate"}}
\ No newline at end of file