mirror of
https://github.com/OpenNebula/one.git
synced 2026-11-20 11:52:37 +09:00
feature #3748: Add host info panel
This commit is contained in:
1 parent
e5adeebbfb
commit
3ce1cbcbea
4 files changed
+193
-4
No files matched your search
@@ -12,10 +12,10 @@ define(function(require) {
|
||||
// require('./hosts-tab/dialogs/clone')
|
||||
//];
|
||||
|
||||
//var _panels = [
|
||||
// require('./hosts-tab/panels/info'),
|
||||
var _panels = [
|
||||
require('./hosts-tab/panels/info'),
|
||||
// require('./hosts-tab/panels/vms')
|
||||
//];
|
||||
];
|
||||
|
||||
var Tab = {
|
||||
tabId: TAB_ID,
|
||||
@@ -33,7 +33,7 @@ define(function(require) {
|
||||
buttons: Buttons,
|
||||
actions: Actions,
|
||||
dataTable: new Table(DATATABLE_ID, {actions: true, info: true}),
|
||||
//panels: _panels,
|
||||
panels: _panels,
|
||||
//dialogs: _dialogs
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
define(function(require) {
|
||||
/*
|
||||
DEPENDENCIES
|
||||
*/
|
||||
|
||||
var Locale = require('utils/locale');
|
||||
var Humanize = require('utils/humanize');
|
||||
var RenameTr = require('utils/panel/rename-tr');
|
||||
var TemplateTable = require('utils/panel/template-table');
|
||||
var PermissionsTable = require('utils/panel/permissions-table');
|
||||
var ClusterTr = require('utils/panel/cluster-tr');
|
||||
var OpenNebulaHost = require('opennebula/host');
|
||||
var CPUBars = require('../utils/cpu-bars');
|
||||
var MemoryBars = require('../utils/memory-bars');
|
||||
|
||||
/*
|
||||
TEMPLATES
|
||||
*/
|
||||
|
||||
var TemplateInfo = require('hbs!./info/html');
|
||||
|
||||
/*
|
||||
CONSTANTS
|
||||
*/
|
||||
|
||||
var TAB_ID = require('../tabId');
|
||||
var PANEL_ID = require('./info/panelId');
|
||||
var RESOURCE = "Host"
|
||||
|
||||
/*
|
||||
CONSTRUCTOR
|
||||
*/
|
||||
|
||||
function Panel(info) {
|
||||
var that = this;
|
||||
that.title = Locale.tr("Info");
|
||||
that.icon = "fa-info-circle";
|
||||
|
||||
that.element = info[RESOURCE.toUpperCase()];
|
||||
|
||||
// Check if any of the existing VMs in the Host define the IMPORT_TEMPLATE
|
||||
// attribute to be imported into OpenNebula.
|
||||
that.canImportWilds = false;
|
||||
if (that.element.TEMPLATE.VM) {
|
||||
var vms = that.element.TEMPLATE.VM;
|
||||
if (!$.isArray(vms)) { // If only 1 VM convert to array
|
||||
vms = [vms];
|
||||
}
|
||||
$.each(vms, function() {
|
||||
if (this.IMPORT_TEMPLATE) {
|
||||
that.canImportWilds = true;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Hide information of the Wild VMs of the Host and the ESX Hosts
|
||||
// in the template table. Unshow values are stored in the unshownTemplate
|
||||
// object to be used when the host info is updated.
|
||||
that.unshownTemplate = {};
|
||||
that.strippedTemplate = {};
|
||||
var unshownKeys = ['HOST', 'VM', 'WILDS'];
|
||||
$.each(that.element.TEMPLATE, function(key, value) {
|
||||
if ($.inArray(key, unshownKeys) > -1) {
|
||||
that.unshownTemplate[key] = value;
|
||||
} else {
|
||||
that.strippedTemplate[key] = value;
|
||||
}
|
||||
});
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
Panel.PANEL_ID = PANEL_ID;
|
||||
Panel.prototype.html = _html;
|
||||
Panel.prototype.setup = _setup;
|
||||
|
||||
return Panel;
|
||||
|
||||
/*
|
||||
FUNCTION DEFINITIONS
|
||||
*/
|
||||
|
||||
function _html() {
|
||||
var templateTableHTML = TemplateTable.html(
|
||||
this.strippedTemplate,
|
||||
RESOURCE,
|
||||
Locale.tr("Attributes"));
|
||||
|
||||
var renameTrHTML = RenameTr.html(RESOURCE, this.element.NAME);
|
||||
var clusterTrHTML = ClusterTr.html(this.element.CLUSTER);
|
||||
var permissionsTableHTML = PermissionsTable.html(TAB_ID, RESOURCE, this.element);
|
||||
var cpuBars = CPUBars.html(this.element);
|
||||
var memoryBars = MemoryBars.html(this.element);
|
||||
var stateStr = Locale.tr(OpenNebulaHost.stateStr(this.element.STATE));
|
||||
|
||||
return TemplateInfo({
|
||||
'element': this.element,
|
||||
'renameTrHTML': renameTrHTML,
|
||||
'clusterTrHTML': clusterTrHTML,
|
||||
'templateTableHTML': templateTableHTML,
|
||||
'permissionsTableHTML': permissionsTableHTML,
|
||||
'cpuBars': cpuBars,
|
||||
'memoryBars': memoryBars,
|
||||
'stateStr': stateStr,
|
||||
});
|
||||
}
|
||||
|
||||
function _setup(context) {
|
||||
RenameTr.setup(RESOURCE, this.element.ID, context);
|
||||
ClusterTr.setup(RESOURCE, this.element.ID, this.element.CLUSTER_ID, context);
|
||||
TemplateTable.setup(this.strippedTemplate, RESOURCE, this.element.ID, context, this.unshownTemplate);
|
||||
PermissionsTable.setup(TAB_ID, RESOURCE, this.element, context);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,70 @@
|
||||
<div class="row">
|
||||
<div class="large-6 columns">
|
||||
<table class="dataTable extended_table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="3">{{tr "Information"}}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="key_td">{{tr "ID"}}</td>
|
||||
<td class="value_td" colspan="2">{{element.ID}}</td>
|
||||
</tr>
|
||||
{{{renameTrHTML}}}
|
||||
{{{clusterTrHTML}}}
|
||||
<tr>
|
||||
<td class="key_td">{{tr "State"}}</td>
|
||||
<td class="value_td">{{stateStr}}</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="key_td">{{tr "IM MAD"}}</td>
|
||||
<td class="value_td">{{element.IM_MAD}}</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="key_td">{{tr "VM MAD"}}</td>
|
||||
<td class="value_td">{{element.VM_MAD}}</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="key_td">{{tr "VN MAD"}}</td>
|
||||
<td class="value_td">{{element.VN_MAD}}</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="large-6 columns">
|
||||
<table class="dataTable extended_table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="3">{{tr "Capacity"}}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="key_td">{{tr "Allocated Memory"}}</td>
|
||||
<td class="value_td" colspan="2" style="width:50%;">{{{memoryBars.allocated}}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="key_td">{{tr "Allocated CPU"}}</td>
|
||||
<td class="value_td" colspan="2" style="width:50%;">{{{cpuBars.allocated}}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="key_td">{{tr "Real Memory"}}</td>
|
||||
<td class="value_td" colspan="2" style="width:50%;">{{{memoryBars.real}}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="key_td">{{tr "Real CPU"}}</td>
|
||||
<td class="value_td" colspan="2" style="width:50%;">{{{cpuBars.real}}}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
{{{datastoreCapacityTableHTML}}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="large-9 columns">{{{templateTableHTML}}}</div>
|
||||
</div>
|
||||
@@ -0,0 +1,3 @@
|
||||
define(function(require) {
|
||||
return 'host_info_tab';
|
||||
})
|
||||
Reference in new issue
Block a user