show version in index pages

This commit is contained in:
CaCO3
2022-09-18 23:25:57 +02:00
parent 39ec90895e
commit 2d68f44a40
4 changed files with 35 additions and 2 deletions

View File

@@ -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;
} }

View File

@@ -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)
{}
}

View File

@@ -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>

View File

@@ -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>