You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// 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.
68
-
if(state.michelleWasHere){
68
+
// if statement is used to replace hard coded data. Hard coded data is needed to avoid a load error caused by Electron querying the database before a user has added or selected a database.
69
+
if(state.setupRequired){
69
70
state.setupRequired=false;
70
-
state.michelleWasHere=false;
71
71
state.services=[JSON.parse(newService)];
72
72
//is updating the /user/settings.json file with the first new service
// What is index? index - is passed on from ServiceDashboard as a prop when the button was created. When the button is pressed, the serviceSelected is set to <ServiceOverview index ={i}>. The ServiceOverview makes the ipcRenderer.send('overviewRequest', props.index). The index indicates which service is being called
125
-
constpool=connectSQL(index);
126
+
pool=connectSQL(index,URI);
126
127
constgetCommunications='SELECT * FROM communications';
127
128
pool.query(getCommunications,(err,result)=>{
128
129
if(err){
129
130
returnmessage.sender.send(JSON.stringify('Database info could not be retrieved.'));
130
131
}
132
+
console.log('Connected to SQL Database')
131
133
//queryResults is an array of objects with the following keys {"id","currentmicroservice","targetedendpoint","reqtype","resstatus","resmessage","timesent"}
132
134
constqueryResults=JSON.stringify(result.rows);
133
135
// Asynchronous event emitter used to transmit query results back to the render process.
// Mongoose connection wrapped in function that takes the index of the selected database as the parameter. This index is used to target the correct database for querying.
// SQL connection wrapped in function that takes the index of the selected database as the parameter. This index is used to target the correct database for querying.
5
-
constconnectSQL=(i)=>{
6
-
//there are no links - the following is being used for SQL "services": [["hard", "coded", "solution"]], useContext should be used here
7
-
constURI=services[i][2];
4
+
constconnectSQL=(i,URI)=>{
8
5
constpool=newPool({
9
6
connectionString: URI,
10
7
})
11
-
//verifying that the connection has been made by stating the time it was connected
12
-
// This code could be causing too many request to the database
13
-
// pool.query('SELECT NOW()', (err, res) => {
14
-
// if(err) return message.sender.send('detailsResponse', JSON.stringify('Did not connect to database',err));
15
-
// console.log('Database '+services[i][0]+' has been connected at '+res.rows[0].now)
0 commit comments