Skip to content

Commit 53eafb6

Browse files
committed
Added comments to explain sections of code, removed inaccuratly described comments from prior groups
1 parent 51d8d98 commit 53eafb6

6 files changed

Lines changed: 14 additions & 32 deletions

File tree

app/components/TransferColumns.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import { DataGrid } from '@material-ui/data-grid';
77
import * as DashboardContext from '../context/DashboardContext';
88
import lightAndDark from './Styling';
99
import { Button, TextField } from '@material-ui/core';
10-
import SearchBar from './SearchBar/SearchBar';
11-
1210

1311
interface Params {
1412
service: string;

app/containers/GraphsContainer/GraphsContainer.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ interface Params {
3333
const GraphsContainer: React.FC = React.memo(() => {
3434
const { app, service } = useParams<keyof Params>() as Params;
3535
const [live, setLive] = useState<boolean>(false);
36-
const { intervalID, setIntervalID, example, chart, setChart } = useContext(ApplicationContext);
36+
const { intervalID, setIntervalID, chart, setChart } = useContext(ApplicationContext);
3737
const { getSavedMetrics } = useContext(ApplicationContext);
3838
const { fetchHealthData, setHealthData } = useContext(HealthContext);
3939
const { setDockerData, dockerData } = useContext(DockerContext);
@@ -47,7 +47,6 @@ const GraphsContainer: React.FC = React.memo(() => {
4747

4848
useEffect(() => {
4949
const serviceArray = service.split(' ');
50-
// You would think you should add "kubernetesmetrics" into the below for consistency's sake but it makes it not work correctly, so it has been omitted
5150
const healthServiceArray = serviceArray.filter(
5251
(value: string) => value !== 'kafkametrics' && value !== 'kubernetesmetrics'
5352
);
@@ -60,23 +59,27 @@ const GraphsContainer: React.FC = React.memo(() => {
6059
if (service.includes('kafkametrics')) {
6160
fetchEventData('kafkametrics');
6261
}
63-
// JJ-ADDITION
6462
if (service.includes('kubernetesmetrics')) {
6563
fetchEventData('kubernetesmetrics');
6664
}
6765
}, 10000)
6866
);
6967
} else {
68+
//This block gets data from the metrics db, the health data from each of the services respective dbs and the communcations logs in the communications db
69+
//The respective states are commsData, healthData and savedMetrics
7070
if (intervalID) clearInterval(intervalID);
71+
// gets all the communication logs from the communications database and sets the communications data state
7172
fetchCommsData(app, live);
73+
// gets all health data stored in each of the services databases
7274
fetchHealthData(healthServiceArray);
75+
//kafka and kubernetes are currently not hooked up so these blocks will never fire
7376
if (service.includes('kafkametrics')) {
7477
fetchEventData('kafkametrics');
7578
}
76-
// JJ-ADDITION
7779
if (service.includes('kubernetesmetrics')) {
7880
fetchEventData('kubernetesmetrics');
7981
}
82+
// gets all metric data (cpu related metrics)
8083
getSavedMetrics();
8184
}
8285

@@ -88,7 +91,6 @@ const GraphsContainer: React.FC = React.memo(() => {
8891
};
8992
}, [service, live]);
9093

91-
//random variable to hold the light or dark mode of the display?..ok....sure
9294
const currentMode = mode === 'light' ? lightAndDark.lightModeText : lightAndDark.darkModeText;
9395

9496
return (

app/context/ApplicationContext.tsx

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,12 @@ const ApplicationContextProvider: React.FC<AppContextProps> = React.memo(props =
2222
const children = props.children;
2323
const [ example,setExample ] = useState(false)
2424
const [chart, setChart] = useState<string>('all');
25-
2625
const [servicesData, setServicesData] = useState([]);
2726
const [app, setApp] = useState<string>('');
2827
const [savedMetrics, setSavedMetrics] = useState({});
2928
const [appIndex, setAppIndex] = useState<number>(0);
3029
const [intervalID, setIntervalID] = useState<NodeJS.Timeout | null>(null);
3130

32-
3331
/**
3432
* @function fetchServicesNames - a function that will take an application name and update the state of `serviceData` based on backend response
3533
* 1. Take in an application name
@@ -40,16 +38,13 @@ const ApplicationContextProvider: React.FC<AppContextProps> = React.memo(props =
4038
*/
4139
// v10: Invoked by connectToDB, passing in app (card title)
4240
const fetchServicesNames = useCallback((application: string) => {
43-
// console.log('Hi, inside ApplicationConext - fetchServicesNames callback. Sending servicesRequest to ipcMain.');
44-
console.log('app when fetch services name: ', application);
45-
console.log(application)
41+
4642
ipcRenderer.send('servicesRequest');
4743
ipcRenderer.on('servicesResponse', (event: Electron.Event, data: any) => {
48-
//data here refers to the data coming the services document of the database
44+
//data here refers to the services coming the services document of the database
4945
let result: any;
5046
result = JSON.parse(data);
51-
console.log('result from ipcrenderer services response is: ', result);
52-
// console.log('Calling setServicesData passing in above result. Current servicesData is the following: ', servicesData);
47+
// console.log({result})
5348
setServicesData(result);
5449
ipcRenderer.removeAllListeners('servicesResponse');
5550
});
@@ -88,8 +83,6 @@ const ApplicationContextProvider: React.FC<AppContextProps> = React.memo(props =
8883
data.forEach(el => {
8984
store[el.metric] = el;
9085
});
91-
// console.log({store})
92-
// console.log('result from getSavedMetrics is: ', store);
9386
setSavedMetrics(store);
9487
});
9588
}, []);

app/context/CommsContext.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ const CommsContextProvider: React.FC<Props> = React.memo((props) => {
5050
ipcRenderer.send('commsRequest');
5151
ipcRenderer.on('commsResponse', (event: Electron.Event, data: any) => {
5252
let result: any;
53-
//Here we are grabbing all the data from our test database
53+
//Here we are grabbing all the data from our communications database
5454
if (tryParseJSON(data)) result = JSON.parse(data);
5555
setCommsData(result);
5656
});

chronos_npm_package/controllers/mongo.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ mongo.health = async ({ microservice, interval, mode }) => {
122122
const HealthModel = HealthModelFunc(`${microservice}`);
123123
await HealthModel.insertMany(healthMetrics);
124124
return
125-
126125
})
127126
.then(() => {
128127
console.log('Health data recorded in MongoDB');

electron/routes/data.ts

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,7 @@ ipcMain.on('servicesRequest', async (message: Electron.IpcMainEvent) => {
115115
ipcMain.on('commsRequest', async (message: Electron.IpcMainEvent) => {
116116
try {
117117
let result: any;
118-
119-
// Mongo Database
120118
if (currentDatabaseType === 'MongoDB') {
121-
// Get all documents
122119
result = await CommunicationModel.find().exec();
123120
// console.log({result})
124121
}
@@ -147,9 +144,7 @@ ipcMain.on('healthRequest', async (message: Electron.IpcMainEvent, service: stri
147144

148145
try {
149146
let result: any;
150-
// Mongo Database
151147
if (currentDatabaseType === 'MongoDB') {
152-
//NOT WORKING CULPRIT IS HERE
153148
result = await mongoFetch(service);
154149
}
155150

@@ -211,27 +206,22 @@ ipcMain.on('dockerRequest', async (message, service) => {
211206
}
212207
});
213208

214-
// This event allows the user to change which metrics are saved by the database, so that their database doesn't get bloated with unnecessary data that they don't actually want.
209+
// This event grabs the metric data from the metric database.
210+
// Storing the metrics is done to allow the user to select which metrics
211+
// they want to see in the metrics container component
215212
ipcMain.on('savedMetricsRequest', async (message: Electron.IpcMainEvent) => {
216213
try {
217214
let result: any = {};
218-
// Mongo Database
219215
if (currentDatabaseType === 'MongoDB') {
220-
// Get all documents from the services collection
221216
result = await MetricsModel.find().lean();
222217
}
223218

224-
// SQL Database
225219
if (currentDatabaseType === 'SQL') {
226-
// Get all rows from the metrics table
227220
const query = `SELECT * FROM metrics;`;
228221
result = await pool.query(query);
229222
result = result.rows;
230223
}
231-
232-
// Async event emitter - send response
233224
message.sender.send('savedMetricsResponse', result);
234-
// eslint-disable-next-line no-shadow
235225
} catch (err) {
236226
if (err) console.log('Error in "metricsRequest" event :', err.message);
237227
}

0 commit comments

Comments
 (0)