-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
64 lines (57 loc) · 1.79 KB
/
index.html
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
<html>
<head>
<title>Zabbix monitor</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
</head>
<body>
<script type="text/javascript">
var gui = require('nw.gui');
var zabbix = require('./lib/zabbix.js');
var secretsProvider = require('./lib/secrets.js');
var storage = require('./lib/storage.js').storage;
var tray = require('./lib/tray.js');
var win = gui.Window.get();
var secrets = secretsProvider.loadSecrets();
var triggerFilter = storage.getJSONItem('triggerFilter');
var common = storage.getJSONItem('common');
var triggerWin = gui.Window.open('html/triggers.html', {
show: false,
toolbar: false,
position: 'mouse'
});
triggerWin.on('close', function() {
this.hide();
});
tray.init(gui);
tray.on('click', function() {
triggerWin.show();
triggerWin.focus();
});
if (secrets && triggerFilter && common) {
zabbix.connect(secrets.url, secrets.username, secrets.password, function() {
var updateTriggers = function() {
zabbix.retrieveTriggers(triggerFilter, function(triggers) {
var maxPriority = 0;
triggers.forEach(function(trigger) {
maxPriority = trigger.priority > maxPriority ? trigger.priority : maxPriority;
});
tray.setPriority(maxPriority);
triggerWin.reload();
});
};
setInterval(updateTriggers, common.updateInterval * 60000);
updateTriggers();
});
} else {
gui.Window.open('html/settings.html');
}
win.on('close', function() {
if (zabbix.isConnected()) {
zabbix.disconnect();
}
tray.remove();
this.close(true);
});
</script>
</body>
</html>