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

Make webpage translatable #47

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 37 additions & 8 deletions esp-knx-ip-webserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ void ESPKNXIP::__handle_root()
m += F("<link rel='stylesheet' href='https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css' integrity='sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm' crossorigin='anonymous'>");
m += F("<style>.input-group-insert > .input-group-text { border-radius: 0; }</style>");
#endif
m += F("<title>");
m += config_webUI.WebPageTitle;
m += F("</title>");
m += F("</head><body><div class='container-fluid'>");
m += F("<h2>ESP KNX</h2>");

Expand Down Expand Up @@ -49,11 +52,22 @@ void ESPKNXIP::__handle_root()
m += (*(bool *)feedbacks[i].data) ? F("True") : F("False");
m += F("</span>");
break;
case FEEDBACK_TYPE_ACTION:
case FEEDBACK_TYPE_ACTION:
m += F("<input class='form-control' type='hidden' name='id' value='");
m += i;
m += F("' /><div class='input-group-append'><button type='submit' class='btn btn-primary'>Do this</button></div>");
break;
m += F("' />");
if (feedbacks[i].name.length()) // if there is no text, feedback_action is going to be just a button
{
m += F("<div class='input-group-append'>");
}
m += F("<button type='submit' class='btn btn-warning'>");
m += feedbacks[i].button_text;
m += F("</button>");
if (feedbacks[i].name.length())
{
m += F("</div>");
}
break;
}
m += F("</div></div></div>");
m += F("</form>");
Expand Down Expand Up @@ -86,7 +100,9 @@ void ESPKNXIP::__handle_root()
m += F("</span></div>");
m += F("<input class='form-control' type='hidden' name='id' value='");
m += i;
m += F("' /><div class='input-group-append'><button type='submit' class='btn btn-danger'>Delete</button></div>");
m += F("' /><div class='input-group-append'><button type='submit' class='btn btn-danger'>");
m += config_webUI.Delete;
m += F("</button></div>");
m += F("</div></div></div>");
m += F("</form>");
}
Expand Down Expand Up @@ -116,7 +132,9 @@ void ESPKNXIP::__handle_root()
m += F("</option>");
}
m += F("</select>");
m += F("<div class='input-group-append'><button type='submit' class='btn btn-primary'>Set</button></div>");
m += F("<div class='input-group-append'><button type='submit' class='btn btn-primary'>");
m += config_webUI.Add;
m += F("</button></div>");
m += F("</div></div></div>");
m += F("</form>");
}
Expand All @@ -126,7 +144,9 @@ void ESPKNXIP::__handle_root()
// Physical address
m += F("<form action='" __PHYS_PATH "' method='POST'>");
m += F("<div class='row'><div class='col-auto'><div class='input-group'>");
m += F("<div class='input-group-prepend'><span class='input-group-text'>Physical address</span></div>");
m += F("<div class='input-group-prepend'><span class='input-group-text'>");
m += config_webUI.PhysAddrLabel;
m += F("</span></div>");
m += F("<input class='form-control' type='number' name='area' min='0' max='15' value='");
m += physaddr.pa.area;
m += F("'/>");
Expand All @@ -138,7 +158,9 @@ void ESPKNXIP::__handle_root()
m += F("<input class='form-control' type='number' name='member' min='0' max='255' value='");
m += physaddr.pa.member;
m += F("'/>");
m += F("<div class='input-group-append'><button type='submit' class='btn btn-primary'>Set</button></div>");
m += F("<div class='input-group-append'><button type='submit' class='btn btn-primary'>");
m += config_webUI.Set;
m += F("</button></div>");
m += F("</div></div></div>");
m += F("</form>");

Expand Down Expand Up @@ -220,7 +242,9 @@ void ESPKNXIP::__handle_root()
m += F("<input type='hidden' name='id' value='");
m += i;
m += F("'/>");
m += F("<div class='input-group-append'><button type='submit' class='btn btn-primary'>Set</button></div>");
m += F("<div class='input-group-append'><button type='submit' class='btn btn-primary'>");
m += config_webUI.Set;
m += F("</button></div>");
m += F("</div></div></div>");
m += F("</form>");
}
Expand Down Expand Up @@ -269,6 +293,11 @@ void ESPKNXIP::__handle_root()
server->send(200, F("text/html"), m);
}

void ESPKNXIP::config_web_UI(config_webUI_t custom_config_webUI)
{
config_webUI = custom_config_webUI;
}

void ESPKNXIP::__handle_register()
{
DEBUG_PRINTLN(F("Register called"));
Expand Down