mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-20 07:43:12 +09:00
Change name from slaveID to instanceID for consistency accross endpoints
This commit is contained in:
1 parent
7ece1af073
commit
e2a795528f
7 files changed
+50
-50
No files matched your search
@@ -42,7 +42,7 @@ setInterval(function(){
|
||||
indicator.style.backgroundColor = "yellow";
|
||||
indicator.title = "Master server unavailable";
|
||||
// compare with Math.floor(x/100000) allows us to check if they are within 10s of each other
|
||||
} else if(Math.floor(slaveData[getParameterByName("slaveID")].time/100000) == Math.floor(Date.now()/100000)){
|
||||
} else if(Math.floor(slaveData[getParameterByName("instanceID")].time/100000) == Math.floor(Date.now()/100000)){
|
||||
indicator.style.backgroundColor = "green";
|
||||
indicator.title = "Slave is online";
|
||||
} else {
|
||||
@@ -54,9 +54,9 @@ setInterval(function(){
|
||||
|
||||
populateSlaveInfo();
|
||||
function populateSlaveInfo(){
|
||||
let slaveID = getParameterByName("slaveID");
|
||||
if(!slaveID){
|
||||
throw "We need slaveID! GIVE US SLAVEID! ALL HAIL OUR NEW OVERLORDS!"
|
||||
let instanceID = getParameterByName("instanceID");
|
||||
if(!instanceID){
|
||||
throw "We need instanceID! GIVE US SLAVEID! ALL HAIL OUR NEW OVERLORDS!"
|
||||
}
|
||||
getJSON("/api/slaves", function(err, slaveData){
|
||||
/*
|
||||
@@ -83,7 +83,7 @@ function populateSlaveInfo(){
|
||||
"mac":"44-85-00-D2-7E-D6"}
|
||||
}
|
||||
*/
|
||||
let slave = slaveData[slaveID];
|
||||
let slave = slaveData[instanceID];
|
||||
let HTML = "<div id='header'><div id='onlineIndicator'></div><h1>Name: " + slave.instanceName+"</h1>"
|
||||
HTML += "<div class='subbar'><h6>Host: "+slave.mac+" </h6><h6>Unique: "+slave.unique+" </h6>"
|
||||
if(slave.publicIP != "localhost"){
|
||||
@@ -225,9 +225,9 @@ function maximizeTerminal(instant){
|
||||
}
|
||||
|
||||
// ID of slave, ID of canvasjs div without #
|
||||
function makeGraph(slaveID, selector) {
|
||||
post("api/getStats", {slaveID: slaveID}, function(data){
|
||||
//console.log("Building chart " + slaveID + " with this data:")
|
||||
function makeGraph(instanceID, selector) {
|
||||
post("api/getStats", {instanceID: instanceID}, function(data){
|
||||
//console.log("Building chart " + instanceID + " with this data:")
|
||||
//console.log(data)
|
||||
if(data.length > 0) {
|
||||
// find keys
|
||||
|
||||
@@ -14,7 +14,7 @@ setTimeout(function() {
|
||||
let seenDate = moment(Number(slaveData[key].time)).format('DD.MM.YY, hh:mm:ss')
|
||||
HTML += "<div class='slaveBox'>";
|
||||
HTML += '<div id="' + slaveData[key].unique + '" class="productionGraph" style="width: calc(100% - 200px);"></div>';
|
||||
HTML += "<a href='nodeDetails?slaveID="+slaveData[key].unique+"'><h2>" + slaveData[key].instanceName + "</h2></a><p>ID: " + slaveData[key].unique + "</p><p>Last seen: "+seenDate+"</p><p>Online players: "+slaveData[key].playerCount+"</p><p>IP: "+slaveData[key].publicIP +":"+ slaveData[key].serverPort+"</p>"
|
||||
HTML += "<a href='nodeDetails?instanceID="+slaveData[key].unique+"'><h2>" + slaveData[key].instanceName + "</h2></a><p>ID: " + slaveData[key].unique + "</p><p>Last seen: "+seenDate+"</p><p>Online players: "+slaveData[key].playerCount+"</p><p>IP: "+slaveData[key].publicIP +":"+ slaveData[key].serverPort+"</p>"
|
||||
HTML += "<p>Host: "+slaveData[key].mac+"</p>";
|
||||
HTML += "<button onclick='hideAllDatasets(\"" + slaveData[key].unique + "\")\'>Hide all</button>";
|
||||
HTML += "<button onclick='showAllDatasets(\"" + slaveData[key].unique + "\")\'>Show all</button>";
|
||||
@@ -43,9 +43,9 @@ let chartIgnoreList = [
|
||||
]
|
||||
|
||||
// ID of slave, ID of canvasjs div without #
|
||||
function makeGraph(slaveID, selector) {
|
||||
post("api/getTimelineStats", {slaveID: slaveID}, function(pointsInTime) {
|
||||
//console.log("Building chart " + slaveID + " with this data:")
|
||||
function makeGraph(instanceID, selector) {
|
||||
post("api/getTimelineStats", {instanceID: instanceID}, function(pointsInTime) {
|
||||
//console.log("Building chart " + instanceID + " with this data:")
|
||||
|
||||
//Find all keys at all points in time.
|
||||
let itemNames = {};
|
||||
|
||||
+10
-10
@@ -107,15 +107,15 @@ function makeItemGraphs(itemName){
|
||||
if(typeof slaves == "string"){
|
||||
slaves = JSON.parse(slaves);
|
||||
}
|
||||
let slaveIDs = Object.keys(slaves);
|
||||
let instanceIDs = Object.keys(slaves);
|
||||
let HTML = ""
|
||||
// Draw in/out chart for unregistered slaves as well
|
||||
slaveIDs.unshift("unknown");
|
||||
slaveIDs.forEach(function(slaveID){
|
||||
if(slaveID == "unknown" || Date.now() - slaves[slaveID].time < 120000 || JSON.parse(localStorage.settings)["Display offline slaves"]){
|
||||
HTML += '<div id="contentGraph'+slaveID+'" class="storageGraph" style="width: 100%;"></div>';
|
||||
instanceIDs.unshift("unknown");
|
||||
instanceIDs.forEach(function(instanceID){
|
||||
if(instanceID == "unknown" || Date.now() - slaves[instanceID].time < 120000 || JSON.parse(localStorage.settings)["Display offline slaves"]){
|
||||
HTML += '<div id="contentGraph'+instanceID+'" class="storageGraph" style="width: 100%;"></div>';
|
||||
["place", "remove"].forEach(statistic => {
|
||||
console.log("Making chart for "+slaveID+"'s "+statistic+" statistic");
|
||||
console.log("Making chart for "+instanceID+"'s "+statistic+" statistic");
|
||||
|
||||
setTimeout(function(){
|
||||
let xmlhttp = new XMLHttpRequest(); // new HttpRequest instance
|
||||
@@ -128,7 +128,7 @@ function makeItemGraphs(itemName){
|
||||
if(isJSON(xmlhttp.responseText) && JSON.parse(xmlhttp.responseText).statusForDebugging === undefined){
|
||||
let slaveDisplayName = "unknown";
|
||||
try {
|
||||
slaveDisplayName = slaves[slaveID].instanceName;
|
||||
slaveDisplayName = slaves[instanceID].instanceName;
|
||||
} catch(e) {}
|
||||
let whatGraphIsIt = "Item IO from ";
|
||||
// if(statistic == "remove") whatGraphIsIt = "Items taken from cluster by";
|
||||
@@ -143,19 +143,19 @@ function makeItemGraphs(itemName){
|
||||
break;
|
||||
}
|
||||
drawChartWhenCalledTwice(chartData, whatGraphIsIt + " " + slaveDisplayName);
|
||||
//drawChart(statistic+"contentGraph"+slaveID, [JSON.parse(xmlhttp.response).data], `${whatGraphIsIt} ${slaveDisplayName} (${slaveID}) ${itemName}`);
|
||||
//drawChart(statistic+"contentGraph"+instanceID, [JSON.parse(xmlhttp.response).data], `${whatGraphIsIt} ${slaveDisplayName} (${instanceID}) ${itemName}`);
|
||||
// console.log(JSON.parse(xmlhttp.response).data);
|
||||
}
|
||||
}
|
||||
}
|
||||
xmlhttp.send(JSON.stringify({statistic:statistic, itemName:itemName, slaveID:slaveID}));
|
||||
xmlhttp.send(JSON.stringify({statistic:statistic, itemName:itemName, instanceID:instanceID}));
|
||||
},1);
|
||||
});
|
||||
let chartLines = [];
|
||||
function drawChartWhenCalledTwice(data, slaveDisplayName){
|
||||
chartLines.push(data);
|
||||
if(chartLines.length >= 2){
|
||||
drawChart("contentGraph"+slaveID, chartLines, `${slaveDisplayName} (${slaveID}) ${itemName}`);
|
||||
drawChart("contentGraph"+instanceID, chartLines, `${slaveDisplayName} (${instanceID}) ${itemName}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user