-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmonitorWindow.js
More file actions
54 lines (40 loc) · 1.2 KB
/
monitorWindow.js
File metadata and controls
54 lines (40 loc) · 1.2 KB
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
// Modules
const {BrowserWindow, ipcMain} = require('electron');
const datastore = require('./datastore.js');
const filewatch = require('./datasource/filewatch');
exports.win
exports.createWindow = (monitorWindow) => {
this.win = monitorWindow;
this.win.loadURL(`file://${__dirname}/renderer/monitor.html`);
// Create full size app
this.win.maximize();
// Devtools
this.win.webContents.openDevTools()
this.win.once('ready-to-show', async () => {
this.win.show()
})
this.win.once('move', async () => {
//Monitor window moved
})
// Handle window closed
this.win.on('closed', () => {
this.win = null
})
this.win.on('focus', () => {
//Focused on monitor window
})
return this.win;
}
// [ Triggers ]
ipcMain.on('get-history', async (e, msg) => {
try {
let from = msg.data.from
let to = msg.data.to
let unixFrom = parseInt((new Date(from).getTime() / 1000).toFixed())
let unixTo = parseInt((new Date(to).getTime() / 1000).toFixed())
let data = await datastore.getHistoryData({from: unixFrom, to: unixTo, pumpId: msg.data.pumpId})
e.sender.send('get-history', {data: data})
} catch(error) {
e.sender.send('get-history', false)
}
})