mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-13 16:14:40 +00:00
VPN: OpenVPN: Connection Status - fix widget, make sure sorting works as expected and set display format on bytes. closes https://github.com/opnsense/core/issues/6464
This commit is contained in:
parent
a556df4a85
commit
3066c875a2
@ -75,7 +75,6 @@ class ServiceController extends ApiControllerBase
|
||||
$stats['type'] = $role;
|
||||
$stats['id'] = $idx;
|
||||
$stats['description'] = '';
|
||||
$stats['connected_since'] = null;
|
||||
if (!empty($stats['timestamp'])) {
|
||||
$stats['connected_since'] = date('Y-m-d H:i:s', $stats['timestamp']);
|
||||
}
|
||||
@ -102,12 +101,22 @@ class ServiceController extends ApiControllerBase
|
||||
'service_id' => "openvpn/" . $idx,
|
||||
'type' => $role,
|
||||
'description' => (string)$cnf->description ?? '',
|
||||
'connected_since' => null,
|
||||
'status' => null
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
// make sure all records contain the same amount of keys to prevent sorting issues.
|
||||
$all_keys = [];
|
||||
foreach ($records as $record) {
|
||||
$all_keys = array_unique(array_merge(array_keys($record), $all_keys));
|
||||
}
|
||||
foreach ($records as &$record) {
|
||||
foreach ($all_keys as $key) {
|
||||
if (!isset($record[$key])) {
|
||||
$record[$key] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $this->searchRecordsetBase($records);
|
||||
}
|
||||
|
||||
|
||||
@ -33,6 +33,12 @@
|
||||
options:{
|
||||
selection: false,
|
||||
formatters:{
|
||||
bytes: function(column, row) {
|
||||
if (row[column.id]) {
|
||||
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>';
|
||||
@ -131,8 +137,8 @@
|
||||
<th data-column-id="real_address" data-type="string">{{ lang._('Real Address') }}</th>
|
||||
<th data-column-id="virtual_address" data-type="string">{{ lang._('Virtual Address') }}</th>
|
||||
<th data-column-id="connected_since" data-type="string">{{ lang._('Connected Since') }}</th>
|
||||
<th data-column-id="bytes_sent" data-type="string">{{ lang._('Bytes Sent') }}</th>
|
||||
<th data-column-id="bytes_received" data-type="string">{{ lang._('Bytes Received') }}</th>
|
||||
<th data-column-id="bytes_sent" data-type="numeric" data-formatter="bytes">{{ lang._('Bytes Sent') }}</th>
|
||||
<th data-column-id="bytes_received" data-type="numeric" data-formatter="bytes">{{ lang._('Bytes Received') }}</th>
|
||||
<th data-column-id="status" data-type="string">{{ lang._('Status') }}</th>
|
||||
<th data-column-id="commands" data-width="5em" data-formatter="commands" data-sortable="false"></th>
|
||||
</tr>
|
||||
|
||||
@ -88,7 +88,7 @@ foreach ($openvpn_cfg as $section => &$ovpncfg) {
|
||||
elseif (!empty($server['timestamp'])):?>
|
||||
<tr>
|
||||
<td><?=date('Y-m-d H:i:s', $server['timestamp']);?></td>
|
||||
<td><?=$server['remote_host'];?><br/><?=$server['virtual_address'];?></td>
|
||||
<td><?=$server['real_address'];?><br/><?=$server['virtual_address'];?></td>
|
||||
<td>
|
||||
<span class='fa fa-exchange fa-fw <?=$server['status'] == "CONNECTED" ? "text-success" : "text-danger" ;?>'></span>
|
||||
</td>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user