Added quick action select display

This commit is contained in:
CommanderRedYT
2022-01-05 01:21:42 +01:00
parent 280263c145
commit 10501dacf6
17 changed files with 354 additions and 49 deletions

View File

@ -23,8 +23,6 @@
// local includes
#include "newsettings.h"
#include "webserver_lock.h"
#include "ledstrip.h"
#include "handbremse.h"
#ifdef FEATURE_WEBSERVER
using namespace std::chrono_literals;
@ -56,7 +54,8 @@ typename std::enable_if<
!std::is_same_v<T, espchrono::DayLightSavingMode> &&
!std::is_same_v<T, OtaAnimationModes> &&
!std::is_same_v<T, LedstripAnimation> &&
!std::is_same_v<T, HandbremseMode>
!std::is_same_v<T, HandbremseMode> &&
!std::is_same_v<T, BobbyQuickActions>
, void>::type
showInputForSetting(std::string_view key, T value, std::string &body)
{
@ -245,6 +244,20 @@ showInputForSetting(std::string_view key, T value, std::string &body)
body += esphttpdutils::htmlentities(enumKey);
});
}
template<typename T>
typename std::enable_if<
std::is_same_v<T, BobbyQuickActions>
, void>::type
showInputForSetting(std::string_view key, T value, std::string &body)
{
HtmlTag select{"select", fmt::format("name=\"{}\"", esphttpdutils::htmlentities(key)), body};
iterateBobbyQuickActions([&](T enumVal, std::string_view enumKey){
HtmlTag option{"option", fmt::format("value=\"{}\"{}", std::to_underlying(enumVal), value == enumVal ? " selected" : ""), body};
body += esphttpdutils::htmlentities(enumKey);
});
}
} // namespace
esp_err_t webserver_newSettings_handler(httpd_req_t *req)
@ -393,7 +406,8 @@ typename std::enable_if<
!std::is_same_v<T, espchrono::DayLightSavingMode> &&
!std::is_same_v<T, OtaAnimationModes> &&
!std::is_same_v<T, LedstripAnimation> &&
!std::is_same_v<T, HandbremseMode>
!std::is_same_v<T, HandbremseMode> &&
!std::is_same_v<T, BobbyQuickActions>
, tl::expected<void, std::string>>::type
saveSetting(ConfigWrapper<T> &config, std::string_view newValue)
{
@ -479,7 +493,8 @@ typename std::enable_if<
std::is_same_v<T, espchrono::DayLightSavingMode> ||
std::is_same_v<T, OtaAnimationModes> ||
std::is_same_v<T, LedstripAnimation> ||
std::is_same_v<T, HandbremseMode>
std::is_same_v<T, HandbremseMode> ||
std::is_same_v<T, BobbyQuickActions>
, tl::expected<void, std::string>>::type
saveSetting(ConfigWrapper<T> &config, std::string_view newValue)
{