diff --git a/electron-app/ecoindex-app/src/main/main.ts b/electron-app/ecoindex-app/src/main/main.ts index 1f1fb8f1..f23e6b1b 100644 --- a/electron-app/ecoindex-app/src/main/main.ts +++ b/electron-app/ecoindex-app/src/main/main.ts @@ -493,15 +493,20 @@ async function _runCollect( childProcess.on('exit', (code, signal) => { if (isSimple && out.length > 0) { - mainLog.debug(`out`, out) - const filtered = out.filter((item: string) => { - item.includes('Report generated') - }) - mainLog.debug(`filtered`, filtered) - getMainWindow().webContents.send( - channels.OPEN_REPORT, - filtered.at(-1).replace(`Report generated: `, ``) - ) + const fl = (item: string) => { + return item.includes('Report generated') + } + const filtered = out.filter(fl) + const url = + 'file:///' + + filtered + .at(-1) + .replace(`Report generated: `, ``) + .split('generic.report.html')[0] + + `generic.report.html` + mainLog.debug(`url`, url) + shell.openExternal(url, { activate: true }) + // getMainWindow().webContents.send(channels.OPEN_REPORT, url) } _debugLogs( `Child process exited with code ${code} and signal ${signal}` diff --git a/electron-app/ecoindex-app/src/renderer/renderer.ts b/electron-app/ecoindex-app/src/renderer/renderer.ts index 361a5c27..f3e95fc4 100644 --- a/electron-app/ecoindex-app/src/renderer/renderer.ts +++ b/electron-app/ecoindex-app/src/renderer/renderer.ts @@ -55,7 +55,11 @@ window.electronAPI.sendMessageToFrontLog( ) window.electronAPI.openReport((url: any) => { - window.open(url, `_blank`) + try { + window.open(url, `_blank`) + } catch (error) { + frontLog.error(`Error in openReport`, error) + } }) // window.electronAPI.sendDatasToFront((data: any) => {