Feature #3748: Update datatables, add clusters dt.js

This commit is contained in:
Carlos Martín committed 2015-05-25 13:04:14 +02:00
1 parent 96d28c2057
commit ce4e553f97
5 files changed
+133 -4

No files matched your search

@@ -0,0 +1,95 @@
define(function(require) {
/*
DEPENDENCIES
*/
var TabDataTable = require('utils/tab-datatable');
var SunstoneConfig = require('sunstone-config');
var Locale = require('utils/locale');
/*
CONSTANTS
*/
var RESOURCE = "Cluster";
var XML_ROOT = "CLUSTER";
var TAB_NAME = require('./tabId');
/*
CONSTRUCTOR
*/
function Table(dataTableId, conf) {
this.conf = conf || {};
this.tabId = TAB_NAME;
this.dataTableId = dataTableId;
this.resource = RESOURCE;
this.xmlRoot = XML_ROOT;
this.dataTableOptions = {
"bAutoWidth": false,
"bSortClasses" : false,
"bDeferRender": true,
"aoColumnDefs": [
{"bSortable": false, "aTargets": ["check"] },
{"sWidth": "35px", "aTargets": [0]},
{"bVisible": true, "aTargets": SunstoneConfig.tabTableColumns(TAB_NAME)},
{"bVisible": false, "aTargets": ['_all']}
]
};
this.columns = [
Locale.tr("ID"),
Locale.tr("Name"),
Locale.tr("Hosts"),
Locale.tr("VNets"),
Locale.tr("Datastores")
];
this.selectOptions = {
"id_index": 1,
"name_index": 2,
"select_resource": Locale.tr("Please select a Cluster from the list"),
"you_selected": Locale.tr("You selected the following Cluster:"),
"select_resource_multiple": Locale.tr("Please select one or more clusters from the list"),
"you_selected_multiple": Locale.tr("You selected the following clusters:")
};
TabDataTable.call(this);
}
Table.prototype = Object.create(TabDataTable.prototype);
Table.prototype.constructor = Table;
Table.prototype.elementArray = _elementArray;
return Table;
/*
FUNCTION DEFINITIONS
*/
function _elementArray(element_json) {
var element = element_json[XML_ROOT];
return [
'<input class="check_item" type="checkbox" id="'+RESOURCE.toLowerCase()+'_' +
element.ID + '" name="selected_items" value="' +
element.ID + '"/>',
element.ID,
element.NAME,
_lengthOf(element.HOSTS.ID),
_lengthOf(element.VNETS.ID),
_lengthOf(element.DATASTORES.ID)
];
}
function _lengthOf(ids){
var l = 0;
if ($.isArray(ids))
l = ids.length;
else if (!$.isEmptyObject(ids))
l = 1;
return l;
}
});
@@ -0,0 +1,3 @@
define(function(require){
return 'clusters-tab';
});
@@ -15,7 +15,8 @@ define(function(require) {
CONSTANTS
*/
var RESOURCE = "Host"
var RESOURCE = "Host";
var XML_ROOT = "HOST";
var TAB_NAME = require('./tabId');
/*
@@ -24,8 +25,10 @@ define(function(require) {
function Table(dataTableId, conf) {
this.conf = conf || {};
this.tabId = TAB_NAME;
this.dataTableId = dataTableId;
this.resource = RESOURCE;
this.xmlRoot = XML_ROOT;
this.dataTableOptions = {
"bAutoWidth": false,
@@ -52,7 +55,16 @@ define(function(require) {
Locale.tr("IM MAD"),
Locale.tr("VM MAD"),
Locale.tr("Last monitored on")
]
];
this.selectOptions = {
"id_index": 1,
"name_index": 2,
"select_resource": Locale.tr("Please select a Host from the list"),
"you_selected": Locale.tr("You selected the following Host:"),
"select_resource_multiple": Locale.tr("Please select one or more hosts from the list"),
"you_selected_multiple": Locale.tr("You selected the following hosts:")
};
TabDataTable.call(this);
};
@@ -50,7 +50,17 @@ define(function(require) {
Locale.tr("Bridge"),
Locale.tr("Leases"),
Locale.tr("VLAN ID")
]
];
this.selectOptions = {
"id_index": 1,
"name_index": 4,
"uname_index": 2,
"select_resource": Locale.tr("Please select a network from the list"),
"you_selected": Locale.tr("You selected the following network:"),
"select_resource_multiple": Locale.tr("Please select one or more networks from the list"),
"you_selected_multiple": Locale.tr("You selected the following networks:")
};
TabDataTable.call(this);
};
@@ -42,7 +42,16 @@ define(function(require) {
Locale.tr("ID"),
Locale.tr("Name"),
Locale.tr("Endpoint"),
]
];
this.selectOptions = {
"id_index": 1,
"name_index": 2,
"select_resource": Locale.tr("Please select a Zone from the list"),
"you_selected": Locale.tr("You selected the following Zone:"),
"select_resource_multiple": Locale.tr("Please select one or more Zones from the list"),
"you_selected_multiple": Locale.tr("You selected the following Zones:")
};
TabDataTable.call(this);
};