s00500 / ESPUI

A simple web user interface library for ESP32 and ESP8266
https://valencia.lbsfilm.at/midterm-presentation/
Other
919 stars 173 forks source link

Displaying content of a text file in a tab ?!? #286

Closed MisterButcher closed 3 months ago

MisterButcher commented 9 months ago

Hello,

I make this a feature request as I do not rate this an issue ... it is more a question for help.

My sketch is using some ESPUI gui in various tabs controlling a heating device. I would like to add an additional tab which should show the log (a log file) of the ESP sketch which is written to LittleFS. All I tried failed. All I googled did not work (best try was an Iframe solution but whatever I tried the file is only downloaded and not displayed, even if I use small / dummy files).

With the current ESPUI is my request to show a text file achievable at all? If so, could you please give me an example how to do it? Or (if it can be mixed) how to do it in a tab that does not use ESPUI (along with the other ESPUI tabs)?!?

Thanks, Stefan

MartinMueller2003 commented 9 months ago

Is your goal to have the ESPUI give you a text window (super text control) or are you focused on a non ESPUI solution? You can add your own handler for uploading a file using the ESPUI web server and then write your own js script to process the file into a window. That would not need any work from the ESPUI project. If you are asking for a "Log Control" that can be placed on a tab and can be updated by printing to it, that would be an enhancement.

The current text control can be used but you would have to manage content being displayed in your application.

MisterButcher commented 9 months ago

Thanks for your answer Martin. I do not know which solution is best. You wrote it can be done with the current text control, is it possible to have an example how? I am stuck at the moment. If ESPUI could provide a text window, that would be great ... Thanks, Stefan

MartinMueller2003 commented 9 months ago

It is not so much a text window as you can write multiple lines to a text control. You would have to manage the displayed lines on the ESP. It is ugly and uses a lot of ram but it works. I think what you are asking for is a control that takes each line written to it and automatically adds it to the end of the current list of text lines already being displayed. This would take some magic on the UI side but it could be implemented as an optional function on the existing text control. It would take a few special operations:

AppendLine ClearAllLines ClearOldestLine

etc.

Still mulling this over.

MartinMueller2003 commented 8 months ago

I have added code to ESPUI to allow you to simply specify a file name and then trigger a control update when the file is changed. The UI will read the file and display it. You can adjust color etc just like any other control. Under the hood it uses the text control but instead of taking text, the control uses the output string as a file name. It is a bit of an overload on the field but does not stretch the best practises too far. I still have more testing to do but if you want to see and example, look at the pio gui.ino example in my repo.

https://github.com/MartinMueller2003/ESPUI

MisterButcher commented 8 months ago

Hello Martin,

thanks for the new feature. I will test it in the next weeks ....

Regards, Stefan

MartinMueller2003 commented 8 months ago

Pull request has been created.

MartinMueller2003 commented 3 months ago

Code is in main