Skip to content

Commit

Permalink
feat: finish open report
Browse files Browse the repository at this point in the history
  • Loading branch information
hrenaud committed Aug 1, 2024
1 parent 7ae20f2 commit fcdcf63
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
23 changes: 14 additions & 9 deletions electron-app/ecoindex-app/src/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`
Expand Down
6 changes: 5 additions & 1 deletion electron-app/ecoindex-app/src/renderer/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down

0 comments on commit fcdcf63

Please sign in to comment.