diff --git a/src/sunstone/etc/sunstone-views/admin.yaml b/src/sunstone/etc/sunstone-views/admin.yaml index 0f9891abab..e018b49956 100644 --- a/src/sunstone/etc/sunstone-views/admin.yaml +++ b/src/sunstone/etc/sunstone-views/admin.yaml @@ -616,6 +616,7 @@ tabs: secgroups-tab: panel_tabs: security_group_info_tab: true + security_group_vms_tab: true table_columns: - 0 # Checkbox - 1 # ID diff --git a/src/sunstone/etc/sunstone-views/admin_vcenter.yaml b/src/sunstone/etc/sunstone-views/admin_vcenter.yaml index f13df97c84..13a0d9c8c7 100644 --- a/src/sunstone/etc/sunstone-views/admin_vcenter.yaml +++ b/src/sunstone/etc/sunstone-views/admin_vcenter.yaml @@ -615,6 +615,7 @@ tabs: secgroups-tab: panel_tabs: security_group_info_tab: true + security_group_vms_tab: true table_columns: - 0 # Checkbox - 1 # ID diff --git a/src/sunstone/etc/sunstone-views/groupadmin.yaml b/src/sunstone/etc/sunstone-views/groupadmin.yaml index a43a373cfa..0b29e99e8d 100644 --- a/src/sunstone/etc/sunstone-views/groupadmin.yaml +++ b/src/sunstone/etc/sunstone-views/groupadmin.yaml @@ -615,6 +615,7 @@ tabs: secgroups-tab: panel_tabs: security_group_info_tab: true + security_group_vms_tab: true table_columns: - 0 # Checkbox - 1 # ID diff --git a/src/sunstone/etc/sunstone-views/groupadmin_vcenter.yaml b/src/sunstone/etc/sunstone-views/groupadmin_vcenter.yaml index 9bddd8f296..8b5407818b 100644 --- a/src/sunstone/etc/sunstone-views/groupadmin_vcenter.yaml +++ b/src/sunstone/etc/sunstone-views/groupadmin_vcenter.yaml @@ -615,6 +615,7 @@ tabs: secgroups-tab: panel_tabs: security_group_info_tab: true + security_group_vms_tab: true table_columns: - 0 # Checkbox - 1 # ID diff --git a/src/sunstone/etc/sunstone-views/user.yaml b/src/sunstone/etc/sunstone-views/user.yaml index 85f25481ad..528ded8836 100644 --- a/src/sunstone/etc/sunstone-views/user.yaml +++ b/src/sunstone/etc/sunstone-views/user.yaml @@ -619,6 +619,7 @@ tabs: secgroups-tab: panel_tabs: security_group_info_tab: true + security_group_vms_tab: true table_columns: - 0 # Checkbox - 1 # ID diff --git a/src/sunstone/public/app/tabs/secgroups-tab.js b/src/sunstone/public/app/tabs/secgroups-tab.js index 7a86204ba1..97d5153bc3 100644 --- a/src/sunstone/public/app/tabs/secgroups-tab.js +++ b/src/sunstone/public/app/tabs/secgroups-tab.js @@ -28,7 +28,8 @@ define(function(require) { ]; var _panels = [ - require('./secgroups-tab/panels/info') + require('./secgroups-tab/panels/info'), + require('./secgroups-tab/panels/vms') ]; var _panelsHooks = [ diff --git a/src/sunstone/public/app/tabs/secgroups-tab/panels/vms.js b/src/sunstone/public/app/tabs/secgroups-tab/panels/vms.js new file mode 100644 index 0000000000..11363e0f9a --- /dev/null +++ b/src/sunstone/public/app/tabs/secgroups-tab/panels/vms.js @@ -0,0 +1,129 @@ +/* -------------------------------------------------------------------------- */ +/* Copyright 2002-2015, OpenNebula Project, OpenNebula Systems */ +/* */ +/* Licensed under the Apache License, Version 2.0 (the "License"); you may */ +/* not use this file except in compliance with the License. You may obtain */ +/* a copy of the License at */ +/* */ +/* http://www.apache.org/licenses/LICENSE-2.0 */ +/* */ +/* Unless required by applicable law or agreed to in writing, software */ +/* distributed under the License is distributed on an "AS IS" BASIS, */ +/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ +/* See the License for the specific language governing permissions and */ +/* limitations under the License. */ +/* -------------------------------------------------------------------------- */ + +define(function(require){ + /* + DEPENDENCIES + */ + + var Locale = require('utils/locale'); + var VMsTable = require('tabs/vms-tab/datatable'); + var Template = require('hbs!./vms/html'); + + /* + CONSTANTS + */ + + var PANEL_ID = require('./vms/panelId'); + var VMS_TABLE_ID = PANEL_ID + "VMsTable" + + var RESOURCE = "SecurityGroup"; + var XML_ROOT = "SECURITY_GROUP"; + + /* + CONSTRUCTOR + */ + + function Panel(info) { + this.title = Locale.tr("VMs"); + this.icon = "fa-th"; + + this.element = info[XML_ROOT]; + + return this; + }; + + Panel.PANEL_ID = PANEL_ID; + Panel.prototype.html = _html; + Panel.prototype.setup = _setup; + + return Panel; + + /* + FUNCTION DEFINITIONS + */ + + function _html() { + var ids; + + var updatingIds = _getIds(this.element.UPDATING_VMS.ID); + updatingIds = updatingIds.concat( _getIds(this.element.OUTDATED_VMS.ID) ); + + var ids = _getIds(this.element.UPDATED_VMS.ID); + ids = ids.concat( updatingIds ); + + var opt = { + info: true, + select: true, + selectOptions: { + read_only: true, + fixed_ids: ids, + starred_ids: updatingIds, + starred_icon: '' + } + }; + + this.vmsDataTable = new VMsTable(PANEL_ID + '_UPDATED', opt); + + ids = _getIds(this.element.ERROR_VMS.ID); + this.errorDataTable = new VMsTable(PANEL_ID + '_ERROR', _buildOpts(ids)); + + var allUpdated = (this.element.UPDATING_VMS.ID == undefined && + this.element.OUTDATED_VMS.ID == undefined && + this.element.ERROR_VMS.ID == undefined); + + return Template({ + 'allUpdated': allUpdated, + 'vmsTableHTML': this.vmsDataTable.dataTableHTML, + 'errorTableHTML': this.errorDataTable.dataTableHTML + }); + } + + function _getIds(attr){ + var ids = []; + + if (attr != undefined){ + ids = attr; + + if (!$.isArray(ids)){ + ids = [ids]; + } + } + + return ids; + } + + function _buildOpts(ids){ + return { + info: true, + select: true, + selectOptions: { + read_only: true, + fixed_ids: ids + } + }; + } + + function _setup(context) { + this.vmsDataTable.initialize(); + this.vmsDataTable.refreshResourceTableSelect(); + + this.errorDataTable.initialize(); + this.errorDataTable.refreshResourceTableSelect(); + + return false; + } +}) diff --git a/src/sunstone/public/app/tabs/secgroups-tab/panels/vms/html.hbs b/src/sunstone/public/app/tabs/secgroups-tab/panels/vms/html.hbs new file mode 100644 index 0000000000..dcd3289c23 --- /dev/null +++ b/src/sunstone/public/app/tabs/secgroups-tab/panels/vms/html.hbs @@ -0,0 +1,38 @@ +{{! -------------------------------------------------------------------------- }} +{{! Copyright 2002-2015, OpenNebula Project, OpenNebula Systems }} +{{! }} +{{! Licensed under the Apache License, Version 2.0 (the "License"); you may }} +{{! not use this file except in compliance with the License. You may obtain }} +{{! a copy of the License at }} +{{! }} +{{! http://www.apache.org/licenses/LICENSE-2.0 }} +{{! }} +{{! Unless required by applicable law or agreed to in writing, software }} +{{! distributed under the License is distributed on an "AS IS" BASIS, }} +{{! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. }} +{{! See the License for the specific language governing permissions and }} +{{! limitations under the License. }} +{{! -------------------------------------------------------------------------- }} + +{{#unless allUpdated}} +
+

{{{tr "VMs marked with are waiting to be updated with the latest rules:"}}} +

+{{/unless}} +
+
+ {{{vmsTableHTML}}} +
+
+{{#unless allUpdated}} +
+
+
+

{{tr "VMs in error. The update to the latest rules failed:"}} +

+
+
+ {{{errorTableHTML}}} +
+
+{{/unless}} \ No newline at end of file diff --git a/src/sunstone/public/app/tabs/secgroups-tab/panels/vms/panelId.js b/src/sunstone/public/app/tabs/secgroups-tab/panels/vms/panelId.js new file mode 100644 index 0000000000..be7e1ee8ae --- /dev/null +++ b/src/sunstone/public/app/tabs/secgroups-tab/panels/vms/panelId.js @@ -0,0 +1,19 @@ +/* -------------------------------------------------------------------------- */ +/* Copyright 2002-2015, OpenNebula Project, OpenNebula Systems */ +/* */ +/* Licensed under the Apache License, Version 2.0 (the "License"); you may */ +/* not use this file except in compliance with the License. You may obtain */ +/* a copy of the License at */ +/* */ +/* http://www.apache.org/licenses/LICENSE-2.0 */ +/* */ +/* Unless required by applicable law or agreed to in writing, software */ +/* distributed under the License is distributed on an "AS IS" BASIS, */ +/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ +/* See the License for the specific language governing permissions and */ +/* limitations under the License. */ +/* -------------------------------------------------------------------------- */ + +define(function(require){ + return 'security_group_vms_tab'; +}) diff --git a/src/sunstone/public/app/utils/tab-datatable.js b/src/sunstone/public/app/utils/tab-datatable.js index 7014166ae0..9693bdd603 100644 --- a/src/sunstone/public/app/utils/tab-datatable.js +++ b/src/sunstone/public/app/utils/tab-datatable.js @@ -127,6 +127,10 @@ define(function(require) { $.each(that.selectOptions.starred_ids, function() { that.selectOptions.starred_ids_map[this] = true; }); + + if (that.selectOptions.starred_icon == undefined) { + that.selectOptions.starred_icon = ''; + } } if (that.selectOptions.multiple_choice == undefined) { @@ -970,7 +974,7 @@ define(function(require) { if (that.selectOptions.starred_ids != undefined){ if (that.selectOptions.starred_ids_map[this[that.xmlRoot].ID]){ elementArray[that.selectOptions.name_index] = - (' ' + + (that.selectOptions.starred_icon + ' ' + elementArray[that.selectOptions.name_index]); } else { elementArray[that.selectOptions.name_index] =