Fix: Correct total number of monitoring entries in admin panel.
See: https://github.com/freifunkhamburg/ffffng/issues/16
This commit is contained in:
parent
f720c0e028
commit
ecc82e30c1
|
@ -355,9 +355,28 @@ angular.module('ffffng')
|
||||||
|
|
||||||
return {
|
return {
|
||||||
getAll: function (restParams, callback) {
|
getAll: function (restParams, callback) {
|
||||||
|
var sortFields = [
|
||||||
|
'id',
|
||||||
|
'mac',
|
||||||
|
'state',
|
||||||
|
'last_seen',
|
||||||
|
'import_timestamp',
|
||||||
|
'last_status_mail_type',
|
||||||
|
'last_status_mail_sent',
|
||||||
|
'created_at',
|
||||||
|
'modified_at'
|
||||||
|
];
|
||||||
|
var filterFields = [
|
||||||
|
'mac',
|
||||||
|
'state',
|
||||||
|
'last_status_mail_type'
|
||||||
|
];
|
||||||
|
|
||||||
|
var where = Resources.whereCondition(restParams, filterFields);
|
||||||
|
|
||||||
Database.get(
|
Database.get(
|
||||||
'SELECT count(*) AS total FROM node_state',
|
'SELECT count(*) AS total FROM node_state WHERE ' + where.query,
|
||||||
[],
|
_.concat([], where.params),
|
||||||
function (err, row) {
|
function (err, row) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return callback(err);
|
return callback(err);
|
||||||
|
@ -368,22 +387,8 @@ angular.module('ffffng')
|
||||||
var filter = Resources.filterClause(
|
var filter = Resources.filterClause(
|
||||||
restParams,
|
restParams,
|
||||||
'id',
|
'id',
|
||||||
[
|
sortFields,
|
||||||
'id',
|
filterFields
|
||||||
'mac',
|
|
||||||
'state',
|
|
||||||
'last_seen',
|
|
||||||
'import_timestamp',
|
|
||||||
'last_status_mail_type',
|
|
||||||
'last_status_mail_sent',
|
|
||||||
'created_at',
|
|
||||||
'modified_at'
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'mac',
|
|
||||||
'state',
|
|
||||||
'last_status_mail_type'
|
|
||||||
]
|
|
||||||
);
|
);
|
||||||
|
|
||||||
Database.all(
|
Database.all(
|
||||||
|
|
|
@ -147,6 +147,8 @@ angular.module('ffffng').factory('Resources', function (_, Constraints, Validato
|
||||||
return entities.slice((page - 1) * perPage, page * perPage);
|
return entities.slice((page - 1) * perPage, page * perPage);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
whereCondition: filterCondition,
|
||||||
|
|
||||||
filterClause: function (restParams, defaultSortField, allowedSortFields, filterFields) {
|
filterClause: function (restParams, defaultSortField, allowedSortFields, filterFields) {
|
||||||
var orderBy = orderByClause(
|
var orderBy = orderByClause(
|
||||||
restParams,
|
restParams,
|
||||||
|
|
Loading…
Reference in a new issue