UIbootgrid usage - use generic bytes formatter in pf_top, ipsec and openvpn.

This commit is contained in:
Ad Schellevis 2023-09-04 20:49:15 +02:00
parent a3d74d84a1
commit 58b2efccd5
3 changed files with 2 additions and 21 deletions

View File

@ -60,19 +60,6 @@
return addr_txt;
}
return "";
},
bytes: function(column, row) {
if (!isNaN(row[column.id]) && row[column.id] > 0) {
let fileSizeTypes = ["", "K", "M", "G", "T", "P", "E", "Z", "Y"];
let ndx = Math.floor(Math.log(row[column.id]) / Math.log(1024) );
if (ndx > 0) {
return (row[column.id] / Math.pow(1024, ndx)).toFixed(2) + ' ' + fileSizeTypes[ndx];
} else {
return row[column.id].toFixed(2);
}
} else {
return "";
}
}
},
requestHandler:function(request){

View File

@ -154,8 +154,8 @@
<th data-column-id="remote-ts" data-type="string" data-formatter="addresses">{{ lang._('Remote subnets') }}</th>
<th data-column-id="state" data-type="string">{{ lang._('State') }}</th>
<th data-column-id="install-time" data-type="string">{{ lang._('Time') }}</th>
<th data-column-id="bytes-in" data-type="string">{{ lang._('Bytes in') }}</th>
<th data-column-id="bytes-out" data-type="string">{{ lang._('Bytes out') }}</th>
<th data-column-id="bytes-in" data-type="numeric" data-formatter="bytes">{{ lang._('Bytes in') }}</th>
<th data-column-id="bytes-out" data-type="numeric" data-formatter="bytes">{{ lang._('Bytes out') }}</th>
</tr>
</thead>
<tbody>

View File

@ -33,12 +33,6 @@
options:{
selection: false,
formatters:{
bytes: function(column, row) {
if (row[column.id] && row[column.id] > 0) {
return byteFormat(row[column.id], 2);
}
return '';
},
commands: function (column, row) {
if (row.is_client) {
return '<button type="button" class="btn btn-xs btn-default ovpn-command command-kill" data-toggle="tooltip" title="{{ lang._('Kill') }}" data-common_name="'+row.common_name+'" data-row-id="' + row.id + '"><span class="fa fa-times fa-fw"></span></button>';