Itemstats on storage page respects offlineSlaves setting

This commit is contained in:
Danielv123 committed 2017-10-29 12:22:50 +01:00
1 parent a7474fdb86
commit fe704b46e9
1 file changed
+24 -19
+24 -19
View File
@@ -113,29 +113,34 @@ function makeItemGraphs(itemName){
let HTML = "" let HTML = ""
// Draw in/out chart for unregistered slaves as well // Draw in/out chart for unregistered slaves as well
slaveIDs.unshift("unknown"); slaveIDs.unshift("unknown");
slaveIDs.unshift("debug");
slaveIDs.forEach(function(slaveID){ slaveIDs.forEach(function(slaveID){
["place", "remove"].forEach(statistic => { if(slaveID == "unknown" || Date.now() - slaves[slaveID].time < 120000 || JSON.parse(localStorage.settings)["Display offline slaves"]){
console.log("Making chart for "+slaveID+"'s "+statistic+" statistic") ["place", "remove"].forEach(statistic => {
HTML += '<div id="'+statistic+'contentGraph'+slaveID+'" class="storageGraph" style="width: 100%;"></div>'; console.log("Making chart for "+slaveID+"'s "+statistic+" statistic");
HTML += '<div id="'+statistic+'contentGraph'+slaveID+'" class="storageGraph" style="width: 100%;"></div>';
setTimeout(function(){ setTimeout(function(){
let xmlhttp = new XMLHttpRequest(); // new HttpRequest instance let xmlhttp = new XMLHttpRequest(); // new HttpRequest instance
xmlhttp.open("POST", "/api/getStats"); xmlhttp.open("POST", "/api/getStats");
xmlhttp.setRequestHeader("Content-Type", "application/json"); xmlhttp.setRequestHeader("Content-Type", "application/json");
xmlhttp.onreadystatechange = function(){ xmlhttp.onreadystatechange = function(){
console.log(xmlhttp.status); console.log(xmlhttp.status);
if(xmlhttp.readyState === XMLHttpRequest.DONE && xmlhttp.status === 200) { if(xmlhttp.readyState === XMLHttpRequest.DONE && xmlhttp.status === 200) {
// console.log(xmlhttp.responseText); // console.log(xmlhttp.responseText);
if(isJSON(xmlhttp.responseText) && JSON.parse(xmlhttp.responseText).statusForDebugging === undefined){ if(isJSON(xmlhttp.responseText) && JSON.parse(xmlhttp.responseText).statusForDebugging === undefined){
drawChart(statistic+"contentGraph"+slaveID, [JSON.parse(xmlhttp.response).data], slaveID+" "+itemName); let slaveDisplayName = "unknown";
// console.log(JSON.parse(xmlhttp.response).data); try {
slaveDisplayName = slaves[slaveID].instanceName;
} catch(e) {}
drawChart(statistic+"contentGraph"+slaveID, [JSON.parse(xmlhttp.response).data], `${slaveDisplayName} (${slaveID}) ${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, slaveID:slaveID})); },1);
},1000); });
}); }
}); });
document.querySelector("#graphDisplay > #storageGraphContainer").innerHTML = HTML; document.querySelector("#graphDisplay > #storageGraphContainer").innerHTML = HTML;
}); });