cotestatnt / esp-fs-webserver

ESP32/ESP8266 webserver, WiFi manager and web editor Arduino library
MIT License
105 stars 27 forks source link

add multiple OptionBox #18

Closed Blueforcer closed 1 year ago

Blueforcer commented 1 year ago

Hello,

i created a with addOptionBox like in the optionsExample. is it possible to add multiple option sites with different settings?

cotestatnt commented 1 year ago

Hi @Blueforcer I'm not sure if I understand your question. Perhaps you intend to change the CSS styling of each section, or is it something else? Could you possibly give an example?

With the new features you can add as many "option boxes" as you want. In the latest release I also added the possibility of injecting custom CSS, which allows you to define the style of both the new elements added, but also to override the style of what is already used by default.

Check the updated example customHTML.ino for more details.

image

In any case, if you want to radically change the look of the page, the advice is to directly modify the HTML/CSS/Js sources that you find in this folder and then overwrite the setup_htm.h file with the one obtained by following the instructions in the readme. inside the build folder.

Blueforcer commented 1 year ago

i will try to explane: i made this option page

image

only with this few lines of code

mws.addOptionBox("MQTT");
mws.addOption("Broker", mqtthost);
mws.addOption("Port", mqttport);
mws.addOption("Username", mqttuser);
mws.addOption("Password", mqttpass);
mws.addOption("Prefix", mqttprefix);
mws.addOption("raw-html-button", save_btn_htm);
mws.addJavascript(button_script);

so my question is, if it is possible to create a second optionpage in the same way (via code) or do i need to create custom html pages?

cotestatnt commented 1 year ago

No, it's really simple indeed. Every time you call the method addOptionBox("label"), the c++/ JavaScript "under the cover" create a new box and every option you add after will be showed in that new option box.

Keep the addJavascrit() or addCSS() at the end just for a clearer config.json file.

Blueforcer commented 1 year ago

nice, i will try. thank you very much for your help and of course for your good work. Im pretty sure you will see me again:) Do you have a discord server or something like this? Or should i open a issue again for next questions?

Blueforcer commented 1 year ago

Just a small hint: if your add or rearange your options afterwards again the pages are completely messed up, you need to delete the config.json and reboot to have a correct config.json. A function would be nice, wich rearange the config.json at boot to fit the addOptions sequence

cotestatnt commented 1 year ago

Thanks for your hint, I will take in account for the next developments.

arimukhlas commented 1 year ago

hi @cotestatnt thanks for making this library, its great!!

i have question,

  1. How to show value of variable in custom HTML??
  2. How do i clear the input, and go back to default
  3. It will be better if you add label on Wifisetup page to give information about esp is connected or not, and when its connected, label also show local IP address. Thanks, youre great man!!