forked from rapid7/awsaml
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
82 lines (64 loc) · 1.95 KB
/
app.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
'use strict';
const electron = require('electron');
const Application = electron.app;
const BrowserWindow = electron.BrowserWindow;
const path = require('path');
const Server = require('./lib/server');
const config = require('./config');
const storagePath = path.join(Application.getPath('userData'), 'data.json');
global.Storage = require('./lib/storage')(storagePath);
const WindowWidth = 800;
const WindowHeight = 800;
let mainWindow = null;
Application.commandLine.appendSwitch('disable-http-cache');
Application.on('window-all-closed', () => {
Application.quit();
});
Application.on('ready', () => {
require('./app-menu');
const host = Server.get('host');
const port = Server.get('port');
Server.listen(port, host, () => {
console.log('Server listening on http://%s:%s', host, port); // eslint-disable-line no-console
});
let lastWindowState = Storage.get('lastWindowState');
if (lastWindowState === null) {
lastWindowState = {
width: WindowWidth,
height: WindowHeight
};
}
mainWindow = new BrowserWindow({
title: 'Rapid7 - Awsaml',
x: lastWindowState.x,
y: lastWindowState.y,
width: lastWindowState.width,
height: lastWindowState.height,
show: false,
webPreferences: {
nodeIntegration: false
}
});
mainWindow.on('close', () => {
const bounds = mainWindow.getBounds();
Storage.set('lastWindowState', {
x: bounds.x,
y: bounds.y,
width: bounds.width,
height: bounds.height,
version: 1
});
});
mainWindow.on('closed', () => {
mainWindow = null;
});
mainWindow.loadURL(Server.get('configureUrl'));
mainWindow.show();
setInterval(() => {
const entryPointUrl = Server.get('entryPointUrl');
if (entryPointUrl) {
console.log('Reloading...'); // eslint-disable-line no-console
mainWindow.loadURL(entryPointUrl);
}
}, (config.aws.duration - 10) * 1000); // eslint-disable-line rapid7/static-magic-numbers
});