-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
65 lines (54 loc) · 1.54 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
const { app, Menu, Tray, BrowserWindow } = require('electron');
const path = require('path');
const host = "ncentre";
const delay = ms => new Promise(resolve => setTimeout(resolve, ms))
let parentWindow = undefined
const start = async function() {
}
openCockpit = function() {
// open with 'ready-to-show'
const childWindow = new BrowserWindow(
{
show: true,
backgroundColor: '#ffffff',
webPreferences: {
}
});
childWindow.setMenuBarVisibility(false);
childWindow.loadURL(`https://${host}:9090/cockpit/@localhost/podman/index.html#`)
}
createTrayMenu = function() {
const contextMenu = Menu.buildFromTemplate([
{
label: 'Open Cockpit',
click() { openCockpit(); }
},
{
label: 'Exit',
click() { app.quit(); },
accelerator: 'CommandOrControl+Q'
}
]);
tray.setContextMenu(contextMenu);
}
app.commandLine.appendSwitch('ignore-certificate-errors');
app.whenReady().then(() => {
// Parent window to prevent app closing
parentWindow = new BrowserWindow({ show: false })
// Setup tray
tray = new Tray(path.join(app.getAppPath(), 'assets', 'podman.png'))
tray.setToolTip('Podman Desktop');
createTrayMenu();
tray.on('click', () => {
tray.popUpContextMenu()
});
start();
});
app.on('certificate-error', (event, webContents, url, error, certificate, callback) => {
if (url.startsWith('https://${host}:9090/')) {
event.preventDefault()
callback(true)
} else {
callback(false)
}
})