From 94eedf07bd16b29036c38cb0d0915cbbf6b07741 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Schr=C3=B6der?= Date: Thu, 21 May 2015 15:27:01 +0200 Subject: [PATCH] Added status page --- luciexpress/htdocs/js/timeout.js | 5 +- .../plugins/status/pages/status.status.html | 52 +++++-- .../plugins/status/pages/status.status.js | 140 +++++------------- 3 files changed, 80 insertions(+), 117 deletions(-) diff --git a/luciexpress/htdocs/js/timeout.js b/luciexpress/htdocs/js/timeout.js index 9b2d23523..263e82595 100644 --- a/luciexpress/htdocs/js/timeout.js +++ b/luciexpress/htdocs/js/timeout.js @@ -11,7 +11,7 @@ _timeouts[name] = i; }, repeat: function(name, t, fn){ - var i = setTimeout(function _onTimeout(){ + function _onTimeout(){ fn(function next(ret, err){ if(ret){ clearTimeout(i); @@ -21,7 +21,8 @@ setTimeout(_onTimeout, t); } }); - }, t); + } + var i = setTimeout(_onTimeout, t); _onTimeout(); _timeouts[name] = i; }, $clearAll: function(){ diff --git a/luciexpress/htdocs/plugins/status/pages/status.status.html b/luciexpress/htdocs/plugins/status/pages/status.status.html index 98562ea1e..77293af38 100644 --- a/luciexpress/htdocs/plugins/status/pages/status.status.html +++ b/luciexpress/htdocs/plugins/status/pages/status.status.html @@ -1,14 +1,46 @@
-

Status

- - - + + {{ 'Status' | translate }} + {{ 'status.status.info' | translate }} + +
+
+
+ + + + +
+

+ {{sec.name | translate}} +

+
+
+
+
+
    +
  • {{err.subsystem}}: {{err.code}}
  • +
+
+ + + {{sec.interface["ipv4-address"][0].address}} + + + {{sec.interface["route"][0].nexthop}} + + + {{sec.interface["dns-server"][0]}} + + + {{sec.interface["dns-server"][1]}} + + +
+
diff --git a/luciexpress/htdocs/plugins/status/pages/status.status.js b/luciexpress/htdocs/plugins/status/pages/status.status.js index 2ec579fec..43e4a0653 100644 --- a/luciexpress/htdocs/plugins/status/pages/status.status.js +++ b/luciexpress/htdocs/plugins/status/pages/status.status.js @@ -1,114 +1,44 @@ //! Author: Martin K. Schröder JUCI.app -.controller("StatsOverviewCtrl", function ($scope, $session, $rootScope, $rpc, gettext, $tr) { - $scope.sysinfo = {}; - $scope.info = {}; +.controller("StatsOverviewCtrl", function ($scope, $uci, $rpc, gettext) { + //$scope.expanded = false; + $scope.sections = [{}, {}, {}]; - $scope.systemStatusTbl = { - rows: [["", ""]] - }; - $scope.systemExtStatusTbl = { - rows: [["", ""]] - }; - $scope.systemMemoryTbl = { - rows: [["", ""]] - }; - $scope.systemStorageTbl = { - rows: [["", ""]] - }; - $scope.systemConnectionsTbl = { - rows: [["", ""]] - }; - $scope.systemDHCPLeasesTbl = { - columns: [gettext("Hostname"), gettext("IPv4-Address"), gettext("MAC-Address"), gettext("Leasetime remaining")], - rows: [ - [gettext("No active leases"), '', '', ''] - ] - }; - $scope.systemStationsTbl = { - columns: [gettext("IPv4-Address"), gettext("MAC address"), gettext("Signal"), gettext("Noise"), gettext("RX Rate"), gettext("TX Rate")], - rows: [] - }; - var info = {}; - var sys = {}; - var conntrack = {}; - var disk = {}; - var clients = {}; - var leases = {}; - function doUpdate(){ - async.parallel([ - function (cb){$rpc.router.info().done(function(res){info = res; cb();}).fail(function(res){cb();});}, - function (cb){$rpc.system.info().done(function(res){sys = res; cb();}).fail(function(res){cb();});}, - function (cb){$rpc.luci2.network.conntrack_count().done(function(res){conntrack = res; cb();}).fail(function(res){cb();});}, - function (cb){$rpc.luci2.system.diskfree().done(function(res){disk = res; cb();}).fail(function(res){cb();});}, - function (cb){$rpc.router.clients().done(function(res){clients = res; cb();}).fail(function(res){cb();});}, - function (cb){$rpc.luci2.network.dhcp_leases().done(function(res){leases = res.leases || []; cb();}).fail(function(res){cb();});} - ], function(err, next){ - $scope.systemStatusTbl.rows = [ - [$tr(gettext("Hostname")), info.system.name], - [$tr(gettext("Model")), info.system.nvramver], - [$tr(gettext("Firmware Version")), info.system.firmware], - [$tr(gettext("Kernel Version")), info.system.kernel], - [$tr(gettext("Local Time")), new Date(sys.localtime)], - [$tr(gettext("Uptime")), info.system.uptime], - //[$tr(gettext("Load Average")), sys.load[0] + " " + sys.load[1] + " " + sys.load[2]] - ]; - $scope.systemExtStatusTbl.rows = [ - [$tr(gettext("Wifi")), (info.specs.wifi)?gettext("yes"):gettext("no")], - [$tr(gettext("ADSL")), (info.specs.adsl)?gettext("yes"):gettext("no")], - [$tr(gettext("VDSL")), (info.specs.vdsl)?gettext("yes"):gettext("no")], - [$tr(gettext("Voice")), (info.specs.voice)?gettext("yes"):gettext("no")], - [$tr(gettext("Voice Ports")), info.specs.voice_ports], - [$tr(gettext("Ethernet Ports")), info.specs.eth_ports] - ]; - $scope.systemMemoryTbl.rows = [ - [$tr(gettext("Usage")), ''], - [$tr(gettext("Shared")), ''], - [$tr(gettext("Buffered")), ''], - [$tr(gettext("Swap")), ''] - ]; - $scope.systemStorageTbl.rows = [ - [$tr(gettext("Root Usage (/)")), ''], - [$tr(gettext("Temporary Usage (/tmp)")), ''] - ]; - $scope.systemConnectionsTbl.rows = [ - [$tr(gettext("Active Connections")), ''] - ]; - if(leases.length){ - $scope.systemDHCPLeasesTbl.rows = []; - leases.map(function(lease){ - var date = new Date(null); - date.setSeconds(lease.expires); // specify value for SECONDS here - var time = date.toISOString().substr(11, 8); - $scope.systemDHCPLeasesTbl.rows.push( - [lease.hostname, lease.ipaddr, lease.macaddr, time] - ); + JUCI.interval.repeat("status.refresh", 2000, function(resume){ + async.series([ + function(next){ + $uci.sync("boardpanel").done(function(){ next(); }); + }, + function(next){ + $rpc.network.interface.dump().done(function(result){ + _interfaces = result.interface; + next(); }); - } else { - $scope.systemDHCPLeasesTbl.rows = [ - [$tr(gettext("No active leases")), '', '', ''] - ]; - } - if(Object.keys(clients).length){ - $scope.systemStationsTbl.rows = []; - Object.keys(clients).map(function(id){ - var cl = clients[id]; - $scope.systemStationsTbl.rows.push( - [cl.ipaddr, cl.macaddr, 0, 0, cl.rx_rate || 0, cl.tx_rate || 0] - ); + }, + function(next){ + var sections = []; + [ + { name: gettext("Internet"), value: $uci.boardpanel.network.internet.value||"wan" }, + { name: gettext("Voice"), value: $uci.boardpanel.network.voice.value }, + { name: gettext("IPTV"), value: $uci.boardpanel.network.iptv.value } + ] + .filter(function(x){ return x.value != "" }) + .forEach(function(x, c){ + sections.push({ + "name": x.name, + "interface": _interfaces.find(function(i){ return i.interface == x.value; }) + }); }); - } else { - $scope.systemStationsTbl.rows = [ - [$tr(gettext("No active stations")), '', '', '', '', ''] - ]; + sections = sections.sort(function(a, b) { return a.interface.up > b.interface.up; }); + for(var c = 0; c < $scope.sections.length; c++){ + Object.assign($scope.sections[c], sections[c]); + } + $scope.$apply(); + next(); } - $scope.$apply(); - }, function(){ - setTimeout(function(){ - doUpdate(); - }, 5000); + ], function(){ + resume(); }); - } - doUpdate(); + }); });