From bb62e1cdbef4d73fafc48a342989a442e433f8ea Mon Sep 17 00:00:00 2001 From: "Carlos J. Herrera" <37907824+carloshm91@users.noreply.github.com> Date: Wed, 22 Jan 2020 11:56:47 -0500 Subject: [PATCH] F #1269: show resource pool inside cards (#4108) - first step to resource tab - verify hypervisor - add it to kvm views - adding new view and table - show resource pool inside cards Signed-off-by: Carlos Herrera --- .../etc/sunstone-views/kvm/admin.yaml | 1 + .../etc/sunstone-views/mixed/admin.yaml | 1 + .../etc/sunstone-views/mixed/groupadmin.yaml | 1 + .../etc/sunstone-views/mixed/user.yaml | 1 + .../etc/sunstone-views/vcenter/admin.yaml | 1 + .../sunstone-views/vcenter/groupadmin.yaml | 1 + .../etc/sunstone-views/vcenter/user.yaml | 1 + src/sunstone/public/app/tabs/hosts-tab.js | 1 + .../public/app/tabs/hosts-tab/panels/pool.js | 65 +++++++++++++++++++ .../app/tabs/hosts-tab/panels/pool/html.hbs | 23 +++++++ .../app/tabs/hosts-tab/panels/pool/panelId.js | 19 ++++++ .../public/app/tabs/hosts-tab/utils/cards.js | 65 +++++++++++++++++++ .../utils/resource-pool-cards/html.hbs | 27 ++++++++ .../utils/resource-pool-table/html.hbs | 25 +++++++ 14 files changed, 232 insertions(+) create mode 100644 src/sunstone/public/app/tabs/hosts-tab/panels/pool.js create mode 100644 src/sunstone/public/app/tabs/hosts-tab/panels/pool/html.hbs create mode 100644 src/sunstone/public/app/tabs/hosts-tab/panels/pool/panelId.js create mode 100644 src/sunstone/public/app/tabs/hosts-tab/utils/cards.js create mode 100644 src/sunstone/public/app/tabs/hosts-tab/utils/resource-pool-cards/html.hbs create mode 100644 src/sunstone/public/app/tabs/hosts-tab/utils/resource-pool-table/html.hbs diff --git a/src/sunstone/etc/sunstone-views/kvm/admin.yaml b/src/sunstone/etc/sunstone-views/kvm/admin.yaml index 60fc9968ae..1d27582e08 100644 --- a/src/sunstone/etc/sunstone-views/kvm/admin.yaml +++ b/src/sunstone/etc/sunstone-views/kvm/admin.yaml @@ -529,6 +529,7 @@ tabs: panel_tabs: host_info_tab: true host_monitoring_tab: true + host_pool_tab: true host_vms_tab: true host_wilds_tab: true host_zombies_tab: true diff --git a/src/sunstone/etc/sunstone-views/mixed/admin.yaml b/src/sunstone/etc/sunstone-views/mixed/admin.yaml index bdeb1316b3..e6017f1e5c 100644 --- a/src/sunstone/etc/sunstone-views/mixed/admin.yaml +++ b/src/sunstone/etc/sunstone-views/mixed/admin.yaml @@ -531,6 +531,7 @@ tabs: panel_tabs: host_info_tab: true host_monitoring_tab: true + host_pool_tab: true host_vms_tab: true host_wilds_tab: true host_zombies_tab: true diff --git a/src/sunstone/etc/sunstone-views/mixed/groupadmin.yaml b/src/sunstone/etc/sunstone-views/mixed/groupadmin.yaml index 2eeca20446..240e4e68a1 100644 --- a/src/sunstone/etc/sunstone-views/mixed/groupadmin.yaml +++ b/src/sunstone/etc/sunstone-views/mixed/groupadmin.yaml @@ -530,6 +530,7 @@ tabs: panel_tabs: host_info_tab: true host_monitoring_tab: true + host_pool_tab: true host_vms_tab: true host_wilds_tab: true host_zombies_tab: true diff --git a/src/sunstone/etc/sunstone-views/mixed/user.yaml b/src/sunstone/etc/sunstone-views/mixed/user.yaml index 4ca828e27b..9590b980c7 100644 --- a/src/sunstone/etc/sunstone-views/mixed/user.yaml +++ b/src/sunstone/etc/sunstone-views/mixed/user.yaml @@ -523,6 +523,7 @@ tabs: panel_tabs: host_info_tab: true host_monitoring_tab: true + host_pool_tab: true host_vms_tab: true host_wilds_tab: true host_zombies_tab: true diff --git a/src/sunstone/etc/sunstone-views/vcenter/admin.yaml b/src/sunstone/etc/sunstone-views/vcenter/admin.yaml index ccab7d8222..95083c09a7 100644 --- a/src/sunstone/etc/sunstone-views/vcenter/admin.yaml +++ b/src/sunstone/etc/sunstone-views/vcenter/admin.yaml @@ -529,6 +529,7 @@ tabs: panel_tabs: host_info_tab: true host_monitoring_tab: true + host_pool_tab: true host_vms_tab: true host_wilds_tab: true host_zombies_tab: true diff --git a/src/sunstone/etc/sunstone-views/vcenter/groupadmin.yaml b/src/sunstone/etc/sunstone-views/vcenter/groupadmin.yaml index 50fde68195..c4eba7673f 100644 --- a/src/sunstone/etc/sunstone-views/vcenter/groupadmin.yaml +++ b/src/sunstone/etc/sunstone-views/vcenter/groupadmin.yaml @@ -530,6 +530,7 @@ tabs: panel_tabs: host_info_tab: true host_monitoring_tab: true + host_pool_tab: true host_vms_tab: true host_wilds_tab: true host_zombies_tab: true diff --git a/src/sunstone/etc/sunstone-views/vcenter/user.yaml b/src/sunstone/etc/sunstone-views/vcenter/user.yaml index 4ca828e27b..9590b980c7 100644 --- a/src/sunstone/etc/sunstone-views/vcenter/user.yaml +++ b/src/sunstone/etc/sunstone-views/vcenter/user.yaml @@ -523,6 +523,7 @@ tabs: panel_tabs: host_info_tab: true host_monitoring_tab: true + host_pool_tab: true host_vms_tab: true host_wilds_tab: true host_zombies_tab: true diff --git a/src/sunstone/public/app/tabs/hosts-tab.js b/src/sunstone/public/app/tabs/hosts-tab.js index 4e96840192..435c2b5357 100644 --- a/src/sunstone/public/app/tabs/hosts-tab.js +++ b/src/sunstone/public/app/tabs/hosts-tab.js @@ -37,6 +37,7 @@ define(function(require) { require('./hosts-tab/panels/esx'), require('./hosts-tab/panels/pci'), require('./hosts-tab/panels/numa'), + require('./hosts-tab/panels/pool'), require('./hosts-tab/panels/nsx') ]; var _panelsHooks = [ diff --git a/src/sunstone/public/app/tabs/hosts-tab/panels/pool.js b/src/sunstone/public/app/tabs/hosts-tab/panels/pool.js new file mode 100644 index 0000000000..e1dff96647 --- /dev/null +++ b/src/sunstone/public/app/tabs/hosts-tab/panels/pool.js @@ -0,0 +1,65 @@ +/* -------------------------------------------------------------------------- */ +/* Copyright 2002-2019, 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 ResourcePoolCards = require("../utils/cards"); + /* + TEMPLATES + */ + var TemplatePool = require('hbs!./pool/html'); + /* + CONSTANTS + */ + var PANEL_ID = require('./pool/panelId'); + var RESOURCE = "Host" + /* + CONSTRUCTOR + */ + function Panel(info) { + var self = this; + this.title = Locale.tr("POOL"); + this.icon = "fa-server"; + this.element = info[RESOURCE.toUpperCase()]; + // Do not create an instance of this panel if no vcenter hypervisor + // porque el hypervisor proviene de la monitorizacion de por si no esta en el template + if(this.element && this.element.TEMPLATE && this.element.TEMPLATE.HYPERVISOR){ + if(this.element.TEMPLATE.HYPERVISOR != "vcenter"){ + throw "Panel not available for this element"; + } + }else{ + throw "Panel not available for this element"; + } + + return this; + }; + Panel.PANEL_ID = PANEL_ID; + Panel.prototype.html = _html; + Panel.prototype.setup = _setup; + return Panel; + /* + FUNCTION DEFINITIONS + */ + function _html() { + return TemplatePool({ + "resourcePoolCards": ResourcePoolCards.html(this.element) + }); + } + function _setup(context) { + } +}) diff --git a/src/sunstone/public/app/tabs/hosts-tab/panels/pool/html.hbs b/src/sunstone/public/app/tabs/hosts-tab/panels/pool/html.hbs new file mode 100644 index 0000000000..fe0efe2e50 --- /dev/null +++ b/src/sunstone/public/app/tabs/hosts-tab/panels/pool/html.hbs @@ -0,0 +1,23 @@ +{{! -------------------------------------------------------------------------- }} +{{! Copyright 2002-2019, 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. }} +{{! -------------------------------------------------------------------------- }} + +
+
+
+ {{{resourcePoolCards}}} +
+
+
diff --git a/src/sunstone/public/app/tabs/hosts-tab/panels/pool/panelId.js b/src/sunstone/public/app/tabs/hosts-tab/panels/pool/panelId.js new file mode 100644 index 0000000000..4aec4bd57e --- /dev/null +++ b/src/sunstone/public/app/tabs/hosts-tab/panels/pool/panelId.js @@ -0,0 +1,19 @@ +/* -------------------------------------------------------------------------- */ +/* Copyright 2002-2019, 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 'host_pool_tab'; +}) diff --git a/src/sunstone/public/app/tabs/hosts-tab/utils/cards.js b/src/sunstone/public/app/tabs/hosts-tab/utils/cards.js new file mode 100644 index 0000000000..10e0d71c45 --- /dev/null +++ b/src/sunstone/public/app/tabs/hosts-tab/utils/cards.js @@ -0,0 +1,65 @@ +/* -------------------------------------------------------------------------- */ +/* Copyright 2002-2019, 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) { + + /* + TEMPLATES + */ + + var TemplateResourcePoolTable = require('hbs!./resource-pool-table/html'); + var TemplateResourcePoolCard = require('hbs!./resource-pool-cards/html'); + + /* + FUNCTION DEFINITIONS + */ + + var _html = function(element) { + var vCenterResourcePoolInfo = element.TEMPLATE['VCENTER_RESOURCE_POOL_INFO'] + + if (Array.isArray(vCenterResourcePoolInfo)) + this.resourcePoolItems = vCenterResourcePoolInfo; + else if (!$.isEmptyObject(vCenterResourcePoolInfo)) + this.resourcePoolItems = [vCenterResourcePoolInfo]; + else + return ""; + + var resourcePoolCards = []; + this.resourcePoolItems.forEach(function(value){ + var propertyArray = []; + for (var key in value) { + if (key !== "NAME" && value.hasOwnProperty(key)) { + propertyArray.push({ + 'key': key, + 'value': value[key] + }) + } + } + + resourcePoolCards.push({ + 'resourcePoolName': value["NAME"], + 'resourcePoolTable': TemplateResourcePoolTable({ + 'resourcePool': propertyArray + }) + }); + }); + return TemplateResourcePoolCard({'resourcePools': resourcePoolCards}); + } + + return { + 'html': _html + } +}) diff --git a/src/sunstone/public/app/tabs/hosts-tab/utils/resource-pool-cards/html.hbs b/src/sunstone/public/app/tabs/hosts-tab/utils/resource-pool-cards/html.hbs new file mode 100644 index 0000000000..0d0ac82a0a --- /dev/null +++ b/src/sunstone/public/app/tabs/hosts-tab/utils/resource-pool-cards/html.hbs @@ -0,0 +1,27 @@ +{{! -------------------------------------------------------------------------- }} +{{! Copyright 2002-2019, 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 resourcePools}} +
+ +
+{{/each}} diff --git a/src/sunstone/public/app/tabs/hosts-tab/utils/resource-pool-table/html.hbs b/src/sunstone/public/app/tabs/hosts-tab/utils/resource-pool-table/html.hbs new file mode 100644 index 0000000000..fd0d34e60a --- /dev/null +++ b/src/sunstone/public/app/tabs/hosts-tab/utils/resource-pool-table/html.hbs @@ -0,0 +1,25 @@ +{{! -------------------------------------------------------------------------- }} +{{! Copyright 2002-2019, 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 resourcePool}} + + + + + {{/each}} + +
{{key}}{{{value}}}