Skip to content

Commit 817dc37

Browse files
committed
Fix some UI issues
1 parent 709a504 commit 817dc37

File tree

3 files changed

+18
-12
lines changed

3 files changed

+18
-12
lines changed

html/template.html

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,18 @@
3434
</style>
3535
<script type="application/javascript">
3636
function sendValue(input) {
37-
$.ajax({
38-
url: input.dataset.url, method: "POST", data: $(input).closest("form").find("input").val()
39-
}).complete(function (data, textStatus, jqXHR) {
40-
alert(textStatus);
41-
});
37+
$.ajax(input.dataset.url,{
38+
'data': $(input).closest("form").find("input").val(),
39+
'type': 'POST',
40+
'processData': false,
41+
'contentType': 'application/json'
42+
});
4243
}
4344
setInterval(function() {
4445
$("[data-ajaxurl]").each(function(index) {
4546
var ele = $(this);
4647
$.getJSON( ele.data("ajaxurl"), function (data) {
47-
var eleValue = $(ele.find(".panel-body")[0]);
48+
var eleValue = $(ele.find("#value")[0]);
4849
if(data.value.toUpperCase() == "OPEN") {
4950
eleValue.html("<span class=\"label label-success\">" + data.value + "</span>");
5051
} else if(data.value.toUpperCase() == "CLOSE") {
@@ -129,7 +130,7 @@
129130
<!-- split:sensnor_input -->
130131
<!-- split:sensor_output -->
131132
<li class="list-group-item" style="font-size: 24px;">
132-
<span>{value}</span>
133+
<span id="value">{value}</span>
133134
</li>
134135
<!-- split:sensor_output -->
135136
</ul>

src/WebPortal.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,16 @@ void WebPortal::sendSensor(Entry* entry) {
7979
String page = FPSTR(HTML_SENSOR);
8080
page.replace("{color}", entry->isInternal() ? "warning" : "primary");
8181
page.replace("{name}", getName(entry));
82+
bool include = false;
8283
if(entry->isOut()) {
84+
include = true;
8385
page.replace("{input}", FPSTR(HTML_SENSOR_INPUT));
84-
page.replace("{path}", getRestPath(entry));
8586
} else {
8687
page.replace("{input}", "");
8788
}
8889
String value = entry->getValue();
8990
if(value != NULL) {
91+
include = true;
9092
page.replace("{output}", FPSTR(HTML_SENSOR_OUTPUT));
9193
if(getName(entry).endsWith("password")) {
9294
page.replace("{value}", "***");
@@ -96,8 +98,11 @@ void WebPortal::sendSensor(Entry* entry) {
9698
} else {
9799
page.replace("{output}", "");
98100
}
99-
page.replace("{last_updated}", time(entry->getLastUpdate()));
100-
webServer->sendContent(page);
101+
if(include) {
102+
page.replace("{path}", getRestPath(entry));
103+
page.replace("{last_updated}", time(entry->getLastUpdate()));
104+
webServer->sendContent(page);
105+
}
101106
}
102107

103108
void WebPortal::sendConfigs() {

0 commit comments

Comments
 (0)