diff --git a/src/sunstone/etc/sunstone-views/admin.yaml b/src/sunstone/etc/sunstone-views/admin.yaml index 1723e2a9ae..a9e0541373 100644 --- a/src/sunstone/etc/sunstone-views/admin.yaml +++ b/src/sunstone/etc/sunstone-views/admin.yaml @@ -320,6 +320,7 @@ tabs: host_vms_tab: true host_wilds_tab: true host_esx_tab: true + host_pci_tab: true table_columns: - 0 # Checkbox - 1 # ID diff --git a/src/sunstone/etc/sunstone-views/admin_vcenter.yaml b/src/sunstone/etc/sunstone-views/admin_vcenter.yaml index 0bea2fb07d..3586c21e0e 100644 --- a/src/sunstone/etc/sunstone-views/admin_vcenter.yaml +++ b/src/sunstone/etc/sunstone-views/admin_vcenter.yaml @@ -320,6 +320,7 @@ tabs: host_vms_tab: true host_wilds_tab: true host_esx_tab: true + host_pci_tab: true table_columns: - 0 # Checkbox - 1 # ID diff --git a/src/sunstone/etc/sunstone-views/user.yaml b/src/sunstone/etc/sunstone-views/user.yaml index d12b192d12..af022fb4ce 100644 --- a/src/sunstone/etc/sunstone-views/user.yaml +++ b/src/sunstone/etc/sunstone-views/user.yaml @@ -321,6 +321,7 @@ tabs: host_vms_tab: true host_wilds_tab: true host_esx_tab: true + host_pci_tab: true table_columns: - 0 # Checkbox - 1 # ID diff --git a/src/sunstone/public/app/tabs/hosts-tab.js b/src/sunstone/public/app/tabs/hosts-tab.js index 252f6aefbf..ce56413b61 100644 --- a/src/sunstone/public/app/tabs/hosts-tab.js +++ b/src/sunstone/public/app/tabs/hosts-tab.js @@ -17,7 +17,8 @@ define(function(require) { require('./hosts-tab/panels/monitor'), require('./hosts-tab/panels/vms'), require('./hosts-tab/panels/wilds'), - require('./hosts-tab/panels/esx') + require('./hosts-tab/panels/esx'), + require('./hosts-tab/panels/pci') ]; var _formPanels = [ diff --git a/src/sunstone/public/app/tabs/hosts-tab/panels/pci.js b/src/sunstone/public/app/tabs/hosts-tab/panels/pci.js new file mode 100644 index 0000000000..8a7d07b55d --- /dev/null +++ b/src/sunstone/public/app/tabs/hosts-tab/panels/pci.js @@ -0,0 +1,92 @@ +define(function(require) { + /* + DEPENDENCIES + */ + + var Locale = require('utils/locale'); + var DomDataTable = require('utils/dom-datatable'); + + /* + TEMPLATES + */ + + var TemplateHTML = require('hbs!./pci/html'); + + /* + CONSTANTS + */ + + var TAB_ID = require('../tabId'); + var PANEL_ID = require('./pci/panelId'); + var RESOURCE = "Host" + var XML_ROOT = "HOST" + + /* + CONSTRUCTOR + */ + + function Panel(info) { + this.title = Locale.tr("PCI"); + this.icon = "fa-list-ul"; + + this.element = info[XML_ROOT]; + + this.panelId = PANEL_ID; + + // Do not create an instance of this panel if no pci devices are found + if (this.element.HOST_SHARE.PCI_DEVICES.PCI == undefined) { + throw "Panel not available for this element"; + } + + return this; + } + + Panel.PANEL_ID = PANEL_ID; + Panel.prototype.html = _html; + Panel.prototype.setup = _setup; + + return Panel; + + /* + FUNCTION DEFINITIONS + */ + + function _html() { + if(this.element.HOST_SHARE && + this.element.HOST_SHARE.PCI_DEVICES && + this.element.HOST_SHARE.PCI_DEVICES.PCI){ + + $.each(this.element.HOST_SHARE.PCI_DEVICES.PCI, function(){ + if(this.VMID == "-1"){ + this.VMID = ""; + } + }); + } + + return TemplateHTML({ + 'element': this.element, + 'panelId': this.panelId + }); + } + + function _setup(context) { + this.pciDataTable = new DomDataTable( + 'datatable_pci_'+this.panelId, + { + actions: false, + info: false, + dataTableOptions: { + "bAutoWidth": false, + "bSortClasses" : false, + "bDeferRender": true, + "ordering": false, + "aoColumnDefs": [ + ] + } + }); + + this.pciDataTable.initialize(); + + return false; + } +}); diff --git a/src/sunstone/public/app/tabs/hosts-tab/panels/pci/html.hbs b/src/sunstone/public/app/tabs/hosts-tab/panels/pci/html.hbs new file mode 100644 index 0000000000..a2d4ecc116 --- /dev/null +++ b/src/sunstone/public/app/tabs/hosts-tab/panels/pci/html.hbs @@ -0,0 +1,28 @@ +
+
+ + + + + + + + + + + + + {{#each element.HOST_SHARE.PCI_DEVICES.PCI}} + + + + + + + + + {{/each}} + +
{{tr "VM"}}{{tr "PCI Address"}}{{tr "Type"}}{{tr "Class"}}{{tr "Name"}}{{tr "Vendor"}}
{{VMID}}{{SHORT_ADDRESS}}{{TYPE}}{{CLASS_NAME}}{{DEVICE_NAME}}{{VENDOR_NAME}}
+
+
\ No newline at end of file diff --git a/src/sunstone/public/app/tabs/hosts-tab/panels/pci/panelId.js b/src/sunstone/public/app/tabs/hosts-tab/panels/pci/panelId.js new file mode 100644 index 0000000000..d552a6b2db --- /dev/null +++ b/src/sunstone/public/app/tabs/hosts-tab/panels/pci/panelId.js @@ -0,0 +1,3 @@ +define(function(require) { + return 'host_pci_tab'; +}) 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 cd142c89a7..29fdb925c8 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 @@ -15,6 +15,7 @@ define(function(require) { */ var TemplateHTML = require('hbs!./other/html'); + var RowTemplateHTML = require('hbs!./other/pciRow'); /* CONSTANTS @@ -71,6 +72,18 @@ define(function(require) { $("#data_vmx_div", context).hide(); } }); + + context.off("click", ".add_pci"); + context.on("click", ".add_pci", function(){ + $(".pci_devices tbody", context).append(RowTemplateHTML()); + }); + + $(".add_pci", context).trigger("click"); + + context.on("click", ".pci_devices i.remove-tab", function(){ + var tr = $(this).closest('tr'); + tr.remove(); + }); } function _retrieve(context) { @@ -86,6 +99,18 @@ 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; } @@ -100,6 +125,15 @@ define(function(require) { delete templateJSON.RAW } + $(".pci_devices i.remove-tab", context).trigger("click"); + + $.each(templateJSON['PCI'], function(i, pci){ + var tr = $(RowTemplateHTML()).appendTo( $(".pci_devices tbody", context) ); + 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 3015ced0af..35d6cdfd59 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 @@ -31,6 +31,34 @@ +
+ {{tr "PCI Devices"}} +
+
+ + + + + + + + + + + + + + + + +
{{tr "Vendor"}}{{tr "Device"}}{{tr "Class"}}
+ + {{tr "Add PCI device"}} + +
+
+
+
{{tr "Custom Tags"}} {{{customTagsTableHTML}}} diff --git a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/other/pciRow.hbs b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/other/pciRow.hbs new file mode 100644 index 0000000000..62277824cd --- /dev/null +++ b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/other/pciRow.hbs @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file