Browse Source

show version in index pages

CaCO3 3 years ago
parent
commit
2d68f44a40

+ 3 - 2
code/main/server_main.cpp

@@ -80,10 +80,11 @@ esp_err_t info_get_handler(httpd_req_t *req)
         return ESP_OK;        
         return ESP_OK;        
     }
     }
 
 
-    // No longer used
     if (_task.compare("GitBaseBranch") == 0)
     if (_task.compare("GitBaseBranch") == 0)
     {
     {
-        httpd_resp_sendstr_chunk(req, "");
+        string buf = "Branch: '" + std::string(GIT_BRANCH) + "', Tag: '" + std::string(GIT_TAG) + \
+            "', Revision: " + std::string(GIT_REV);
+        httpd_resp_sendstr_chunk(req, buf.c_str());
         httpd_resp_sendstr_chunk(req, NULL);  
         httpd_resp_sendstr_chunk(req, NULL);  
         return ESP_OK;        
         return ESP_OK;        
     }
     }

+ 25 - 0
sd-card/html/common.js

@@ -29,3 +29,28 @@ function LoadHostname() {
 //               alert("Loading Hostname failed");
 //               alert("Loading Hostname failed");
     }
     }
 }
 }
+
+
+function LoadVersion() {
+    _basepath = getbasepath(); 
+
+    var xhttp = new XMLHttpRequest();
+    xhttp.addEventListener('load', function(event) {
+        if (xhttp.status >= 200 && xhttp.status < 300) {
+            version = xhttp.responseText;
+            document.getElementById("Version").innerHTML  = version;
+        } 
+        else {
+                console.warn(request.statusText, request.responseText);
+        }
+    });
+
+    try {
+            url = _basepath + '/version?type=GitBaseBranch';     
+            xhttp.open("GET", url, true);
+            xhttp.send();
+
+    }
+    catch (error)
+    {}
+}

+ 3 - 0
sd-card/html/index.html

@@ -151,8 +151,11 @@ li.dropdown {
 
 
 <iframe name="maincontent" class="iframe" id="maincontent" src="wasserzaehler_roi.html"></iframe>
 <iframe name="maincontent" class="iframe" id="maincontent" src="wasserzaehler_roi.html"></iframe>
 
 
+<span id="Version" style="font-size: 10px; margin-top: -5px">Loading version...</span>
+
 <script type="text/javascript">
 <script type="text/javascript">
   LoadHostname();
   LoadHostname();
+  LoadVersion();
 </script>
 </script>
 
 
 </div>
 </div>

+ 4 - 0
sd-card/html/index_configure.html

@@ -152,11 +152,15 @@ li.dropdown {
 
 
 <iframe name="maincontent" class="iframe" id="maincontent" src="edit_config_param.html"></iframe>
 <iframe name="maincontent" class="iframe" id="maincontent" src="edit_config_param.html"></iframe>
 
 
+<span id="Version" style="font-size: 10px; margin-top: -5px">Loading version...</span>
+
 <script type="text/javascript" src="common.js"></script>
 <script type="text/javascript" src="common.js"></script>
 <script type="text/javascript" src="gethost.js"></script>
 <script type="text/javascript" src="gethost.js"></script>
 
 
+
 <script type="text/javascript">
 <script type="text/javascript">
   LoadHostname();
   LoadHostname();
+  LoadVersion();
 </script>
 </script>
 
 
 </div>
 </div>