Skip to content

Commit e32ef53

Browse files
committed
routing to AWScpntainer sucessfully, added a scss file for it
1 parent 54f0c74 commit e32ef53

File tree

8 files changed

+747
-139
lines changed

8 files changed

+747
-139
lines changed

app/components/Occupied.tsx

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import { DashboardContext } from '../context/DashboardContext';
4545
import { ApplicationContext } from '../context/ApplicationContext';
4646
import { CommsContext } from '../context/CommsContext';
4747
import { AwsContext } from '../context/AwsContext';
48+
import { useNavigate } from 'react-router-dom';
4849

4950
// TYPESCRIPT
5051
interface StyleProps {
@@ -65,6 +66,9 @@ const Occupied = React.memo(() => {
6566
const [searchTerm, setSearchTerm] = useState<string>('');
6667
const [clickedAt, setClickedAt] = useState<string>('2000-01-01T00:00:00Z');
6768

69+
// const [showAwsContainer, setShowAwsContainer] = useState(false);
70+
const navigate = useNavigate();
71+
6872
// Grab services and applications whenever the user changes
6973
useEffect(() => {
7074
setServicesData([]);
@@ -81,15 +85,23 @@ const Occupied = React.memo(() => {
8185
};
8286

8387
// Handle clicks on Application cards
84-
const handleClick = (event: ClickEvent, selectedApp: string, i: number) => {
85-
console.log(selectedApp, i);
88+
const handleClick = (
89+
event: ClickEvent,
90+
selectedApp: string,
91+
selectedService: string,
92+
i: number
93+
) => {
94+
//delRaf refers to the delete button
8695
if (delRef.current[i] && !delRef.current[i].contains(event.target)) {
87-
console.log('the application that you clicked is: ', selectedApp)
88-
setIndex(i);
89-
setApp(selectedApp);
90-
setServicesData([]);
91-
setServiceModalOpen(true);
92-
fetchAwsData();
96+
if (selectedService === 'AWS') {
97+
navigate(`/aws/:${app}`);
98+
fetchAwsData();
99+
} else {
100+
setIndex(i);
101+
setApp(selectedApp);
102+
setServicesData([]);
103+
setServiceModalOpen(true);
104+
}
93105
}
94106
};
95107

@@ -281,7 +293,7 @@ const Occupied = React.memo(() => {
281293
key={`card-${i}`}
282294
className={classes.paper}
283295
variant="outlined"
284-
onClick={event => handleClick(event, application[0], i)}
296+
onClick={event => handleClick(event, application[0], application[3], i)}
285297
>
286298
<div className="databaseIconContainer">
287299
<div className="databaseIconHeader">
@@ -333,7 +345,6 @@ const Occupied = React.memo(() => {
333345
</Card>
334346
</div>
335347
))}
336-
337348
<Modal open={addModalOpen} onClose={() => setAddModalOpen(false)}>
338349
<AddModal setOpen={setAddModalOpen} />
339350
</Modal>

app/containers/AWSGraphsContainer.tsx

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
/* eslint-disable no-bitwise */
22
import React, { useEffect, useState, useContext } from 'react';
3-
import { useNavigate, useParams } from 'react-router-dom';
43
import { ApplicationContext } from '../context/ApplicationContext';
54
import * as DashboardContext from '../context/DashboardContext';
65
import lightAndDark from '../components/Styling';
76
import { useQuery } from 'react-query';
87
import { AwsContext } from '../context/AwsContext';
98

9+
import '../stylesheets/AWSGraphsContainer.scss';
10+
1011
const AwsGraphsContainer: React.FC = React.memo(props => {
1112
const { awsData, fetchAwsData, setAwsData } = useContext(AwsContext);
1213

1314
useEffect(() => {
1415
fetchAwsData();
15-
})
16-
16+
});
17+
1718
// const { data, status, isLoading } = useQuery('awsData', fetchAwsData);
1819

1920
// if(status === 'loading') {
@@ -25,13 +26,16 @@ const AwsGraphsContainer: React.FC = React.memo(props => {
2526
// }
2627

2728
// else {
28-
return (
29-
<div className='test-container'>
30-
<p>AWS TEST DATAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA</p>
31-
<p>Here is our data: {awsData}</p>
32-
</div>
33-
)
34-
// }
29+
return (
30+
<div className="AWS-container">
31+
<p>
32+
AWS TEST
33+
DATAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
34+
</p>
35+
<p>Here is our data: {awsData}</p>
36+
</div>
37+
);
38+
// }
3539
});
3640

37-
export default AwsGraphsContainer;
41+
export default AwsGraphsContainer;

app/containers/MainContainer.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@ import GraphsContainer from './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';
13+
1214
import '../stylesheets/MainContainer.scss';
1315

1416
const MainContainer = React.memo(() => {
1517
const { mode } = useContext(DashboardContext);
16-
const currentModeCSS =
17-
mode === 'light' ? lightAndDark.lightModeMain : lightAndDark.darkModeMain;
18+
const currentModeCSS = mode === 'light' ? lightAndDark.lightModeMain : lightAndDark.darkModeMain;
1819

1920
return (
2021
<>
@@ -27,11 +28,12 @@ const MainContainer = React.memo(() => {
2728
<Route path="/about" element={<About />} />
2829
<Route path="/contact" element={<Contact />} />
2930
<Route path="/settings" element={<Settings />} />
31+
<Route path="/applications/:app/:service" element={<GraphsContainer />} />
32+
<Route path="/aws/:app" element={<AwsGraphsContainer />} />
3033
<Route
31-
path="/applications/:app/:service"
32-
element={<GraphsContainer />}
34+
path="*"
35+
element={<h1 style={{ color: 'red', fontSize: '200px' }}>Not Found</h1>}
3336
/>
34-
<Route path="*" element={<h1 style={{color: 'red', fontSize: '200px'}}>Not Found</h1>} />
3537
</Routes>
3638
</div>
3739
</div>

app/context/ApplicationContext.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ const ApplicationContextProvider: React.FC<AppContextProps> = React.memo(props =
3737
}
3838

3939
const fetchServicesNames = useCallback((application: string) => {
40-
setApp(application);
40+
console.log('app when fetch services name', application);
41+
// setApp(application);
4142

4243
ipcRenderer.send('servicesRequest');
4344

@@ -65,8 +66,8 @@ const ApplicationContextProvider: React.FC<AppContextProps> = React.memo(props =
6566
const store: object = {};
6667
data.forEach(el => {
6768
store[el.metric] = el;
68-
})
69-
console.log('result from getSavedMetrics is: ', store)
69+
});
70+
console.log('result from getSavedMetrics is: ', store);
7071
setSavedMetrics(store);
7172
});
7273
}, []);
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@import './constants.scss';
2+
3+
.AWS-container {
4+
margin-top: 40px;
5+
}

electron/Main.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ let win: Electron.BrowserWindow;
99

1010
/**
1111
* @desc createWindow sets up the environment of the window (dimensions, port, initial settings)
12-
*/
12+
*/
1313
const createWindow = () => {
1414
win = new BrowserWindow({
1515
width: 1920,
@@ -25,7 +25,7 @@ const createWindow = () => {
2525

2626
if (process.env.NODE_ENV === 'development') {
2727
// Development: load the application window to the port in the webpack config
28-
win.loadURL('http://localhost:8080/');
28+
win.loadURL('http://localhost:8081/');
2929
// console.log(win.webContents);
3030
win.webContents.openDevTools();
3131
} else {

0 commit comments

Comments
 (0)