diff --git a/package.json b/package.json index b7fcd24..8d424c9 100644 --- a/package.json +++ b/package.json @@ -12,12 +12,12 @@ "socket.io-client": "^3.1.1" }, "devDependencies": { - "@babel/core": "^7.12.17", - "@babel/eslint-parser": "^7.12.17", + "@babel/core": "^7.13.1", + "@babel/eslint-parser": "^7.13.4", "concurrently": "^6.0.0", "cross-env": "^7.0.3", - "electron": "^11.2.3", - "electron-builder": "^22.9.0", + "electron": "^11.3.0", + "electron-builder": "^22.8.1", "electron-devtools-installer": "^3.1.1", "electron-rebuild": "^2.3.5", "eslint": "^7.20.0", @@ -31,7 +31,7 @@ "wait-on": "^5.2.1" }, "scripts": { - "rebuild": "rebuild zeromq --runtime=electron --target=11.2.1", + "rebuild": "rebuild --runtime=electron --target=11.2.1", "react-start": "cross-env BROWSER=NONE react-scripts start", "electron-start": "cross-env DEV=1 electron .", "start": "concurrently 'npm run react-start' 'wait-on http://localhost:3000/ && npm run electron-start'", @@ -107,11 +107,12 @@ "build/**/*", "node_modules/**/*", "utils/**/*", - "python/**/*" + "python/**/*", + "dist/*", + "package.json" ], "directories": { "buildResources": "assets" - }, - "extends": "zeromq" + } } } diff --git a/public/electron.js b/public/electron.js index 151fc45..30d54d3 100644 --- a/public/electron.js +++ b/public/electron.js @@ -6,7 +6,9 @@ const {app} = electron; const {BrowserWindow} = electron; const nativeImage = electron.nativeImage; -const PycatService = require('../public/pycatService'); +const PycatService = process.env.DEV ? + require('../public/pycatService') : + require(path.join(__dirname, '../build/pycatService')); // Launch python service. const pycatService = new PycatService('production'); // production or development @@ -21,10 +23,10 @@ if (process.env.DEV) { app.whenReady().then(() => { installExtension(REDUX_DEVTOOLS).then((name) => - console.log(`Added Extension: ${name}`), + console.info(`Added Extension: ${name}`), ); installExtension(REACT_DEVELOPER_TOOLS).then((name) => - console.log(`Added Extension: ${name}`), + console.info(`Added Extension: ${name}`), ); }); } @@ -39,11 +41,7 @@ let mainWindow; const createWindow = () => { const startUrl = process.env.DEV ? 'http://localhost:3000' : - url.format({ - pathname: path.join(__dirname, '/../build/index.html'), - protocol: 'file:', - slashes: true, - }); + url.pathToFileURL(path.join(__dirname, '/../build/index.html')).href; mainWindow = new BrowserWindow({ show: false, icon, @@ -60,11 +58,19 @@ const createWindow = () => { minHeight: 600, backgroundColor: '#0A826E', }); + mainWindow.removeMenu(); // Hides menu on Linux & Windows // mainWindow.maximize(); mainWindow.show(); - mainWindow.loadURL(startUrl); - // process.env.DEV && mainWindow.webContents.openDevTools(); + mainWindow.loadURL(startUrl).then(() => { + console.info('pyCat '); + }); + console.log('LOOK here:'); + console.log(startUrl); + console.log(String(Object.assign(new URL('http://localhost:3000'), + {pathname: ''} + ))); + process.env.DEV && mainWindow.webContents.openDevTools(); mainWindow.on('closed', function() { pycatService.shutdown(); diff --git a/public/pycatService.js b/public/pycatService.js index e83ee98..e30de93 100644 --- a/public/pycatService.js +++ b/public/pycatService.js @@ -1,6 +1,5 @@ const {spawn} = require('child_process'); // {fork} - /** * PycatService */ @@ -27,23 +26,7 @@ module.exports = class PycatService { 'dist/pycat-service-windows.exe' : 'dist/pycat-service' ); - console.log(pathToService); - this.process = spawn(pathToService, [], { - // stdio: ['pipe', 'pipe', 'pipe'], - silent: true, - // encoding: 'utf8', - }); - this.process.stdout.on('data', (data) => { - console.log('stdout data:'); - console.log(`stdout: ${data}`); - }); - this.process.stderr.on('data', (data) => { - console.log('stderr data:'); - }); - this.process.on('close', (code) => { - console.log('close:'); - console.log(`child process exited with code ${code}`); - }); + this.process = spawn(pathToService); } /** * shutdown the service process @@ -51,7 +34,7 @@ module.exports = class PycatService { shutdown() { if (this.mode === 'development') return; if (this.process) { - console.log('SHUTDOWN of pycatService'); + console.info('[SHUTDOWN of pycatService]'); this.process.kill(); this.process = null; } diff --git a/src/App.js b/src/App.js index 01ad0ee..b3c5ba6 100644 --- a/src/App.js +++ b/src/App.js @@ -50,12 +50,9 @@ const App = () => { }, setTask: (key, value) => { task[key] = value; - console.log(task); setTask(task); }, getFromTask: (key) => { - console.log('getFromTask:'); - console.log(task[key]); return task[key]; }, }}> diff --git a/src/jsx/Converter.js b/src/jsx/Converter.js index 29f1fd8..16ba49d 100644 --- a/src/jsx/Converter.js +++ b/src/jsx/Converter.js @@ -21,12 +21,14 @@ const Converter = (props) => { */ const beginBidsCreation = () => { socketContext.emit('ieeg_to_bids', { - file_path: appContext.getFromTask('edfFile').path, - bids_directory: appContext.getFromTask('bidsDirectory'), + file_path: appContext.getFromTask('edfFile') ? + appContext.getFromTask('edfFile').path : '', + bids_directory: appContext.getFromTask('bidsDirectory') ?? '', read_only: false, - events_tsv: appContext.getFromTask('eventsTSV').path, - line_freq: appContext.getFromTask('lineFreq'), - site_id: appContext.getFromTask('siteID'), + events_tsv: appContext.getFromTask('eventsTSV') ? + appContext.getFromTask('eventsTSV').path : '', + line_freq: appContext.getFromTask('lineFreq') ?? '', + site_id: appContext.getFromTask('siteID') ?? '', }); };