Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTML "_blank" links open in default system browser, fix issue #54 #53

Merged
merged 2 commits into from
Jan 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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