diff --git a/src/sunstone/public/app/tabs/clusters-tab/datatable.js b/src/sunstone/public/app/tabs/clusters-tab/datatable.js new file mode 100644 index 0000000000..d9eb1a7c48 --- /dev/null +++ b/src/sunstone/public/app/tabs/clusters-tab/datatable.js @@ -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 [ + '', + 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; + } +}); diff --git a/src/sunstone/public/app/tabs/clusters-tab/tabId.js b/src/sunstone/public/app/tabs/clusters-tab/tabId.js new file mode 100644 index 0000000000..a4ede04543 --- /dev/null +++ b/src/sunstone/public/app/tabs/clusters-tab/tabId.js @@ -0,0 +1,3 @@ +define(function(require){ + return 'clusters-tab'; +}); \ No newline at end of file diff --git a/src/sunstone/public/app/tabs/hosts-tab/datatable.js b/src/sunstone/public/app/tabs/hosts-tab/datatable.js index ff9681f22f..eceb6f94d1 100644 --- a/src/sunstone/public/app/tabs/hosts-tab/datatable.js +++ b/src/sunstone/public/app/tabs/hosts-tab/datatable.js @@ -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); }; diff --git a/src/sunstone/public/app/tabs/vnets-tab/datatable.js b/src/sunstone/public/app/tabs/vnets-tab/datatable.js index e5b7a319c6..4af2a30899 100644 --- a/src/sunstone/public/app/tabs/vnets-tab/datatable.js +++ b/src/sunstone/public/app/tabs/vnets-tab/datatable.js @@ -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); }; diff --git a/src/sunstone/public/app/tabs/zones-tab/datatable.js b/src/sunstone/public/app/tabs/zones-tab/datatable.js index d457ee31de..6a0be88fd3 100644 --- a/src/sunstone/public/app/tabs/zones-tab/datatable.js +++ b/src/sunstone/public/app/tabs/zones-tab/datatable.js @@ -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); };