Skip to content

Commit 516fbd3

Browse files
committed
updating addAWSApp method in datashboard.ts to use db instead of local instance
1 parent 088720b commit 516fbd3

File tree

3 files changed

+76
-13
lines changed

3 files changed

+76
-13
lines changed

electron/routes/dashboard.ts

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,19 @@ const User = require('../models/UserModel')
88
const mongoose = require('mongoose');
99
// const db = require('../databases/mongo')
1010

11-
const MONGO_URI = ''
11+
const MONGO_URI = 'mongodb+srv://chronoslany:[email protected]/?retryWrites=true&w=majority';
1212

13-
mongoose.connect(MONGO_URI, {
14-
useNewUrlParser: true,
15-
useUnifiedtopology: true,
16-
})
13+
main().catch(err => console.log(err));
14+
async function main() {
15+
await mongoose.connect(MONGO_URI);
16+
console.log('user info db connection established...')
17+
}
18+
// mongoose.connect(MONGO_URI, {
19+
// useNewUrlParser: true,
20+
// useUnifiedtopology: true,
21+
// })
1722

23+
// may need to first check if db has a current user and if not, change it to guest
1824
// GLOBAL VARIABLES
1925
let currentUser = 'guest';
2026
const settingsLocation = path.resolve(__dirname, '../../settings.json');
@@ -67,6 +73,8 @@ function clearGuestSettings() {
6773
*/
6874
ipcMain.on('addApp', (message: IpcMainEvent, application: any) => {
6975
const newApp = JSON.parse(application)
76+
console.log('parsed newApp: ', newApp);
77+
console.log('currentUser', currentUser);
7078
const createdOn = moment().format('lll');
7179
newApp.push(createdOn);
7280

@@ -107,6 +115,19 @@ ipcMain.on('addApp', (message: IpcMainEvent, application: any) => {
107115
* @return New list of applications
108116
*/
109117
ipcMain.on('addAwsApp', (message: IpcMainEvent, application: any) => {
118+
119+
const newAWSApp = JSON.parse(application);
120+
console.log('parsed newApp: ', newAWSApp);
121+
console.log('currentUser', currentUser);
122+
const createdOn = moment().format('lll');
123+
newAWSApp.push(createdOn);
124+
125+
if(currentUser !== 'guest'){
126+
127+
}
128+
129+
// if user is not guest, should not have to pull info from settings.json file
130+
110131
// Retrieves file contents from settings.json
111132
const settings = JSON.parse(fs.readFileSync(settingsLocation).toString('utf8'));
112133
const services = settings[currentUser].services;
@@ -118,7 +139,7 @@ ipcMain.on('addAwsApp', (message: IpcMainEvent, application: any) => {
118139
const newAwsApp = JSON.parse(application);
119140

120141
// Add a creation date to the application on the 5th index
121-
const createdOn = moment().format('lll');
142+
// const createdOn = moment().format('lll');
122143
newAwsApp.splice(5, 0, createdOn);
123144

124145
// Add app to list of applications

package-lock.json

Lines changed: 48 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"electron-log": "^5.0.0-beta.23",
2222
"jest-environment-jsdom": "^29.5.0",
2323
"moment": "^2.29.4",
24+
"mongodb": "^5.4.0",
2425
"mongoose": "^6.8.0",
2526
"pg": "^8.8.0",
2627
"react": "^17.0.0",

0 commit comments

Comments
 (0)