From eedfec2aa6c8cfa0686c0b5c37ad310b1aebac48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Schr=C3=B6der?= Date: Mon, 25 May 2015 14:19:13 +0200 Subject: [PATCH] Fixed nat connections count.. --- .../plugins/core/widgets/luci.progress.js | 40 +++++-------------- .../plugins/internet/pages/status.nat.html | 10 ++++- .../plugins/internet/pages/status.nat.js | 11 ++++- 3 files changed, 30 insertions(+), 31 deletions(-) diff --git a/luciexpress/htdocs/plugins/core/widgets/luci.progress.js b/luciexpress/htdocs/plugins/core/widgets/luci.progress.js index 48ac047c9..d0dac6dd5 100644 --- a/luciexpress/htdocs/plugins/core/widgets/luci.progress.js +++ b/luciexpress/htdocs/plugins/core/widgets/luci.progress.js @@ -1,32 +1,11 @@ -/* - * juci - javascript universal client interface - * - * Project Author: Martin K. Schröder - * - * Copyright (C) 2012-2013 Inteno Broadband Technology AB. All rights reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA - */ - -$juci.module("core") +//! Author: Martin K. Schröder + +JUCI.app .directive("luciProgress", function(){ var plugin_root = $juci.module("core").plugin_root; return { // accepted parameters for this tag scope: { - percent: "=", value: "=", total: "=", units: "=" @@ -34,7 +13,6 @@ $juci.module("core") templateUrl: plugin_root+"/widgets/luci.progress.html", replace: true, controller: "LuciProgressControl", - controllerAs: "ctrl", link: function(scope, element, attributes){ // make sure we interpret the units as string scope.units = attributes.units; @@ -42,8 +20,12 @@ $juci.module("core") }; }) .controller("LuciProgressControl", function($scope, $navigation){ - if($scope.value && Number($scope.value) != 0) - $scope.width = Math.round((Number($scope.value) / Number($scope.total)) * 100); - else - $scope.width = 0; + function update(){ + if($scope.value && Number($scope.value) != 0) + $scope.width = Math.round((Number($scope.value||0) / Number($scope.total||0)) * 100); + else + $scope.width = 0; + } + $scope.$watch("value", update); + $scope.$watch("total", update); }); diff --git a/luciexpress/htdocs/plugins/internet/pages/status.nat.html b/luciexpress/htdocs/plugins/internet/pages/status.nat.html index 4af4f20ee..c21d66d1a 100644 --- a/luciexpress/htdocs/plugins/internet/pages/status.nat.html +++ b/luciexpress/htdocs/plugins/internet/pages/status.nat.html @@ -1,5 +1,13 @@
+ +

Connections

+ + + + + +
{{ 'Connections for each Device' | translate }} {{ 'status.nat.connections.info' | translate }} @@ -18,7 +26,7 @@ - + {{ 'NAT Connection Table' | translate }} {{ 'status.nat.info' | translate }} diff --git a/luciexpress/htdocs/plugins/internet/pages/status.nat.js b/luciexpress/htdocs/plugins/internet/pages/status.nat.js index 464aa5dae..4cfa623e3 100644 --- a/luciexpress/htdocs/plugins/internet/pages/status.nat.js +++ b/luciexpress/htdocs/plugins/internet/pages/status.nat.js @@ -1,5 +1,7 @@ JUCI.app -.controller("StatusNATPageCtrl", function($scope, $rpc){ +.controller("StatusNATPageCtrl", function($scope, $rpc, $tr, gettext){ + $scope.conntrack = { count: 0, limit: 0 }; + $rpc.router.clients().done(function(table){ var clients = []; Object.keys(table).map(function(x){ @@ -7,8 +9,15 @@ JUCI.app if(cl.connected) clients.push(cl); }); $scope.clients = clients; + $scope.conntrack.count = clients.reduce(function(prev, cur){ return prev + (cur.active_cons||0); }, 0); $scope.$apply(); }); + + $rpc.luci2.network.conntrack_count().done(function(res){ + $scope.conntrack.limit = res.limit; + $scope.$apply(); + }); + $rpc.luci2.network.conntrack_table().done(function(table){ if(table && table.entries){ $scope.connections = table.entries.sort(function(a, b){ return (a.src+a.dest) < (b.src+b.dest); }).map(function(x){