Skip to content

Commit d3667e3

Browse files
committed
debugging electron frontend and backend while trying to update to user DB instead of using settings.json
1 parent 377caaf commit d3667e3

File tree

4 files changed

+27
-13
lines changed

4 files changed

+27
-13
lines changed

app/context/AwsContext.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,14 @@ const AwsContextProvider: React.FC<Props> = React.memo(({ children }) => {
7070
};
7171

7272
const fetchAwsAppInfo = (username: string, index: number) => {
73+
console.log('Hi, AwsContext -> fetchAwsAppInfo was invoked.');
7374
ipcRenderer.removeAllListeners('awsAppInfoResponse');
74-
75+
console.log('fetchAAWSAppInfo was invoked for card index: ', index);
76+
console.log('Sending request to ipcMain.on for channel awsAppInfoRequest...');
7577
ipcRenderer.send('awsAppInfoRequest', username, index);
7678
ipcRenderer.on('awsAppInfoResponse', (event: Electron.Event, res: any) => {
7779
const appInfo = JSON.parse(res);
78-
80+
console.log('received response: ', res);
7981
setAwsAppInfo(appInfo);
8082
});
8183
};

app/modals/ServicesModal.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,15 @@ interface IService {
1717
microservice: string;
1818
}
1919

20+
// v10: Seems to never have been updated for cloud-based info...
21+
// applications[i][2] refers to the local instance URI
2022
const ServicesModal: React.FC<ServicesModalProps> = React.memo(({ i, app }) => {
23+
console.log('Hi, inside ServicesModal. Memoize function invoked in ServicesModal.');
24+
2125
const { user, applications } = useContext(DashboardContext)
22-
console.log('hereerer', useContext(DashboardContext))
23-
console.log('aappp', applications[i][2])
26+
console.log('user from Dashboard Context:', user);
27+
console.log('applications from Dashboard Context: ', applications);
28+
console.log('applications[i][2]: ', applications[i][2]);
2429
const { servicesData, connectToDB } = useContext(ApplicationContext);
2530
const [services, setServices] = useState<Array<string>>([]);
2631

electron/routes/dashboard.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ ipcMain.on('addAwsApp', (message: IpcMainEvent, application: any) => {
142142
const settings = JSON.parse(fs.readFileSync(settingsLocation).toString('utf8'));
143143
const services = settings[currentUser].services;
144144

145-
// order of variables from addAwsApp
145+
// order of variables from addAwsApp
146146
// name, instance, region, description, typeOfService, accessKey, secretAccessKey
147147

148148
// Add new applicaiton to list

electron/routes/data.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ let currentDatabaseType: string;
3636
// Provide location to settings.json
3737
const settingsLocation = path.resolve(__dirname, '../../settings.json');
3838

39+
// v10 notes: should only be calling connect for local instances. Currently, the services array is differenct for
40+
// local instances vs cloud instances but this function can still be called by cloud isntances, causing an issue.
41+
// fix below is a band-aid for now, a better solution would be optimal.
3942
/**
4043
* @event connect
4144
* @desc Connects user to database and sets global currentDatabaseType which
@@ -49,18 +52,20 @@ ipcMain.on('connect', async (message: Electron.IpcMainEvent, username: string, i
4952
// Connect to User database instantiated in 'dashboard.ts'
5053
if (username !== 'guest') {
5154

52-
const MONGO_URI = URI
53-
mongoose.connect(MONGO_URI, {
54-
useNewUrlParser: true,
55-
useUnifiedtopology: true,
56-
})
55+
// const MONGO_URI = URI
56+
// mongoose.connect(MONGO_URI, {
57+
// useNewUrlParser: true,
58+
// useUnifiedtopology: true,
59+
// })
5760

5861
// Check for existing user in DB, if found, connect to load application based on database type
5962
return User.findOne({ username: username })
6063
.then(async (data) => {
64+
console.log('Hi, inside ipcMain.on connect in data.ts!');
6165
const databaseType = data.services[index][1]
6266
const appURI = data.services[index][2]
63-
console.log('database type', databaseType)
67+
console.log('database type', databaseType);
68+
console.log('appURI', appURI);
6469
if (databaseType === 'MongoDB') {
6570
await connectMongo(index, appURI)
6671
currentDatabaseType = databaseType;
@@ -70,6 +75,7 @@ ipcMain.on('connect', async (message: Electron.IpcMainEvent, username: string, i
7075
currentDatabaseType = databaseType;
7176
message.sender.send('databaseConnected', 'connected!');
7277
}
78+
console.log('leaving ipcMain.on connect.')
7379
})
7480
.catch((error) => {
7581
console.log(` Error in connect, failed to load application : ${error}`)
@@ -594,12 +600,13 @@ ipcMain.on(
594600
}
595601
);
596602

597-
// ELENA WHERE I LEFT OFF
603+
// returns response object containing the typeOfService, region, and awsURL for a selected AWS APP
598604
ipcMain.on(
599605
'awsAppInfoRequest',
600606
async (message: Electron.IpcMainEvent, username: string, appIndex: number) => {
601-
607+
console.log('Hi, inside data.ts - awsAppInfoRequest');
602608
if(username !== 'guest'){
609+
console.log('inside awsAppInfoRequest, not a guest');
603610
return User.findOne({username: username})
604611
.then((data) => {
605612
console.log('DB returned user data: ', data);

0 commit comments

Comments
 (0)