mirror of
https://github.com/shouptech/tempgopher.git
synced 2026-02-03 08:39:43 +00:00
parent
f13c557b38
commit
e3ec4803de
2 changed files with 116 additions and 112 deletions
|
|
@ -60,15 +60,9 @@ function fahrenheitToCelsius(degree) {
|
||||||
return (degree - 32) * 5 / 9;
|
return (degree - 32) * 5 / 9;
|
||||||
};
|
};
|
||||||
|
|
||||||
function renderThermostats() {
|
function appendData(data) {
|
||||||
$.ajax({
|
|
||||||
url: jsconfig.baseurl + "/api/status/",
|
|
||||||
beforeSend: authHeaders
|
|
||||||
}).then(function(data) {
|
|
||||||
$("#thermostats").empty();
|
|
||||||
for (var key in data) {
|
|
||||||
// Title of thermostat
|
// Title of thermostat
|
||||||
var titleh = $("<h4></h4>").text(data[key].alias);
|
var titleh = $("<h4></h4>").text(data.alias);
|
||||||
var titlediv = $("<div></div>").addClass("row").append(titleh);
|
var titlediv = $("<div></div>").addClass("row").append(titleh);
|
||||||
|
|
||||||
// Thermostat status
|
// Thermostat status
|
||||||
|
|
@ -77,18 +71,18 @@ function renderThermostats() {
|
||||||
|
|
||||||
// Display temperature
|
// Display temperature
|
||||||
if (jsconfig.fahrenheit) {
|
if (jsconfig.fahrenheit) {
|
||||||
var temp = celsiusToFahrenheit(parseFloat(data[key].temp)).toFixed(1) + "°F";
|
var temp = celsiusToFahrenheit(parseFloat(data.temp)).toFixed(1) + "°F";
|
||||||
} else {
|
} else {
|
||||||
var temp = parseFloat(data[key].temp).toFixed(1) + "°C";
|
var temp = parseFloat(data.temp).toFixed(1) + "°C";
|
||||||
}
|
}
|
||||||
var temph = $("<h2></h2>").text(temp);
|
var temph = $("<h2></h2>").text(temp);
|
||||||
var tempdiv = $("<div></div>").addClass("two columns").append(temph);
|
var tempdiv = $("<div></div>").addClass("two columns").append(temph);
|
||||||
rowdiv.append(tempdiv);
|
rowdiv.append(tempdiv);
|
||||||
|
|
||||||
// Display status
|
// Display status
|
||||||
if (data[key].cooling) {
|
if (data.cooling) {
|
||||||
var statustext = "Cooling"
|
var statustext = "Cooling"
|
||||||
} else if (data[key].heating) {
|
} else if (data.heating) {
|
||||||
var statustext = "Heating"
|
var statustext = "Heating"
|
||||||
} else {
|
} else {
|
||||||
var statustext = "Idle"
|
var statustext = "Idle"
|
||||||
|
|
@ -99,7 +93,7 @@ function renderThermostats() {
|
||||||
|
|
||||||
// Display sensor config
|
// Display sensor config
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: jsconfig.baseurl + "/api/config/sensors/" + data[key].alias,
|
url: jsconfig.baseurl + "/api/config/sensors/" + data.alias,
|
||||||
beforeSend: authHeaders
|
beforeSend: authHeaders
|
||||||
}).then(function(configData){
|
}).then(function(configData){
|
||||||
if (jsconfig.fahrenheit) {
|
if (jsconfig.fahrenheit) {
|
||||||
|
|
@ -178,6 +172,16 @@ function renderThermostats() {
|
||||||
$("#thermostats").append(titlediv);
|
$("#thermostats").append(titlediv);
|
||||||
$("#thermostats").append(rowdiv);
|
$("#thermostats").append(rowdiv);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderThermostats() {
|
||||||
|
$.ajax({
|
||||||
|
url: jsconfig.baseurl + "/api/status/",
|
||||||
|
beforeSend: authHeaders
|
||||||
|
}).then(function(data) {
|
||||||
|
$("#thermostats").empty();
|
||||||
|
for (var key in data) {
|
||||||
|
appendData(data[key])
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
||||||
2
main.go
2
main.go
|
|
@ -8,7 +8,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// Version is the current code version of tempgopher
|
// Version is the current code version of tempgopher
|
||||||
const Version = "0.3.0"
|
const Version = "0.3.1-dev"
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
var args struct {
|
var args struct {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue