diff --git a/src/accept.c b/src/accept.c index 19f7279..f3f9680 100644 --- a/src/accept.c +++ b/src/accept.c @@ -1569,6 +1569,7 @@ int accept_listener_status(cJSON *listeners, cJSON *totals) continue; cJSON *jl = cJSON_CreateObject(); cJSON_AddNumberToObject(jl, "fd", l->fd); + cJSON_AddNumberToObject(jl, "id", l->id); cJSON_AddStringToObject(jl, "name", l->name); cJSON_AddStringToObject(jl, "proto", (l->udp) ? "udp" : "tcp"); cJSON_AddStringToObject(jl, "addr", l->addr_s); diff --git a/src/web/aprsc.js b/src/web/aprsc.js index 29da7ba..1332be5 100644 --- a/src/web/aprsc.js +++ b/src/web/aprsc.js @@ -918,7 +918,7 @@ function ratestr(rate) return prefix + rate; } -function rehash_clients(status) +function rehash_clients_old(status) { var clients_id = {}; @@ -930,6 +930,18 @@ function rehash_clients(status) status['clients_id'] = clients_id; } +function array_to_dict_by_id(arr) +{ + var dict = {}; + + for (var c in arr) { + var cl = arr[c]; + dict[cl['id']] = cl; + } + + return dict; +} + function calculate_rates(status_old, status_new) { var i = 0; @@ -1088,7 +1100,8 @@ app.controller('aprscc', [ '$scope', '$http', 'graphs', function($scope, $http, if ($scope.status) { d.tick_dif = d.server.tick_now - $scope.status.server.tick_now; calculate_rates($scope.status, d); - rehash_clients($scope.status); + $scope.status['clients_id'] = array_to_dict_by_id($scope.status.clients); + $scope.status['listeners_id'] = array_to_dict_by_id($scope.status.listeners); } $scope.status_prev = $scope.status; diff --git a/src/web/index.html b/src/web/index.html index 2183a12..58a3237 100644 --- a/src/web/index.html +++ b/src/web/index.html @@ -104,7 +104,20 @@ - + + + + + + + + + + + + +
{{ title }}
{{ l[k] }} {{ status_prev.listeners[$parent.$index][k] }}{{ l.proto }}{{ l.addr }}{{ l.name }}{{ l.clients }}{{ l.clients_peak }}{{ l.clients_max }}{{ l.connects }}{{ (l.connects - status_prev.listeners_id[l.id].connects) / status.tick_dif | ratestr }}{{ l.pkts_tx }}{{ l.pkts_rx }}{{ l.bytes_tx }}{{ l.bytes_rx }}{{ (l.bytes_tx - status_prev.listeners_id[l.id].bytes_tx) / status.tick_dif | ratestr }} + / {{ (l.bytes_rx - status_prev.clisteners_id[l.id].bytes_rx) / status.tick_dif | ratestr }}