From 7df870c77c36bc382924edf501996e106620754d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Hru=C5=A1ka?= Date: Sun, 20 Mar 2016 11:56:08 +0100 Subject: [PATCH] system status page --- Makefile | 7 +-- esp_meas.pro | 6 ++- esp_meas.pro.user | 2 +- html/css/app.css | 10 ++++ html/js/{all.min.js => all.js} | 13 ++++- html/pages/home.tpl | 84 ++++++++++++++++++++++++++---- html/pages/wifi.tpl | 13 ++--- html_src/_start.php | 18 ++++--- html_src/css/app.css | 10 ++++ html_src/css/app.css.map | 2 +- html_src/gulpfile.js | 2 +- html_src/home.php | 72 ++++++++++++++++++++++++- html_src/js-src/app.js | 11 +++- html_src/js/{all.min.js => all.js} | 13 ++++- html_src/js/all.js.map | 1 + html_src/js/all.min.js.map | 1 - html_src/sass/app.scss | 1 + html_src/sass/pages/_home.scss | 11 ++++ html_src/wifi.php | 1 - libesphttpd/include/esp8266.h | 1 + libesphttpd/util/cgiwifi.c | 16 ++++-- user/cgi.c | 61 +++++++++++++++++++--- user/cgi.h | 2 +- user/uptime.c | 38 ++++++++++++++ user/uptime.h | 13 +++++ user/user_main.c | 9 +++- 26 files changed, 360 insertions(+), 58 deletions(-) rename html/js/{all.min.js => all.js} (98%) rename html_src/js/{all.min.js => all.js} (98%) create mode 100644 html_src/js/all.js.map delete mode 100644 html_src/js/all.min.js.map create mode 100644 html_src/sass/pages/_home.scss create mode 100644 user/uptime.c create mode 100644 user/uptime.h diff --git a/Makefile b/Makefile index 953cf8b..7655c3e 100644 --- a/Makefile +++ b/Makefile @@ -183,17 +183,18 @@ $1/%.o: %.S $(Q) $(CC) $(INCDIR) $(MODULE_INCDIR) $(EXTRA_INCDIR) $(SDK_INCDIR) $(CFLAGS) -c $$< -o $$@ endef -.PHONY: all checkdirs clean libesphttpd default-tgt +.PHONY: all checkdirs clean libesphttpd default-tgt html -all: checkdirs htmlbuild $(TARGET_OUT) $(FW_BASE) +all: checkdirs $(TARGET_OUT) $(FW_BASE) $(Q) echo -e "\nBuild OK.\n" + # libesphttpd/Makefile: # $(Q) echo "No libesphttpd submodule found. Using git to fetch it..." # $(Q) git submodule init # $(Q) git submodule update -htmlbuild: +html: $(vecho) "Building HTML..." $(Q) ./html_build.sh diff --git a/esp_meas.pro b/esp_meas.pro index c5c5b05..e5e67d8 100644 --- a/esp_meas.pro +++ b/esp_meas.pro @@ -49,7 +49,8 @@ SOURCES += \ sbmp/sbmp_frame.c \ sbmp/sbmp_session.c \ user/datalink.c \ - user/serial.c + user/serial.c \ + user/uptime.c HEADERS += \ include/uart_hw.h \ @@ -120,7 +121,8 @@ HEADERS += \ sbmp/sbmp_session.h \ user/datalink.h \ user/serial.h \ - libesphttpd/include/logging.h + libesphttpd/include/logging.h \ + user/uptime.h DISTFILES += \ style.astylerc \ diff --git a/esp_meas.pro.user b/esp_meas.pro.user index 9fca527..8aee40e 100644 --- a/esp_meas.pro.user +++ b/esp_meas.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId diff --git a/html/css/app.css b/html/css/app.css index b3a1bae..b1e4822 100644 --- a/html/css/app.css +++ b/html/css/app.css @@ -1074,4 +1074,14 @@ label.select-wrap { -ms-flex: 0 0 15%; flex: 0 0 15%; } +.page-home #rssi-perc:after { + padding-left: 0.1459102934rem; + content: '%'; + font-size: 0.8888888889em; } + +.page-home #rssi-dbm:after { + padding-left: 0.1459102934rem; + content: 'dBm'; + font-size: 0.8888888889em; } + /*# sourceMappingURL=app.css.map */ diff --git a/html/js/all.min.js b/html/js/all.js similarity index 98% rename from html/js/all.min.js rename to html/js/all.js index 2510b18..9a95112 100644 --- a/html/js/all.min.js +++ b/html/js/all.js @@ -27,6 +27,14 @@ function regexEscape(s) { return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'); } +/** Convert RSSI 0-255 to % */ +function rssiPerc(rssi) { + var r = parseInt(rssi); + if (r > -50) return 100; // 100% + if (r < -100) return 0; // 0% + return Math.round(2 * (r + 100)); // approximation +} + /** Perform a substitution in the given string. * * Arguments - array or list of replacements. @@ -122,6 +130,7 @@ var wifi = (function () { var done = !bool(resp.result.inProgress) && (resp.result.APs.length > 0); rescan(done ? 15000 : 1000); + if (!done) return; // no redraw yet // clear the AP list var $list = $('#ap-list'); @@ -155,7 +164,7 @@ var wifi = (function () { var inner = document.createElement('div'); var $inner = $(inner).addClass('inner') - .htmlAppend('
{0}
'.format(Math.round(ap.rssi / 2.55))) + .htmlAppend('
{0}
'.format(rssiPerc(ap.rssi))) .htmlAppend('
{0}
'.format(e(ap.essid))) .htmlAppend('
{0}
'.format(authStr[ap.enc])); @@ -947,4 +956,4 @@ function initDef() { }()); -//# sourceMappingURL=all.min.js.map +//# sourceMappingURL=all.js.map diff --git a/html/pages/home.tpl b/html/pages/home.tpl index 59fb117..46896bc 100644 --- a/html/pages/home.tpl +++ b/html/pages/home.tpl @@ -9,16 +9,10 @@ - - - - + + - +