Skip to content

Commit 2f33208

Browse files
committed
awscomtainer modularized
1 parent 9703c7d commit 2f33208

9 files changed

Lines changed: 97 additions & 139 deletions

File tree

app/containers/AWSGraphsContainer.tsx

Lines changed: 0 additions & 135 deletions
This file was deleted.
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import React, { useContext, useEffect } from 'react';
2+
import { ApplicationContext } from '../../context/ApplicationContext';
3+
import { DashboardContext } from '../../context/DashboardContext';
4+
import { Typography } from '@material-ui/core';
5+
import { AwsContext } from '../../context/AwsContext';
6+
import './styles.scss';
7+
import { useLocation } from 'react-router-dom';
8+
import EC2GraphsComponent from './EC2GraphsComponent';
9+
import ECSGraphsComponent from './ECSGraphsComponent';
10+
import EKSGraphsComponent from './EKSGraphsComponent';
11+
12+
const AwsGraphsContainer = () => {
13+
const { app, appIndex, setIntervalID, intervalID } = useContext(ApplicationContext);
14+
const { user } = useContext(DashboardContext);
15+
const { awsAppInfo, fetchAwsData, fetchAwsEcsData, fetchAwsEksData, fetchAwsAppInfo } = useContext(AwsContext);
16+
const { state } = useLocation();
17+
const { typeOfService } = state;
18+
const [awsLive, setAwsLive] = React.useState(false);
19+
20+
useEffect(() => {
21+
if (awsLive) {
22+
const id = setInterval(() => {
23+
fetchAwsAppInfo(user, appIndex);
24+
if (typeOfService === 'AWS/EC2') {
25+
fetchAwsData(user, appIndex);
26+
}
27+
if (typeOfService === 'AWS/ECS') {
28+
fetchAwsEcsData(user, appIndex);
29+
}
30+
if (typeOfService === 'AWS/EKS') {
31+
fetchAwsEksData(user, appIndex);
32+
}
33+
}, 10000);
34+
setIntervalID(id);
35+
} else {
36+
if (intervalID) {
37+
clearInterval(intervalID);
38+
}
39+
}
40+
41+
return () => {
42+
if (intervalID) {
43+
clearInterval(intervalID);
44+
}
45+
};
46+
}, [awsLive, user, appIndex, typeOfService, fetchAwsAppInfo, fetchAwsData, fetchAwsEcsData, fetchAwsEksData, intervalID, setIntervalID]);
47+
48+
return (
49+
<div className="AWS-container">
50+
<div className="AWS-header">
51+
<Typography variant="h3">{app}</Typography>
52+
<p>Metrics for AWS Service</p>
53+
<button onClick={() => setAwsLive(!awsLive)}>
54+
{awsLive ? 'Stop Live Update' : 'Start Live Update'}
55+
</button>
56+
</div>
57+
{typeOfService === 'AWS/ECS' && <ECSGraphsComponent region={awsAppInfo.region} typeOfService={typeOfService} />}
58+
{typeOfService === 'AWS/EC2' && <EC2GraphsComponent />}
59+
{typeOfService === 'AWS/EKS' && <EKSGraphsComponent awsEksData={awsAppInfo.awsUrl} />}
60+
</div>
61+
);
62+
};
63+
64+
export default AwsGraphsContainer;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import React from 'react';
2+
import AwsEC2Graphs from '../../components/AwsEC2Graphs';
3+
4+
const EC2GraphsComponent = () => (
5+
<div className="cluster-table">
6+
<AwsEC2Graphs />
7+
</div>
8+
);
9+
10+
export default EC2GraphsComponent;
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import React from 'react';
2+
import ClusterTable from '../../components/ClusterTable';
3+
import AwsECSClusterGraphs from '../../components/AwsECSClusterGraphs';
4+
5+
const ECSGraphsComponent = ({ region, typeOfService }) => (
6+
<div className="cluster-table">
7+
<ClusterTable typeOfService={typeOfService} region={region} />
8+
<AwsECSClusterGraphs />
9+
</div>
10+
);
11+
12+
export default ECSGraphsComponent;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import React from 'react';
2+
3+
const EKSGraphsComponent = ({ awsEksData }) => (
4+
<iframe src={`${awsEksData}?orgId=1&refresh=10s&theme=light&kiosk`} width="1300" height="1300"></iframe>
5+
);
6+
7+
export default EKSGraphsComponent;

app/stylesheets/AWSGraphsContainer.scss renamed to app/containers/AWSGraphsContainer/styles.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@import './constants.scss';
1+
@import '../../stylesheets/constants.scss';
22

33
.AWS-container {
44
margin-top: 40px;

app/containers/GraphsContainer/GraphsContainer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import DockerHealthContainer from '../DockerHealthContainer';
2222

2323
import GraphNavBar from '../../components/GraphNavBar/GraphNavBar';
2424

25-
import '../../stylesheets/GraphsContainer.scss';
25+
import './styles.scss';
2626
import Inspect from '../Inspect';
2727

2828
interface Params {

app/stylesheets/GraphsContainer.scss renamed to app/containers/GraphsContainer/styles.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@import './constants.scss';
1+
@import '../../stylesheets/constants.scss';
22

33
.traceContainer {
44
display: flex;

app/containers/MainContainer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import GraphsContainer from './GraphsContainer/GraphsContainer';
99
import { DashboardContext } from '../context/DashboardContext';
1010
import SignUp from '../components/SignUp';
1111
import Login from '../components/Login';
12-
import AwsGraphsContainer from '../containers/AWSGraphsContainer';
12+
import AwsGraphsContainer from './AwsGraphsContainer/AwsGraphsContainer';
1313

1414
import '../stylesheets/MainContainer.scss';
1515

0 commit comments

Comments
 (0)