Skip to content

Commit

Permalink
Merge pull request #22 from oslabs-beta/stephenfeature
Browse files Browse the repository at this point in the history
Stephenfeature
  • Loading branch information
tedpham3 authored May 10, 2024
2 parents bdf3b1c + 5aa4ed2 commit 0cb3058
Show file tree
Hide file tree
Showing 8 changed files with 1,569 additions and 108 deletions.
3 changes: 3 additions & 0 deletions app/context/ApplicationContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ const ApplicationContextProvider: React.FC<AppContextProps> = React.memo(props =
*/
// v10: Invoked by connectToDB, passing in app (card title)
const fetchServicesNames = useCallback((application: string) => {

console.log({application});
// console.log('Hi, inside ApplicationConext - fetchServicesNames callback. Sending servicesRequest to ipcMain.');
console.log('app when fetch services name: ', application);
console.log(application)
Expand Down Expand Up @@ -69,6 +71,7 @@ const ApplicationContextProvider: React.FC<AppContextProps> = React.memo(props =
ipcRenderer.removeAllListeners('databaseConnected');
ipcRenderer.send('connect', username, index, URI, databaseType);
ipcRenderer.on('databaseConnected', (event: Electron.Event, data: any) => {
console.log({data});
if(data === true) {
fetchServicesNames(application);
} else {
Expand Down
33 changes: 32 additions & 1 deletion electron/Main.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import { app, BrowserWindow, ipcMain } from 'electron';
import { app, BrowserWindow, ipcMain, session } from 'electron';
import './routes/dashboard';
import { clearGuestSettings } from './routes/dashboard';
import './routes/data';
import './routes/cloudbased';
import path from 'path';
import installExtension, { REACT_DEVELOPER_TOOLS, REDUX_DEVTOOLS } from 'electron-devtools-installer'

// Declare variable to be used as the application window
let win: Electron.BrowserWindow;

app.commandLine.appendSwitch('remote-debugging-port', '9222');

// Path to reactDevTools
const reactDevToolsPath = path.resolve(__dirname, '../node_modules/react-devtools');

/**
* @desc createWindow sets up the environment of the window (dimensions, port, initial settings)
*/
Expand Down Expand Up @@ -56,9 +60,36 @@ const createWindow = () => {
});
};

const addDevTools = async () => {
// await installExtension(REACT_DEVELOPER_TOOLS, { loadExtensionOptions: { allowFileAccess: true }})
// .then((name) => console.log(`Added Extension: ${name}`))
// .catch((err) => console.log('An error occurred: ', err));
// await installExtension(reactDevToolsPath)
// .then((name) => console.log(`Added Extension: ${name}`))
// .catch((err) => console.log('An error occurred: ', err));

await installExtension(REDUX_DEVTOOLS)
.then((name) => console.log(`Added Extension: ${name}`))
.catch((err) => console.log('An error occurred: ', err));

await session.defaultSession.loadExtension(reactDevToolsPath);
};

app.whenReady().then(async () => {
await addDevTools();

// await session.defaultSession.loadExtension(reactDevToolsPath);
});
// Invoke the createWindow function when Electron application loads
app.on('ready', createWindow);

// Loads reactDevTools extension
// app.whenReady().then(async () => {
// console.log(reactDevToolsPath);
// await session.defaultSession.loadExtension(reactDevToolsPath);
// console.log({reactDevToolsPath})
// });

// Quits application when all windows are closed
app.on('window-all-closed', () => {
app.quit();
Expand Down
2 changes: 1 addition & 1 deletion electron/routes/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ ipcMain.on('servicesRequest', async (message: Electron.IpcMainEvent) => {
// console.log('Hi, inside data.ts line 97 - servicesRequest. Fetching services...');

// Mongo Database
// console.log('data.ts line 100 CurrentDataBase TYPE:', currentDatabaseType);
console.log('data.ts line 100 CurrentDataBase TYPE:', currentDatabaseType);
if (currentDatabaseType === 'MongoDB' ) {
// Get all documents from the services collection
//>>>>>
Expand Down
15 changes: 0 additions & 15 deletions examples/microservices/sample.env

This file was deleted.

Loading

0 comments on commit 0cb3058

Please sign in to comment.