Frontend now displays environment temperature. Moved from using '-1' and an 'invalid' indicator to nulls, which in hindsight is what it should've been before. Old habits die hard.
This commit is contained in:
parent
4e43c799f7
commit
f579dd4c16
|
@ -4,9 +4,9 @@ import uuid
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
# Vitals
|
# Vitals
|
||||||
vitalsHeartrate = -1
|
vitalsHeartrate = None
|
||||||
vitalsOxygen = -1
|
vitalsOxygen = None
|
||||||
vitalsBodytemp = -1.0
|
vitalsBodytemp = None
|
||||||
|
|
||||||
@app.route('/api/vitals/heartrate')
|
@app.route('/api/vitals/heartrate')
|
||||||
def getVitalsHeartrate():
|
def getVitalsHeartrate():
|
||||||
|
@ -89,7 +89,7 @@ def setVitals():
|
||||||
return 'Information set successfully', 204
|
return 'Information set successfully', 204
|
||||||
|
|
||||||
# Fitness
|
# Fitness
|
||||||
fitnessSteps = -1
|
fitnessSteps = None
|
||||||
|
|
||||||
@app.route('/api/fitness/steps')
|
@app.route('/api/fitness/steps')
|
||||||
def getSteps():
|
def getSteps():
|
||||||
|
@ -220,8 +220,8 @@ def resetCyberwareMalfunction():
|
||||||
return 'Not Implemented', 501
|
return 'Not Implemented', 501
|
||||||
|
|
||||||
# Environment data
|
# Environment data
|
||||||
environmentTemperature = -1
|
environmentTemperature = None
|
||||||
environmentHumidity = -1
|
environmentHumidity = None
|
||||||
|
|
||||||
@app.route('/api/environment')
|
@app.route('/api/environment')
|
||||||
def getEnvironment():
|
def getEnvironment():
|
||||||
|
|
|
@ -65,6 +65,10 @@
|
||||||
border: 1px solid #F00; /* TODO: Remove this later */
|
border: 1px solid #F00; /* TODO: Remove this later */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#environmentTemperature {
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
/* Below are all Map styling */
|
/* Below are all Map styling */
|
||||||
#map {
|
#map {
|
||||||
margin-right: 2px;
|
margin-right: 2px;
|
||||||
|
@ -183,7 +187,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div id="projectName">
|
<div id="projectName">
|
||||||
<p>K.A.T.I.E.</p>
|
<p>K.A.T.I.E.</p>
|
||||||
<p style="text-align: right;">0°C</p>
|
<div id="environmentTemperature"><p>‌</p></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="mapProper">
|
<div id="mapProper">
|
||||||
|
@ -215,6 +219,7 @@
|
||||||
// TODO: Make baseUrl be set by Flask
|
// TODO: Make baseUrl be set by Flask
|
||||||
var baseUrl = "http://localhost:5000";
|
var baseUrl = "http://localhost:5000";
|
||||||
var vitalsUrl = baseUrl + "/api/vitals";
|
var vitalsUrl = baseUrl + "/api/vitals";
|
||||||
|
var environmentUrl = baseUrl + "/api/environment";
|
||||||
|
|
||||||
// Malfunction Messages (human-friendly)
|
// Malfunction Messages (human-friendly)
|
||||||
malfunctionMessage = [ "API Malfunction" ]
|
malfunctionMessage = [ "API Malfunction" ]
|
||||||
|
@ -226,7 +231,6 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function setVitals(vitalsData) {
|
function setVitals(vitalsData) {
|
||||||
//var data = JSON.parse(vitalsData)
|
|
||||||
heartrate = vitalsData["0"]["heartrate"];
|
heartrate = vitalsData["0"]["heartrate"];
|
||||||
oxygen = vitalsData["0"]["oxygen"];
|
oxygen = vitalsData["0"]["oxygen"];
|
||||||
bodytemp = vitalsData["0"]["bodytemp"];
|
bodytemp = vitalsData["0"]["bodytemp"];
|
||||||
|
@ -237,29 +241,49 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function setVitalsHeartrate(heartrate) {
|
function setVitalsHeartrate(heartrate) {
|
||||||
if(heartrate > 0) {
|
if(heartrate === null) {
|
||||||
document.getElementById("heartrate").innerHTML = "<p>Heartrate: " + heartrate + " BPM</p>";
|
|
||||||
} else {
|
|
||||||
document.getElementById("heartrate").innerHTML = "";
|
document.getElementById("heartrate").innerHTML = "";
|
||||||
|
} else {
|
||||||
|
document.getElementById("heartrate").innerHTML = "<p>Heartrate: " + heartrate + " BPM</p>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setVitalsOxygen(oxygen) {
|
function setVitalsOxygen(oxygen) {
|
||||||
if(oxygen > 0) {
|
if(oxygen === null) {
|
||||||
document.getElementById("oxygen").innerHTML = "<p>Oxygen: " + oxygen + "% O2</p>";
|
|
||||||
} else {
|
|
||||||
document.getElementById("oxygen").innerHTML = "";
|
document.getElementById("oxygen").innerHTML = "";
|
||||||
|
} else {
|
||||||
|
document.getElementById("oxygen").innerHTML = "<p>Oxygen: " + oxygen + "% O2</p>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setVitalsBodytemp(bodytemp) {
|
function setVitalsBodytemp(bodytemp) {
|
||||||
if(bodytemp > 0) {
|
if(bodytemp === null) {
|
||||||
document.getElementById("bodyTemperature").innerHTML = "<p>Body Temp: " + bodytemp + "°C</p>";
|
|
||||||
} else {
|
|
||||||
document.getElementById("bodyTemperature").innerHTML = "";
|
document.getElementById("bodyTemperature").innerHTML = "";
|
||||||
|
} else {
|
||||||
|
document.getElementById("bodyTemperature").innerHTML = "<p>Body Temp: " + bodytemp + "°C</p>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setEnvironment(environmentData) {
|
||||||
|
temperature = environmentData["0"]["temperature"];
|
||||||
|
humidity = environmentData["0"]["humidity"];
|
||||||
|
|
||||||
|
setEnvironmentTemperature(temperature);
|
||||||
|
setEnvironmentHumidity(humidity);
|
||||||
|
}
|
||||||
|
|
||||||
|
function setEnvironmentTemperature(temperature) {
|
||||||
|
if(temperature === null) {
|
||||||
|
document.getElementById("environmentTemperature").innerHTML = "<p>‌</p>";
|
||||||
|
} else {
|
||||||
|
document.getElementById("environmentTemperature").innerHTML = "<p>" + temperature + "°C";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function setEnvironmentHumidity(humidity) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
function updateAll() {
|
function updateAll() {
|
||||||
$.get(vitalsUrl, (data, status) => {
|
$.get(vitalsUrl, (data, status) => {
|
||||||
if(status == "success") {
|
if(status == "success") {
|
||||||
|
@ -268,6 +292,14 @@
|
||||||
displayMalfunction(malfunctionMessage[apiMalfunctionI] + ": " + status);
|
displayMalfunction(malfunctionMessage[apiMalfunctionI] + ": " + status);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$.get(environmentUrl, (data, status) => {
|
||||||
|
if(status == "success") {
|
||||||
|
setEnvironment(data);
|
||||||
|
} else {
|
||||||
|
displayMalfunction(malfunctionMessage[apiMalfunctionI] + ": " + status);
|
||||||
|
}
|
||||||
|
});
|
||||||
//stopInterval(t)
|
//stopInterval(t)
|
||||||
}
|
}
|
||||||
var t=setInterval(updateAll, 1000)
|
var t=setInterval(updateAll, 1000)
|
||||||
|
|
Loading…
Reference in a new issue