Removed api end point to retrieve the software version, this information is now included in the systemInfo api end point. Improved dashboard ( still some pannels with missing logic)

This commit is contained in:
Anatole SCHRAMM 2022-10-13 14:12:41 +02:00
parent 436e0d7336
commit cdf013f6dd
5 changed files with 28 additions and 33 deletions

View File

@ -53,6 +53,11 @@
{ {
display:block; display:block;
} }
.cursor-hand
{
cursor: pointer;
}
</style> </style>
@ -173,17 +178,11 @@
<div class="col m6"> <div class="col m6">
<span id="ap_connected_dev_count_id">0</span> <span id="ap_connected_dev_count_id">0</span>
</div> </div>
<div class="col m2"> <div class="col m5">
AP IP : AP IP : <span id="ap_IP"></span>
</div> </div>
<div class="col m4"> <div class="col m7">
<span id="ap_IP"></span> MAC : <span id="ap_MAC"></span>
</div>
<div class="col m2">
MAC :
</div>
<div class="col m4">
<span id="ap_MAC"></span>
</div> </div>
</div> </div>
</div> </div>
@ -196,7 +195,7 @@
<tr> <tr>
<td><label for="ap_password" class="white-text" style="font-size:1em;">Password :</label></td> <td><label for="ap_password" class="white-text" style="font-size:1em;">Password :</label></td>
<td><input placeholder="Password" id="ap_password" type="password" class="validate white-text"></td> <td><input placeholder="Password" id="ap_password" type="password" class="validate white-text"></td>
<td><img onmouseleave="showHidePassword('ap_password','hide')" onmouseover="showHidePassword('ap_password','show');" style="width:40px;" src="rsrc/show_pass.png"></td> <td><img class="cursor-hand" onmouseup="showHidePassword('ap_password','hide')" onmouseleave="showHidePassword('ap_password','hide')" onmousedown="showHidePassword('ap_password','show');" style="width:40px;" src="rsrc/show_pass.png"></td>
</tr> </tr>
</table> </table>
<hr> <hr>
@ -247,7 +246,7 @@
<tr> <tr>
<td><label for="sta_password" class="white-text" style="font-size:1em;">Password :</label></td> <td><label for="sta_password" class="white-text" style="font-size:1em;">Password :</label></td>
<td><input placeholder="Password" id="sta_password" type="password" class="validate white-text"></td> <td><input placeholder="Password" id="sta_password" type="password" class="validate white-text"></td>
<td><img onmouseleave="showHidePassword('sta_password','hide')" onmouseover="showHidePassword('sta_password','show');" style="width:40px;" src="rsrc/show_pass.png"></td> <td><img class="cursor-hand" onmouseleave="showHidePassword('sta_password','hide')" onmouseover="showHidePassword('sta_password','show');" style="width:40px;" src="rsrc/show_pass.png"></td>
</tr> </tr>
</table> </table>
@ -274,7 +273,13 @@
<div class="white-text" style="font-size:1.2em;"> <div class="white-text" style="font-size:1.2em;">
<div class="row"> <div class="row">
<div class="col m6"> <div class="col m6">
Cpu frequency : Software version :
</div>
<div class="col m6">
<span id="softInfo"></span>&nbsp;&nbsp;<!--Needed to have the row on the same line-->
</div>
<div class="col m6">
CPU frequency :
</div> </div>
<div class="col m6"> <div class="col m6">
<label style="margin: 0 10px 0 0;"> <label style="margin: 0 10px 0 0;">
@ -320,8 +325,7 @@
Available OTA update : Available OTA update :
</div> </div>
<div class="col m6"> <div class="col m6">
<button class="btn waves-effect waves-light lime darken-3" id="otaUpdateAction"><span id="ota_update_message">refresh</span></button> <button onclick="fetchOtaUpdate(this.id);" class="btn waves-effect waves-light lime darken-3" id="otaUpdateAction"><span id="ota_update_message">refresh</span></button>
<button class="btn waves-effect waves-light green darken-3 hide" id="otaUpdateAction">update device to <span id="ota_update_version"></span> !</button>
</div> </div>
</div> </div>
</div> </div>
@ -459,7 +463,7 @@
<tr> <tr>
<td><label for="user_password" class="white-text" style="font-size:1em;">Password :</label></td> <td><label for="user_password" class="white-text" style="font-size:1em;">Password :</label></td>
<td><input placeholder="Password" id="user_password" type="password" class="validate white-text"></td> <td><input placeholder="Password" id="user_password" type="password" class="validate white-text"></td>
<td><img onmouseleave="showHidePassword('user_password','hide')" onmouseover="showHidePassword('user_password','show');" style="width:40px;" src="rsrc/show_pass.png"></td> <td><img class="cursor-hand" onmouseleave="showHidePassword('user_password','hide')" onmouseover="showHidePassword('user_password','show');" style="width:40px;" src="rsrc/show_pass.png"></td>
</tr> </tr>
</table> </table>
<hr> <hr>

View File

@ -163,6 +163,7 @@ function sysInfoRefreshHandler(data,kind)
if(kind === 'OK') if(kind === 'OK')
{ {
let systemInfoObj = JSON.parse(data); let systemInfoObj = JSON.parse(data);
elemById('softInfo').innerHTML = systemInfoObj.version;
elemById('temperature').innerHTML = systemInfoObj['temperature'].level + systemInfoObj['temperature'].unit; elemById('temperature').innerHTML = systemInfoObj['temperature'].level + systemInfoObj['temperature'].unit;
elemById('ramInfo').innerHTML = systemInfoObj['free RAM']; elemById('ramInfo').innerHTML = systemInfoObj['free RAM'];
let cpuFreq = systemInfoObj['CPU freq']; let cpuFreq = systemInfoObj['CPU freq'];
@ -180,6 +181,7 @@ function sysInfoRefreshHandler(data,kind)
} }
else else
{ {
elemById('softInfo').innerHTML = 'NaN';
elemById('temperature').innerHTML = 'NaN'; elemById('temperature').innerHTML = 'NaN';
elemById('ramInfo').innerHTML = 'NaN'; elemById('ramInfo').innerHTML = 'NaN';
elemById('fragInfo').innerHTML = 'NaN'; elemById('fragInfo').innerHTML = 'NaN';
@ -491,6 +493,11 @@ function apStation()
apStationReq.send(); apStationReq.send();
} }
function fetchOtaUpdate(button_id)
{
console.log(button_id);
}
App = { App = {
init:function() init:function()

View File

@ -95,7 +95,6 @@ void setup()
sab.getWebServerManager().getWEBServer().addApiRoutine("/sab/io/set/level", &(ioSetLevelApi), &sab, WEBServer<WEBClient>::GET); sab.getWebServerManager().getWEBServer().addApiRoutine("/sab/io/set/level", &(ioSetLevelApi), &sab, WEBServer<WEBClient>::GET);
sab.getWebServerManager().getWEBServer().addApiRoutine("/sab/io/get/mode", &(ioGetModeApi), &sab, WEBServer<WEBClient>::GET); sab.getWebServerManager().getWEBServer().addApiRoutine("/sab/io/get/mode", &(ioGetModeApi), &sab, WEBServer<WEBClient>::GET);
sab.getWebServerManager().getWEBServer().addApiRoutine("/sab/io/set/mode", &(ioSetModeApi), &sab, WEBServer<WEBClient>::GET); sab.getWebServerManager().getWEBServer().addApiRoutine("/sab/io/set/mode", &(ioSetModeApi), &sab, WEBServer<WEBClient>::GET);
sab.getWebServerManager().getWEBServer().addApiRoutine("/sab/sw/version", &(swVersionApi), &sab, WEBServer<WEBClient>::GET);
sab.getWebServerManager().getWEBServer().addApiRoutine("/sab/ota/update/upload", &(otaUpdateUploadApi), NULL, WEBServer<WEBClient>::POST); sab.getWebServerManager().getWEBServer().addApiRoutine("/sab/ota/update/upload", &(otaUpdateUploadApi), NULL, WEBServer<WEBClient>::POST);
sab.getWebServerManager().getWEBServer().addApiRoutine("/sab/ota/update/device", &(otaUpdateRemoteApi), &sab, WEBServer<WEBClient>::GET); sab.getWebServerManager().getWEBServer().addApiRoutine("/sab/ota/update/device", &(otaUpdateRemoteApi), &sab, WEBServer<WEBClient>::GET);

View File

@ -293,7 +293,7 @@ boolean systemInfoApi(WEBServer<WEBClient>::HttpRequestData &HRD, WiFiClient *wc
ESP.getHeapStats(&freeMem, &biggestContigMemBlock, &frag); ESP.getHeapStats(&freeMem, &biggestContigMemBlock, &frag);
TimeSpan ts(p->getUpTime()); TimeSpan ts(p->getUpTime());
sprintf(buffer, "{\"status\":\"ok\",\"CPU freq\":%u,\"free RAM\":%u,\"heap frag\":%u,\"max block\":%u,\"nb views\":%u,\"up time\":{\"days\":%d,\"hours\":%d,\"minutes\":%d,\"seconds\":%d},\"temperature\":{\"level\":%.2f, \"unit\":\"°C\"}}", ESP.getCpuFreqMHz(), freeMem, frag, biggestContigMemBlock, p->getScreenManager().getViewCount(), ts.days(), ts.hours(), ts.minutes(), ts.seconds(), p->getRTC_DS3231().getTemperature()); sprintf(buffer, "{\"status\":\"ok\",\"version\":\"%s\",\"CPU freq\":%u,\"free RAM\":%u,\"heap frag\":%u,\"max block\":%u,\"nb views\":%u,\"up time\":{\"days\":%d,\"hours\":%d,\"minutes\":%d,\"seconds\":%d},\"temperature\":{\"level\":%.2f, \"unit\":\"°C\"}}", p->getSoftVersion(), ESP.getCpuFreqMHz(), freeMem, frag, biggestContigMemBlock, p->getScreenManager().getViewCount(), ts.days(), ts.hours(), ts.minutes(), ts.seconds(), p->getRTC_DS3231().getTemperature());
WEBServer<WEBClient>::sendHTTPHeader(wc, HttpConstants::httpMIMETypeToString(HttpConstants::APPLICATION_JSON), strlen(buffer)); WEBServer<WEBClient>::sendHTTPHeader(wc, HttpConstants::httpMIMETypeToString(HttpConstants::APPLICATION_JSON), strlen(buffer));
wc->print(buffer); wc->print(buffer);
@ -577,20 +577,6 @@ boolean ioSetModeApi(WEBServer<WEBClient>::HttpRequestData &HRD, WiFiClient *wc,
return true; return true;
} }
boolean swVersionApi(WEBServer<WEBClient>::HttpRequestData &HRD, WiFiClient *wc, void *pData)
{
(void)HRD;
SAB *p = (SAB *)pData;
char buffer[100] = "";
sprintf(buffer ,"{\"status\":\"ok\",\"version\":\"%s\"}", p->getSoftVersion());
WEBServer<WEBClient>::sendHTTPHeader(wc, HttpConstants::httpMIMETypeToString(HttpConstants::APPLICATION_JSON), strlen(buffer));
wc->print(buffer);
return true;
}
boolean otaUpdateUploadApi(WEBServer<WEBClient>::HttpRequestData &HRD, WiFiClient *wc, void *pData) boolean otaUpdateUploadApi(WEBServer<WEBClient>::HttpRequestData &HRD, WiFiClient *wc, void *pData)
{ {
(void)HRD; (void)HRD;

View File

@ -30,7 +30,6 @@ boolean ioGetLevelApi(WEBServer<WEBClient>::HttpRequestData&, WiFiClient*, void*
boolean ioSetLevelApi(WEBServer<WEBClient>::HttpRequestData&, WiFiClient*, void*); boolean ioSetLevelApi(WEBServer<WEBClient>::HttpRequestData&, WiFiClient*, void*);
boolean ioGetModeApi(WEBServer<WEBClient>::HttpRequestData&, WiFiClient*, void*); boolean ioGetModeApi(WEBServer<WEBClient>::HttpRequestData&, WiFiClient*, void*);
boolean ioSetModeApi(WEBServer<WEBClient>::HttpRequestData&, WiFiClient*, void*); boolean ioSetModeApi(WEBServer<WEBClient>::HttpRequestData&, WiFiClient*, void*);
boolean swVersionApi(WEBServer<WEBClient>::HttpRequestData&, WiFiClient*, void*);
boolean otaUpdateUploadApi(WEBServer<WEBClient>::HttpRequestData&, WiFiClient*, void*); boolean otaUpdateUploadApi(WEBServer<WEBClient>::HttpRequestData&, WiFiClient*, void*);
boolean otaUpdateRemoteApi(WEBServer<WEBClient>::HttpRequestData&, WiFiClient*, void*); boolean otaUpdateRemoteApi(WEBServer<WEBClient>::HttpRequestData&, WiFiClient*, void*);