now windows it's selected based on id not in focus

This commit is contained in:
Guille 2024-04-23 06:28:03 +02:00
parent 610ad66475
commit 9c81a2b241

View File

@ -2,6 +2,8 @@ const { dialog, BrowserWindow } = require ("electron");
const dotenv = require('dotenv')
const session_start = 'https://nextgenerations-cities.encs.concordia.ca/api/v1.4/session/start'
const retrofit_results = 'https://nextgenerations-cities.encs.concordia.ca/api/v1.4/persistence/retrofit-results'
//const session_start = 'http://127.0.0.1:15789/v1.4/session/start'
//const retrofit_results = 'http://127.0.0.1:15789/v1.4/persistence/retrofit-results'
exports.run = async (application, buildings, tmp_path) => {
@ -24,6 +26,7 @@ exports.run = async (application, buildings, tmp_path) => {
const application_response = await response.json()
const session_id = response.headers.get('session_id')
let token = response.headers.get('token')
console.log(`token: ${token}`)
request = { 'scenarios': [] }
application_response.scenarios.forEach((scenario) => {
scenario_request = {}
@ -40,7 +43,8 @@ exports.run = async (application, buildings, tmp_path) => {
'accept': 'application/json'
},
body: JSON.stringify(request)
})
}, 600000)
console.log(`response: ${response.status}`)
if (response.status == 200) {
results = await response.json()
@ -184,7 +188,7 @@ exports.run = async (application, buildings, tmp_path) => {
`${operational_co2_header}\n${operational_co2_lines.join('\n')}`,
function (err) { console.log(err ? err : 'operational_co2 saved') }
)
BrowserWindow.getFocusedWindow().webContents.send('task-completed', '<a href="../../tmp/meb.csv">meb</a><br /><a href="../../tmp/cost.csv">costs</a><br /><a href="../../tmp/operational_co2.csv">operational_co2</a>')
BrowserWindow.fromId(1).webContents.send('task-completed', '<a href="../../tmp/meb.csv">meb</a><br /><a href="../../tmp/cost.csv">costs</a><br /><a href="../../tmp/operational_co2.csv">operational_co2</a>')
}
else {
console.log('unautorized retrofit')