Skip to content

Commit 1e4bb46

Browse files
committed
added widget inside storage manager that shows distribution of fixed/unfixed event by storage system.
1 parent af3f297 commit 1e4bb46

File tree

8 files changed

+133
-6
lines changed

8 files changed

+133
-6
lines changed

app/controllers/ems_storage_dashboard_controller.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ def aggregate_status_data
2323
render :json => {:data => aggregate_status(params[:id])}
2424
end
2525

26+
def aggregate_event_data
27+
assert_privileges('ems_storage_show') #TODO: might be ems_event_show
28+
render :json => {:data => aggregate_event(params[:id])}
29+
end
30+
2631
private
2732

2833
def block_storage_heatmap_data(ems_id)
@@ -33,6 +38,10 @@ def aggregate_status(ems_id)
3338
EmsStorageDashboardService.new(ems_id, self, EmsStorage).aggregate_status_data
3439
end
3540

41+
def aggregate_event(ems_id)
42+
EmsStorageDashboardService.new(ems_id, self, EmsStorage).aggregate_event_data
43+
end
44+
3645
def get_session_data
3746
@layout = "ems_storage_dashboard"
3847
end

app/javascript/components/carbon-charts/stackBarChart.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react';
22
import PropTypes from 'prop-types';
33
import { StackedBarChart } from '@carbon/charts-react';
44

5-
const StackBarChartGraph = ({ data, title }) => {
5+
const StackBarChartGraph = ({ data, title, chart_options=null }) => {
66
const options = {
77
title,
88
axes: {
@@ -24,7 +24,7 @@ const StackBarChartGraph = ({ data, title }) => {
2424
};
2525

2626
return (
27-
<StackedBarChart data={data} options={options} />
27+
<StackedBarChart data={data} options={chart_options? chart_options : options} />
2828
);
2929
};
3030

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
import React, { useEffect, useState } from 'react';
2+
import PropTypes from 'prop-types';
3+
import { http } from '../../../http_api';
4+
import EmptyChart from "../emptyChart";
5+
import StackBarChartGraph from "../../carbon-charts/stackBarChart";
6+
7+
const EventChart = ({
8+
providerId, apiUrl, dataPoint1, dataPoint2, dataPointAvailable, title,
9+
}) => {
10+
const [data, setCardData] = useState({ loading: true });
11+
12+
useEffect(() => {
13+
const url = `/${apiUrl}/${providerId}`;
14+
15+
http.get(url)
16+
.then((response) => {
17+
setCardData({
18+
loading: false,
19+
vms: response.data.aggEvents ,
20+
});
21+
});
22+
}, []);
23+
if (data.loading) return null;
24+
25+
const chart_options = {
26+
title,
27+
axes: {
28+
left: {
29+
mapsTo: 'value',
30+
stacked: true,
31+
},
32+
bottom: {
33+
mapsTo: 'key',
34+
scaleType: 'labels',
35+
},
36+
},
37+
height: '400px',
38+
tooltip: {
39+
truncation: {
40+
type: 'none',
41+
},
42+
},
43+
color: {
44+
pairing: {
45+
option: 2
46+
},
47+
scale: {
48+
fixed: "#1A52F3",
49+
not_fixed: "#FF0000"
50+
}
51+
}
52+
};
53+
54+
return (
55+
<div className="card-pf card-pf-utilization">
56+
<div className="card-pf-heading">
57+
<h2 className="card-pf-title">{title}</h2>
58+
</div>
59+
<div className="card-pf-body">
60+
{(data.vms.length > 0) ? <StackBarChartGraph data={data.vms} title={title} chart_options={chart_options} />
61+
: <EmptyChart />}
62+
</div>
63+
</div>
64+
);
65+
};
66+
67+
EventChart.propTypes = {
68+
providerId: PropTypes.string.isRequired,
69+
apiUrl: PropTypes.string.isRequired,
70+
title: PropTypes.string.isRequired,
71+
};
72+
73+
export default EventChart;

app/javascript/components/provider-dashboard-charts/heat-map-chart/HeatMapChartGraph.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ const HeatMapChartGraph = ({
7474
},
7575
experimental: true,
7676
height: '400px',
77-
width: '280px',
7877
tooltip: {
7978
customHTML: heatmapCpuTooltip(data),
8079
truncation: {
@@ -108,7 +107,6 @@ const HeatMapChartGraph = ({
108107
},
109108
},
110109
height: '400px',
111-
width: '280px',
112110
tooltip: {
113111
customHTML: heatmapMemoryTooltip(data),
114112
truncation: {

app/javascript/packs/component-definitions-common.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import CopyDashboardForm from '../components/copy-dashboard-form/copy-dashboard-
3535
import DashboardWidget from '../components/dashboard-widgets/dashboard-charts';
3636
import Datastore from '../components/data-tables/datastore';
3737
import DbList from '../components/data-tables/db-list';
38+
import EventChart from "../components/provider-dashboard-charts/events-bar-chart";
3839
import FlavorForm from '../components/flavor-form';
3940
import FilterDropdown from '../components/filter-dropdown';
4041
import FirmwareRegistryForm from '../components/firmware-registry/firmware-registry-form';
@@ -167,6 +168,7 @@ ManageIQ.component.addReact('CopyDashboardForm', CopyDashboardForm);
167168
ManageIQ.component.addReact('DashboardWidget', DashboardWidget);
168169
ManageIQ.component.addReact('Datastore', Datastore);
169170
ManageIQ.component.addReact('DbList', DbList);
171+
ManageIQ.component.addReact('EventChart', EventChart);
170172
ManageIQ.component.addReact('FirmwareRegistryForm', FirmwareRegistryForm);
171173
ManageIQ.component.addReact('FlavorForm', FlavorForm);
172174
ManageIQ.component.addReact('FilterDropdown', FilterDropdown);

app/services/ems_storage_dashboard_service.rb

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ def aggregate_status_data
1111
}.compact
1212
end
1313

14+
def aggregate_event_data
15+
{
16+
:aggEvents => agg_events
17+
}.compact
18+
end
19+
1420
def aggregate_status
1521
{
1622
:quadicon => @controller.instance_exec(@ems, &EmsStorageDashboardService.quadicon_calc),
@@ -71,7 +77,6 @@ def get_physical_storages_ids
7177

7278
def heatmaps
7379
resource_usage = []
74-
7580
@ems.physical_storages.each do |system|
7681
system.storage_resources.each do |resource|
7782
resource_usage << {
@@ -90,4 +95,40 @@ def heatmaps
9095
:title => 'Used capacity [%]'
9196
}
9297
end
98+
99+
def agg_events
100+
event_hash = Hash.new
101+
event_list = []
102+
events = EmsEvent.where("ems_id=#{@ems_id}")
103+
# events = EmsEvent.where("ems_id=#{@ems_id}", "event_type LIKE 'autosde_critical_alert%'")
104+
105+
events.each do |event|
106+
unless event_hash[event.physical_storage_name]
107+
event_hash[event.physical_storage_name] = { :fixed => 0, :not_fixed => 0}
108+
end
109+
end
110+
111+
events.each do |event|
112+
if event.event_type == "autosde_critical_alert_fixed"
113+
event_hash[event.physical_storage_name][:fixed] = event_hash[event.physical_storage_name][:fixed] + 1
114+
else
115+
event_hash[event.physical_storage_name][:not_fixed] = event_hash[event.physical_storage_name][:not_fixed] + 1
116+
end
117+
end
118+
119+
event_hash.each_pair do |key, value|
120+
event_list << {
121+
:group => "fixed",
122+
:key => key,
123+
:value => value[:fixed]
124+
}
125+
event_list << {
126+
:group => "not_fixed",
127+
:key => key,
128+
:value => value[:not_fixed]
129+
}
130+
end
131+
132+
event_list.to_a
133+
end
93134
end

app/views/ems_storage/_show_block_storage_dashboard.html.haml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
.row.row-tile-pf
66
.col-xs-12.col-sm-12.col-md-6
77
= react('HeatChart', :providerId => @record.id.to_s,
8-
:apiUrl => 'ems_storage_dashboard/resources_capacity_data', :dataPoint1 => 'resourceUsage', :dataPointAvailable => false, :title => _('Used capacity [%]'))
8+
:apiUrl => 'ems_storage_dashboard/resources_capacity_data', :dataPoint1 => 'resourceUsage', :dataPointAvailable => false, :title => _('Used Capacity [%]'))
9+
.col-xs-12.col-sm-12.col-md-6
10+
= react('EventChart', :providerId => @record.id.to_s, :apiUrl => 'ems_storage_dashboard/aggregate_event_data',:title => ('Fixed vs Not-Fixed Events By Storage-System') )
911

1012
:javascript
1113
ManageIQ.angular.app.value('providerId', '#{@record.id}');

config/routes.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@
119119
show
120120
aggregate_status_data
121121
resources_capacity_data
122+
aggregate_event_data
122123
]
123124
},
124125

@@ -134,6 +135,7 @@
134135
tagging_edit
135136
download_private_key
136137
ownership
138+
137139
) +
138140
compare_get,
139141
:post => %w(

0 commit comments

Comments
 (0)