Browse Source

Merge pull request #558 from hyteoo/master

Add Reset to factory settings in admin page of web UI
rfm69
Xose Pérez 6 years ago
committed by GitHub
parent
commit
ab07def2d8
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 2 deletions
  1. +7
    -0
      code/espurna/ws.ino
  2. +2
    -1
      code/html/custom.css
  3. +11
    -0
      code/html/custom.js
  4. +2
    -1
      code/html/index.html

+ 7
- 0
code/espurna/ws.ino View File

@ -95,6 +95,13 @@ void _wsParse(AsyncWebSocketClient *client, uint8_t * payload, size_t length) {
if (strcmp(action, "reboot") == 0) deferredReset(100, CUSTOM_RESET_WEB);
if (strcmp(action, "reconnect") == 0) _web_defer.once_ms(100, wifiDisconnect);
if (strcmp(action, "factory_reset") == 0)
{
DEBUG_MSG_P(PSTR("\n\nFACTORY RESET\n\n"));
resetSettings();
deferredReset(100, CUSTOM_RESET_FACTORY);
}
JsonObject& data = root["data"];
if (data.success()) {


+ 2
- 1
code/html/custom.css View File

@ -148,7 +148,8 @@ div.state {
.button-rfb-forget,
.button-del-network,
.button-del-schedule,
.button-upgrade {
.button-upgrade,
.button-settings-factory {
background: rgb(192, 0, 0); /* redish */
}


+ 11
- 0
code/html/custom.js View File

@ -494,6 +494,16 @@ function doRestore() {
return false;
}
function doFactoryReset() {
var response = window.confirm("Are you sure you want to restore to factory settings?");
if (response === false) {
return false;
}
websock.send(JSON.stringify({"action": "factory_reset"}));
doReload(5000);
return false;
}
function doToggle(element, value) {
var id = parseInt(element.attr("data"), 10);
sendAction("relay", {id: id, status: value ? 1 : 0 });
@ -1253,6 +1263,7 @@ $(function() {
$(".button-wifi-scan").on("click", doScan);
$(".button-settings-backup").on("click", doBackup);
$(".button-settings-restore").on("click", doRestore);
$(".button-settings-factory").on("click", doFactoryReset);
$("#uploader").on("change", onFileUpload);
$(".button-upgrade").on("click", doUpgrade);


+ 2
- 1
code/html/index.html View File

@ -523,7 +523,8 @@
<div class="pure-g">
<label class="pure-u-1 pure-u-lg-1-4">Settings</label>
<div class="pure-u-1-2 pure-u-lg-1-8"><button class="pure-button button-settings-backup pure-u-23-24">Backup</button></div>
<div class="pure-u-1-2 pure-u-lg-1-8"><button class="pure-button button-settings-restore pure-u-1">Restore</button></div>
<div class="pure-u-1-2 pure-u-lg-1-8"><button class="pure-button button-settings-restore pure-u-23-24">Restore</button></div>
<div class="pure-u-1-4 pure-u-lg-1-4"><button class="pure-button button-settings-factory pure-u-1">Factory Reset</button></div>
</div>
<div class="pure-g">


Loading…
Cancel
Save