Skip to content

Commit e946fc4

Browse files
authored
Merge pull request #1 from oslabs-beta/Taylor/AWS-Graphs
Taylor/aws graphs
2 parents 7504da9 + ee49801 commit e946fc4

File tree

21 files changed

+6048
-169
lines changed

21 files changed

+6048
-169
lines changed

app/components/Occupied.tsx

Lines changed: 69 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import {
1919
Typography,
2020
} from '@material-ui/core';
2121

22-
2322
import { makeStyles } from '@material-ui/core/styles';
2423
import { BaseCSSProperties } from '@material-ui/core/styles/withStyles';
2524

@@ -32,7 +31,6 @@ import Badge from '@material-ui/core/Badge';
3231
import PersonIcon from '@material-ui/icons/Person';
3332
import UpdateIcon from '@material-ui/icons/Update';
3433

35-
3634
// // MODALS
3735
import AddModal from '../modals/AddModal';
3836
import ProfileContainer from '../containers/ProfileContainer';
@@ -49,40 +47,40 @@ import { CommsContext } from '../context/CommsContext';
4947

5048
// TYPESCRIPT
5149
interface StyleProps {
52-
root: BaseCSSProperties;
53-
}
54-
type ClickEvent = React.MouseEvent<HTMLElement>;
55-
50+
root: BaseCSSProperties;
51+
}
52+
type ClickEvent = React.MouseEvent<HTMLElement>;
5653

5754
const Occupied = React.memo(() => {
58-
const { setServicesData } = useContext(ApplicationContext);
55+
const { setServicesData, app, setApp } = useContext(ApplicationContext);
5956
const { user, applications, getApplications, deleteApp, mode } = useContext(DashboardContext);
6057
const { commsData } = useContext(CommsContext);
6158
const [serviceModalOpen, setServiceModalOpen] = useState<boolean>(false);
6259
const [addModalOpen, setAddModalOpen] = useState<boolean>(false);
6360
const [personModalOpen, setPersonModalOpen] = useState<boolean>(false);
6461
const [index, setIndex] = useState<number>(0);
65-
const [app, setApp] = useState<string>('');
62+
// const [app, setApp] = useState<string>('');
6663
const [searchTerm, setSearchTerm] = useState<string>('');
6764
const [clickedAt, setClickedAt] = useState<string>('2000-01-01T00:00:00Z');
68-
65+
6966
// Grab services and applications whenever the user changes
7067
useEffect(() => {
7168
setServicesData([]);
7269
getApplications();
73-
}, [ user ]);
70+
}, [user]);
7471

7572
// Dynamic refs
7673
const delRef = useRef<any>([]);
77-
74+
7875
// Asks user to confirm deletion
7976
const confirmDelete = (event: ClickEvent, application: string, i: number) => {
8077
const message = `The application '${app}' will be permanently deleted. Continue?`;
8178
if (confirm(message)) deleteApp(i);
8279
};
83-
80+
8481
// Handle clicks on Application cards
8582
const handleClick = (event: ClickEvent, selectedApp: string, i: number) => {
83+
console.log(selectedApp, i);
8684
if (delRef.current[i] && !delRef.current[i].contains(event.target)) {
8785
setIndex(i);
8886
setApp(selectedApp);
@@ -249,7 +247,11 @@ const Occupied = React.memo(() => {
249247
You have {notification ? notification.length : 0} new alerts
250248
</span>
251249
<NotificationsIcon className="navIcon" id="notificationsIcon" />
252-
<Badge overlap="rectangular" badgeContent={notification ? notification.length : 0} color="secondary" />
250+
<Badge
251+
overlap="rectangular"
252+
badgeContent={notification ? notification.length : 0}
253+
color="secondary"
254+
/>
253255
</div>
254256
<div className="personIconArea">
255257
<Button className="personTooltip" onClick={() => setPersonModalOpen(true)}>
@@ -267,61 +269,66 @@ const Occupied = React.memo(() => {
267269
</Button>
268270
</div>
269271
{applications &&
270-
applications.filter((db: any) => db[0].toLowerCase().includes(searchTerm.toLowerCase()))
271-
.map((application: string[], i: number | any | string | undefined) => (
272-
<div className="card" key={`card-${i}`} id={`card-${application[1]}`}>
273-
<Card
274-
key={`card-${i}`}
275-
className={classes.paper}
276-
variant="outlined"
277-
onClick={event => handleClick(event, application[0], i)}
278-
>
279-
<div className="databaseIconContainer">
280-
<div className="databaseIconHeader">
281-
{application[1] === 'SQL' ? (
282-
<img className="databaseIcon" alt="SQL" />
283-
) : (
284-
<img className="databaseIcon" alt="MongoDB" />
285-
)}
272+
applications
273+
.filter((db: any) => db[0].toLowerCase().includes(searchTerm.toLowerCase()))
274+
.map((application: string[], i: number | any | string | undefined) => (
275+
<div className="card" key={`card-${i}`} id={`card-${application[1]}`}>
276+
<Card
277+
key={`card-${i}`}
278+
className={classes.paper}
279+
variant="outlined"
280+
onClick={event => handleClick(event, application[0], i)}
281+
>
282+
<div className="databaseIconContainer">
283+
<div className="databaseIconHeader">
284+
{application[1] === 'SQL' ? (
285+
<img className="databaseIcon" alt="SQL" />
286+
) : (
287+
<img className="databaseIcon" alt="MongoDB" />
288+
)}
289+
</div>
286290
</div>
287-
</div>
288291

289-
<CardHeader
290-
avatar={
291-
<IconButton
292-
id="iconButton"
293-
ref={element => {
294-
delRef.current[i] = element;
295-
}}
296-
className={classes.iconbutton}
297-
aria-label="Delete"
298-
onClick={event => confirmDelete(event, application[0], i)}
299-
>
300-
<HighlightOffIcon
301-
className={classes.btnStyle}
302-
id="deleteIcon"
292+
<CardHeader
293+
avatar={
294+
<IconButton
295+
id="iconButton"
303296
ref={element => {
304297
delRef.current[i] = element;
305298
}}
306-
/>
307-
</IconButton>
308-
}
309-
/>
310-
<CardContent>
311-
<p id="databaseName">Database Name:</p>
312-
<Typography className={classes.fontStyles}>{application[0]}</Typography>
313-
</CardContent>
314-
<hr className="cardLine" />
299+
className={classes.iconbutton}
300+
aria-label="Delete"
301+
onClick={event => confirmDelete(event, application[0], i)}
302+
>
303+
<HighlightOffIcon
304+
className={classes.btnStyle}
305+
id="deleteIcon"
306+
ref={element => {
307+
delRef.current[i] = element;
308+
}}
309+
/>
310+
</IconButton>
311+
}
312+
/>
313+
<CardContent>
314+
{/* <p id="databaseName">Name:</p> */}
315+
<Typography noWrap id="databaseName" className={classes.fontStyles}>
316+
{application[0]}
317+
</Typography>
318+
<p id="serviceName">Service:</p>
319+
<Typography className={classes.fontStyles}>{application[3]}</Typography>
320+
</CardContent>
321+
<hr className="cardLine" />
315322

316-
<div className="cardFooter">
317-
<UpdateIcon className="cardFooterIcon" />
318-
<em>
319-
<p id="cardFooterText">{application[3]}</p>
320-
</em>
321-
</div>
322-
</Card>
323-
</div>
324-
))}
323+
<div className="cardFooter">
324+
<UpdateIcon className="cardFooterIcon" />
325+
<em>
326+
<p id="cardFooterText">{application[4]}</p>
327+
</em>
328+
</div>
329+
</Card>
330+
</div>
331+
))}
325332

326333
<Modal open={addModalOpen} onClose={() => setAddModalOpen(false)}>
327334
<AddModal setOpen={setAddModalOpen} />

app/components/Splash.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
import React, { useState, useEffect } from 'react';
22
import '../stylesheets/Splash.scss';
33

4-
const Splash: React.FC = React.memo((props) => {
5-
const [visible, setVisible] = useState(true);
6-
useEffect(() => {
7-
setTimeout(() => setVisible(false), 4000);
8-
}, []);
4+
const Splash: React.FC = React.memo(props => {
5+
const [visible, setVisible] = useState(false);
6+
// useEffect(() => {
7+
// setTimeout(() => setVisible(false), 4000);
8+
// }, []);
99

1010
return (
1111
<>
12-
{visible &&
13-
<div id="splash">
12+
{visible && (
13+
<div id="splash">
1414
<img id="splashLogo" src="../assets/logo.svg" alt="Chronos" />
1515
</div>
16-
}
16+
)}
1717
</>
1818
);
1919
});

app/components/TransferColumns.tsx

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,15 @@ const TransferColumns = React.memo(() => {
6262
} else if (eventMetricsReady) {
6363
setMetricsPool(eventMetrics);
6464
}
65-
}
65+
}
6666
// JJ-ADDITION (CAN ALSO JUST ADD OR OPERATOR TO ABOVE CONDITIONAL)
6767
else if (service === 'kubernetesmetrics') {
6868
if (healthDataList && healthDataList.length > 0) {
6969
setMetricsPool(getMetrics('health', healthDataList));
7070
} else if (healthMetricsReady) {
7171
setMetricsPool(healthMetrics);
7272
}
73-
}
74-
else if (!service.includes('kafkametrics')) {
73+
} else if (!service.includes('kafkametrics')) {
7574
if (healthDataList && healthDataList.length > 0) {
7675
setMetricsPool(getMetrics('health', healthDataList));
7776
} else if (healthMetricsReady) {
@@ -129,7 +128,7 @@ const TransferColumns = React.memo(() => {
129128
// setSelectedMetrics
130129
const temp: any[] = [];
131130
const categorySet = new Set();
132-
console.log('targetKeys is: ', targetKeys)
131+
console.log('targetKeys is: ', targetKeys);
133132
for (let i = 0; i < targetKeys.length; i++) {
134133
const str: string = targetKeys[i];
135134
const strArr: string[] = str.split(' | ');
@@ -149,12 +148,12 @@ const TransferColumns = React.memo(() => {
149148
temp.push(newCategory);
150149
}
151150
}
152-
console.log('temp is: ', temp);
151+
console.log('SelectedMetrics is: ', temp);
153152
setSelectedMetrics(temp);
154153
};
155154

156155
const columns = [
157-
{ field: 'id', headerName: 'ID', width: 100},
156+
{ field: 'id', headerName: 'ID', width: 100 },
158157
{
159158
field: 'tag',
160159
headerName: 'Category',
@@ -168,7 +167,7 @@ const TransferColumns = React.memo(() => {
168167
editable: true,
169168
},
170169
];
171-
170+
172171
const rows: any[] = [];
173172

174173
metricsPool.forEach((el, index) => {
@@ -182,17 +181,19 @@ const TransferColumns = React.memo(() => {
182181
const selectedRows: any[] = [];
183182

184183
targetKeys.forEach(el => {
185-
selectedRows.push(<li style={{marginLeft: '30px', marginTop: '5px', color: currentMode.color}}>{el}</li>)
186-
})
184+
selectedRows.push(
185+
<li style={{ marginLeft: '30px', marginTop: '5px', color: currentMode.color }}>{el}</li>
186+
);
187+
});
187188

188189
return (
189190
<>
190191
<div id="getChartsContainer">
191-
<Button id="getCharts" onClick={getCharts} variant='contained' color='primary'>
192+
<Button id="getCharts" onClick={getCharts} variant="contained" color="primary">
192193
Get Charts
193194
</Button>
194195
</div>
195-
<div id='transferTest'>
196+
<div id="transferTest">
196197
<div style={{ height: '500px', width: '100%' }}>
197198
<DataGrid
198199
style={currentMode}
@@ -205,18 +206,18 @@ const TransferColumns = React.memo(() => {
205206
const metrics: any[] = [];
206207
metricIndeces.forEach(el => {
207208
metrics.push(metricsPool[el].key);
208-
})
209+
});
209210
setTargetKeys(metrics);
210211
}}
211212
/>
212213
</div>
213-
{selectedRows.length > 0 && <h3 style={{marginTop: '20px', color: currentMode.color}}>Selected Rows:</h3>}
214-
<ol id="selectedRows">
215-
{selectedRows}
216-
</ol>
214+
{selectedRows.length > 0 && (
215+
<h3 style={{ marginTop: '20px', color: currentMode.color }}>Selected Rows:</h3>
216+
)}
217+
<ol id="selectedRows">{selectedRows}</ol>
217218
</div>
218219
</>
219220
);
220221
});
221222

222-
export default TransferColumns;
223+
export default TransferColumns;

app/containers/AWSGraphsContainer.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/* eslint-disable no-bitwise */
2+
import React, { useEffect, useState, useContext } from 'react';
3+
import { useNavigate, useParams } from 'react-router-dom';
4+
import { ApplicationContext } from '../context/ApplicationContext';
5+
import * as DashboardContext from '../context/DashboardContext';
6+
import lightAndDark from '../components/Styling';

0 commit comments

Comments
 (0)