From f2a2ec5555e0deb6ac7a432be5cd5fc4ebd55801 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Tue, 29 Mar 2016 18:26:42 +0200 Subject: [PATCH] Feature #4369: Show multiple clusters in sunstone --- src/sunstone/etc/sunstone-views/admin.yaml | 2 + .../etc/sunstone-views/admin_vcenter.yaml | 2 + .../etc/sunstone-views/groupadmin.yaml | 2 + .../sunstone-views/groupadmin_vcenter.yaml | 2 + src/sunstone/etc/sunstone-views/user.yaml | 2 + .../public/app/tabs/datastores-tab.js | 3 +- .../tabs/datastores-tab/panels/clusters.js | 87 ++++++++++++++++++ .../datastores-tab/panels/clusters/panelId.js | 19 ++++ .../app/tabs/datastores-tab/panels/info.js | 4 - .../tabs/datastores-tab/panels/info/html.hbs | 1 - src/sunstone/public/app/tabs/vnets-tab.js | 3 +- .../app/tabs/vnets-tab/panels/clusters.js | 88 +++++++++++++++++++ .../tabs/vnets-tab/panels/clusters/panelId.js | 19 ++++ .../public/app/tabs/vnets-tab/panels/info.js | 4 - .../app/tabs/vnets-tab/panels/info/html.hbs | 3 - 15 files changed, 227 insertions(+), 14 deletions(-) create mode 100644 src/sunstone/public/app/tabs/datastores-tab/panels/clusters.js create mode 100644 src/sunstone/public/app/tabs/datastores-tab/panels/clusters/panelId.js create mode 100644 src/sunstone/public/app/tabs/vnets-tab/panels/clusters.js create mode 100644 src/sunstone/public/app/tabs/vnets-tab/panels/clusters/panelId.js diff --git a/src/sunstone/etc/sunstone-views/admin.yaml b/src/sunstone/etc/sunstone-views/admin.yaml index bfeb979d15..0f9891abab 100644 --- a/src/sunstone/etc/sunstone-views/admin.yaml +++ b/src/sunstone/etc/sunstone-views/admin.yaml @@ -402,6 +402,7 @@ tabs: panel_tabs: datastore_info_tab: true datastore_image_tab: true + datastore_clusters_tab: true table_columns: - 0 # Checkbox - 1 # ID @@ -555,6 +556,7 @@ tabs: vnet_leases_tab: true vnet_sg_list_tab: true vnet_vr_list_tab: true + vnet_clusters_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 596429d6da..f13df97c84 100644 --- a/src/sunstone/etc/sunstone-views/admin_vcenter.yaml +++ b/src/sunstone/etc/sunstone-views/admin_vcenter.yaml @@ -402,6 +402,7 @@ tabs: panel_tabs: datastore_info_tab: true datastore_image_tab: true + datastore_clusters_tab: true table_columns: - 0 # Checkbox - 1 # ID @@ -554,6 +555,7 @@ tabs: vnet_leases_tab: true vnet_sg_list_tab: false vnet_vr_list_tab: true + vnet_clusters_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 6b237d92b9..a43a373cfa 100644 --- a/src/sunstone/etc/sunstone-views/groupadmin.yaml +++ b/src/sunstone/etc/sunstone-views/groupadmin.yaml @@ -401,6 +401,7 @@ tabs: panel_tabs: datastore_info_tab: true datastore_image_tab: true + datastore_clusters_tab: false table_columns: - 0 # Checkbox - 1 # ID @@ -554,6 +555,7 @@ tabs: vnet_leases_tab: true vnet_sg_list_tab: true vnet_vr_list_tab: false + vnet_clusters_tab: false 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 f00a171c60..9bddd8f296 100644 --- a/src/sunstone/etc/sunstone-views/groupadmin_vcenter.yaml +++ b/src/sunstone/etc/sunstone-views/groupadmin_vcenter.yaml @@ -403,6 +403,7 @@ tabs: panel_tabs: datastore_info_tab: true datastore_image_tab: true + datastore_clusters_tab: false table_columns: - 0 # Checkbox - 1 # ID @@ -554,6 +555,7 @@ tabs: vnet_leases_tab: true vnet_sg_list_tab: false vnet_vr_list_tab: false + vnet_clusters_tab: false 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 eb294201e7..85f25481ad 100644 --- a/src/sunstone/etc/sunstone-views/user.yaml +++ b/src/sunstone/etc/sunstone-views/user.yaml @@ -405,6 +405,7 @@ tabs: panel_tabs: datastore_info_tab: false datastore_image_tab: true + datastore_clusters_tab: false table_columns: - 0 # Checkbox - 1 # ID @@ -558,6 +559,7 @@ tabs: vnet_leases_tab: true vnet_sg_list_tab: true vnet_vr_list_tab: true + vnet_clusters_tab: false table_columns: - 0 # Checkbox - 1 # ID diff --git a/src/sunstone/public/app/tabs/datastores-tab.js b/src/sunstone/public/app/tabs/datastores-tab.js index 876060d5bd..27234904fd 100644 --- a/src/sunstone/public/app/tabs/datastores-tab.js +++ b/src/sunstone/public/app/tabs/datastores-tab.js @@ -33,7 +33,8 @@ define(function(require) { var _panels = [ require('./datastores-tab/panels/info'), - require('./datastores-tab/panels/images') + require('./datastores-tab/panels/images'), + require('./datastores-tab/panels/clusters') ]; var _panelsHooks = [ diff --git a/src/sunstone/public/app/tabs/datastores-tab/panels/clusters.js b/src/sunstone/public/app/tabs/datastores-tab/panels/clusters.js new file mode 100644 index 0000000000..88bd4ad405 --- /dev/null +++ b/src/sunstone/public/app/tabs/datastores-tab/panels/clusters.js @@ -0,0 +1,87 @@ +/* -------------------------------------------------------------------------- */ +/* 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 ClustersTable = require('tabs/clusters-tab/datatable'); + + /* + CONSTANTS + */ + + var PANEL_ID = require('./clusters/panelId'); + var CLUSTERS_TABLE_ID = PANEL_ID + "ClustersTable" + var RESOURCE = "Datastore" + + /* + CONSTRUCTOR + */ + + function Panel(info) { + this.title = Locale.tr("Clusters"); + this.icon = "fa-server"; + + this.element = info[RESOURCE.toUpperCase()]; + + return this; + }; + + Panel.PANEL_ID = PANEL_ID; + Panel.prototype.html = _html; + Panel.prototype.setup = _setup; + + return Panel; + + /* + FUNCTION DEFINITIONS + */ + + function _html() { + var clusters = []; + + if (this.element.CLUSTERS.ID != undefined){ + clusters = this.element.CLUSTERS.ID; + + if (!$.isArray(clusters)){ + clusters = [clusters]; + } + } + + var opts = { + info: true, + select: true, + selectOptions: { + read_only: true, + fixed_ids: clusters + } + }; + + this.clustersDataTable = new ClustersTable(CLUSTERS_TABLE_ID, opts); + + return this.clustersDataTable.dataTableHTML; + } + + function _setup(context) { + this.clustersDataTable.initialize(); + this.clustersDataTable.refreshResourceTableSelect(); + + return false; + } +}) diff --git a/src/sunstone/public/app/tabs/datastores-tab/panels/clusters/panelId.js b/src/sunstone/public/app/tabs/datastores-tab/panels/clusters/panelId.js new file mode 100644 index 0000000000..b6002fd302 --- /dev/null +++ b/src/sunstone/public/app/tabs/datastores-tab/panels/clusters/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 'datastore_clusters_tab'; +}) diff --git a/src/sunstone/public/app/tabs/datastores-tab/panels/info.js b/src/sunstone/public/app/tabs/datastores-tab/panels/info.js index f8128c6848..dc58041785 100644 --- a/src/sunstone/public/app/tabs/datastores-tab/panels/info.js +++ b/src/sunstone/public/app/tabs/datastores-tab/panels/info.js @@ -24,7 +24,6 @@ define(function(require) { var RenameTr = require('utils/panel/rename-tr'); var TemplateTable = require('utils/panel/template-table'); var PermissionsTable = require('utils/panel/permissions-table'); - var ClusterTr = require('utils/panel/cluster-tr'); var OpenNebulaDatastore = require('opennebula/datastore'); var DatastoreCapacityBar = require('../utils/datastore-capacity-bar'); @@ -68,7 +67,6 @@ define(function(require) { function _html() { var renameTrHTML = RenameTr.html(TAB_ID, RESOURCE, this.element.NAME); - var clusterTrHTML = ClusterTr.html(this.element.CLUSTER); var templateTableHTML = TemplateTable.html( this.element.TEMPLATE, RESOURCE, Locale.tr("Attributes")); @@ -85,7 +83,6 @@ define(function(require) { return TemplateInfo({ 'element': this.element, 'renameTrHTML': renameTrHTML, - 'clusterTrHTML': clusterTrHTML, 'templateTableHTML': templateTableHTML, 'permissionsTableHTML': permissionsTableHTML, 'capacityBar': capacityBar, @@ -97,7 +94,6 @@ define(function(require) { function _setup(context) { RenameTr.setup(TAB_ID, RESOURCE, this.element.ID, context); - ClusterTr.setup(RESOURCE, this.element.ID, this.element.CLUSTER_ID, context); TemplateTable.setup(this.element.TEMPLATE, RESOURCE, this.element.ID, context); PermissionsTable.setup(TAB_ID, RESOURCE, this.element, context); return false; diff --git a/src/sunstone/public/app/tabs/datastores-tab/panels/info/html.hbs b/src/sunstone/public/app/tabs/datastores-tab/panels/info/html.hbs index a45bb2efc2..691138bf54 100644 --- a/src/sunstone/public/app/tabs/datastores-tab/panels/info/html.hbs +++ b/src/sunstone/public/app/tabs/datastores-tab/panels/info/html.hbs @@ -28,7 +28,6 @@ {{element.ID}} {{{renameTrHTML}}} - {{{clusterTrHTML}}} {{tr "State"}} {{stateStr}} diff --git a/src/sunstone/public/app/tabs/vnets-tab.js b/src/sunstone/public/app/tabs/vnets-tab.js index be97b0d0bb..1e3d1edc9b 100644 --- a/src/sunstone/public/app/tabs/vnets-tab.js +++ b/src/sunstone/public/app/tabs/vnets-tab.js @@ -34,7 +34,8 @@ define(function(require) { require('./vnets-tab/panels/ar'), require('./vnets-tab/panels/leases'), require('./vnets-tab/panels/secgroups'), - require('./vnets-tab/panels/vrouters') + require('./vnets-tab/panels/vrouters'), + require('./vnets-tab/panels/clusters') ]; var _panelsHooks = [ diff --git a/src/sunstone/public/app/tabs/vnets-tab/panels/clusters.js b/src/sunstone/public/app/tabs/vnets-tab/panels/clusters.js new file mode 100644 index 0000000000..7d539a3889 --- /dev/null +++ b/src/sunstone/public/app/tabs/vnets-tab/panels/clusters.js @@ -0,0 +1,88 @@ +/* -------------------------------------------------------------------------- */ +/* 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 ClustersTable = require('tabs/clusters-tab/datatable'); + + /* + CONSTANTS + */ + + var PANEL_ID = require('./clusters/panelId'); + var CLUSTERS_TABLE_ID = PANEL_ID + "ClustersTable" + var RESOURCE = "Network"; + var XML_ROOT = "VNET"; + + /* + CONSTRUCTOR + */ + + function Panel(info) { + this.title = Locale.tr("Clusters"); + this.icon = "fa-server"; + + 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 clusters = []; + + if (this.element.CLUSTERS.ID != undefined){ + clusters = this.element.CLUSTERS.ID; + + if (!$.isArray(clusters)){ + clusters = [clusters]; + } + } + + var opts = { + info: true, + select: true, + selectOptions: { + read_only: true, + fixed_ids: clusters + } + }; + + this.clustersDataTable = new ClustersTable(CLUSTERS_TABLE_ID, opts); + + return this.clustersDataTable.dataTableHTML; + } + + function _setup(context) { + this.clustersDataTable.initialize(); + this.clustersDataTable.refreshResourceTableSelect(); + + return false; + } +}) diff --git a/src/sunstone/public/app/tabs/vnets-tab/panels/clusters/panelId.js b/src/sunstone/public/app/tabs/vnets-tab/panels/clusters/panelId.js new file mode 100644 index 0000000000..f61cbd7d76 --- /dev/null +++ b/src/sunstone/public/app/tabs/vnets-tab/panels/clusters/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 'vnet_clusters_tab'; +}) diff --git a/src/sunstone/public/app/tabs/vnets-tab/panels/info.js b/src/sunstone/public/app/tabs/vnets-tab/panels/info.js index e972f7ba84..0494bb1b36 100644 --- a/src/sunstone/public/app/tabs/vnets-tab/panels/info.js +++ b/src/sunstone/public/app/tabs/vnets-tab/panels/info.js @@ -22,7 +22,6 @@ define(function(require) { var TemplateInfo = require('hbs!./info/html'); var Locale = require('utils/locale'); var PermissionsTable = require('utils/panel/permissions-table'); - var ClusterTr = require('utils/panel/cluster-tr'); var RenameTr = require('utils/panel/rename-tr'); var OpenNebulaNetwork = require('opennebula/network'); @@ -66,7 +65,6 @@ define(function(require) { function _html() { 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); // TODO: simplify interface? @@ -101,7 +99,6 @@ define(function(require) { return TemplateInfo({ 'element': this.element, 'renameTrHTML': renameTrHTML, - 'clusterTrHTML': clusterTrHTML, 'reservationTrHTML': reservationTrHTML, 'permissionsTableHTML': permissionsTableHTML, 'templateTableHTML': templateTableHTML @@ -110,7 +107,6 @@ define(function(require) { function _setup(context) { RenameTr.setup(TAB_ID, RESOURCE, this.element.ID, context); - ClusterTr.setup(RESOURCE, this.element.ID, this.element.CLUSTER_ID, context); PermissionsTable.setup(TAB_ID, RESOURCE, this.element, context); // TODO: simplify interface? diff --git a/src/sunstone/public/app/tabs/vnets-tab/panels/info/html.hbs b/src/sunstone/public/app/tabs/vnets-tab/panels/info/html.hbs index cbd7d3d005..fbe2391b3d 100644 --- a/src/sunstone/public/app/tabs/vnets-tab/panels/info/html.hbs +++ b/src/sunstone/public/app/tabs/vnets-tab/panels/info/html.hbs @@ -29,9 +29,6 @@ {{{renameTrHTML}}} - - {{{clusterTrHTML}}} - {{{reservationTrHTML}}}