Skip to content

Commit 7af63fd

Browse files
committed
moved styles associated with aws charts to component folders
1 parent 4f8c54c commit 7af63fd

7 files changed

Lines changed: 47 additions & 50 deletions

File tree

app/charts/AwsChart.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ interface SoloStyles {
2626
const AwsChart: React.FC<any> = React.memo(props => {
2727
const { renderService, metric, timeList, valueList, colourGenerator, sizing } = props;
2828
const [solo, setSolo] = useState<SoloStyles | null>(null);
29+
2930
setInterval(() => {
3031
if (solo !== soloStyle) {
3132
setSolo(soloStyle);

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

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

79
const AwsEC2Graphs: React.FC = React.memo(props => {
810
const { awsData, setAwsData, isLoading, setLoadingState } = useContext(AwsContext);
@@ -14,24 +16,6 @@ const AwsEC2Graphs: React.FC = React.memo(props => {
1416
};
1517
}, []);
1618

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-
3519
return (
3620
<div className="charts">
3721
{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/containers/AWSGraphsContainer/AWSGraphsContainer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Typography } from '@mui/material';
55
import { AwsContext } from '../../context/AwsContext';
66
import './styles.scss';
77
import { useLocation } from 'react-router-dom';
8-
import AwsEC2Graphs from '../../components/AwsEC2Graphs';
8+
import AwsEC2Graphs from '../../components/AwsEC2Graphs/AwsEC2Graphs';
99
import ClusterTable from '../../components/ClusterTable';
1010
import AwsECSClusterGraphs from '../../components/AwsECSClusterGraphs';
1111

app/containers/AWSGraphsContainer/styles.scss

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,16 @@
2424
}
2525
}
2626

27-
.charts {
28-
display: grid;
29-
grid-template-columns: auto auto;
30-
padding: 10px;
31-
}
32-
33-
.chart {
34-
margin: 10px;
35-
text-align: center;
36-
}
27+
// .charts {
28+
// display: grid;
29+
// grid-template-columns: auto auto;
30+
// padding: 10px;
31+
// }
32+
33+
// .chart {
34+
// margin: 10px;
35+
// text-align: center;
36+
// }
3737

3838
.js-plotly-plot {
3939
box-shadow: $boxshadow;

app/utils/index.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
2+
3+
export const stringToColor = (string: string, recurses = 0) => {
4+
if (recurses > 20) return string;
5+
function hashString(str: string) {
6+
let hash = 0;
7+
for (let i = 0; i < str.length; i++) {
8+
hash = str.charCodeAt(i) + ((hash << 5) - hash);
9+
}
10+
let colour = '#';
11+
for (let i = 0; i < 3; i++) {
12+
const value = (hash >> (i * 8)) & 0xff;
13+
colour += `00${value.toString(16)}`.substring(-2);
14+
}
15+
16+
// console.log(colour);
17+
return colour;
18+
}
19+
};

0 commit comments

Comments
 (0)