mirror of
https://github.com/OpenNebula/one.git
synced 2025-02-05 21:57:24 +03:00
Feature #3028: Add pci devices to sunstone
This commit is contained in:
parent
4019971caa
commit
a34b2e27ee
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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 = [
|
||||
|
92
src/sunstone/public/app/tabs/hosts-tab/panels/pci.js
Normal file
92
src/sunstone/public/app/tabs/hosts-tab/panels/pci.js
Normal file
@ -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;
|
||||
}
|
||||
});
|
28
src/sunstone/public/app/tabs/hosts-tab/panels/pci/html.hbs
Normal file
28
src/sunstone/public/app/tabs/hosts-tab/panels/pci/html.hbs
Normal file
@ -0,0 +1,28 @@
|
||||
<div class="row">
|
||||
<div class="large-12 columns">
|
||||
<table id="datatable_pci_{{panelId}}" class="dataTable extended_table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{{tr "VM"}}</th>
|
||||
<th>{{tr "PCI Address"}}</th>
|
||||
<th>{{tr "Type"}}</th>
|
||||
<th>{{tr "Class"}}</th>
|
||||
<th>{{tr "Name"}}</th>
|
||||
<th>{{tr "Vendor"}}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{#each element.HOST_SHARE.PCI_DEVICES.PCI}}
|
||||
<tr>
|
||||
<td>{{VMID}}</td>
|
||||
<td>{{SHORT_ADDRESS}}</td>
|
||||
<td>{{TYPE}}</td>
|
||||
<td>{{CLASS_NAME}}</td>
|
||||
<td>{{DEVICE_NAME}}</td>
|
||||
<td>{{VENDOR_NAME}}</td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
@ -0,0 +1,3 @@
|
||||
define(function(require) {
|
||||
return 'host_pci_tab';
|
||||
})
|
@ -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);
|
||||
}
|
||||
});
|
||||
|
@ -31,6 +31,34 @@
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset class="hypervisor only_kvm">
|
||||
<legend>{{tr "PCI Devices"}}</legend>
|
||||
<div class="row">
|
||||
<div class="large-12 columns">
|
||||
<table class="dataTable pci_devices">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{{tr "Vendor"}}</th>
|
||||
<th>{{tr "Device"}}</th>
|
||||
<th>{{tr "Class"}}</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td colspan="4">
|
||||
<a type="button" class="add_pci button small large-12 secondary radius">
|
||||
<i class="fa fa-plus"></i> {{tr "Add PCI device"}}
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend>{{tr "Custom Tags"}}</legend>
|
||||
{{{customTagsTableHTML}}}
|
||||
|
@ -0,0 +1,14 @@
|
||||
<tr>
|
||||
<td>
|
||||
<input type="text" wizard_field="VENDOR" value="{{vendor}}">
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" wizard_field="DEVICE" value="{{device}}">
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" wizard_field="CLASS" value="{{class}}">
|
||||
</td>
|
||||
<td>
|
||||
<a href="#"><i class="fa fa-times-circle remove-tab"></i></a>
|
||||
</td>
|
||||
</tr>
|
Loading…
x
Reference in New Issue
Block a user