JXCT Soil Sensor 7-in-1 v3.4.9 (June 2025)
Professional IoT soil monitoring system with ESP32, Modbus RTU, MQTT, and advanced compensation algorithms
Загрузка...
Поиск...
Не найдено
web_templates.cpp
См. документацию.
3#include "../wifi_manager.h"
4
5// External function declarations
6extern String navHtml();
7
8String generatePageHeader(const String& title, const String& icon)
9{
10 String iconStr = icon.length() > 0 ? icon + " " : "";
11 String html = "<!DOCTYPE html><html><head><meta charset='UTF-8'>";
12 html += "<meta name='viewport' content='width=device-width, initial-scale=1.0'>";
13 html += "<title>" + iconStr + title + "</title>";
14 html += "<style>" + String(getUnifiedCSS()) + "</style>";
15 html += "</head><body><div class='container'>";
16 return html;
17}
18
20{
21 return "</div>" + String(getToastHTML()) + "</body></html>";
22}
23
24String generateBasePage(const String& title, const String& content, const String& icon)
25{
26 String html = generatePageHeader(title, icon);
27 html += navHtml();
28 html += content;
29 html += generatePageFooter();
30 return html;
31}
32
33String generateErrorPage(int errorCode, const String& errorMessage)
34{
35 String content = "<h1>" UI_ICON_ERROR " Ошибка " + String(errorCode) + "</h1>";
36 content += "<div class='msg msg-error'>" UI_ICON_ERROR " " + errorMessage + "</div>";
37 content += "<p><a href='/' style='color: #4CAF50; text-decoration: none;'>← Вернуться на главную</a></p>";
38
39 return generateBasePage("Ошибка " + String(errorCode), content, UI_ICON_ERROR);
40}
41
42String generateSuccessPage(const String& title, const String& message, const String& redirectUrl, int redirectDelay)
43{
44 String content = "<h1>" UI_ICON_SUCCESS " " + title + "</h1>";
45 content += "<div class='msg msg-success'>" UI_ICON_SUCCESS " " + message + "</div>";
46
47 if (redirectUrl.length() > 0)
48 {
49 content += "<p><em>Перенаправление через " + String(redirectDelay) + " секунд...</em></p>";
50 content += "<script>setTimeout(function(){window.location.href='" + redirectUrl + "';}, " +
51 String(redirectDelay * 1000) + ");</script>";
52 }
53
54 return generateBasePage(title, content, UI_ICON_SUCCESS);
55}
56
66String generateForm(const String& action, const String& method, const String& formContent, const String& buttonText,
67 const String& buttonIcon)
68{
69 String html = "<form action='" + action + "' method='" + method + "'>";
70 html += formContent;
71 html += generateButton(ButtonType::PRIMARY, buttonIcon.c_str(), buttonText.c_str(), "");
72 html += "</form>";
73 return html;
74}
75
83String generateConfigSection(const String& title, const String& content, const String& helpText)
84{
85 String html = "<div class='section'>";
86 html += "<h2>" + title + "</h2>";
87 html += content;
88 if (helpText.length() > 0)
89 {
90 html += "<div class='help'>" UI_ICON_INFO " " + helpText + "</div>";
91 }
92 html += "</div>";
93 return html;
94}
95
107String generateInputField(const String& id, const String& name, const String& label, const String& value,
108 const String& type, bool required, const String& placeholder)
109{
110 String html = "<div class='form-group'>";
111 html += "<label for='" + id + "'>" + label + ":</label>";
112 html += "<input type='" + type + "' id='" + id + "' name='" + name + "' value='" + value + "'";
113 if (required) html += " required";
114 if (placeholder.length() > 0) html += " placeholder='" + placeholder + "'";
115 html += "></div>";
116 return html;
117}
118
127String generateCheckboxField(const String& id, const String& name, const String& label, bool checked)
128{
129 String html = "<div class='form-group'>";
130 html += "<label for='" + id + "'>" + label + ":</label>";
131 html += "<input type='checkbox' id='" + id + "' name='" + name + "'";
132 if (checked) html += " checked";
133 html += "></div>";
134 return html;
135}
136
148String generateNumberField(const String& id, const String& name, const String& label, int value, int min, int max,
149 int step)
150{
151 String html = "<div class='form-group'>";
152 html += "<label for='" + id + "'>" + label + ":</label>";
153 html += "<input type='number' id='" + id + "' name='" + name + "' value='" + String(value) + "'";
154 html += " min='" + String(min) + "' max='" + String(max) + "' step='" + String(step) + "'>";
155 html += "</div>";
156 return html;
157}
158
164String generateFormError(const String& message)
165{
166 return "<div class='msg msg-error'>" UI_ICON_ERROR " " + message + "</div>";
167}
168
175String generateApModeUnavailablePage(const String& title, const String& icon)
176{
177 String content = "<h1>" + icon + " " + title + "</h1>";
178 content += "<div class='msg msg-error'>" UI_ICON_ERROR " Недоступно в режиме точки доступа</div>";
179 content += "<p>Эта функция доступна только после подключения к WiFi сети.</p>";
180
181 return generateBasePage(title, content, icon);
182}
const char * getUnifiedCSS()
Определения jxct_ui_system.cpp:4
String generateButton(ButtonType type, const char *icon, const char *text, const char *action)
Определения jxct_ui_system.cpp:286
const char * getToastHTML()
Определения jxct_ui_system.cpp:320
#define UI_ICON_ERROR
Определения jxct_ui_system.h:53
#define UI_ICON_SUCCESS
Определения jxct_ui_system.h:52
@ PRIMARY
Определения jxct_ui_system.h:65
#define UI_ICON_INFO
Определения jxct_ui_system.h:55
String generateErrorPage(int errorCode, const String &errorMessage)
Генерация страницы ошибки
Определения web_templates.cpp:33
String generateApModeUnavailablePage(const String &title, const String &icon)
Генерация страницы "Недоступно в AP режиме".
Определения web_templates.cpp:175
String generateConfigSection(const String &title, const String &content, const String &helpText)
Генерация секции конфигурации
Определения web_templates.cpp:83
String generateBasePage(const String &title, const String &content, const String &icon)
Генерация базовой HTML структуры с навигацией
Определения web_templates.cpp:24
String generateSuccessPage(const String &title, const String &message, const String &redirectUrl, int redirectDelay)
Генерация страницы успеха
Определения web_templates.cpp:42
String generatePageHeader(const String &title, const String &icon)
Генерация заголовка HTML страницы
Определения web_templates.cpp:8
String generateNumberField(const String &id, const String &name, const String &label, int value, int min, int max, int step)
Генерация числового поля с валидацией
Определения web_templates.cpp:148
String navHtml()
Определения wifi_manager.cpp:82
String generatePageFooter()
Генерация футера HTML страницы
Определения web_templates.cpp:19
String generateForm(const String &action, const String &method, const String &formContent, const String &buttonText, const String &buttonIcon)
Генерация формы с общими элементами
Определения web_templates.cpp:66
String generateInputField(const String &id, const String &name, const String &label, const String &value, const String &type, bool required, const String &placeholder)
Генерация поля ввода
Определения web_templates.cpp:107
String generateCheckboxField(const String &id, const String &name, const String &label, bool checked)
Генерация поля чекбокса
Определения web_templates.cpp:127
String generateFormError(const String &message)
Генерация сообщения об ошибке в форме
Определения web_templates.cpp:164