Browse Source

webui: 2nd try at using css for light controls

register channels with their respective tags, instead of using count
both on backend and frontend

revert to useCCT mireds slider rule, disallow white channels with useWhite
pull/2558/head
Maxim Prokhorov 1 year ago
parent
commit
f37f380c04
24 changed files with 14042 additions and 14003 deletions
  1. BIN
      code/espurna/data/index.all.html.gz
  2. BIN
      code/espurna/data/index.curtain.html.gz
  3. BIN
      code/espurna/data/index.garland.html.gz
  4. BIN
      code/espurna/data/index.light.html.gz
  5. BIN
      code/espurna/data/index.lightfox.html.gz
  6. BIN
      code/espurna/data/index.rfbridge.html.gz
  7. BIN
      code/espurna/data/index.rfm69.html.gz
  8. BIN
      code/espurna/data/index.sensor.html.gz
  9. BIN
      code/espurna/data/index.small.html.gz
  10. BIN
      code/espurna/data/index.thermostat.html.gz
  11. +7
    -1
      code/espurna/light.cpp
  12. +2296
    -2293
      code/espurna/static/index.all.html.gz.h
  13. +1098
    -1098
      code/espurna/static/index.curtain.html.gz.h
  14. +1054
    -1055
      code/espurna/static/index.garland.html.gz.h
  15. +1982
    -1975
      code/espurna/static/index.light.html.gz.h
  16. +1059
    -1059
      code/espurna/static/index.lightfox.html.gz.h
  17. +1089
    -1089
      code/espurna/static/index.rfbridge.html.gz.h
  18. +1430
    -1430
      code/espurna/static/index.rfm69.html.gz.h
  19. +1521
    -1523
      code/espurna/static/index.sensor.html.gz.h
  20. +1043
    -1043
      code/espurna/static/index.small.html.gz.h
  21. +1414
    -1414
      code/espurna/static/index.thermostat.html.gz.h
  22. +0
    -3
      code/html/custom.css
  23. +45
    -17
      code/html/custom.js
  24. +4
    -3
      code/html/index.html

BIN
code/espurna/data/index.all.html.gz View File


BIN
code/espurna/data/index.curtain.html.gz View File


BIN
code/espurna/data/index.garland.html.gz View File


BIN
code/espurna/data/index.light.html.gz View File


BIN
code/espurna/data/index.lightfox.html.gz View File


BIN
code/espurna/data/index.rfbridge.html.gz View File


BIN
code/espurna/data/index.rfm69.html.gz View File


BIN
code/espurna/data/index.sensor.html.gz View File


BIN
code/espurna/data/index.small.html.gz View File


BIN
code/espurna/data/index.thermostat.html.gz View File


+ 7
- 1
code/espurna/light.cpp View File

@ -2581,7 +2581,13 @@ void _lightWebSocketOnVisible(JsonObject& root) {
wsPayloadModule(root, PSTR("light"));
JsonObject& light = root.createNestedObject("light");
light["channels"] = _light_channels.size();
JsonArray& channels = light.createNestedArray("channels");
const auto Channels = _light_channels.size();
for (size_t index = 0; index < Channels; ++index) {
channels.add(_lightTag(Channels, index));
}
if (_light_use_cct) {
JsonObject& cct = light.createNestedObject("cct");


+ 2296
- 2293
code/espurna/static/index.all.html.gz.h
File diff suppressed because it is too large
View File


+ 1098
- 1098
code/espurna/static/index.curtain.html.gz.h
File diff suppressed because it is too large
View File


+ 1054
- 1055
code/espurna/static/index.garland.html.gz.h
File diff suppressed because it is too large
View File


+ 1982
- 1975
code/espurna/static/index.light.html.gz.h
File diff suppressed because it is too large
View File


+ 1059
- 1059
code/espurna/static/index.lightfox.html.gz.h
File diff suppressed because it is too large
View File


+ 1089
- 1089
code/espurna/static/index.rfbridge.html.gz.h
File diff suppressed because it is too large
View File


+ 1430
- 1430
code/espurna/static/index.rfm69.html.gz.h
File diff suppressed because it is too large
View File


+ 1521
- 1523
code/espurna/static/index.sensor.html.gz.h
File diff suppressed because it is too large
View File


+ 1043
- 1043
code/espurna/static/index.small.html.gz.h
File diff suppressed because it is too large
View File


+ 1414
- 1414
code/espurna/static/index.thermostat.html.gz.h
File diff suppressed because it is too large
View File


+ 0
- 3
code/html/custom.css View File

@ -600,8 +600,5 @@ input::placeholder {
padding-bottom: 1em;
padding-top: 1em;
transition: visibility 0.2s;
}
.IroColorPicker, .light-control {
content-visibility: hidden;
}

+ 45
- 17
code/html/custom.js View File

@ -1861,7 +1861,6 @@ function initMagnitudesExpected(id) {
const [expected, result] = template.querySelectorAll("input");
const info = emonRatioInfo(id);
const root = template.children[0];
expected.name += `${info.key}`;
expected.id = expected.name;
@ -2189,17 +2188,16 @@ function updateLightState(value) {
const state = document.getElementById("light-state");
state.checked = value;
const picker = document.querySelector(".IroColorPicker");
picker.style["display"] = value ? "block" : "none";
const picker = document.getElementById("light-picker");
picker.style["content-visibility"] = value ? "visible" : "hidden";
}
function colorEnabled(value) {
const rules = []
rules.push(styleVisible(".IroColorPicker", value));
for (let channel = 0; channel < 3; ++channel) {
rules.push(
styleVisible(`.light-channel-${channel}`, !value));
for (let type of ["r", "g", "b"]) {
rules.push(styleVisible(`.light-channel-${type}`, !value));
}
styleInject(rules);
@ -2254,19 +2252,33 @@ function updateMireds(value) {
// When there are CCT controls, no need for raw white channel sliders
function cctEnabled(value) {
if (value) {
let rules = [];
for (let channel = 3; channel < 5; ++channel) {
rules.push(
styleVisible(`.light-channel-${channel}`, false));
}
styleInject([
styleVisible(".light-channel-w", false),
styleVisible(".light-channel-c", false)
]);
} else {
styleInject([
styleVisible(".light-cct", false),
]);
}
}
styleInject(rules);
// Only allow cold white
function whiteEnabled(value) {
if (value) {
styleInject([
styleVisible(".light-channel-w", false),
styleVisible(".light-channel-c", true)
]);
}
}
function cctInit(value) {
const control = loadTemplate("mireds-control");
const root = control.querySelector("div");
root.classList.add("light-cct");
const slider = control.getElementById("mireds");
slider.setAttribute("min", value.cold);
slider.setAttribute("max", value.warm);
@ -2275,6 +2287,12 @@ function cctInit(value) {
sendAction("light", {mireds: event.target.value});
});
const datalist = control.querySelector("datalist");
datalist.innerHTML = `
<option value="${value.cold}">Cold</option>
<option value="${value.warm}">Warm</option>
`;
mergeTemplate(document.getElementById("light"), control);
}
@ -2289,7 +2307,6 @@ function updateLight(data) {
initLightState();
initBrightness();
initChannels(value);
addSimpleEnumerables("channel", "Channel", value);
break;
case "cct":
@ -2349,19 +2366,26 @@ function updateBrightness(value) {
}
function initChannels(channels) {
const enumerables = [];
const container = document.getElementById("light");
for (let channel = 0; channel < channels; ++channel) {
channels.forEach((tag, channel) => {
const line = loadTemplate("channel-control");
line.querySelector("span.slider").dataset["id"] = channel;
line.querySelector("div").classList.add(`light-channel-${channel}`);
line.querySelector("div").classList.add(`light-channel-${tag}`);
const slider = line.querySelector("input.slider");
slider.dataset["id"] = channel;
slider.addEventListener("change", onChannelSliderChange);
line.querySelector("label").textContent = "Channel #".concat(channel);
const label = `Channel #${channel} (${tag.toUpperCase()})`;
line.querySelector("label").textContent = label;
mergeTemplate(container, line);
}
enumerables.push({"id": channel, "name": label});
});
addEnumerables("Channels", enumerables);
}
function updateChannels(values) {
@ -2631,6 +2655,10 @@ function processData(data) {
showLightState(value);
}
if ("useWhite" === key) {
whiteEnabled(value);
}
if ("useCCT" === key) {
cctEnabled(value);
}


+ 4
- 3
code/html/index.html View File

@ -2371,7 +2371,6 @@
<span class="pure-form-message-inline emon-expected-pwrP">In Watts (W). Calibrate your sensor connecting a pure resistive load (like a bulb) and enter here its nominal power or use a multimeter.</span>
<span class="pure-form-message-inline emon-expected-volt">In Volts (V). Enter your the nominal AC voltage for your household or facility, or use multimeter to get this value.</span>
<span class="pure-form-message-inline emon-expected-curr">In Amperes (A). If you are using a pure resistive load like a bulb, this will be the ratio between the two previous values, i.e. power / voltage. You can also use a current clamp around one of the power wires to get this value.</span>
<span class="pure-form-message-inline emon-expected-ene"></span>
</div>
</template>
@ -2396,9 +2395,11 @@
<template id="template-mireds-control">
<div class="pure-control-group">
<label>Mireds (Cold &harr; Warm)</label>
<input type="range" min="153" max="500" class="slider pure-input-2-3" id="mireds">
<label>Mireds</label>
<input type="range" class="slider pure-input-2-3" id="mireds" list="mired-range">
<span class="slider mireds"></span>
<datalist id="mired-range">
</datalist>
</div>
</template>
<!-- endRemoveIf(!light) -->


Loading…
Cancel
Save