Skip to content

Commit 323fd80

Browse files
committed
final changes to dev branch
1 parent e366815 commit 323fd80

File tree

6 files changed

+18
-39
lines changed

6 files changed

+18
-39
lines changed

app/components/AwsEC2Graphs.tsx

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,12 @@ import { CircularProgress } from '@material-ui/core';
55
import zIndex from '@material-ui/core/styles/zIndex';
66

77
const AwsEC2Graphs: React.FC = React.memo(props => {
8-
const { awsData, setAwsData } = useContext(AwsContext);
9-
const [isLoading, setLoadingState] = useState<boolean>(true);
10-
11-
useEffect(() => {
12-
if (awsData) setLoadingState(false);
13-
}, []);
8+
const { awsData, setAwsData, isLoading, setLoadingState } = useContext(AwsContext);
149

1510
useEffect(() => {
1611
return () => {
1712
setAwsData({ CPUUtilization: [], NetworkIn: [], NetworkOut: [], DiskReadBytes: [] });
13+
setLoadingState(true);
1814
};
1915
}, []);
2016

@@ -38,28 +34,13 @@ const AwsEC2Graphs: React.FC = React.memo(props => {
3834

3935
return (
4036
<div className="charts">
41-
{isLoading && (
42-
<div
43-
style={{
44-
display: 'flex',
45-
width: 100,
46-
height: 100,
47-
justifyContent: 'center',
48-
position: 'absolute',
49-
alignItems: 'center',
50-
zIndex: 50,
51-
}}
52-
>
53-
<CircularProgress />
54-
</div>
55-
)}
5637
{Object.keys(awsData)?.map(metric => {
5738
return (
5839
<AwsChart
5940
className="chart"
6041
key={`Chart${metric}`}
61-
renderService={metric}
62-
metric={awsData[metric][0]?.unit}
42+
renderService={isLoading? 'Loading...' : metric}
43+
metric={isLoading ? '' : awsData[metric][0]?.unit}
6344
timeList={awsData[metric]?.map(el => el.time)}
6445
valueList={awsData[metric]?.map(el => el.value)}
6546
colourGenerator={stringToColor}

app/components/AwsECSClusterGraphs.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ import AwsChart from '../charts/AwsChart';
33
import { AwsContext } from '../context/AwsContext';
44

55
const AwsECSClusterGraphs: React.FC = React.memo(props => {
6-
const { awsEcsData, setAwsEcsData } = useContext(AwsContext);
6+
const { awsEcsData, setAwsEcsData, setLoadingState } = useContext(AwsContext);
77

88
useEffect(() => {
99
return () => {
1010
setAwsEcsData({});
11+
setLoadingState(true);
1112
};
1213
}, []);
1314

app/components/ClusterTable.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import {
1010
} from '@material-ui/core';
1111
import { makeStyles } from '@material-ui/core/styles';
1212
import { AwsContext } from '../context/AwsContext';
13-
import cluster from 'cluster';
1413

1514
const useStyles = makeStyles({
1615
table: {
@@ -77,7 +76,7 @@ const ClusterTable: React.FC<ClusterTableProps> = React.memo(({ region }) => {
7776
{isLoading ? 'Loading...' : Object.keys(awsEcsData).length - 1}
7877
</TableCell>
7978
<TableCell className={classes.body}>
80-
{String(activeServices().length) + '/' + String(Object.keys(awsEcsData).length - 1)}
79+
{isLoading ? 'Loading...' : String(activeServices().length) + '/' + String(Object.keys(awsEcsData).length - 1)}
8180
</TableCell>
8281
</TableBody>
8382
</Table>

app/components/Occupied.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ interface StyleProps {
5757
type ClickEvent = React.MouseEvent<HTMLElement>;
5858

5959
const Occupied = React.memo(() => {
60-
const { awsData, fetchAwsData, fetchAwsAppInfo } = useContext(AwsContext);
60+
const { awsData, fetchAwsData, fetchAwsAppInfo, setLoadingState } = useContext(AwsContext);
6161
const { setServicesData, app, setApp } = useContext(ApplicationContext);
6262
const { user, applications, getApplications, deleteApp, mode } = useContext(DashboardContext);
6363
const { commsData } = useContext(CommsContext);

app/containers/SidebarContainer.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,16 @@ import SettingsIcon from '@material-ui/icons/Settings';
88

99
import '../stylesheets/SidebarContainer.scss';
1010
import { ApplicationContext } from '../context/ApplicationContext';
11+
import { AwsContext } from '../context/AwsContext';
1112

1213
const SidebarContainer = React.memo(props => {
1314
const { intervalID } = useContext(ApplicationContext);
15+
const { isLoading, setLoadingState } = useContext(AwsContext);
1416

15-
//stopInterval button -> clear interval when leaving graph containers
16-
const stopIntervalOnClick = () => {
17+
// clear interval and set loading state to true when leaving graph containers
18+
const handleClick = () => {
1719
if(intervalID) clearInterval(intervalID);
20+
if(!isLoading) setLoadingState(true);
1821
}
1922

2023
return (
@@ -30,7 +33,7 @@ const SidebarContainer = React.memo(props => {
3033
</div>
3134
<hr className="line" id="firstLine" />
3235
<div className="thirdRow">
33-
<Link className="sidebar-link" to="/" id="dash" onClick={stopIntervalOnClick}>
36+
<Link className="sidebar-link" to="/" id="dash" onClick={handleClick}>
3437
<ListIcon
3538
style={{
3639
WebkitBoxSizing: 'content-box',
@@ -41,7 +44,7 @@ const SidebarContainer = React.memo(props => {
4144
/>
4245
&emsp;Dashboard
4346
</Link>
44-
<Link className="sidebar-link" to="/settings" id="settings" onClick={stopIntervalOnClick}>
47+
<Link className="sidebar-link" to="/settings" id="settings" onClick={handleClick}>
4548
<SettingsIcon
4649
style={{
4750
WebkitBoxSizing: 'content-box',
@@ -52,7 +55,7 @@ const SidebarContainer = React.memo(props => {
5255
/>
5356
&emsp;Settings
5457
</Link>
55-
<Link className="sidebar-link" to="/about" id="about" onClick={stopIntervalOnClick}>
58+
<Link className="sidebar-link" to="/about" id="about" onClick={handleClick}>
5659
<InfoIcon
5760
style={{
5861
WebkitBoxSizing: 'content-box',
@@ -63,7 +66,7 @@ const SidebarContainer = React.memo(props => {
6366
/>
6467
&emsp;About
6568
</Link>
66-
<Link className="sidebar-link" to="/contact" id="contact" onClick={stopIntervalOnClick}>
69+
<Link className="sidebar-link" to="/contact" id="contact" onClick={handleClick}>
6770
<ContactSupportIcon
6871
style={{
6972
WebkitBoxSizing: 'content-box',

app/context/AwsContext.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ const AwsContextProvider: React.FC<Props> = React.memo(({ children }) => {
3434
ipcRenderer.send('ec2MetricsRequest', username, index);
3535
ipcRenderer.on('ec2MetricsResponse', (event: Electron.Event, res: any) => {
3636
const data = JSON.parse(res);
37-
console.log('ec2 data fetched from AWS context is: ', data);
3837

3938
setAwsData(data);
4039
setLoadingState(false);
@@ -43,12 +42,10 @@ const AwsContextProvider: React.FC<Props> = React.memo(({ children }) => {
4342

4443
const fetchAwsEcsData = (username: string, index: number) => {
4544
ipcRenderer.removeAllListeners('ecsMetricsResponse');
46-
setLoadingState(true);
4745

4846
ipcRenderer.send('ecsMetricsRequest', username, index);
4947
ipcRenderer.on('ecsMetricsResponse', (event: Electron.Event, res: any) => {
5048
const data = JSON.parse(res);
51-
console.log('ecs data fetched from AWS context is: ', data);
5249

5350
setAwsEcsData(data);
5451
setLoadingState(false);
@@ -57,20 +54,18 @@ const AwsContextProvider: React.FC<Props> = React.memo(({ children }) => {
5754

5855
const fetchAwsAppInfo = (username: string, index: number) => {
5956
ipcRenderer.removeAllListeners('awsAppInfoResponse');
60-
setLoadingState(true);
6157

6258
ipcRenderer.send('awsAppInfoRequest', username, index);
6359
ipcRenderer.on('awsAppInfoResponse', (event: Electron.Event, res: any) => {
6460
const appInfo = JSON.parse(res);
65-
console.log('app info requested from fetchAwsAppInfo: ', appInfo)
6661

6762
setAwsAppInfo(appInfo);
6863
});
6964
};
7065

7166
return (
7267
<AwsContext.Provider
73-
value={{ fetchAwsData, awsData, setAwsData, fetchAwsEcsData, awsEcsData, setAwsEcsData, awsAppInfo, setAwsAppInfo, fetchAwsAppInfo, isLoading}}
68+
value={{ fetchAwsData, awsData, setAwsData, fetchAwsEcsData, awsEcsData, setAwsEcsData, awsAppInfo, setAwsAppInfo, fetchAwsAppInfo, isLoading, setLoadingState}}
7469
>
7570
{children}
7671
</AwsContext.Provider>

0 commit comments

Comments
 (0)