From 75032b54908864ac84b8dbb0ca1417731b1c12d5 Mon Sep 17 00:00:00 2001 From: Harpreet Kataria Date: Fri, 16 Jun 2017 12:33:20 -0400 Subject: [PATCH] Fixed titles and labels for Hosts & Clusters Openstack Providers - Changed to show Nodes/Deployment Roles as titles for Hosts/Clusters for Openstack Dashboards charts where appropriate on screen. - Removed Datastores count chart for Openstack Provider. https://bugzilla.redhat.com/show_bug.cgi?id=1430241 --- .../ems_infra_dashboard_controller.js | 3 ++ .../util/infra-dashboard-utils-factory.js | 5 ++-- app/services/ems_infra_dashboard_service.rb | 30 +++++++++++++------ app/views/ems_infra/_show_dashboard.html.haml | 15 +++++----- .../ems_infra_dashboard_no_data_response.json | 10 +++++++ .../json/ems_infra_dashboard_response.json | 10 +++++++ 6 files changed, 55 insertions(+), 18 deletions(-) diff --git a/app/assets/javascripts/controllers/ems_infra_dashboard/ems_infra_dashboard_controller.js b/app/assets/javascripts/controllers/ems_infra_dashboard/ems_infra_dashboard_controller.js index bed7dc31a95b..897e8bcb0adb 100644 --- a/app/assets/javascripts/controllers/ems_infra_dashboard/ems_infra_dashboard_controller.js +++ b/app/assets/javascripts/controllers/ems_infra_dashboard/ems_infra_dashboard_controller.js @@ -122,12 +122,15 @@ $scope.clusterCpuUsage = infraChartsMixin.processHeatmapData($scope.clusterCpuUsage, data.heatmaps.clusterCpuUsage); $scope.clusterCpuUsage.loadingDone = true; + $scope.clusterChartTitle = data.heatmaps.title; $scope.clusterMemoryUsage = infraChartsMixin.processHeatmapData($scope.clusterMemoryUsage, data.heatmaps.clusterMemoryUsage); $scope.clusterMemoryUsage.loadingDone = true; // Recent Hosts $scope.recentHostsConfig = infraChartsMixin.chartConfig.recentHostsConfig; + $scope.recentHostsConfig.headTitle = data.recentHosts.title + $scope.recentHostsConfig.label = data.recentHosts.label // recent Hosts chart $scope.recentHostsData = infraChartsMixin.processRecentHostsData(data.recentHosts, diff --git a/app/assets/javascripts/controllers/ems_infra_dashboard/util/infra-dashboard-utils-factory.js b/app/assets/javascripts/controllers/ems_infra_dashboard/util/infra-dashboard-utils-factory.js index d9efa9cb0dd7..4814aba78e43 100644 --- a/app/assets/javascripts/controllers/ems_infra_dashboard/util/infra-dashboard-utils-factory.js +++ b/app/assets/javascripts/controllers/ems_infra_dashboard/util/infra-dashboard-utils-factory.js @@ -8,7 +8,6 @@ angular.module('miq.util').factory('infraDashboardUtilsFactory', function() { }; var createClustersStatus = function() { return { - title: __("Clusters"), iconClass: " pficon pficon-cluster", count: 0, notification: {} @@ -16,7 +15,6 @@ angular.module('miq.util').factory('infraDashboardUtilsFactory', function() { }; var createHostsStatus = function() { return { - title: __("Hosts"), iconClass: "pficon pficon-screen", count: 0, notification: {} @@ -51,6 +49,9 @@ angular.module('miq.util').factory('infraDashboardUtilsFactory', function() { statusObject.notification = {}; if (data) { statusObject.count = data.count; + if (data.title) + statusObject.title = data.title; + if (data.errorCount > 0) { statusObject.notification = { iconClass: "pficon pficon-error-circle-o", diff --git a/app/services/ems_infra_dashboard_service.rb b/app/services/ems_infra_dashboard_service.rb index 8cc827738a79..b62ed0ef2636 100644 --- a/app/services/ems_infra_dashboard_service.rb +++ b/app/services/ems_infra_dashboard_service.rb @@ -21,25 +21,21 @@ def all_data end def status - { + status_hsh = { :ems_clusters => { + :title => is_opensatck? ? _('Deplyoment Roles') : _('Cluster'), :count => @ems.present? ? @ems.ems_clusters.count : EmsCluster.count, :errorCount => 0, :warningCount => 0, :href => get_url_to_entity(:ems_cluster) }, :hosts => { + :title => is_opensatck? ? _('Nodes') : _('Hosts'), :count => @ems.present? ? @ems.hosts.count : Host.where.not(:ext_management_system => nil).count, :errorCount => 0, :warningCount => 0, :href => get_url_to_entity(:host) }, - :datastores => { - :count => @ems.present? ? @ems.storages.count : Storage.count, - :errorCount => 0, - :warningCount => 0, - :href => get_url_to_entity(:storage) - }, :vms => { :count => @ems.present? ? @ems.vms.count : VmInfra.where.not(:ext_management_system => nil).count, :errorCount => 0, @@ -54,6 +50,15 @@ def status :href => get_url_to_entity(:miq_template) } } + + status_hsh[:datastores] = { + :count => @ems.present? ? @ems.storages.count : Storage.count, + :errorCount => 0, + :warningCount => 0, + :href => get_url_to_entity(:storage) + } unless is_opensatck? + + status_hsh end def providers @@ -124,7 +129,8 @@ def heatmaps { :clusterCpuUsage => cluster_cpu_usage.presence, - :clusterMemoryUsage => cluster_memory_usage.presence + :clusterMemoryUsage => cluster_memory_usage.presence, + :title => is_opensatck? ? _('Deplyoment Roles Utilization') : _('Cluster Utilization') } end @@ -140,7 +146,9 @@ def recentHosts { :xData => all_hosts.keys, - :yData => all_hosts.values.map + :yData => all_hosts.values.map, + :title => is_opensatck? ? _('Recent Nodes') : _('Recent Hosts'), + :label => is_opensatck? ? _('Nodes') : _('Hosts'), } end @@ -205,4 +213,8 @@ def daily_provider_metrics .where(:resource => (@ems || ManageIQ::Providers::InfraManager.all)) .where('timestamp > ?', 30000.days.ago.utc).order('timestamp') end + + def is_opensatck? + @ems.kind_of?(ManageIQ::Providers::Openstack::InfraManager) + end end diff --git a/app/views/ems_infra/_show_dashboard.html.haml b/app/views/ems_infra/_show_dashboard.html.haml index cd9c089d0486..5ddc3b4861e9 100644 --- a/app/views/ems_infra/_show_dashboard.html.haml +++ b/app/views/ems_infra/_show_dashboard.html.haml @@ -20,12 +20,13 @@ "show-top-border" => "true", :status => "objectStatus.hosts", :url => "navigation"} - .col-xs-6.col-sm-6.col-md-3 - %div{:layout => "mini", - "pf-aggregate-status-card" => "", - "show-top-border" => "true", - :status => "objectStatus.datastores", - :url => "navigation"} + - unless @ems.kind_of?(ManageIQ::Providers::Openstack::InfraManager) + .col-xs-6.col-sm-6.col-md-3 + %div{:layout => "mini", + "pf-aggregate-status-card" => "", + "show-top-border" => "true", + :status => "objectStatus.datastores", + :url => "navigation"} .col-xs-6.col-sm-6.col-md-3 %div{:layout => "mini", "pf-aggregate-status-card" => "", @@ -75,7 +76,7 @@ :heatmaps => "heatmaps", "heatmaps-card" => "", :hidetopborder => "true", - :title => _("Cluster Utilization")} + "title" => "{{clusterChartTitle}}"} .row.row-tile-pf.row-tile-pf-last .col-xs-12.col-sm-6.col-md-6 %div{"head-title" => "{{recentHostsConfig.headTitle}}", diff --git a/spec/javascripts/fixtures/json/ems_infra_dashboard_no_data_response.json b/spec/javascripts/fixtures/json/ems_infra_dashboard_no_data_response.json index 75cd3f0597dd..78f94184d451 100644 --- a/spec/javascripts/fixtures/json/ems_infra_dashboard_no_data_response.json +++ b/spec/javascripts/fixtures/json/ems_infra_dashboard_no_data_response.json @@ -31,6 +31,16 @@ "clusterCpuUsage": null, "clusterMemoryUsage": null }, + "recentHosts": { + "title": "Recent Hosts", + "label": "hosts", + "xData": [ + "2015-11-26" + ], + "yData": [ + 3 + ] + }, "providers": [ { "count": 1, diff --git a/spec/javascripts/fixtures/json/ems_infra_dashboard_response.json b/spec/javascripts/fixtures/json/ems_infra_dashboard_response.json index fb49412d7dc0..ca53c522adcb 100644 --- a/spec/javascripts/fixtures/json/ems_infra_dashboard_response.json +++ b/spec/javascripts/fixtures/json/ems_infra_dashboard_response.json @@ -47,6 +47,16 @@ } ] }, + "recentHosts": { + "title": "Recent Hosts", + "label": "hosts", + "xData": [ + "2015-11-26" + ], + "yData": [ + 3 + ] + }, "providers": [ { "count": 1,