Fixed issue with the javascript getting confused about which API updates which canvases
This commit is contained in:
parent
dda2eff4c4
commit
f2cfc4bcec
@ -3,19 +3,21 @@ const apis = [
|
|||||||
"id":"Main",
|
"id":"Main",
|
||||||
"url":"https://api.nolancasey.click/server",
|
"url":"https://api.nolancasey.click/server",
|
||||||
"online": true,
|
"online": true,
|
||||||
"failedAttempts": 0
|
"failedAttempts": 0,
|
||||||
},
|
"cpu": null,
|
||||||
{
|
"threads": null,
|
||||||
"id":"Proxy",
|
"ram": null,
|
||||||
"url":"https://api.nolancasey.click/proxy",
|
"swap": null
|
||||||
"online": true,
|
|
||||||
"failedAttempts": 0
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id":"Lightweight",
|
"id":"Lightweight",
|
||||||
"url":"https://api.nolancasey.click/lightweight",
|
"url":"https://api.nolancasey.click/lightweight",
|
||||||
"online": true,
|
"online": true,
|
||||||
"failedAttempts": 0
|
"failedAttempts": 0,
|
||||||
|
"cpu": null,
|
||||||
|
"threads": null,
|
||||||
|
"ram": null,
|
||||||
|
"swap": null
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
const colors = ["red", "green", "blue", "chartreuse", "darkmagenta", "darkkhaki", "purple", "salmon", "yellow", "blueviolet", "chocolate", "crimson", "cyan", "darkslategrey", "khaki", "hotpink"];
|
const colors = ["red", "green", "blue", "chartreuse", "darkmagenta", "darkkhaki", "purple", "salmon", "yellow", "blueviolet", "chocolate", "crimson", "cyan", "darkslategrey", "khaki", "hotpink"];
|
||||||
@ -96,7 +98,7 @@ window.addEventListener("load", async function () {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
cpu = new Chart(api.id + "_cpu",{
|
api["cpu"] = new Chart(api.id + "_cpu",{
|
||||||
type: "line",
|
type: "line",
|
||||||
data:{
|
data:{
|
||||||
labels: labels,
|
labels: labels,
|
||||||
@ -135,7 +137,7 @@ window.addEventListener("load", async function () {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
threads = new Chart(api.id + "_threads", {
|
api["threads"] = new Chart(api.id + "_threads", {
|
||||||
type: "line",
|
type: "line",
|
||||||
data:{
|
data:{
|
||||||
labels: labels,
|
labels: labels,
|
||||||
@ -158,7 +160,7 @@ window.addEventListener("load", async function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
var x = ["Used", "Free"]
|
var x = ["Used", "Free"]
|
||||||
ram = new Chart(api.id + "_ram",{
|
api["ram"] = new Chart(api.id + "_ram",{
|
||||||
type: "doughnut",
|
type: "doughnut",
|
||||||
data:{
|
data:{
|
||||||
labels: x,
|
labels: x,
|
||||||
@ -182,7 +184,7 @@ window.addEventListener("load", async function () {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
swap = new Chart(api.id + "_swap",{
|
api["swap"] = new Chart(api.id + "_swap",{
|
||||||
type: "doughnut",
|
type: "doughnut",
|
||||||
labels: x,
|
labels: x,
|
||||||
data:{
|
data:{
|
||||||
@ -235,24 +237,23 @@ async function increment() {
|
|||||||
api.failedAttempts = 0;
|
api.failedAttempts = 0;
|
||||||
|
|
||||||
for (var i = 1; i < resolution; i++){
|
for (var i = 1; i < resolution; i++){
|
||||||
cpu.data.datasets[0].data[i - 1] = cpu.data.datasets[0].data[i];
|
api["cpu"].data.datasets[0].data[i - 1] = api["cpu"].data.datasets[0].data[i];
|
||||||
}
|
}
|
||||||
cpu.data.datasets[0].data[resolution - 1] = json["cpu0"];
|
api["cpu"].data.datasets[0].data[resolution - 1] = json["cpu0"];
|
||||||
cpu.update();
|
api["cpu"].update();
|
||||||
for (var i = 0; i < json["cpuCount"]; i++){
|
for (var i = 0; i < json["cpuCount"]; i++){
|
||||||
for (var j = 1; j < resolution; j++){
|
for (var j = 1; j < resolution; j++){
|
||||||
threads.data.datasets[i].data[j - 1] = threads.data.datasets[i].data[j];
|
api["threads"].data.datasets[i].data[j - 1] = api["threads"].data.datasets[i].data[j];
|
||||||
}
|
}
|
||||||
threads.data.datasets[i].data[resolution - 1] = json["cpu" + (i + 1)];
|
api["threads"].data.datasets[i].data[resolution - 1] = json["cpu" + (i + 1)];
|
||||||
threads.update();
|
|
||||||
}
|
}
|
||||||
threads.update();
|
api["threads"].update();
|
||||||
ram.data.datasets[0].data[0] = json["usedRam"];
|
api["ram"].data.datasets[0].data[0] = json["usedRam"];
|
||||||
ram.data.datasets[0].data[1] = json["totalRam"] - json["usedRam"];
|
api["ram"].data.datasets[0].data[1] = json["totalRam"] - json["usedRam"];
|
||||||
swap.data.datasets[0].data[0] = json["usedSwap"];
|
api["swap"].data.datasets[0].data[0] = json["usedSwap"];
|
||||||
swap.data.datasets[0].data[1] = json["totalSwap"] - json["usedSwap"];
|
api["swap"].data.datasets[0].data[1] = json["totalSwap"] - json["usedSwap"];
|
||||||
ram.update();
|
api["ram"].update();
|
||||||
swap.update();
|
api["swap"].update();
|
||||||
}catch (error){
|
}catch (error){
|
||||||
if (api.failedAttempts > 5){
|
if (api.failedAttempts > 5){
|
||||||
api.online = false;
|
api.online = false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user