diff --git a/src/sunstone/etc/sunstone-views/admin.yaml b/src/sunstone/etc/sunstone-views/admin.yaml index a6c28fdcce..2bc7c74c83 100644 --- a/src/sunstone/etc/sunstone-views/admin.yaml +++ b/src/sunstone/etc/sunstone-views/admin.yaml @@ -808,11 +808,12 @@ tabs: table_columns: - 0 # Checkbox - 1 # ID - - 2 # Owner + - 2 # Name - 3 # Group - - 4 # Name - #- 5 # Labels - #- 6 # Search data + - 4 # Owner + - 5 # Vms + #- 6 # Labels + #- 7 # Search data actions: VMGroup.create_dialog: true VMGroup.update_dialog: true diff --git a/src/sunstone/etc/sunstone-views/admin_vcenter.yaml b/src/sunstone/etc/sunstone-views/admin_vcenter.yaml index e3a17fe603..e3e86a56a0 100644 --- a/src/sunstone/etc/sunstone-views/admin_vcenter.yaml +++ b/src/sunstone/etc/sunstone-views/admin_vcenter.yaml @@ -805,11 +805,12 @@ tabs: table_columns: - 0 # Checkbox - 1 # ID - - 2 # Owner + - 2 # Name - 3 # Group - - 4 # Name - #- 5 # Labels - #- 6 # Search data + - 4 # Owner + - 5 # Vms + #- 6 # Labels + #- 7 # Search data actions: VMGroup.create_dialog: true VMGroup.update_dialog: true diff --git a/src/sunstone/etc/sunstone-views/cloud.yaml b/src/sunstone/etc/sunstone-views/cloud.yaml index 6eff081693..9d0b6c2561 100644 --- a/src/sunstone/etc/sunstone-views/cloud.yaml +++ b/src/sunstone/etc/sunstone-views/cloud.yaml @@ -142,8 +142,9 @@ tabs: table_columns: - 0 # Checkbox - 1 # ID - - 2 # Owner + - 2 # Name - 3 # Group - - 4 # Name - #- 5 # Labels - #- 6 # Search data \ No newline at end of file + - 4 # Owner + - 5 # Vms + #- 6 # Labels + #- 7 # Search data \ No newline at end of file diff --git a/src/sunstone/etc/sunstone-views/groupadmin.yaml b/src/sunstone/etc/sunstone-views/groupadmin.yaml index d12b8d3b73..20177111b7 100644 --- a/src/sunstone/etc/sunstone-views/groupadmin.yaml +++ b/src/sunstone/etc/sunstone-views/groupadmin.yaml @@ -806,11 +806,12 @@ tabs: table_columns: - 0 # Checkbox - 1 # ID - - 2 # Owner + - 2 # Name - 3 # Group - - 4 # Name - #- 5 # Labels - #- 6 # Search data + - 4 # Owner + - 5 # Vms + #- 6 # Labels + #- 7 # Search data actions: VMGroup.create_dialog: true VMGroup.update_dialog: true diff --git a/src/sunstone/etc/sunstone-views/groupadmin_vcenter.yaml b/src/sunstone/etc/sunstone-views/groupadmin_vcenter.yaml index 15b1b516cd..5595824615 100644 --- a/src/sunstone/etc/sunstone-views/groupadmin_vcenter.yaml +++ b/src/sunstone/etc/sunstone-views/groupadmin_vcenter.yaml @@ -806,11 +806,12 @@ tabs: table_columns: - 0 # Checkbox - 1 # ID - - 2 # Owner + - 2 # Name - 3 # Group - - 4 # Name - #- 5 # Labels - #- 6 # Search data + - 4 # Owner + - 5 # Vms + #- 6 # Labels + #- 7 # Search data actions: VMGroup.create_dialog: true VMGroup.update_dialog: true \ No newline at end of file diff --git a/src/sunstone/etc/sunstone-views/user.yaml b/src/sunstone/etc/sunstone-views/user.yaml index 5e726383e0..ffcf195d93 100644 --- a/src/sunstone/etc/sunstone-views/user.yaml +++ b/src/sunstone/etc/sunstone-views/user.yaml @@ -805,11 +805,12 @@ tabs: table_columns: - 0 # Checkbox - 1 # ID - - 2 # Owner + - 2 # Name - 3 # Group - - 4 # Name - #- 5 # Labels - #- 6 # Search data + - 4 # Owner + - 5 # Vms + #- 6 # Labels + #- 7 # Search data actions: VMGroup.create_dialog: true VMGroup.update_dialog: true \ No newline at end of file diff --git a/src/sunstone/public/app/tabs/acls-tab/datatable.js b/src/sunstone/public/app/tabs/acls-tab/datatable.js index 771418b84a..b56eb6cd48 100644 --- a/src/sunstone/public/app/tabs/acls-tab/datatable.js +++ b/src/sunstone/public/app/tabs/acls-tab/datatable.js @@ -180,6 +180,9 @@ define(function(require) { case "MARKETPLACEAPP": resources_str+=Locale.tr("Marketplace Apps")+", "; break; + case "VMGROUP": + resources_str+=Locale.tr("VM Groups")+", "; + break; } } //remove ", " from end diff --git a/src/sunstone/public/app/tabs/vmgroup-tab.js b/src/sunstone/public/app/tabs/vmgroup-tab.js index 21fee5b435..8d6d4a99d1 100644 --- a/src/sunstone/public/app/tabs/vmgroup-tab.js +++ b/src/sunstone/public/app/tabs/vmgroup-tab.js @@ -25,6 +25,7 @@ define(function(require) { var _panels = [ require('./vmgroup-tab/panels/info'), + require('./vmgroup-tab/panels/vms') ]; var _formPanels = [ diff --git a/src/sunstone/public/app/tabs/vmgroup-tab/datatable.js b/src/sunstone/public/app/tabs/vmgroup-tab/datatable.js index 9dcd8c4715..498443b84a 100644 --- a/src/sunstone/public/app/tabs/vmgroup-tab/datatable.js +++ b/src/sunstone/public/app/tabs/vmgroup-tab/datatable.js @@ -33,8 +33,8 @@ define(function(require) { var RESOURCE = "VMGroup"; var XML_ROOT = "VM_GROUP"; var TAB_NAME = require('./tabId'); - var LABELS_COLUMN = 5; - var SEARCH_COLUMN = 6; + var LABELS_COLUMN = 6; + var SEARCH_COLUMN = 7; var TEMPLATE_ATTR = 'TEMPLATE'; /* @@ -66,6 +66,7 @@ define(function(require) { Locale.tr("Name"), Locale.tr("Owner"), Locale.tr("Group"), + Locale.tr("VMs"), Locale.tr("Labels"), "search_data" ]; @@ -98,6 +99,15 @@ define(function(require) { function _elementArray(element_json) { var element = element_json[XML_ROOT]; + var numVms = 0; + + for(role_index in element.ROLES.ROLE){ + if(element.ROLES.ROLE[role_index].VMS){ + var vms = element.ROLES.ROLE[role_index].VMS; + var vms = vms.split(","); + numVms += vms.length; + } + } var search = { NAME: element.NAME, @@ -113,6 +123,7 @@ define(function(require) { element.NAME, element.UNAME, element.GNAME, + numVms, (LabelsUtils.labelsStr(element[TEMPLATE_ATTR])||''), btoa(unescape(encodeURIComponent(JSON.stringify(search)))) ]; diff --git a/src/sunstone/public/app/tabs/vmgroup-tab/panels/vms.js b/src/sunstone/public/app/tabs/vmgroup-tab/panels/vms.js new file mode 100644 index 0000000000..a6c480c2b7 --- /dev/null +++ b/src/sunstone/public/app/tabs/vmgroup-tab/panels/vms.js @@ -0,0 +1,138 @@ +/* -------------------------------------------------------------------------- */ +/* Copyright 2002-2016, 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 TemplateVms = require('hbs!./vms/html'); + var Locale = require('utils/locale'); + var VMsTable = require('tabs/vms-tab/datatable'); + + /* + CONSTANTS + */ + var PANEL_ID = require('./vms/panelId'); + var VMS_TABLE_ID = PANEL_ID + "VMsTable"; + var RESOURCE = "VMGroup"; + var XML_ROOT = "VM_GROUP"; + var indexTable=0; + + /* + CONSTRUCTOR + */ + function Panel(info) { + this.title = Locale.tr("VMs"); + this.icon = "fa-cloud"; + this.element = info[XML_ROOT].ROLES.ROLE; + + return this; + } + + Panel.PANEL_ID = PANEL_ID; + Panel.prototype.html = _html; + Panel.prototype.setup = _setup; + + return Panel; + + /* + FUNCTION DEFINITIONS + */ + function _html(){ + var vms = []; + this.vmsTable = []; + this.vmsTableHTML = []; + var that = this; + + if (this.element != undefined){ + if(Array.isArray(this.element)){ + $.each(this.element, function(){ + if(this.VMS){ + vms = this.VMS.split(","); + var opts = { + info: true, + select: true, + selectOptions: { + read_only: true, + fixed_ids: vms + } + }; + var table = new VMsTable(VMS_TABLE_ID + indexTable, opts); + that.vmsTable.push(table); + var html={} + html.name = this.NAME; + html.table = table.dataTableHTML; + that.vmsTableHTML.push(html); + indexTable++; + } + }); + } + else { + if(this.VMS){ + vms = this.VMS.split(","); + var opts = { + info: true, + select: true, + selectOptions: { + read_only: true, + fixed_ids: vms + } + }; + + var table = new VMsTable(VMS_TABLE_ID + indexTable, opts); + that.vmsTable.push(table); + var html={} + html.name = Locale.tr(this.NAME); + html.table = table.dataTableHTML; + that.vmsTableHTML.push(html); + indexTable++; + } + } + } + if(that.vmsTable.length == 0){ + vms = []; + var opts = { + info: true, + select: true, + selectOptions: { + read_only: true, + fixed_ids: vms + } + }; + var table = new VMsTable(VMS_TABLE_ID + indexTable, opts); + that.vmsTable.push(table); + var html={} + html.name = Locale.tr("Role"); + html.table = table.dataTableHTML; + that.vmsTableHTML.push(html); + } + + return TemplateVms({ + 'arrayDataTable': this.vmsTableHTML + }); + } + + function _setup(context) { + + $.each(this.vmsTable, function(){ + this.initialize(); + this.refreshResourceTableSelect(); + }); + + return false; + } +}); \ No newline at end of file diff --git a/src/sunstone/public/app/tabs/vmgroup-tab/panels/vms/html.hbs b/src/sunstone/public/app/tabs/vmgroup-tab/panels/vms/html.hbs new file mode 100644 index 0000000000..d78a8fe4a3 --- /dev/null +++ b/src/sunstone/public/app/tabs/vmgroup-tab/panels/vms/html.hbs @@ -0,0 +1,32 @@ +{{! -------------------------------------------------------------------------- }} +{{! Copyright 2002-2016, 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. }} +{{! -------------------------------------------------------------------------- }} + +{{#each arrayDataTable}} +
+
+
+ +
+ {{this.name}} +
+
+
+ {{{this.table}}} +
+
+
+
+{{/each}} \ No newline at end of file diff --git a/src/sunstone/public/app/tabs/vmgroup-tab/panels/vms/panelId.js b/src/sunstone/public/app/tabs/vmgroup-tab/panels/vms/panelId.js new file mode 100644 index 0000000000..4edf14a92a --- /dev/null +++ b/src/sunstone/public/app/tabs/vmgroup-tab/panels/vms/panelId.js @@ -0,0 +1,19 @@ +/* -------------------------------------------------------------------------- */ +/* Copyright 2002-2016, 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 'vm_group_vms_tab'; +}) diff --git a/src/sunstone/public/app/tabs/vmgroup-tab/utils/affinity-role-tab.js b/src/sunstone/public/app/tabs/vmgroup-tab/utils/affinity-role-tab.js index 5a9832ac6e..59c915b157 100644 --- a/src/sunstone/public/app/tabs/vmgroup-tab/utils/affinity-role-tab.js +++ b/src/sunstone/public/app/tabs/vmgroup-tab/utils/affinity-role-tab.js @@ -187,7 +187,7 @@ define(function(require) { function _add_group_affinity_box(rolesSt, context, group_roles_index, group_roles_affinity, affinity){ for(group in group_roles_affinity){ if(group_roles_affinity[group].retrieve(context) == rolesSt){ - Notifier.notifyError(Locale.tr("Already exist a group role with this vaues.")); + Notifier.notifyError(Locale.tr("Already exists a group role with these values.")); return false; } }