diff --git a/scripts/convertHtml.py b/scripts/convertHtml.py index 4e01a875d..c39e95acb 100644 --- a/scripts/convertHtml.py +++ b/scripts/convertHtml.py @@ -23,18 +23,33 @@ def readVersion(path): today = date.today() search = ["_MAJOR", "_MINOR", "_PATCH"] - version = today.strftime("%y%m%d") + "_ahoy_" ver = "" for line in lines: if(line.find("VERSION_") != -1): for s in search: p = line.find(s) if(p != -1): - version += line[p+13:].rstrip() + "." ver += line[p+13:].rstrip() + "." return ver[:-1] -def htmlParts(file, header, nav, footer, version, lang): +def readVersionFull(path): + f = open(path, "r") + lines = f.readlines() + f.close() + + today = date.today() + search = ["_MAJOR", "_MINOR", "_PATCH"] + version = today.strftime("%y%m%d") + "_ahoy_" + for line in lines: + if(line.find("VERSION_") != -1): + for s in search: + p = line.find(s) + if(p != -1): + version += line[p+13:].rstrip() + "." + version = version[:-1] + "_" + get_git_sha() + return version + +def htmlParts(file, header, nav, footer, versionPath, lang): p = ""; f = open(file, "r") lines = f.readlines() @@ -59,8 +74,10 @@ def htmlParts(file, header, nav, footer, version, lang): p += line #placeholders + version = readVersion(versionPath); link = 'GIT SHA: ' + get_git_sha() + ' :: ' + version + '' p = p.replace("{#VERSION}", version) + p = p.replace("{#VERSION_FULL}", readVersionFull(versionPath)) p = p.replace("{#VERSION_GIT}", link) # remove if - endif ESP32 @@ -120,7 +137,7 @@ def translate(file, data, lang="de"): return data -def convert2Header(inFile, version, lang): +def convert2Header(inFile, versionPath, lang): fileType = inFile.split(".")[1] define = inFile.split(".")[0].upper() define2 = inFile.split(".")[1].upper() @@ -140,7 +157,7 @@ def convert2Header(inFile, version, lang): f.close() else: if fileType == "html": - data = htmlParts(inFile, "includes/header.html", "includes/nav.html", "includes/footer.html", version, lang) + data = htmlParts(inFile, "includes/header.html", "includes/nav.html", "includes/footer.html", versionPath, lang) else: f = open(inFile, "r") data = f.read() @@ -193,7 +210,6 @@ def convert2Header(inFile, version, lang): Path("h").mkdir(exist_ok=True) Path("tmp").mkdir(exist_ok=True) # created to check if webpages are valid with all replacements shutil.copyfile("style.css", "tmp/style.css") -version = readVersion("../../defines.h") # get language from environment lang = "en" @@ -202,4 +218,4 @@ def convert2Header(inFile, version, lang): # go throw the array for val in files_grabbed: - convert2Header(val, version, lang) + convert2Header(val, "../../defines.h", lang) diff --git a/src/CHANGES.md b/src/CHANGES.md index 626160968..db4618d58 100644 --- a/src/CHANGES.md +++ b/src/CHANGES.md @@ -5,6 +5,9 @@ * changed scope of variables and member functions inside display classes * removed automatically "minimal" builds * fix include of "settings.h" (was already done in #1360) +* merge PR: Enhancement: Add info about compiled modules to version string #1357 +* add info about installed binary to `/update` #1353 +* fix lang in `/system` #1346 ## 0.8.54 - 2024-01-13 * added minimal version (without: MqTT, Display, History), WebUI is not changed! diff --git a/src/app.cpp b/src/app.cpp index ddbc27717..dd84ec617 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -465,42 +465,42 @@ void app:: zeroIvValues(bool checkAvail, bool skipYieldDay) { //----------------------------------------------------------------------------- void app::resetSystem(void) { - snprintf(mVersion, sizeof(mVersion), "%d.%d.%d%s", VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH, - "-" -#ifdef ENABLE_PROMETHEUS_EP - "P" -#endif + snprintf(mVersion, sizeof(mVersion), "%d.%d.%d", VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH); + snprintf(mVersionModules, sizeof(mVersionModules), "%s", + #ifdef ENABLE_PROMETHEUS_EP + "P" + #endif -#ifdef ENABLE_MQTT - "M" -#endif + #ifdef ENABLE_MQTT + "M" + #endif -#ifdef PLUGIN_DISPLAY - "D" -#endif + #ifdef PLUGIN_DISPLAY + "D" + #endif -#ifdef ENABLE_HISTORY - "H" -#endif + #ifdef ENABLE_HISTORY + "H" + #endif -#ifdef AP_ONLY - "A" -#endif + #ifdef AP_ONLY + "A" + #endif -#ifdef ENABLE_SYSLOG - "Y" -#endif + #ifdef ENABLE_SYSLOG + "Y" + #endif -#ifdef ENABLE_SIMULATOR - "S" -#endif + #ifdef ENABLE_SIMULATOR + "S" + #endif - "-" -#ifdef LANG_DE - "de" -#else - "en" -#endif + "-" + #ifdef LANG_DE + "de" + #else + "en" + #endif ); #ifdef AP_ONLY diff --git a/src/app.h b/src/app.h index 0015ede43..5b39405c7 100644 --- a/src/app.h +++ b/src/app.h @@ -188,6 +188,10 @@ class app : public IApp, public ah::Scheduler { return mVersion; } + const char *getVersionModules() { + return mVersionModules; + } + uint32_t getSunrise() { return mSunrise; } @@ -386,7 +390,8 @@ class app : public IApp, public ah::Scheduler { CmtRadio<> mCmtRadio; #endif - char mVersion[23]; + char mVersion[12]; + char mVersionModules[12]; settings mSettings; settings_t *mConfig; bool mSavePending; diff --git a/src/appInterface.h b/src/appInterface.h index 5feccd3ca..ad38f7568 100644 --- a/src/appInterface.h +++ b/src/appInterface.h @@ -27,6 +27,7 @@ class IApp { virtual bool getShouldReboot() = 0; virtual void setRebootFlag() = 0; virtual const char *getVersion() = 0; + virtual const char *getVersionModules() = 0; #if !defined(ETHERNET) virtual void scanAvailNetworks() = 0; diff --git a/src/web/RestApi.h b/src/web/RestApi.h index afaa34552..edf92a972 100644 --- a/src/web/RestApi.h +++ b/src/web/RestApi.h @@ -252,6 +252,7 @@ class RestApi { obj[F("ts_uptime")] = mApp->getUptime(); obj[F("ts_now")] = mApp->getTimestamp(); obj[F("version")] = String(mApp->getVersion()); + obj[F("modules")] = String(mApp->getVersionModules()); obj[F("build")] = String(AUTO_GIT_HASH); obj[F("env")] = String(ENV_NAME); obj[F("menu_prot")] = mApp->getProtection(request); @@ -325,7 +326,9 @@ class RestApi { void getHtmlSystem(AsyncWebServerRequest *request, JsonObject obj) { getSysInfo(request, obj.createNestedObject(F("system"))); getGeneric(request, obj.createNestedObject(F("generic"))); - obj[F("html")] = F("AhoyFactory Reset

Reboot"); + char tmp[100]; + snprintf(tmp, 100, "%s

%s", FACTORY_RESET, BTN_REBOOT); + obj[F("html")] = String(tmp); } void getHtmlLogout(AsyncWebServerRequest *request, JsonObject obj) { diff --git a/src/web/html/system.html b/src/web/html/system.html index ab0b52898..a646e8b86 100644 --- a/src/web/html/system.html +++ b/src/web/html/system.html @@ -24,7 +24,7 @@ const data = ["sdk", "cpu_freq", "chip_revision", "chip_model", "chip_cores", "esp_type", "mac", "wifi_rssi", "ts_uptime", "flash_size", "sketch_used", "heap_total", "heap_free", "heap_frag", - "max_free_blk", "version", "core_version", "reboot_reason"]; + "max_free_blk", "version", "modules", "env", "core_version", "reboot_reason"]; lines = []; for (const [key, value] of Object.entries(obj)) { diff --git a/src/web/html/update.html b/src/web/html/update.html index f0e39fe7b..3fed75a56 100644 --- a/src/web/html/update.html +++ b/src/web/html/update.html @@ -10,6 +10,7 @@
{#SELECT_FILE} (*.bin) +

{#INSTALLED_VERSION}:

@@ -26,6 +27,7 @@ parseNav(obj); parseESP(obj); parseRssi(obj); + document.getElementById("version").innerHTML = "{#VERSION_FULL}_" + obj.env + ".bin" } function hide() { diff --git a/src/web/lang.h b/src/web/lang.h index a82c78883..3c3cd6310 100644 --- a/src/web/lang.h +++ b/src/web/lang.h @@ -72,4 +72,16 @@ #define INV_NOT_FOUND "inverter not found!" #endif +#ifdef LANG_DE + #define FACTORY_RESET "Ahoy Factory Reset" +#else /*LANG_EN*/ + #define FACTORY_RESET "Ahoy auf Werkseinstellungen zurücksetzen" +#endif + +#ifdef LANG_DE + #define BTN_REBOOT "Reboot" +#else /*LANG_EN*/ + #define BTN_REBOOT "Ahoy neustarten" +#endif + #endif /*__LANG_H__*/ diff --git a/src/web/lang.json b/src/web/lang.json index c495ac9fa..c910650e9 100644 --- a/src/web/lang.json +++ b/src/web/lang.json @@ -51,7 +51,7 @@ { "token": "WELCOME", "en": "Welcome to AhoyDTU", - "de": "Willkommen zu AhoyDTU" + "de": "Willkommen bei AhoyDTU" }, { "token": "NETWORK_SETUP", @@ -1043,6 +1043,11 @@ "en": "Download latest Release and Development versions (without login)", "de": "Lade die letzte Releaseversion oder Entwicklerversion herunter (ohne Login)" }, + { + "token": "INSTALLED_VERSION", + "en": "installed version (original filename)", + "de": "aktuell installierte Version" + }, { "token": "UPDATE_STARTED", "en": "update started",