mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
* F #4913 changed code for disable or enable icons * F #4913 Added new section for vcenter information in datastore * F #4913 Added new section for vcenter information in host-tab * F #4913 Added new section for vcenter information in vms-tab * F #4913 Added new section for vcenter information in vnets-tab
This commit is contained in:
parent
d642526d17
commit
65b333b1b2
@ -67,9 +67,18 @@ define(function(require) {
|
||||
|
||||
function _html() {
|
||||
var renameTrHTML = RenameTr.html(TAB_ID, RESOURCE, this.element.NAME);
|
||||
var templateTableHTML = TemplateTable.html(
|
||||
this.element.TEMPLATE, RESOURCE,
|
||||
Locale.tr("Attributes"));
|
||||
var strippedTemplate = {};
|
||||
var strippedTemplateVcenter = {};
|
||||
$.each(this.element.TEMPLATE, function(key, value) {
|
||||
if (key.match(/^VCENTER_*/)){
|
||||
strippedTemplateVcenter[key] = value;
|
||||
}
|
||||
else {
|
||||
strippedTemplate[key] = value;
|
||||
}
|
||||
});
|
||||
var templateTableHTML = TemplateTable.html(strippedTemplate, RESOURCE, Locale.tr("Attributes"), true);
|
||||
var templateTableVcenterHTML = TemplateTable.html(strippedTemplateVcenter, RESOURCE, Locale.tr("Vcenter information"), false);
|
||||
var permissionsTableHTML = PermissionsTable.html(TAB_ID, RESOURCE, this.element);
|
||||
var capacityBar = DatastoreCapacityBar.html(this.element);
|
||||
var stateStr = OpenNebulaDatastore.stateStr(this.element.STATE);
|
||||
@ -84,6 +93,7 @@ define(function(require) {
|
||||
'element': this.element,
|
||||
'renameTrHTML': renameTrHTML,
|
||||
'templateTableHTML': templateTableHTML,
|
||||
'templateTableVcenterHTML': templateTableVcenterHTML,
|
||||
'permissionsTableHTML': permissionsTableHTML,
|
||||
'capacityBar': capacityBar,
|
||||
'stateStr': stateStr,
|
||||
@ -94,7 +104,20 @@ define(function(require) {
|
||||
|
||||
function _setup(context) {
|
||||
RenameTr.setup(TAB_ID, RESOURCE, this.element.ID, context);
|
||||
TemplateTable.setup(this.element.TEMPLATE, RESOURCE, this.element.ID, context);
|
||||
var strippedTemplate = {};
|
||||
var strippedTemplateVcenter = {};
|
||||
$.each(this.element.TEMPLATE, function(key, value) {
|
||||
if (key.match(/^VCENTER_*/)){
|
||||
strippedTemplateVcenter[key] = value;
|
||||
}
|
||||
else {
|
||||
strippedTemplate[key] = value;
|
||||
}
|
||||
});
|
||||
if($.isEmptyObject(strippedTemplateVcenter)){
|
||||
$('.vcenter', context).hide();
|
||||
}
|
||||
TemplateTable.setup(strippedTemplate, RESOURCE, this.element.ID, context);
|
||||
PermissionsTable.setup(TAB_ID, RESOURCE, this.element, context);
|
||||
return false;
|
||||
}
|
||||
|
@ -58,6 +58,9 @@
|
||||
{{{permissionsTableHTML}}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="row vcenter">
|
||||
<div class="large-9 columns">{{{templateTableVcenterHTML}}}</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="large-9 columns">{{{templateTableHTML}}}</div>
|
||||
</div>
|
||||
|
@ -65,12 +65,17 @@ define(function(require) {
|
||||
// in the template table. Unshow values are stored in the unshownTemplate
|
||||
// object to be used when the host info is updated.
|
||||
that.unshownTemplate = {};
|
||||
that.strippedTemplateVcenter = {};
|
||||
that.strippedTemplate = {};
|
||||
var unshownKeys = ['HOST', 'VM', 'WILDS', 'ZOMBIES', 'RESERVED_CPU', 'RESERVED_MEM'];
|
||||
$.each(that.element.TEMPLATE, function(key, value) {
|
||||
if ($.inArray(key, unshownKeys) > -1) {
|
||||
that.unshownTemplate[key] = value;
|
||||
} else {
|
||||
that.unshownTemplate[key] = value;
|
||||
}
|
||||
else if (key.match(/^VCENTER_*/)){
|
||||
that.strippedTemplateVcenter[key] = value;
|
||||
}
|
||||
else {
|
||||
that.strippedTemplate[key] = value;
|
||||
}
|
||||
});
|
||||
@ -92,6 +97,10 @@ define(function(require) {
|
||||
this.strippedTemplate,
|
||||
RESOURCE,
|
||||
Locale.tr("Attributes"));
|
||||
var templateTableVcenterHTML = TemplateTable.html(
|
||||
this.strippedTemplateVcenter,
|
||||
RESOURCE,
|
||||
Locale.tr("Vcenter information"),false);
|
||||
var renameTrHTML = RenameTr.html(TAB_ID, RESOURCE, this.element.NAME);
|
||||
var clusterTrHTML = ClusterTr.html(this.element.CLUSTER);
|
||||
var permissionsTableHTML = PermissionsTable.html(TAB_ID, RESOURCE, this.element);
|
||||
@ -106,6 +115,7 @@ define(function(require) {
|
||||
'renameTrHTML': renameTrHTML,
|
||||
'clusterTrHTML': clusterTrHTML,
|
||||
'templateTableHTML': templateTableHTML,
|
||||
'templateTableVcenterHTML': templateTableVcenterHTML,
|
||||
'permissionsTableHTML': permissionsTableHTML,
|
||||
'cpuBars': cpuBars,
|
||||
'memoryBars': memoryBars,
|
||||
@ -137,6 +147,10 @@ define(function(require) {
|
||||
TemplateTable.setup(this.strippedTemplate, RESOURCE, this.element.ID, context, this.unshownTemplate);
|
||||
PermissionsTable.setup(TAB_ID, RESOURCE, this.element, context);
|
||||
|
||||
if($.isEmptyObject(this.strippedTemplateVcenter)){
|
||||
$('.vcenter', context).hide();
|
||||
}
|
||||
|
||||
//.off and .on prevent multiple clicks events
|
||||
$(document).off('click', '.update_reserved_hosts').on("click", '.update_reserved', function(){
|
||||
var reservedCPU = parseInt(document.getElementById('change_bar_cpu_hosts').value);
|
||||
|
@ -107,6 +107,9 @@
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row vcenter">
|
||||
<div class="large-9 columns">{{{templateTableVcenterHTML}}}</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="large-9 columns">{{{templateTableHTML}}}</div>
|
||||
</div>
|
||||
|
@ -91,17 +91,24 @@ define(function(require) {
|
||||
// Get rid of the unwanted (for show) SCHED_* keys
|
||||
var that = this;
|
||||
var strippedTemplate = {};
|
||||
var strippedTemplateVcenter = {};
|
||||
var unshownValues = {};
|
||||
|
||||
$.each(that.element.USER_TEMPLATE, function(key, value) {
|
||||
if (key.match(/^SCHED_*/) || key == "USER_INPUTS") {
|
||||
unshownValues[key] = value;
|
||||
} else {
|
||||
}
|
||||
else if (key.match(/^VCENTER_*/)){
|
||||
strippedTemplateVcenter[key] = value;
|
||||
}
|
||||
else {
|
||||
strippedTemplate[key] = value;
|
||||
}
|
||||
});
|
||||
|
||||
var templateTableHTML = TemplateTable.html(strippedTemplate, RESOURCE, Locale.tr("Attributes"));
|
||||
var templateTableHTML = TemplateTable.html(strippedTemplate, RESOURCE, Locale.tr("Attributes"), true);
|
||||
var templateTableVcenterHTML = TemplateTable.html(strippedTemplateVcenter, RESOURCE, Locale.tr("Vcenter information"), false);
|
||||
|
||||
|
||||
var monitoring = $.extend({}, this.element.MONITORING);
|
||||
delete monitoring.CPU;
|
||||
@ -127,6 +134,7 @@ define(function(require) {
|
||||
'IP': IP,
|
||||
'resched': resched,
|
||||
'permissionsTableHTML': permissionsTableHTML,
|
||||
'templateTableVcenterHTML': templateTableVcenterHTML,
|
||||
'templateTableHTML': templateTableHTML,
|
||||
'monitoringTableContentHTML': monitoringTableContentHTML,
|
||||
'vrouterHTML': vrouterHTML
|
||||
@ -139,14 +147,22 @@ define(function(require) {
|
||||
// Get rid of the unwanted (for show) SCHED_* keys
|
||||
var that = this;
|
||||
var strippedTemplate = {};
|
||||
var strippedTemplateVcenter = {};
|
||||
var unshownValues = {};
|
||||
$.each(that.element.USER_TEMPLATE, function(key, value) {
|
||||
if (!key.match(/^SCHED_*/)) {
|
||||
strippedTemplate[key] = value;
|
||||
} else {
|
||||
$.each(that.element.USER_TEMPLATE, function(key, value) {
|
||||
if (key.match(/^SCHED_*/) || key == "USER_INPUTS") {
|
||||
unshownValues[key] = value;
|
||||
}
|
||||
})
|
||||
else if (key.match(/^VCENTER_*/)){
|
||||
strippedTemplateVcenter[key] = value;
|
||||
}
|
||||
else {
|
||||
strippedTemplate[key] = value;
|
||||
}
|
||||
});
|
||||
if($.isEmptyObject(strippedTemplateVcenter)){
|
||||
$('.vcenter', context).hide();
|
||||
}
|
||||
|
||||
TemplateTable.setup(strippedTemplate, RESOURCE, this.element.ID, context, unshownValues);
|
||||
}
|
||||
|
@ -81,6 +81,9 @@
|
||||
</div>
|
||||
<div class="large-6 columns">{{{permissionsTableHTML}}}</div>
|
||||
</div>
|
||||
<div class="row vcenter">
|
||||
<div class="large-9 columns">{{{templateTableVcenterHTML}}}</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="large-9 columns">{{{templateTableHTML}}}</div>
|
||||
</div>
|
||||
|
@ -78,14 +78,22 @@ define(function(require) {
|
||||
"OUTBOUND_PEAK_BW",
|
||||
"OUTBOUND_PEAK_KB" ];
|
||||
|
||||
var strippedTemplate = $.extend({}, this.element.TEMPLATE);
|
||||
|
||||
$.each(hiddenKeys, function(i, key){
|
||||
delete strippedTemplate[key];
|
||||
var strippedTemplate = {};
|
||||
var strippedTemplateVcenter = {};
|
||||
$.each(this.element.TEMPLATE, function(key, value) {
|
||||
if (!$.inArray(key, hiddenKeys) > -1) {
|
||||
if (key.match(/^VCENTER_*/)){
|
||||
strippedTemplateVcenter[key] = value;
|
||||
}
|
||||
else {
|
||||
strippedTemplate[key] = value;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var templateTableHTML = TemplateTable.html(strippedTemplate, RESOURCE,
|
||||
Locale.tr("Attributes"));
|
||||
var templateTableVcenterHTML = TemplateTable.html(strippedTemplateVcenter, RESOURCE,
|
||||
Locale.tr("Vcenter information"), false);
|
||||
//====
|
||||
|
||||
// TODO: move to util?
|
||||
@ -114,7 +122,8 @@ define(function(require) {
|
||||
'renameTrHTML': renameTrHTML,
|
||||
'reservationTrHTML': reservationTrHTML,
|
||||
'permissionsTableHTML': permissionsTableHTML,
|
||||
'templateTableHTML': templateTableHTML
|
||||
'templateTableHTML': templateTableHTML,
|
||||
'templateTableVcenterHTML': templateTableVcenterHTML
|
||||
});
|
||||
}
|
||||
|
||||
@ -134,20 +143,25 @@ define(function(require) {
|
||||
"OUTBOUND_PEAK_BW",
|
||||
"OUTBOUND_PEAK_KB" ];
|
||||
|
||||
var strippedTemplate = $.extend({}, this.element.TEMPLATE);
|
||||
|
||||
$.each(hiddenKeys, function(i, key){
|
||||
delete strippedTemplate[key];
|
||||
});
|
||||
|
||||
var hiddenValues = {};
|
||||
|
||||
$.each(hiddenKeys, function(i, key){
|
||||
if (that.element.TEMPLATE[key] != undefined){
|
||||
hiddenValues[key] = that.element.TEMPLATE[key];
|
||||
var strippedTemplate = {};
|
||||
var strippedTemplateVcenter = {};
|
||||
$.each(that.element.TEMPLATE, function(key, value) {
|
||||
if ($.inArray(key, hiddenKeys) > -1) {
|
||||
hiddenValues[key] = value;
|
||||
}
|
||||
if (key.match(/^VCENTER_*/)){
|
||||
strippedTemplateVcenter[key] = value;
|
||||
}
|
||||
else {
|
||||
strippedTemplate[key] = value;
|
||||
}
|
||||
});
|
||||
|
||||
if($.isEmptyObject(strippedTemplateVcenter)){
|
||||
$('.vcenter', context).hide();
|
||||
}
|
||||
|
||||
TemplateTable.setup(strippedTemplate, RESOURCE, this.element.ID, context, hiddenValues);
|
||||
//===
|
||||
|
||||
|
@ -96,6 +96,11 @@
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row vcenter">
|
||||
<div class="large-9 columns">
|
||||
{{{templateTableVcenterHTML}}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="large-9 columns">
|
||||
{{{templateTableHTML}}}
|
||||
|
@ -31,7 +31,7 @@ define(function(require) {
|
||||
@param {String} tableName Header of the table (i.e: Locale.tr("Attributes"))
|
||||
@returns {String} HTML table
|
||||
*/
|
||||
function _html(templateJSON, resourceType, tableName) {
|
||||
function _html(templateJSON, resourceType, tableName, modify=true) {
|
||||
var str =
|
||||
'<table id="' + resourceType.toLowerCase() + '_template_table" class="dataTable configuration_attrs">\
|
||||
<thead>\
|
||||
@ -41,13 +41,15 @@ define(function(require) {
|
||||
'</th>\
|
||||
</tr>\
|
||||
</thead>' +
|
||||
fromJSONtoHTMLTable(templateJSON, resourceType) +
|
||||
'<tr>\
|
||||
fromJSONtoHTMLTable(templateJSON, resourceType, undefined, undefined,modify);
|
||||
if (modify) {
|
||||
str += '<tr>\
|
||||
<td class="key_td"><input type="text" name="new_key" id="new_key" /></td>\
|
||||
<td class="value_td"><textarea type="text" name="new_value" id="new_value"></textarea></td>\
|
||||
<td class="text-right"><button type="button" id="button_add_value" class="button small secondary"><i class="fa fa-lg fa-plus-circle"></i></button>\</td>\
|
||||
</tr>\
|
||||
</table>'
|
||||
</tr>';
|
||||
}
|
||||
str += '</table>'
|
||||
|
||||
return str;
|
||||
}
|
||||
@ -359,7 +361,7 @@ define(function(require) {
|
||||
}
|
||||
|
||||
// Returns an HTML string with the json keys and values
|
||||
function fromJSONtoHTMLTable(templateJSON, resourceType, vectorial, ocurrence) {
|
||||
function fromJSONtoHTMLTable(templateJSON, resourceType, vectorial, ocurrence, modify) {
|
||||
var str = ""
|
||||
if (!templateJSON) { return "Not defined";}
|
||||
var field = null;
|
||||
@ -370,14 +372,15 @@ define(function(require) {
|
||||
templateJSON[field],
|
||||
resourceType,
|
||||
vectorial,
|
||||
ocurrence);
|
||||
ocurrence,
|
||||
modify);
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
// Helper for fromJSONtoHTMLTable function
|
||||
function fromJSONtoHTMLRow(field, value, resourceType, vectorial_key, ocurrence) {
|
||||
function fromJSONtoHTMLRow(field, value, resourceType, vectorial_key, ocurrence, modify) {
|
||||
var str = "";
|
||||
|
||||
// value can be an array
|
||||
@ -391,28 +394,32 @@ define(function(require) {
|
||||
if (typeof current_value == 'object') {
|
||||
str += '<tr id="' + resourceType.toLowerCase() + '_template_table_' + field + '">\
|
||||
<td class="key_td key_vectorial_td">' + Locale.tr(field) + '</td>\
|
||||
<td class="value_vectorial_td"></td>\
|
||||
<td class="text-right nowrap">\
|
||||
<span id="div_add_vectorial">\
|
||||
<a id="div_add_vectorial_' + field + '" class="add_vectorial_a ocurrence_' + it + ' vectorial_key_' + field + '" href="#"><i class="fa fa-plus-sign"/></a>\
|
||||
</span> \
|
||||
<span id="div_minus">\
|
||||
<a id="div_minus_' + field + '" class="remove_vectorial_x ocurrence_' + it + '" href="#"><i class="fa fa-pencil-square-o"/><i class="fa fa-trash-o"/></a>\
|
||||
</span>\
|
||||
</td>\
|
||||
</tr>'
|
||||
<td class="value_vectorial_td"></td>';
|
||||
if (modify) {
|
||||
str += '<td class="text-right nowrap">\
|
||||
<span id="div_add_vectorial">\
|
||||
<a id="div_add_vectorial_' + field + '" class="add_vectorial_a ocurrence_' + it + ' vectorial_key_' + field + '" href="#"><i class="fa fa-plus-sign"/></a>\
|
||||
</span> \
|
||||
<span id="div_minus">\
|
||||
<a id="div_minus_' + field + '" class="remove_vectorial_x ocurrence_' + it + '" href="#"><i class="fa fa-pencil-square-o"/><i class="fa fa-trash-o"/></a>\
|
||||
</span>\
|
||||
</td>';
|
||||
}
|
||||
str += '</tr>'
|
||||
|
||||
str += fromJSONtoHTMLTable(current_value,
|
||||
resourceType,
|
||||
field,
|
||||
it);
|
||||
it,
|
||||
modify);
|
||||
} else {
|
||||
// if it is a single value, create the row for this occurence of the key
|
||||
str += fromJSONtoHTMLRow(field,
|
||||
current_value,
|
||||
resourceType,
|
||||
false,
|
||||
it);
|
||||
it,
|
||||
modify);
|
||||
}
|
||||
}
|
||||
} else // or value can be a string
|
||||
@ -425,48 +432,55 @@ define(function(require) {
|
||||
if (vectorial_key) {
|
||||
str += '<tr>\
|
||||
<td class="key_td key_vectorial_td">  ' + Locale.tr(field) + '</td>\
|
||||
<td class="value_td value_vectorial_td value_td_input_' + field + ocurrence_str + ' vectorial_key_' + vectorial_key + '" id="value_td_input_' + field + '">' + TemplateUtils.htmlEncode(value) + '</td>\
|
||||
<td class="text-right nowrap">\
|
||||
<span id="div_edit_vectorial">\
|
||||
<a id="div_edit_' + field + '" class="edit_e' + ocurrence_str + ' vectorial_key_' + vectorial_key + '" href="#"><i class="fa fa-pencil-square-o"/></a>\
|
||||
</span> \
|
||||
<span id="div_minus_vectorial">\
|
||||
<a id="div_minus_' + field + '" class="remove_x' + ocurrence_str + ' vectorial_key_' + vectorial_key + '" href="#"><i class="fa fa-trash-o"/></a>\
|
||||
</span>\
|
||||
</td>\
|
||||
</tr>';
|
||||
<td class="value_td value_vectorial_td value_td_input_' + field + ocurrence_str + ' vectorial_key_' + vectorial_key + '" id="value_td_input_' + field + '">' + TemplateUtils.htmlEncode(value) + '</td>';
|
||||
if (modify) {
|
||||
str += '<td class="text-right nowrap">\
|
||||
<span id="div_edit_vectorial">\
|
||||
<a id="div_edit_' + field + '" class="edit_e' + ocurrence_str + ' vectorial_key_' + vectorial_key + '" href="#"><i class="fa fa-pencil-square-o"/></a>\
|
||||
</span> \
|
||||
<span id="div_minus_vectorial">\
|
||||
<a id="div_minus_' + field + '" class="remove_x' + ocurrence_str + ' vectorial_key_' + vectorial_key + '" href="#"><i class="fa fa-trash-o"/></a>\
|
||||
</span>\
|
||||
</td>'
|
||||
}
|
||||
str += '</tr>';
|
||||
} else {
|
||||
// If it is not comming from a vectorial daddy key, it can still vectorial itself
|
||||
if (typeof value == 'object') {
|
||||
str += '<tr id="' + resourceType.toLowerCase() + '_template_table_' + field + '">\
|
||||
<td class="key_td key_vectorial_td">' + Locale.tr(field) + '</td>\
|
||||
<td class="value_vectorial_td"></td>\
|
||||
<td class="text-right nowrap">\
|
||||
<span id="div_add_vectorial">\
|
||||
<a id="div_add_vectorial_' + field + '" class="add_vectorial_a' + ocurrence_str + ' vectorial_key_' + field + '" href="#"><i class="fa fa-plus-sign"/></a>\
|
||||
</span> \
|
||||
<span id="div_minus">\
|
||||
<a id="div_minus_' + field + '" class="remove_vectorial_x' + ocurrence_str + '" href="#"><i class="fa fa-trash-o"/></a>\
|
||||
</span>\
|
||||
</td>'
|
||||
<td class="value_vectorial_td"></td>';
|
||||
if (modify) {
|
||||
str += '<td class="text-right nowrap">\
|
||||
<span id="div_add_vectorial">\
|
||||
<a id="div_add_vectorial_' + field + '" class="add_vectorial_a' + ocurrence_str + ' vectorial_key_' + field + '" href="#"><i class="fa fa-plus-sign"/></a>\
|
||||
</span> \
|
||||
<span id="div_minus">\
|
||||
<a id="div_minus_' + field + '" class="remove_vectorial_x' + ocurrence_str + '" href="#"><i class="fa fa-trash-o"/></a>\
|
||||
</span>\
|
||||
</td>'
|
||||
}
|
||||
str += fromJSONtoHTMLTable(value,
|
||||
resourceType,
|
||||
field,
|
||||
ocurrence);
|
||||
ocurrence,
|
||||
modify);
|
||||
} else // or, just a single value
|
||||
{
|
||||
str += '<tr>\
|
||||
<td class="key_td">' + Locale.tr(field) + '</td>\
|
||||
<td class="value_td" id="value_td_input_' + field + '">' + TemplateUtils.htmlEncode(value) + '</td>\
|
||||
<td class="text-right nowrap">\
|
||||
<span id="div_edit">\
|
||||
<a id="div_edit_' + field + '" class="edit_e' + ocurrence_str + '" href="#"><i class="fa fa-pencil-square-o"/></a>\
|
||||
</span> \
|
||||
<span id="div_minus">\
|
||||
<a id="div_minus_' + field + '" class="remove_x' + ocurrence_str + '" href="#"><i class="fa fa-trash-o"/></a>\
|
||||
</span>\
|
||||
</td>\
|
||||
</tr>';
|
||||
<td class="value_td" id="value_td_input_' + field + '">' + TemplateUtils.htmlEncode(value) + '</td>';
|
||||
if (modify) {
|
||||
str += '<td class="text-right nowrap">\
|
||||
<span id="div_edit">\
|
||||
<a id="div_edit_' + field + '" class="edit_e' + ocurrence_str + '" href="#"><i class="fa fa-pencil-square-o"/></a>\
|
||||
</span> \
|
||||
<span id="div_minus">\
|
||||
<a id="div_minus_' + field + '" class="remove_x' + ocurrence_str + '" href="#"><i class="fa fa-trash-o"/></a>\
|
||||
</span>\
|
||||
</td>';
|
||||
}
|
||||
str += '</tr>';
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user