Skip to content

Commit 22dfe06

Browse files
committed
Resolved Conflicts
2 parents 5626149 + e39a117 commit 22dfe06

32 files changed

Lines changed: 1474 additions & 1693 deletions

.DS_Store

6 KB
Binary file not shown.

Main.js

Lines changed: 71 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,97 @@
1-
const { app, BrowserWindow, ipcMain } = require('electron');
1+
//node requirements
2+
const { dialog, app, BrowserWindow, ipcMain } = require('electron');
23
const fs = require('fs');
34
const path = require('path');
45
const connectSQL = require('./model/sql-connect');
56
const connectMongoose = require('./model/mongoose-connect');
67
const CommunicationSchema = require('./model/mongoose-communicatonSchema');
78
const HealthInfoSchema = require('./model/mongoose-healthInfoSchema');
89

10+
//declare a variable pool for SQL connection
11+
let pool;
12+
13+
//declare win variable ---> Ousman
914
let win;
15+
16+
//declaring a createWindow function ---> Ousman
1017
function createWindow() {
18+
//assign win to an instance of a new browser window.
1119
win = new BrowserWindow({
20+
//giving our window its width
1221
width: 900,
22+
//giving our window its hieght
1323
height: 800,
24+
//specify the path of the icon -- Which icon is this?.. note too tsure --> Ousman
1425
icon: path.join(__dirname, 'app/assets/icons/icon.png'),
26+
//enable node inegreation --> node intgeration, default is usally false --> Ousman
1527
webPreferences: {
1628
nodeIntegration: true,
1729
},
1830
});
1931

2032
// Development
33+
//loads our application window to localHost 8080, application will not render without this loadUrl --> Ousman
2134
win.loadURL('http://localhost:8080/');
2235

2336
// Production
2437
// win.loadURL(`file://${path.join(__dirname, './dist/index.html')}`);
25-
38+
39+
//assign window to null on close
2640
win.on('closed', () => {
2741
win = null;
2842
});
2943
}
44+
45+
//invoke createWindow function on Electron application load --> Ousman
3046
app.on('ready', createWindow);
3147

48+
// quits the application when all windows are closed --> Ousman
3249
app.on('window-all-closed', () => {
50+
//process platform is a property that return a string identifying the OS platform on which NodeJs process is running --> Ousman
3351
if (process.platform !== 'darwin') {
52+
//quits application
3453
app.quit();
3554
}
3655
});
3756

57+
//event 'activate' emmitted upon application starting
3858
app.on('activate', () => {
59+
//if there is no window present invoke the create window function --> Ousman
3960
if (win === null) {
4061
createWindow();
4162
}
4263
});
4364

4465
// Load settings JSON and returns current setup status back to the render process.
66+
//ipc 'setup' route --> Ousman
4567
ipcMain.on('setup', (message) => {
68+
//assigns state to the returned the object returned from settings.json --> Ousman
4669
const state = JSON.parse(
70+
//read json from settings.json
4771
fs.readFileSync(path.resolve(__dirname, './user/settings.json'), {
4872
encoding: 'UTF-8',
4973
}),
5074
);
51-
const { setupRequired } = state;
75+
//destructure setupRequired from state constant ---> Ousman
76+
const { setupRequired } = state;
77+
//assigning message object a property of return value and assigning it the setupRequired from state destructuring --> Ousman
5278
message.returnValue = setupRequired;
5379
});
5480

5581
// Loads existing settings JSON and update settings to include new services entered by the user.
82+
//on ipc 'submit' request --> Ousman
5683
ipcMain.on('submit', (message, newService) => {
84+
//assigning state to the parsed return of setting
5785
const state = JSON.parse(
5886
fs.readFileSync(path.resolve(__dirname, './user/settings.json'), {
5987
encoding: 'UTF-8',
6088
}),
6189
);
62-
// if statement is used to replace hard coded data. Hard coded data and the michelleWasHere key is needed to avoid a load error caused by Electron querying the database before a user has added or selected a database.
63-
if (state.michelleWasHere) {
90+
// if statement is used to replace hard coded data. Hard coded data and the michelleWasHere key is needed to avoid a load error caused by Electron querying the database before a user has added or selected a database.
91+
92+
//*** What is happening here --> Ousman */
93+
if (state.setupRequired) {
6494
state.setupRequired = false;
65-
state.michelleWasHere = false;
6695
state.services = [JSON.parse(newService)];
6796
fs.writeFileSync(path.resolve(__dirname, './user/settings.json'), JSON.stringify(state));
6897
} else {
@@ -73,12 +102,15 @@ ipcMain.on('submit', (message, newService) => {
73102
});
74103

75104
// Load settings JSON and returns updated state back to the render process.
105+
//on ipc 'dashboard' request --> Ousman
76106
ipcMain.on('dashboard', (message) => {
107+
//assign state to the parsed return of setting --> Ousman
77108
const state = JSON.parse(
78109
fs.readFileSync(path.resolve(__dirname, './user/settings.json'), {
79110
encoding: 'UTF-8',
80111
}),
81112
);
113+
//destructure services from state... what is services? --> Ousman
82114
const { services } = state;
83115
const dashboardList = services.reduce((acc, curVal) => {
84116
acc.push(curVal[0]);
@@ -89,34 +121,53 @@ ipcMain.on('dashboard', (message) => {
89121

90122
// Queries the database for communications information and returns it back to the render process.
91123
ipcMain.on('overviewRequest', (message, index) => {
92-
const databaseType = JSON.parse(
124+
const services = JSON.parse(
93125
fs.readFileSync(path.resolve(__dirname, './user/settings.json'), { encoding: 'UTF-8' }),
94-
).services[index][1];
126+
).services;
127+
128+
const databaseType = services[index][1];
129+
const URI = services[index][2];
95130

96131
if (databaseType === 'MongoDB') {
97-
connectMongoose(index);
132+
connectMongoose(index, URI);
98133
CommunicationSchema.find({}, (err, data) => {
99134
if (err) {
100135
console.log(`An error occured while querying the database: ${err}`);
101136
message.sender.send('overviewResponse', JSON.stringify(err));
102-
}
103-
const queryResults = JSON.stringify(data);
104-
// Asynchronous event emitter used to transmit query results back to the render process.
105-
message.sender.send('overviewResponse', queryResults);
137+
}
138+
139+
const queryResults = JSON.stringify(data);
140+
// Asynchronous event emitter used to transmit query results back to the render process.
141+
message.sender.send('overviewResponse', queryResults);
142+
106143
});
107144
}
108-
145+
109146
if (databaseType === 'SQL') {
110-
const pool = connectSQL(index);
147+
pool = connectSQL(index, URI);
111148
const getCommunications = 'SELECT * FROM communications';
112149
pool.query(getCommunications, (err, result) => {
113150
if (err) {
114-
console.log(err);
115-
message.sender.send(JSON.stringify('Database info could not be retreived.'));
151+
152+
//error object to log to Electron GUI ---> Ousman
153+
const errorAlert = {
154+
type: "error",
155+
title: "Error in Main process",
156+
message: "Database information could not be retreived. Check that table exists."
157+
};
158+
159+
//after requiring dialog in the topmost section of main. We invoke the method showMessagebox passing the error object we created --> Ousman
160+
dialog.showMessageBox(errorAlert);
161+
162+
163+
message.sender.send(JSON.stringify('Database info could not be retreived.'));
164+
165+
} else {
166+
console.log('Connected to SQL Database')
167+
const queryResults = JSON.stringify(result.rows);
168+
// Asynchronous event emitter used to transmit query results back to the render process.
169+
message.sender.send('overviewResponse', queryResults);
116170
}
117-
const queryResults = JSON.stringify(result.rows);
118-
// Asynchronous event emitter used to transmit query results back to the render process.
119-
message.sender.send('overviewResponse', queryResults);
120171
});
121172
}
122173
});
@@ -128,7 +179,6 @@ ipcMain.on('detailsRequest', (message, index) => {
128179
).services[index][1];
129180

130181
if (databaseType === 'MongoDB') {
131-
connectMongoose(index);
132182
HealthInfoSchema.find({}, (err, data) => {
133183
if (err) {
134184
message.sender.send('detailsResponse', JSON.stringify(err));
@@ -140,7 +190,6 @@ ipcMain.on('detailsRequest', (message, index) => {
140190
}
141191

142192
if (databaseType === 'SQL') {
143-
const pool = connectSQL(index);
144193
const getHealth = 'SELECT * FROM healthInfo';
145194
pool.query(getHealth, (err, result) => {
146195
if (err) {

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Chronos hopes to inspire an active community of both users and developers. For q
1515
* Michelle Herrera
1616
* Duane McFarlane
1717
* Ben Mizel
18-
* Tim Pagra
18+
* Timothy Atapagra
1919
* Jenae Pennie
2020
* Chris Romano
2121
* Natalie Umanzor

app/.DS_Store

6 KB
Binary file not shown.

app/assets/latencyChart.png

93.5 KB
Loading

app/assets/memoryChart.png

8.28 KB
Loading

app/assets/pieChart.png

47.3 KB
Loading

app/assets/processingChart.png

56 KB
Loading

app/assets/routeChart.png

87.9 KB
Loading

app/assets/speedChart.png

32.8 KB
Loading

0 commit comments

Comments
 (0)