Skip to content

Commit

Permalink
Merge pull request #53 from kristoferlund/kristoferlund
Browse files Browse the repository at this point in the history
HTML "_blank" links open in default system browser, fix issue #54
  • Loading branch information
thedavidmeister authored Jan 15, 2020
2 parents 2ce9ffe + 3375405 commit 3ea49c4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
9 changes: 8 additions & 1 deletion happ-ui-controller.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { BrowserView, dialog, protocol, session, ipcMain } = require('electron')
const { BrowserView, dialog, protocol, session, ipcMain, shell } = require('electron')
const { ncp } = require('ncp')
const fs = require('fs')
const path = require('path')
Expand Down Expand Up @@ -271,6 +271,13 @@ class HappUiController {
console.log('Created view. Loading', windowURL)

view.webContents.loadURL(windowURL)

// Open <a href='' target='_blank'> with default system browser
view.webContents.on("new-window", function (event, url) {
event.preventDefault()
shell.openExternal(url)
})

//setupWindowDevProduction(view)
let holoscape = this.holoscape
view.on('close', (event) => {
Expand Down
17 changes: 9 additions & 8 deletions views/legacy_install_bundle_view.html
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,6 @@ <h2 class="alert alert-success">Bundle successfully installed!</h2>
installed_instances: [],
installed_dnas: [],
installed_bridges: [],
used_ports: [],
happ_index: [],
selected_happ: undefined,
},
Expand Down Expand Up @@ -631,15 +630,17 @@ <h2 class="alert alert-success">Bundle successfully installed!</h2>
console.log('Bridge added')
}

const nextMinPort = () => {
if(app.used_ports.length > 0) {
app.used_ports.sort()
return app.used_ports[app.used_ports.length -1] + 1
const nextMinPort = async () => {
const interfaces = await call('admin/interface/list')()
if (Array.isArray(interfaces) && interfaces.length > 0) {
const ports = []
interfaces.forEach(interface => ports.push(interface.driver.port))
return Math.max(...ports) + 1
} else {
return 10000
}
}

const installUi = async (ui) => {
console.log(JSON.stringify(ui))
let extractedPath = temp.path()
Expand All @@ -658,8 +659,8 @@ <h2 class="alert alert-success">Bundle successfully installed!</h2>
let id = `${ui.name}-interface`
let type = 'websocket'
let admin = app.installAsAdmin
let port = await getPort({port: getPort.makeRange(nextMinPort(), 31000)})
app.used_ports.push(port)
let minPort = await nextMinPort()
let port = await getPort({port: getPort.makeRange(minPort, 31000)})
await call('admin/interface/add')({id,admin,type,port})

for(ref of ui.instance_references) {
Expand Down

0 comments on commit 3ea49c4

Please sign in to comment.