Skip to content

Commit 6e03bfd

Browse files
committed
removed aws keys, added react query package
1 parent 671afcf commit 6e03bfd

File tree

8 files changed

+33
-71
lines changed

8 files changed

+33
-71
lines changed

app/App.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,18 @@ import React, { useState } from 'react';
22
import Splash from './components/Splash';
33
import DashboardContainer from './containers/DashboardContainer';
44
import './stylesheets/scrollBar.scss';
5+
import { useQuery, QueryClient, useQueryClient, QueryClientProvider } from 'react-query';
6+
import { ReactQueryDevtools } from 'react-query/devtools'
7+
8+
const queryClient = new QueryClient();
59

610
const App: React.FC = React.memo(() => {
711
return (
8-
<>
12+
<QueryClientProvider client={queryClient}>
13+
<ReactQueryDevtools initialIsOpen={true} />
914
<Splash />
1015
<DashboardContainer />
11-
</>
16+
</QueryClientProvider>
1217

1318
)
1419
});

app/components/Splash.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import '../stylesheets/Splash.scss';
33

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

1010
return (
1111
<>

app/containers/DashboardContainer.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ import '../stylesheets/Dashboard.scss';
1515
const DashboardContainer = React.memo(() => {
1616
const [visible, setVisible] = useState(true);
1717

18-
useEffect(() => {
19-
setTimeout(() => setVisible(true), 4000);
20-
}, []);
18+
// useEffect(() => {
19+
// setTimeout(() => setVisible(true), 4000);
20+
// }, []);
2121

2222
return (
2323
<>

app/context/AwsContext.tsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import React, { useCallback, useState } from 'react';
1+
import React, { useCallback, useState, useEffect } from 'react';
22
import Electron from 'electron';
33
import { transformData } from './helpers';
44
const { ipcRenderer } = window.require('electron');
5+
import { useQuery } from 'react-query';
56

67
export const AwsContext = React.createContext<any>(null);
78

@@ -11,19 +12,25 @@ interface Props {
1112

1213
const AwsContextProvider: React.FC<Props> = React.memo(({ children }) => {
1314
const [awsData, setAwsData] = useState<any>({ CPUUtilization: [], NetworkIn: [], NetworkOut: [], DiskReadBytes: [] })
14-
15+
1516
const fetchAwsData = useCallback(() => {
1617
console.log('i am here in fetchawsdata!!!')
1718
ipcRenderer.send('awsMetricsRequest');
18-
19+
1920
console.log('i am between the send and on!!!!!!!')
2021
ipcRenderer.on('awsMetricsResponse', (event: Electron.Event, data: any) => {
2122
console.log('data fetched from awsContext', data);
22-
// setAwsData(data);
23+
setAwsData(data);
2324
})
24-
25+
2526
console.log('i am after the ipcrender!!!!')
2627
},[]);
28+
29+
const { isLoading, data, error, isFetching } = useQuery('awsMetricsResponse', fetchAwsData);
30+
31+
// useEffect(() => {
32+
// console.log(data, isLoading, error, isFetching);
33+
// });
2734

2835
return (
2936
<AwsContext.Provider

app/stylesheets/AddModal.scss

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -59,59 +59,6 @@
5959
}
6060

6161

62-
.add-fields {
63-
display: flex;
64-
flex-direction: column;
65-
66-
@include centerWithFlex(space-between);
67-
width: 100%;
68-
margin: 15px 0;
69-
70-
select,
71-
input,
72-
textarea {
73-
font-family: 'Roboto';
74-
font-size: 14px;
75-
padding: 5px;
76-
border: thin solid $grey;
77-
flex: 1;
78-
border-radius: 3px;
79-
color: $darkgrey;
80-
}
81-
82-
// Select field
83-
select {
84-
cursor: pointer;
85-
font-family: 'Roboto';
86-
height: 30px;
87-
margin: 0;
88-
appearance: none;
89-
transition: 0.2s;
90-
91-
&:hover {
92-
background-color: darken(#fff, 5%);
93-
}
94-
}
95-
96-
// Text input
97-
input {
98-
height: 30px;
99-
color: $darkgrey;
100-
}
101-
102-
// Textarea
103-
textarea {
104-
resize: none;
105-
height: 90px;
106-
}
107-
108-
label {
109-
width: 140px;
110-
font-size: 135%;
111-
font-weight: 400;
112-
}
113-
}
114-
11562
}
11663

11764
/* Submit button */

electron/routes/dashboard.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ ipcMain.on('getApps', (message: IpcMainEvent) => {
8181
const services: string[][] = settings[currentUser].services;
8282

8383
// Return an array of arrays that is a subset of the full services array
84-
const dashboardList: string[][] = services.map((arr: string[]) => [arr[0], arr[1], arr[3], arr[4]]);
84+
const dashboardList: string[][] = services.map((arr: string[]) => [arr[0], arr[1], arr[3], arr[4], arr[5]]);
8585
message.returnValue = dashboardList;
8686
});
8787

@@ -105,7 +105,7 @@ ipcMain.on('deleteApp', (message: IpcMainEvent, index) => {
105105
});
106106

107107
// Sync event - return new applications list
108-
message.returnValue = userServices.map((arr: string[]) => [arr[0], arr[1], arr[3], arr[4]]);
108+
message.returnValue = userServices.map((arr: string[]) => [arr[0], arr[1], arr[3], arr[4], arr[5]]);
109109
});
110110

111111

electron/routes/data.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ const mongoFetch = fetchData.mongoFetch;
1919
const postgresFetch = fetchData.postgresFetch;
2020
const AWS = require('aws-sdk');
2121

22-
require('dotenv').config();
22+
require('dotenv').config({
23+
path: path.join(__dirname, './.env')
24+
});
2325
// Initiate pool variable for SQL setup
2426
let pool: any;
2527

@@ -317,8 +319,8 @@ ipcMain.on('awsMetricsRequest', async (message: Electron.IpcMainEvent) => {
317319

318320
const cloudwatch = new AWS.CloudWatch({
319321
region: 'us-west-1',
320-
accessKeyId: 'AKIAU4VDDZOHUKZLQREU',
321-
secretAccessKey: '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'
322+
accessKeyId: process.env.AWS_ACCESS_KEY,
323+
secretAccessKey: process.env.AWS_SECRET_KEY
322324
});
323325

324326
const metricsNamesArray = ['CPUUtilization', 'NetworkIn', 'NetworkOut', 'DiskReadBytes'];

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"react-dom": "^17.0.0",
2323
"react-graph-vis": "^1.0.7",
2424
"react-plotly.js": "^2.6.0",
25+
"react-query": "^3.39.3",
2526
"react-router-dom": "^6.5.0",
2627
"react-table": "^7.8.0",
2728
"styled-components": "^5.3.6"

0 commit comments

Comments
 (0)