From 2042682d77aeb6f66e3be2c9d49042f527f75abb Mon Sep 17 00:00:00 2001 From: Torsten Stauder Date: Mon, 3 May 2021 00:27:57 +0200 Subject: [PATCH] Make logbuffer visible to Webgui, small fixes --- .../{accesspoint.html => accesspoint_DE.html} | 0 html/{management.html => management_DE.html} | 1 + html/management_EN.html | 1 + processHtml.py | 2 +- src/HTMLaccesspoint.h | 64 - src/HTMLaccesspoint_DE.h | 126 +- src/HTMLmanagement.h | 1111 ----------------- src/HTMLmanagement_DE.h | 725 +++++------ src/HTMLmanagement_EN.h | 1 + src/Log.cpp | 2 +- src/Web.cpp | 21 +- 11 files changed, 441 insertions(+), 1613 deletions(-) rename html/{accesspoint.html => accesspoint_DE.html} (100%) rename html/{management.html => management_DE.html} (99%) delete mode 100644 src/HTMLaccesspoint.h delete mode 100644 src/HTMLmanagement.h diff --git a/html/accesspoint.html b/html/accesspoint_DE.html similarity index 100% rename from html/accesspoint.html rename to html/accesspoint_DE.html diff --git a/html/management.html b/html/management_DE.html similarity index 99% rename from html/management.html rename to html/management_DE.html index af0f470..56dad95 100644 --- a/html/management.html +++ b/html/management_DE.html @@ -136,6 +136,7 @@ Neustart Ausschalten + Log
diff --git a/html/management_EN.html b/html/management_EN.html index e603d66..e9d1bbf 100644 --- a/html/management_EN.html +++ b/html/management_EN.html @@ -136,6 +136,7 @@ Restart Shutdown + Log
diff --git a/processHtml.py b/processHtml.py index 74e2749..7cb319f 100644 --- a/processHtml.py +++ b/processHtml.py @@ -18,7 +18,7 @@ def str2bool(v): else: raise argparse.ArgumentTypeError('Boolean value expected.') -HTML_FILES = ["management","management_EN", "accesspoint", "accesspoint_EN"] +HTML_FILES = ["management_DE","management_EN", "accesspoint_DE", "accesspoint_EN"] class htmlHeaderProcessor(object): diff --git a/src/HTMLaccesspoint.h b/src/HTMLaccesspoint.h deleted file mode 100644 index 4405e10..0000000 --- a/src/HTMLaccesspoint.h +++ /dev/null @@ -1,64 +0,0 @@ -static const char accesspoint_HTML[] PROGMEM = "\ -\ - \ - WLAN-Einrichtung\ - \ - \ - \ -
\ -

WLAN-Einrichtung

\ -
\ -
\ -
\ -
\ -
\ -

\ - \ -
\ -
\ -

Fertig?

\ - \ -
\ - \ -"; \ No newline at end of file diff --git a/src/HTMLaccesspoint_DE.h b/src/HTMLaccesspoint_DE.h index fc8acb9..4405e10 100644 --- a/src/HTMLaccesspoint_DE.h +++ b/src/HTMLaccesspoint_DE.h @@ -1,64 +1,64 @@ static const char accesspoint_HTML[] PROGMEM = "\ - \ - \ - WLAN-Einrichtung\ - \ - \ - \ -
\ -

WLAN-Einrichtung

\ -
\ -
\ -
\ -
\ -
\ -

\ - \ -
\ -
\ -

Fertig?

\ - \ -
\ - \ - "; +\ + \ + WLAN-Einrichtung\ + \ + \ + \ +
\ +

WLAN-Einrichtung

\ +
\ +
\ +
\ +
\ +
\ +

\ + \ +
\ +
\ +

Fertig?

\ + \ +
\ + \ +"; \ No newline at end of file diff --git a/src/HTMLmanagement.h b/src/HTMLmanagement.h deleted file mode 100644 index 2322da5..0000000 --- a/src/HTMLmanagement.h +++ /dev/null @@ -1,1111 +0,0 @@ -static const char management_HTML[] PROGMEM = "\ -\ -\ - ESPuino-Konfiguration\ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ -\ -\ -\ -
\ - \ -
\ -
\ -
\ -
\ -
\ -
\ - WLAN-Einstellungen\ - \ - \ -
\ - Bitte SSID des WLANs eintragen.\ -
\ - \ - \ - \ - \ -
\ -
\ -
\ - \ - \ -
\ -
\ -
\ -
\ -
\ -
\ -
\ - Steuerung\ -
\ - \ - \ - \ - \ - \ -
\ -
\ -
\ -
\ - Lautstärke\ - \ -
\ -
\ -
\ -
\ -
\ -
\ -
\ - Dateien\ -
\ -
\ -
\ -
\ -
\ -
\ -
\ - \ - \ - Browse\ - Upload\ - \ - \ -
\ -
\ -
\ -
\ -
\ -
\ -
\ -
\ -
\ -
\ -
\ -
\ -
\ - RFID-Zuweisungen\ -
\ -
\ - \ - \ -
\ - \ -
\ -
\ -
\ - \ - \ - \ - \ -
\ -
\ - \ - \ -
\ -
\ -
\ -
\ -
\ - \ - \ -
\ -
\ -
\ -
\ -
\ -
\ -
\ -
\ -\ -
\ -
\ - MQTT-Einstellungen\ - \ - \ -
\ -
\ - \ - \ - \ - \ - \ - \ - \ - \ -
\ -
\ -
\ - \ - \ -
\ -
\ -
\ -
\ -
\ -
\ -\ -
\ -
\ - FTP-Einstellungen\ - \ - \ - \ - \ -
\ -
\ -
\ - \ - \ -
\ -
\ -
\ -
\ -\ -
\ -
\ -\ -
\ -
\ -
\ - Lautstärke\ - \ -
\ -
\ -
\ - \ -
\ - \ -
\ -
\ - \ -
\ - \ -
\ -
\ -
\ -
\ -
\ -
\ - Neopixel (Helligkeit)\ - \ -
\ - \ - \ -
\ -\ - \ -
\ - \ -
\ -
\ -
\ -
\ -
\ -
\ - Deep Sleep\ -\ - \ -
\ -
\ -
\ -
\ -\ -
\ -
\ - Batterie\ -
Status über Neopixel anzeigen
\ -
\ - \ -
\ - \ -
\ -
\ - \ -
\ - \ -
\ -
\ - \ -\ -
\ - \ -
\ -\ -
\ - \ -
\ - \ -
\ -\ -
\ -
\ -
\ -
\ - \ - \ -
\ -
\ -
\ -
\ -
\ -
\ -
\ - NVS-Importer\ -
\ -
\ - \ - \ -
\ - \ -
\ -
\ -
\ -
\ -
\ - Forum\ -

Du hast Probleme mit ESPuino oder bist an einem Erfahrungsaustausch interessiert?
\ - Dann schaue doch mal im ESPuino-Forum vorbei! Insbesondere gibt es dort auch einen
\ - Bereich, in dem reichlich Dokumentation hinterlegt ist. Wir freuen uns auf deinen Besuch!\ -

\ -
\ -
\ -
\ -\ -\ -"; \ No newline at end of file diff --git a/src/HTMLmanagement_DE.h b/src/HTMLmanagement_DE.h index f151edb..1789009 100644 --- a/src/HTMLmanagement_DE.h +++ b/src/HTMLmanagement_DE.h @@ -45,7 +45,7 @@ static const char management_HTML[] PROGMEM = "\ .icon-pos{\ top: 0.3em;\ position: relative;\ - }\ + }\ .reboot{\ color:white;\ }\ @@ -131,11 +131,12 @@ static const char management_HTML[] PROGMEM = "\
\ \ \"\"/\ + width=\"35\" height=\"35\" class=\"d-inline-block align-top\" alt=\"\"/>\ ESPuino\ \ Neustart\ Ausschalten\ + Log\
\ \
\ @@ -167,7 +168,7 @@ static const char management_HTML[] PROGMEM = "\ \ \ \ + value=\"%HOSTNAME%\" pattern=\"^[^-\\.]{2,32}\" required>\ \
\
\ @@ -212,12 +213,12 @@ static const char management_HTML[] PROGMEM = "\
\
\ Dateien\ -
\ -
\ -
\ -
\ -
\ -
\ +
\ +
\ +
\ +
\ +
\ + \
\ \ \ @@ -233,7 +234,7 @@ static const char management_HTML[] PROGMEM = "\
\
\
\ -
\ +
\
\
\
\ @@ -243,7 +244,7 @@ static const char management_HTML[] PROGMEM = "\
\ \ \ + placeholder=\"%RFID_TAG_ID%\" name=\"rfidIdMusic\" required>\
\
    \
  • \ @@ -309,7 +310,7 @@ static const char management_HTML[] PROGMEM = "\
    \ \ \ + onsubmit=\"mqttSettings('mqttConfig'); return false\">\
    \ MQTT-Einstellungen\ \ @@ -320,13 +321,13 @@ static const char management_HTML[] PROGMEM = "\
    \ \ \ + placeholder=\"z.B. 192.168.2.89\" name=\"mqttServer\" value=\"%MQTT_SERVER%\">\ \ \ + placeholder=\"Benutzername\" name=\"mqttUser\" value=\"%MQTT_USER%\">\ \ \ + placeholder=\"Passwort\" name=\"mqttPwd\" value=\"%MQTT_PWD%\">\ \ \ @@ -347,10 +348,10 @@ static const char management_HTML[] PROGMEM = "\ FTP-Einstellungen\ \ \ + placeholder=\"Benutzername\" name=\"ftpUser\" value=\"%FTP_USER%\" required>\ \ \ + name=\"ftpPwd\" value=\"%FTP_PWD%\" required>\
    \
    \
    \ @@ -375,14 +376,14 @@ static const char management_HTML[] PROGMEM = "\
    \ \
    \ - \
    \
    \ \
    \ \ + data-slider-value=\"%MAX_VOLUME_HEADPHONE%\" value=\"%MAX_VOLUME_HEADPHONE%\" required> \
    \ \
    \ @@ -394,7 +395,7 @@ static const char management_HTML[] PROGMEM = "\
    \ \ \ + data-slider-value=\"%INIT_LED_BRIGHTNESS%\" value=\"%INIT_LED_BRIGHTNESS%\" required>\
    \ \ \ @@ -410,7 +411,7 @@ static const char management_HTML[] PROGMEM = "\ \ \
    \ + data-slider-value=\"%MAX_INACTIVITY%\" value=\"%MAX_INACTIVITY%\" required>
    \ \
    \
    \ @@ -431,21 +432,21 @@ static const char management_HTML[] PROGMEM = "\ \
    \ \ + data-slider-value=\"%VOLTAGE_INDICATOR_LOW%\" value=\"%VOLTAGE_INDICATOR_LOW%\" pattern=\"^\\d{1,2}(\\.\\d{1,3})?\" required> \
    \
    \ \ \
    \ \ + data-slider-value=\"%VOLTAGE_INDICATOR_HIGH%\" value=\"%VOLTAGE_INDICATOR_HIGH%\" pattern=\"^\\d{1,2}(\\.\\d{1,3})?\" required> \
    \ \
    \ \
    \ \ + data-slider-value=\"%VOLTAGE_CHECK_INTERVAL%\" name=\"voltageCheckInterval\" value=\"%VOLTAGE_CHECK_INTERVAL%\" required>\
    \ \ \ @@ -575,353 +576,353 @@ static const char management_HTML[] PROGMEM = "\ }\ \ }\ - lastSelectedNodePath = data.node.data.path;\ + lastSelectedNodePath = data.node.data.path;\ }\ \ \ });\ \ - function doRest(path, callback, obj) {\ - obj.url = path;\ - obj.dataType = \"json\";\ - obj.contentType= \"application/json;charset=IBM437\",\ + function doRest(path, callback, obj) {\ + obj.url = path;\ + obj.dataType = \"json\";\ + obj.contentType= \"application/json;charset=IBM437\",\ obj.scriptCharset= \"IBM437\",\ obj.success = function(data, textStatus, jqXHR) {\ - if (callback) {\ - callback(data);\ - }\ - };\ - obj.error = function(jqXHR, textStatus, errorThrown) {\ - console.log(\"AJAX error\");\ - /*debugger; */\ - };\ - jQuery.ajax(obj);\ - } /* doRest */\ -\ - function getData(path, callback) {\ - doRest(path, callback, {\ - method : \"GET\"\ - });\ - } /* getData */\ -\ - function deleteData(path, callback, _data) {\ - doRest(path, callback, {\ - method : \"DELETE\",\ - data: _data\ - });\ - } /* deleteData */\ -\ - function patchData(path, callback, _data) {\ - doRest(path, callback, {\ - method : \"PATCH\",\ - data: _data\ - });\ - } /* patchData */\ -\ - function postData(path, callback, _data) {\ - doRest(path, callback, {\ - method : \"POST\",\ - data: _data\ - });\ - } /* postData */\ -\ -\ - function putData(path, callback, _data) {\ - doRest(path, callback, {\ - method : \"PUT\",\ - data: _data\ - });\ - } /* putData */\ -\ -\ - /* File Upload */\ - $('#explorerUploadForm').submit(function(e){\ - e.preventDefault();\ - console.log(\"Upload!\");\ - var data = new FormData(this);\ -\ - var ref = $('#explorerTree').jstree(true),\ - sel = ref.get_selected(),\ - path = \"/\";\ + if (callback) {\ + callback(data);\ + }\ + };\ + obj.error = function(jqXHR, textStatus, errorThrown) {\ + console.log(\"AJAX error\");\ + /*debugger; */\ + };\ + jQuery.ajax(obj);\ + } /* doRest */\ +\ + function getData(path, callback) {\ + doRest(path, callback, {\ + method : \"GET\"\ + });\ + } /* getData */\ +\ + function deleteData(path, callback, _data) {\ + doRest(path, callback, {\ + method : \"DELETE\",\ + data: _data\ + });\ + } /* deleteData */\ +\ + function patchData(path, callback, _data) {\ + doRest(path, callback, {\ + method : \"PATCH\",\ + data: _data\ + });\ + } /* patchData */\ +\ + function postData(path, callback, _data) {\ + doRest(path, callback, {\ + method : \"POST\",\ + data: _data\ + });\ + } /* postData */\ +\ +\ + function putData(path, callback, _data) {\ + doRest(path, callback, {\ + method : \"PUT\",\ + data: _data\ + });\ + } /* putData */\ +\ +\ + /* File Upload */\ + $('#explorerUploadForm').submit(function(e){\ + e.preventDefault();\ + console.log(\"Upload!\");\ + var data = new FormData(this);\ +\ + var ref = $('#explorerTree').jstree(true),\ + sel = ref.get_selected(),\ + path = \"/\";\ if(!sel.length) { alert(\"Please select the upload location!\");return false; }\ if(!document.getElementById('uploaded_file').files.length > 0) { alert(\"Please select files to upload!\");return false; }\ - sel = sel[0];\ - selectedNode = ref.get_node(sel);\ - if(selectedNode.data.directory){\ - path = selectedNode.data.path\ - } else {\ - /* remap sel to parent folder */\ - sel = ref.get_node(ref.get_parent(sel));\ - path = parentNode.data.path;\ - console.log(\"Parent path: \" + path);\ - }\ -\ - $.ajax({\ - url: '/explorer?path=' + path,\ + sel = sel[0];\ + selectedNode = ref.get_node(sel);\ + if(selectedNode.data.directory){\ + path = selectedNode.data.path\ + } else {\ + /* remap sel to parent folder */\ + sel = ref.get_node(ref.get_parent(sel));\ + path = parentNode.data.path;\ + console.log(\"Parent path: \" + path);\ + }\ +\ + $.ajax({\ + url: '/explorer?path=' + path,\ type: 'POST',\ data: data,\ contentType: false,\ processData:false,\ - xhr: function() {\ - var xhr = new window.XMLHttpRequest();\ + xhr: function() {\ + var xhr = new window.XMLHttpRequest();\ \ - xhr.upload.addEventListener(\"progress\", function(evt) {\ - if (evt.lengthComputable) {\ - var percentComplete = evt.loaded / evt.total;\ - percentComplete = parseInt(percentComplete * 100);\ + xhr.upload.addEventListener(\"progress\", function(evt) {\ + if (evt.lengthComputable) {\ + var percentComplete = evt.loaded / evt.total;\ + percentComplete = parseInt(percentComplete * 100);\ console.log(percentComplete);\ var percent = percentComplete + '%';\ $(\"#explorerUploadProgress\").css('width', percent).text(percent);\ - }\ - }, false);\ + }\ + }, false);\ \ - return xhr;\ - },\ - success: function(data, textStatus, jqXHR) {\ + return xhr;\ + },\ + success: function(data, textStatus, jqXHR) {\ console.log(\"Upload success!\");\ $(\"#explorerUploadProgress\").text(\"Upload success!\");\ document.getElementById('uploaded_file').value = '';\ document.getElementById('uploaded_file_text').innerHTML = '';\ \ - getData(\"/explorer?path=\" + path, function(data) {\ - /* We now have data! */\ - deleteChildrenNodes(sel);\ - addFileDirectory(sel, data);\ - ref.open_node(sel);\ -\ -\ - });\ -\ - }\ - });\ - });\ -\ - /* File Delete */\ - function handleDeleteData(nodeId) {\ - var ref = $('#explorerTree').jstree(true);\ - var node = ref.get_node(nodeId);\ - console.log(\"call delete request: \" + node.data.path);\ - deleteData(\"/explorer?path=\" + node.data.path);\ - }\ -\ - function fileNameSort( a, b ) {\ - if ( a.dir && !b.dir ) {\ - return -1\ - }\ - if ( !a.dir && b.dir ) {\ - return 1\ - }\ - if ( a.name < b.name ){\ - return -1;\ - }\ - if ( a.name > b.name ){\ - return 1;\ - }\ - return 0;\ - }\ -\ - function createChild(nodeId, data) {\ - var ref = $('#explorerTree').jstree(true);\ - var node = ref.get_node(nodeId);\ - var parentNodePath = node.data.path;\ - /* In case of root node remove leading '/' to avoid '//' */\ - if(parentNodePath == \"/\"){\ - parentNodePath = \"\";\ - }\ - var child = {\ - text: data.name,\ - type: getType(data),\ - data: {\ - path: parentNodePath + \"/\" + data.name,\ - directory: data.dir\ - }\ - };\ -\ - return child;\ -\ - }\ -\ - function deleteChildrenNodes(nodeId) {\ - var ref = $('#explorerTree').jstree(true);\ - var children = $(\"#explorerTree\").jstree(\"get_children_dom\",nodeId);\ - for(var i=0;i b.name ){\ + return 1;\ + }\ + return 0;\ + }\ +\ + function createChild(nodeId, data) {\ + var ref = $('#explorerTree').jstree(true);\ + var node = ref.get_node(nodeId);\ + var parentNodePath = node.data.path;\ + /* In case of root node remove leading '/' to avoid '//' */\ + if(parentNodePath == \"/\"){\ + parentNodePath = \"\";\ + }\ + var child = {\ + text: data.name,\ + type: getType(data),\ + data: {\ + path: parentNodePath + \"/\" + data.name,\ + directory: data.dir\ + }\ + };\ +\ + return child;\ +\ + }\ +\ + function deleteChildrenNodes(nodeId) {\ + var ref = $('#explorerTree').jstree(true);\ + var children = $(\"#explorerTree\").jstree(\"get_children_dom\",nodeId);\ + for(var i=0;i"; \ No newline at end of file diff --git a/src/HTMLmanagement_EN.h b/src/HTMLmanagement_EN.h index c3febf0..3c001ae 100644 --- a/src/HTMLmanagement_EN.h +++ b/src/HTMLmanagement_EN.h @@ -136,6 +136,7 @@ static const char management_HTML[] PROGMEM = "\ \ Restart\ Shutdown\ + Log\
\ \
\ diff --git a/src/Log.cpp b/src/Log.cpp index 2b7ec83..955eef5 100644 --- a/src/Log.cpp +++ b/src/Log.cpp @@ -6,7 +6,7 @@ // Serial-logging buffer uint8_t Log_BufferLength = 200; -char *Log_Buffer = (char *) calloc(Log_BufferLength, sizeof(char)); // Buffer for all log-messages +char *Log_Buffer; static LogRingBuffer Log_RingBuffer; diff --git a/src/Web.cpp b/src/Web.cpp index 22f94fa..b4a79f6 100644 --- a/src/Web.cpp +++ b/src/Web.cpp @@ -182,8 +182,7 @@ void webserverStart(void) { } // Used for substitution of some variables/templates of html-files. Is called by webserver's template-engine -String templateProcessor(const String &templ) -{ +String templateProcessor(const String &templ) { if (templ == "FTP_USER") { return gPrefsSettings.getString("ftpuser", "-1"); } else if (templ == "FTP_PWD") { @@ -193,11 +192,11 @@ String templateProcessor(const String &templ) } else if (templ == "FTP_PWD_LENGTH") { return String(ftpPasswordLength - 1); } else if (templ == "SHOW_FTP_TAB") { // Only show FTP-tab if FTP-support was compiled - #ifdef FTP_ENABLE - return (String) FPSTR(ftpTab); - #else - return String(); - #endif + #ifdef FTP_ENABLE + return (String) FPSTR(ftpTab); + #else + return String(); + #endif } else if (templ == "INIT_LED_BRIGHTNESS") { return String(gPrefsSettings.getUChar("iLedBrightness", 0)); } else if (templ == "NIGHT_LED_BRIGHTNESS") { @@ -223,10 +222,10 @@ String templateProcessor(const String &templ) } else if (templ == "MQTT_SERVER") { return gPrefsSettings.getString("mqttServer", "-1"); } else if (templ == "SHOW_MQTT_TAB") { // Only show MQTT-tab if MQTT-support was compiled - #ifdef MQTT_ENABLE - return (String) FPSTR(mqttTab); - #else - return String(); + #ifdef MQTT_ENABLE + return (String) FPSTR(mqttTab); + #else + return String(); #endif } else if (templ == "MQTT_ENABLE") { if (Mqtt_IsEnabled()) {