Skip to content

Commit a0bb75c

Browse files
committed
Merge branch 'dev' into stephenfeature
2 parents be9b24f + c25bf35 commit a0bb75c

File tree

16 files changed

+119
-149
lines changed

16 files changed

+119
-149
lines changed

app/charts/AwsChart.tsx

Lines changed: 27 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,20 @@ import React, { useState } from 'react';
33
import Plot from 'react-plotly.js';
44
import { all, solo as soloStyle } from './sizeSwitch';
55

6-
// interface AwsCpuChartProps {
7-
// key: string;
8-
// renderService: string;
9-
// metric: string;
10-
// timeList: any;
11-
// valueList: any;
12-
// sizing: string;
13-
// colourGenerator: Function;
14-
// }
15-
166
interface SoloStyles {
177
height: number;
188
width: number;
199
}
2010

11+
interface IPlotlyData {
12+
name: any;
13+
x: any;
14+
y: any;
15+
type: any;
16+
mode: any;
17+
marker: { color: string };
18+
}
19+
2120
/**
2221
* @params props - the props object containing relevant data.
2322
* @desc Handles AWS Charts. Memoized component to generate an AWS chart with formatted data.
@@ -26,34 +25,31 @@ interface SoloStyles {
2625
const AwsChart: React.FC<any> = React.memo(props => {
2726
const { renderService, metric, timeList, valueList, colourGenerator, sizing } = props;
2827
const [solo, setSolo] = useState<SoloStyles | null>(null);
28+
2929
setInterval(() => {
3030
if (solo !== soloStyle) {
3131
setSolo(soloStyle);
3232
}
3333
}, 20);
3434

35-
const createChart = () => {
36-
const timeArr = timeList?.map((el: any) => moment(el).format('kk:mm:ss'));
37-
// const hashedColour = colourGenerator(renderService);
38-
let plotlyData: {
39-
name: any;
40-
x: any;
41-
y: any;
42-
type: any;
43-
mode: any;
44-
marker: { color: string };
45-
};
46-
plotlyData = {
47-
name: metric,
48-
x: timeArr,
49-
y: valueList,
50-
type: 'scattergl',
51-
mode: 'lines',
52-
marker: { color: colourGenerator() },
53-
};
54-
const sizeSwitch = sizing === 'all' ? all : solo;
35+
const timeArr = timeList?.map((el: any) => moment(el).format('kk:mm:ss'));
36+
37+
let plotlyData:IPlotlyData= {
38+
name: metric,
39+
x: timeArr,
40+
y: valueList,
41+
type: 'scattergl',
42+
mode: 'lines',
43+
marker: { color: colourGenerator() },
44+
};
5545

56-
return (
46+
const sizeSwitch = sizing === 'all' ? all : solo;
47+
48+
return (
49+
<div
50+
className="chart"
51+
data-testid="Health Chart"
52+
>
5753
<Plot
5854
data={[plotlyData]}
5955
config={{ displayModeBar: false }}
@@ -90,12 +86,6 @@ const AwsChart: React.FC<any> = React.memo(props => {
9086
},
9187
}}
9288
/>
93-
);
94-
};
95-
96-
return (
97-
<div className="chart" data-testid="Health Chart">
98-
{createChart()}
9989
</div>
10090
);
10191
});

app/components/ApplicationsCard/EventHandlers.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,25 @@ interface EventHandlersProps {
1212

1313
export const getEventHandlers = ({ application, setModal }: EventHandlersProps) => {
1414
const { deleteApp, user } = useContext(DashboardContext);
15-
const { setAppIndex, setApp, setServicesData, app, example, connectToDB, setChart } =
16-
useContext(ApplicationContext);
15+
const { setAppIndex, setApp, setServicesData, app, example, connectToDB, setChart } = useContext(ApplicationContext);
1716
const navigate = useNavigate();
1817

1918
const handleClick = (selectedApp: string, selectedService: string, i: number) => {
20-
const services = ['auth', 'client', 'event-bus', 'items', 'inventory', 'orders'];
19+
// const services = ['auth', 'client', 'event-bus', 'items', 'inventory', 'orders'];
20+
const services = [ 'client', 'items','event-bus'];
21+
2122
setAppIndex(i);
2223
setApp(selectedApp);
2324
if (['AWS', 'AWS/EC2', 'AWS/ECS', 'AWS/EKS'].includes(selectedService)) {
2425
navigate(`/aws/:${app}`, { state: { typeOfService: selectedService } });
25-
} else if (example) {
26+
}
27+
else if (example) {
2628
setServicesData([]);
27-
setChart('communications');
29+
setChart('all');
2830
connectToDB(user, i, app, application[2], application[1]);
2931
navigate(`/applications/example/${services.join(' ')}`);
30-
} else {
32+
}
33+
else {
3134
setServicesData([]);
3235
setModal({ isOpen: true, type: 'serviceModal' });
3336
}

app/components/AwsEC2Graphs.tsx renamed to app/components/AwsEC2Graphs/AwsEC2Graphs.tsx

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import React, { useContext, useEffect, useState } from 'react';
2-
import AwsChart from '../charts/AwsChart';
3-
import { AwsContext } from '../context/AwsContext';
4-
import { CircularProgress } from '@mui/material';
5-
// import zIndex from '@mui/styles/zIndex';
2+
import AwsChart from '../../charts/AwsChart';
3+
import { AwsContext } from '../../context/AwsContext';
4+
import { stringToColor } from '../../utils';
5+
import './styles.scss'
66

77
const AwsEC2Graphs: React.FC = React.memo(props => {
88
const { awsData, setAwsData, isLoading, setLoadingState } = useContext(AwsContext);
@@ -14,24 +14,6 @@ const AwsEC2Graphs: React.FC = React.memo(props => {
1414
};
1515
}, []);
1616

17-
const stringToColor = (string: string, recurses = 0) => {
18-
if (recurses > 20) return string;
19-
function hashString(str: string) {
20-
let hash = 0;
21-
for (let i = 0; i < str.length; i++) {
22-
hash = str.charCodeAt(i) + ((hash << 5) - hash);
23-
}
24-
let colour = '#';
25-
for (let i = 0; i < 3; i++) {
26-
const value = (hash >> (i * 8)) & 0xff;
27-
colour += `00${value.toString(16)}`.substring(-2);
28-
}
29-
30-
// console.log(colour);
31-
return colour;
32-
}
33-
};
34-
3517
return (
3618
<div className="charts">
3719
{Object.keys(awsData)?.map(metric => {
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.charts {
2+
display: grid;
3+
grid-template-columns: auto auto;
4+
padding: 10px;
5+
}
6+
7+
.chart {
8+
margin: 10px;
9+
text-align: center;
10+
}

app/components/AwsECSClusterGraphs.tsx

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React, { useContext, useEffect } from 'react';
22
import AwsChart from '../charts/AwsChart';
3+
import { stringToColor } from '../utils';
34
import { AwsContext } from '../context/AwsContext';
45

56
const AwsECSClusterGraphs: React.FC = React.memo(props => {
@@ -12,24 +13,6 @@ const AwsECSClusterGraphs: React.FC = React.memo(props => {
1213
};
1314
}, []);
1415

15-
const stringToColor = (string: string, recurses = 0) => {
16-
if (recurses > 20) return string;
17-
function hashString(str: string) {
18-
let hash = 0;
19-
for (let i = 0; i < str.length; i++) {
20-
hash = str.charCodeAt(i) + ((hash << 5) - hash);
21-
}
22-
let colour = '#';
23-
for (let i = 0; i < 3; i++) {
24-
const value = (hash >> (i * 8)) & 0xff;
25-
colour += `00${value.toString(16)}`.substring(-2);
26-
}
27-
28-
// console.log(colour);
29-
return colour;
30-
}
31-
};
32-
3316
const activeServices = Object.keys(awsEcsData)
3417
.slice(1)
3518
.filter(el => awsEcsData[el].CPUUtilization?.value.length > 0);

app/components/TransferColumns.tsx

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ interface Params {
1919

2020
const TransferColumns = React.memo(() => {
2121
const [targetKeys, setTargetKeys] = useState<any[]>([]);
22-
// console.log({targetKeys})
2322
const [metricsPool, setMetricsPool] = useState<any[]>([]);
24-
// console.log({metricsPool})
2523
const [healthMetricsReady, setHealthMetricsReady] = useState(false);
2624
const [healthMetrics, setHealthMetrics] = useState<any[]>([]);
2725
const [eventMetricsReady, setEventMetricsReady] = useState(false);
@@ -155,7 +153,6 @@ const TransferColumns = React.memo(() => {
155153
temp.push(newCategory);
156154
}
157155
}
158-
// console.log('temp', temp)
159156
setSelectedMetrics(temp);
160157
};
161158

@@ -182,7 +179,6 @@ const TransferColumns = React.memo(() => {
182179
const rows:any[] = []
183180
let id = 0
184181
for(let savedMetric of Object.keys(savedMetrics)) {
185-
186182
const { metric,category } = savedMetrics[savedMetric]
187183
rows.push({
188184
id:id++,
@@ -207,8 +203,6 @@ const TransferColumns = React.memo(() => {
207203
);
208204
});
209205

210-
//! BZ: creates metrics query page in Chronos
211-
212206
return (
213207
<>
214208
<div id="getChartsContainer">
@@ -249,30 +243,25 @@ const TransferColumns = React.memo(() => {
249243
}}
250244
>
251245
<DataGrid
252-
// style={currentStyle }
253246
rows={rows}
254247
columns={columns}
255248
style={currentStyle}
256249
slots={{ toolbar: GridToolbar }}
257250
slotProps={{
258251
toolbar: {
259252
showQuickFilter: true,
260-
261-
262253
},
263254
}}
264-
pageSizeOptions ={[10]}
255+
pageSizeOptions={[10]}
265256
checkboxSelection
266257
disableRowSelectionOnClick
267258
onRowSelectionModelChange={metricIndeces => {
268259
const metrics: any[] = [];
269260
metricIndeces.forEach(el => {
270-
console.log({rows})
271261
metrics.push(`${rows[el].tag} | ${rows[el].title}`);
272262
});
273263
setTargetKeys(metrics);
274264
}}
275-
276265
/>
277266
</Box>
278267

app/containers/AWSGraphsContainer/AWSGraphsContainer.tsx

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,14 @@ import { Typography } from '@mui/material';
55
import { AwsContext } from '../../context/AwsContext';
66
import './styles.scss';
77
import { useLocation } from 'react-router-dom';
8-
import EC2GraphsComponent from './EC2GraphsComponent';
9-
import ECSGraphsComponent from './ECSGraphsComponent';
10-
import EKSGraphsComponent from './EKSGraphsComponent';
8+
import AwsEC2Graphs from '../../components/AwsEC2Graphs/AwsEC2Graphs';
9+
import ClusterTable from '../../components/ClusterTable';
10+
import AwsECSClusterGraphs from '../../components/AwsECSClusterGraphs';
1111

1212
const AwsGraphsContainer = () => {
1313
const { app, appIndex, setIntervalID, intervalID } = useContext(ApplicationContext);
1414
const { user } = useContext(DashboardContext);
15-
const { awsAppInfo, fetchAwsData, fetchAwsEcsData, fetchAwsEksData, fetchAwsAppInfo } =
16-
useContext(AwsContext);
15+
const { awsAppInfo, fetchAwsData, fetchAwsEcsData, fetchAwsEksData, fetchAwsAppInfo } = useContext(AwsContext);
1716
const { state } = useLocation();
1817
const { typeOfService } = state;
1918
const [awsLive, setAwsLive] = React.useState(false);
@@ -59,18 +58,44 @@ const AwsGraphsContainer = () => {
5958

6059
return (
6160
<div className="AWS-container">
61+
6262
<div className="AWS-header">
63-
<Typography variant="h3">{app}</Typography>
63+
<Typography
64+
variant="h3"
65+
>
66+
{app}
67+
</Typography>
6468
<p>Metrics for AWS Service</p>
65-
<button onClick={() => setAwsLive(!awsLive)}>
69+
<button
70+
onClick={() => setAwsLive(!awsLive)}
71+
>
6672
{awsLive ? 'Stop Live Update' : 'Start Live Update'}
6773
</button>
6874
</div>
75+
6976
{typeOfService === 'AWS/ECS' && (
70-
<ECSGraphsComponent region={awsAppInfo.region} typeOfService={typeOfService} />
77+
<div className="cluster-table">
78+
<ClusterTable
79+
typeOfService={typeOfService}
80+
region={awsAppInfo.region}
81+
/>
82+
<AwsECSClusterGraphs />
83+
</div>
7184
)}
72-
{typeOfService === 'AWS/EC2' && <EC2GraphsComponent />}
73-
{typeOfService === 'AWS/EKS' && <EKSGraphsComponent awsEksData={awsAppInfo.awsUrl} />}
85+
86+
{typeOfService === 'AWS/EC2' &&
87+
<div className="cluster-table">
88+
<AwsEC2Graphs />
89+
</div>
90+
}
91+
92+
{typeOfService === 'AWS/EKS' &&
93+
<iframe
94+
src={`${awsAppInfo.awsUrl}?orgId=1&refresh=10s&theme=light&kiosk`}
95+
width="1300"
96+
height="1300"
97+
></iframe>
98+
}
7499
</div>
75100
);
76101
};

app/containers/AWSGraphsContainer/EC2GraphsComponent.tsx

Lines changed: 0 additions & 10 deletions
This file was deleted.

app/containers/AWSGraphsContainer/ECSGraphsComponent.tsx

Lines changed: 0 additions & 12 deletions
This file was deleted.

app/containers/AWSGraphsContainer/EKSGraphsComponent.tsx

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)