From 9be73d94c43dbfba129a0e07c192e8571921d3fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Schr=C3=B6der?= Date: Wed, 6 May 2015 09:36:36 +0200 Subject: [PATCH] Added dynamic wifi signal indicator --- luciexpress/htdocs/js/uci.js | 7 ++-- .../htdocs/plugins/core/pages/overview.html | 5 ++- .../htdocs/plugins/core/pages/overview.js | 2 +- luciexpress/htdocs/plugins/core/plugin.json | 1 + .../core/widgets/wifi.signal.indicator.html | 3 ++ .../core/widgets/wifi.signal.indicator.js | 35 +++++++++++++++++++ 6 files changed, 48 insertions(+), 5 deletions(-) create mode 100644 luciexpress/htdocs/plugins/core/widgets/wifi.signal.indicator.html create mode 100644 luciexpress/htdocs/plugins/core/widgets/wifi.signal.indicator.js diff --git a/luciexpress/htdocs/js/uci.js b/luciexpress/htdocs/js/uci.js index 568950e21..a0a36f2af 100644 --- a/luciexpress/htdocs/js/uci.js +++ b/luciexpress/htdocs/js/uci.js @@ -8,8 +8,9 @@ angular.module("luci") "status_led": { dvalue: true, type: Boolean }, "power_led": { dvalue: true, type: Boolean }, "power_led_br": { dvalue: 100, type: Number }, - "wifibutton": { dvalue: true, type: Boolean }, - "wpsbutton": { dvalue: true, type: Boolean } + "wifibutton": { dvalue: true, type: Boolean }, + "wpsbutton": { dvalue: true, type: Boolean }, + "wpsdevicepin": { dvalue: true, type: Boolean } }, "firewall-defaults": { "syn_flood": { dvalue: true, type: Boolean }, @@ -53,7 +54,7 @@ angular.module("luci") "ping_wan": { dvalue: false, type: Boolean } }, "wifi-status": { - "wlan": { dvalue: true, type: Boolean }, + "wlan": { dvalue: true, type: Boolean }, "wps": { dvalue: true, type: Boolean }, "schedule": { dvalue: false, type: Boolean }, "sched_status": { dvalue: false, type: Boolean } diff --git a/luciexpress/htdocs/plugins/core/pages/overview.html b/luciexpress/htdocs/plugins/core/pages/overview.html index 2c1e7d875..79fe7a1dd 100644 --- a/luciexpress/htdocs/plugins/core/pages/overview.html +++ b/luciexpress/htdocs/plugins/core/pages/overview.html @@ -42,7 +42,10 @@
{{client.hostname}}
{{client.ipaddr}}
-
+
+ + +
diff --git a/luciexpress/htdocs/plugins/core/pages/overview.js b/luciexpress/htdocs/plugins/core/pages/overview.js index 21dfd6b90..734323f16 100644 --- a/luciexpress/htdocs/plugins/core/pages/overview.js +++ b/luciexpress/htdocs/plugins/core/pages/overview.js @@ -48,5 +48,5 @@ $juci.module("core") }); }); } refresh(); - setInterval(refresh, 5000); + //setInterval(refresh, 5000); }); diff --git a/luciexpress/htdocs/plugins/core/plugin.json b/luciexpress/htdocs/plugins/core/plugin.json index 3cfbc4782..357cf5633 100644 --- a/luciexpress/htdocs/plugins/core/plugin.json +++ b/luciexpress/htdocs/plugins/core/plugin.json @@ -12,6 +12,7 @@ "widgets/luci.nav", "widgets/luci.navbar", "widgets/luci.top_bar", + "widgets/wifi.signal.indicator", "widgets/uci.firewall.nat.rule.edit", "widgets/core.modal", "widgets/luci.input.port" diff --git a/luciexpress/htdocs/plugins/core/widgets/wifi.signal.indicator.html b/luciexpress/htdocs/plugins/core/widgets/wifi.signal.indicator.html new file mode 100644 index 000000000..c0fa3c7d4 --- /dev/null +++ b/luciexpress/htdocs/plugins/core/widgets/wifi.signal.indicator.html @@ -0,0 +1,3 @@ +
+
+
diff --git a/luciexpress/htdocs/plugins/core/widgets/wifi.signal.indicator.js b/luciexpress/htdocs/plugins/core/widgets/wifi.signal.indicator.js new file mode 100644 index 000000000..ab3454bfe --- /dev/null +++ b/luciexpress/htdocs/plugins/core/widgets/wifi.signal.indicator.js @@ -0,0 +1,35 @@ +$juci.module("core") +.directive("wifiSignalIndicator", function($compile, $parse){ + var plugin_root = $juci.module("core").plugin_root; + return { + templateUrl: plugin_root+"/widgets/wifi.signal.indicator.html", + scope: { + value: "=ngModel" + }, + controller: "wifiSignalIndicator", + replace: true, + require: "^ngModel" + }; +}).controller("wifiSignalIndicator", function($scope, $uci, $rpc){ + var step = 100 / 4; + $scope.bars = [false, false, false, false]; + $scope.$watch("value", function(value){ + $scope.bars[0] = true; + $scope.bars[1] = $scope.bars[2] = $scope.bars[3] = false; + if(value > step) $scope.bars[1] = true; + if(value > (step * 2)) $scope.bars[2] = true; + if(value > (step * 3)) $scope.bars[3] = true; + }); + $scope.barStyle = function(idx, active){ + var height = 5 + ((idx) * 5); + var top = 20 - height; + return { + "position": "absolute", + "width": "6px", + "height": ""+height+"px", + "background-color": (active)?"#aab400":"#d5d5d5", + "top": ""+top+"px", + "left": ""+(idx * 8)+"px" + }; + } +});