mirror of
https://github.com/xoseperez/espurna.git
synced 2026-03-15 12:47:07 +01:00
Merge branch 'dev' into sensors
Conflicts: code/espurna/data/index.html.gz code/espurna/static/index.html.gz.h code/html/custom.js
This commit is contained in:
@@ -96,7 +96,15 @@ function validateForm(form) {
|
||||
}
|
||||
|
||||
// These fields will always be a list of values
|
||||
var is_group = ["ssid", "pass", "gw", "mask", "ip", "dns", "mqttGroup", "mqttGroupInv", "dczRelayIdx", "ledMode", "ntpServer", "adminPass"];
|
||||
var is_group = [
|
||||
"ssid", "pass", "gw", "mask", "ip", "dns",
|
||||
"relayBoot", "relayPulse", "relayTime",
|
||||
"mqttGroup", "mqttGroupInv",
|
||||
"dczRelayIdx",
|
||||
"ledMode",
|
||||
"ntpServer",
|
||||
"adminPass"
|
||||
];
|
||||
|
||||
function getData(form) {
|
||||
|
||||
@@ -475,20 +483,23 @@ function initRelays(data) {
|
||||
|
||||
}
|
||||
|
||||
function addRelayGroup() {
|
||||
function initRelayConfig(data) {
|
||||
|
||||
var numGroups = $("#relayGroups > div").length;
|
||||
var tabindex = 200 + numGroups * 2;
|
||||
var template = $("#relayGroupTemplate").children();
|
||||
var line = $(template).clone();
|
||||
var element = $("span.relay_id", line);
|
||||
if (element.length) element.html(numGroups+1);
|
||||
$(line).find("input").each(function() {
|
||||
$(this).attr("tabindex", tabindex++);
|
||||
});
|
||||
line.appendTo("#relayGroups");
|
||||
var current = $("#relayConfig > div").length;
|
||||
if (current > 0) return;
|
||||
|
||||
return line;
|
||||
var template = $("#relayConfigTemplate").children();
|
||||
for (var i=0; i < data.length; i++) {
|
||||
var line = $(template).clone();
|
||||
$("span.gpio", line).html(data[i].gpio);
|
||||
$("span.id", line).html(i+1);
|
||||
$("select[name='relayBoot']", line).val(data[i].boot);
|
||||
$("select[name='relayPulse']", line).val(data[i].pulse);
|
||||
$("input[name='relayTime']", line).val(data[i].pulse_ms);
|
||||
$("intut[name='mqttGroup']", line).val(data[i].group || 0);
|
||||
$("select[name='mqttGroupInv']", line).val(data[i].group_inv || 0);
|
||||
line.appendTo("#relayConfig");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -831,26 +842,9 @@ function processData(data) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Relay groups
|
||||
if (key == "relayGroups") {
|
||||
|
||||
var groups = data.relayGroups;
|
||||
|
||||
for (var i in groups) {
|
||||
|
||||
// add a new row
|
||||
var line = addRelayGroup();
|
||||
|
||||
// fill in the blanks
|
||||
var group = data.relayGroups[i];
|
||||
Object.keys(group).forEach(function(key) {
|
||||
var element = $("input[name=" + key + "]", line);
|
||||
if (element.length) element.val(group[key]);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
return;
|
||||
// Relay configuration
|
||||
if (key == "relayConfig") {
|
||||
initRelayConfig(data[key]);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user