Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI - Schedules - schedules types are not correctly displayed by UI #2628

Open
brunetton opened this issue Nov 9, 2024 · 1 comment
Open
Labels

Comments

@brunetton
Copy link

Device

itead-sonoff-dual-r2

Version

1.18.0-gita518080a+github240830

Bug description

After changing event type (Disabled, Calendar, Relative) and come back again to the Schedule page, events types are all displayed as "Disabled"

Steps to reproduce

  • goto Schedule page
  • change one or more schedules types to "Relative"
  • save changes
  • reload UI (ctrl-R on browser)
  • goto Schedule page again
  • => all Schedules are displayed as "Disabled"

We can confirm that it's only a display problem using terminal. Using keys command we can check, for relative schedules:

> schType0 => "3"
> schType1 => "3"

That corresponds to definitions in code/espurna/scheduler.cpp:

enum class Type : int {
    Unknown = 0,
    Disabled,
    Calendar,
    Relative,
};

Build tools used

PlatformIO

Any relevant log output (when available)

No response

Decoded stack trace (when available)

No response

@brunetton brunetton added the bug label Nov 9, 2024
mcspr added a commit that referenced this issue Dec 7, 2024
de-hardcode sch and led enumeration types from .html
publish raw type & pretty-string from .cpp indexed settings

de-fpstr string view references, use the object directly

publish 'faulty' schedule specs indexes, focus & report elems
ref. #2626

should fix faulty enum<->number references in selects
ref. #2628 - schedule types were numeric, while websocket delivered strings
@mcspr
Copy link
Collaborator

mcspr commented Dec 7, 2024

The issue was that enumerations were sent as strings, ref. schedule 0 output. Internally, string input is converted back to enumeration. Not the other way around, though

pls check out current dev branch, I think the issue should be fixed there?
IndexedSettings here is key-prefix and a function to load key-prefix + index from settings and serialize it. Replacing output for webui lists may be helpful here, as every other place would prefer the string representation

espurna::web::ws::EnumerableConfig config{root, STRING_VIEW("schConfig")};
config.replacement(
settings::internal::type,
[](JsonArray& out, size_t index) {
out.add(std::to_underlying(settings::type(index)));
});
config(STRING_VIEW("schedules"), settings::count(), settings::IndexedSettings);

Another change is UI now receives these as type pairs '[[number, string], [number, string], ...]' on load, so .html does not have to embed both description (at the top of the page) and the keys themselves (in the select / option)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants