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 bed7dc31a95..6328c5ed05d 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 d9efa9cb0dd..b7c2bb19b0f 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,10 @@ 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 8cc827738a7..6e2d004c9d1 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 => openstack? ? _('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 => openstack? ? _('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,16 @@ def status :href => get_url_to_entity(:miq_template) } } + unless openstack? + status_hsh[:datastores] = { + :count => @ems.present? ? @ems.storages.count : Storage.count, + :errorCount => 0, + :warningCount => 0, + :href => get_url_to_entity(:storage) + } + end + + status_hsh end def providers @@ -124,42 +130,42 @@ def heatmaps { :clusterCpuUsage => cluster_cpu_usage.presence, - :clusterMemoryUsage => cluster_memory_usage.presence + :clusterMemoryUsage => cluster_memory_usage.presence, + :title => openstack? ? _('Deplyoment Roles Utilization') : _('Cluster Utilization') } end def recentHosts # Get recent hosts - all_hosts = Hash.new(0) - hosts = Host.where('created_on > ? and ems_id = ?', 30.days.ago.utc, @ems.id) - hosts = hosts.includes(:resource => [:ext_management_system]) unless @ems.present? - hosts.sort_by { |h| h.created_on }.uniq.each do |h| - date = h.created_on.strftime("%Y-%m-%d") - all_hosts[date] += Host.where('created_on = ?', h.created_on).count - end - - { + all_hosts = recentRecords(Host) + { :xData => all_hosts.keys, - :yData => all_hosts.values.map + :yData => all_hosts.values.map, + :title => openstack? ? _('Recent Nodes') : _('Recent Hosts'), + :label => openstack? ? _('Nodes') : _('Hosts'), } end def recentVms # Get recent VMs - all_vms = Hash.new(0) - vms = VmOrTemplate.where('created_on > ? and ems_id = ?', 30.days.ago.utc, @ems.id) - vms = vms.includes(:resource => [:ext_management_system]) unless @ems.present? - vms.sort_by { |v| v.created_on }.uniq.each do |v| - date = v.created_on.strftime("%Y-%m-%d") - all_vms[date] += VmOrTemplate.where('created_on = ?', v.created_on).count - end - + all_vms = recentRecords(VmOrTemplate) { :xData => all_vms.keys, :yData => all_vms.values.map } end + def recentRecords(model) + all_records = Hash.new(0) + records = model.where('created_on > ? and ems_id = ?', 30.days.ago.utc, @ems.id) + records = records.includes(:resource => [:ext_management_system]) unless @ems.present? + records.sort_by { |r| r.created_on }.uniq.each do |r| + date = r.created_on.strftime("%Y-%m-%d") + all_records[date] += model.where('created_on = ?', r.created_on).count + end + all_records + end + def ems_utilization used_cpu = Hash.new(0) used_mem = Hash.new(0) @@ -205,4 +211,8 @@ def daily_provider_metrics .where(:resource => (@ems || ManageIQ::Providers::InfraManager.all)) .where('timestamp > ?', 30000.days.ago.utc).order('timestamp') end + + def openstack? + @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 cd9c089d048..5ddc3b4861e 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 75cd3f0597d..78f94184d45 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 fb49412d7dc..ca53c522adc 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,