-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.js
96 lines (80 loc) · 2.72 KB
/
index.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
const { ipcRenderer } = require("electron");
let $ = require("jquery");
require("popper.js");
require("bootstrap");
const Store = require("electron-store");
const Chart = require("chart.js");
require("chartjs-adapter-moment");
require("chartjs-plugin-streaming");
require("chartjs-plugin-datalabels");
const computeutils = require("./app/computeutils");
const refreshutils = require("./app/refreshutils");
const charts = require("./app/charts");
const settings = require("./app/settings");
const sensors = require("./app/sensors");
let interval;
let refresh_rate;
let maxvalues;
let autostart = false;
let theme = "./themes/flatly.css";
let sensorList = [];
let store = new Store();
getNames();
settings.loadSettings().then(() => {
getValues();
setInterval(getValues, refresh_rate);
charts.createCharts();
});
settings.setupButtons();
document.getElementById("cpuChart").style.display = "none";
document.getElementById("gpuChart").style.display = "none";
document.getElementById("aneChart").style.display = "none";
document.getElementById("buymeacoffee").addEventListener("click", () => {
const shell = require("electron").shell;
shell.openExternal("https://www.buymeacoffee.com/andreivdev");
});
document.getElementById("showallbutton").addEventListener("click", () => {
ipcRenderer.send("index", "showalltoggle");
document.getElementById("cpuChart").style.display =
document.getElementById("cpuChart").style.display == "none"
? "flex"
: "none";
document.getElementById("gpuChart").style.display =
document.getElementById("gpuChart").style.display == "none"
? "flex"
: "none";
document.getElementById("aneChart").style.display =
document.getElementById("aneChart").style.display == "none"
? "flex"
: "none";
});
document.getElementById("close").addEventListener("click", () => {
ipcRenderer.send("index", "close");
});
function getNames() {
ipcRenderer.send("index", "getNames");
}
function getValues() {
ipcRenderer.send("index", "getValues");
}
ipcRenderer.on("names", (event, arg) => {
let argArray = arg.split("_");
sensors.addNames(argArray);
});
ipcRenderer.on("values", (event, arg) => {
let argArray = arg.split("_");
sensors.addValues(argArray);
});
ipcRenderer.on("visibility", (event, arg) => {
if (arg) {
document.getElementById("mainChart").hidden = false;
document.getElementById("cpuChart").hidden = false;
document.getElementById("gpuChart").hidden = false;
document.getElementById("aneChart").hidden = false;
} else {
document.getElementById("mainChart").hidden = true;
document.getElementById("cpuChart").hidden = true;
document.getElementById("gpuChart").hidden = true;
document.getElementById("aneChart").hidden = true;
}
});