Firewall / Diagnostics / States, Sessions - fix some minor glitches.

o mark unsortable columns
o fix type validations (avg=* isn't an int).
o better to return an empty structure than [], avoid JS errors in the frontend
This commit is contained in:
Ad Schellevis 2021-07-21 18:49:10 +02:00
parent 74ccf1683b
commit be90cf00a6
3 changed files with 18 additions and 8 deletions

View File

@ -199,7 +199,12 @@ class FirewallController extends ApiControllerBase
];
}
}
return [];
return [
'rows' => [],
'rowCount' => 0,
'total' => 0,
'current' => 0
];
}
/**
@ -244,7 +249,12 @@ class FirewallController extends ApiControllerBase
];
}
}
return [];
return [
'rows' => [],
'rowCount' => 0,
'total' => 0,
'current' => 0
];
}
/**
* delete / drop a specific state by state+creator id

View File

@ -221,9 +221,9 @@
<th data-column-id="interface" data-type="string" data-width="6em">{{ lang._('Int') }}</th>
<th data-column-id="direction" data-type="string" data-width="4em" data-formatter="direction">{{ lang._('Dir') }}</th>
<th data-column-id="proto" data-type="string" data-width="6em">{{ lang._('Proto') }}</th>
<th data-column-id="src" data-type="string" data-formatter="address">{{ lang._('Source') }}</th>
<th data-column-id="nat" data-type="string" data-formatter="address">{{ lang._('Nat') }}</th>
<th data-column-id="dst" data-type="string" data-formatter="address">{{ lang._('Destination') }}</th>
<th data-column-id="src" data-type="string" data-formatter="address" data-sortable="false">{{ lang._('Source') }}</th>
<th data-column-id="nat" data-type="string" data-formatter="address" data-sortable="false">{{ lang._('Nat') }}</th>
<th data-column-id="dst" data-type="string" data-formatter="address" data-sortable="false">{{ lang._('Destination') }}</th>
<th data-column-id="state" data-type="string">{{ lang._('State') }}</th>
<th data-column-id="descr" data-type="string" data-formatter="rule">{{ lang._('Rule') }}</th>
<th data-column-id="commands" data-width="7em" data-formatter="commands" data-sortable="false">{{ lang._('Commands') }}</th>

View File

@ -192,9 +192,9 @@ def query_top(rule_label, filter_str):
record['state'] = parts[idx]
record['age'] = parts[idx+1]
record['expire'] = parts[idx+2]
record['pkts'] = int(parts[idx+3])
record['bytes'] = int(parts[idx+4])
record['avg'] = int(parts[idx+5])
record['pkts'] = int(parts[idx+3]) if parts[idx+3].isdigit() else 0
record['bytes'] = int(parts[idx+4]) if parts[idx+4].isdigit() else 0
record['avg'] = int(parts[idx+5]) if parts[idx+5].isdigit() else 0
record['rule'] = parts[idx+6]
if record['rule'] in rule_labels:
record['label'] = rule_labels[record['rule']]['rid']