mirror of
https://github.com/ngoduykhanh/wireguard-ui.git
synced 2025-04-21 20:12:33 +03:00
In status page the rx and tx bytes now are shown with units (needed code added in this file)
This commit is contained in:
parent
e97d6b95c1
commit
50e7cf4b12
1 changed files with 16 additions and 2 deletions
|
@ -14,6 +14,20 @@ Connected Peers
|
|||
{{end}}
|
||||
|
||||
{{define "page_content"}}
|
||||
<script>
|
||||
function bytesToHumanReadable(temporal) {
|
||||
const units = [" ", " K", " M", " G", " T", " P", " E", " Z", " Y"]
|
||||
let pow = 0
|
||||
|
||||
while (temporal > 1024) {
|
||||
temporal /= 1024
|
||||
pow ++
|
||||
if (pow == units.length-1) break
|
||||
}
|
||||
|
||||
return parseFloat(temporal.toFixed(3)) + units[pow]+"Bytes"
|
||||
}
|
||||
</script>
|
||||
<section class="content">
|
||||
<div class="container-fluid">
|
||||
{{ if .error }}
|
||||
|
@ -41,8 +55,8 @@ Connected Peers
|
|||
<td>{{ $peer.Name }}</td>
|
||||
<td>{{ $peer.Email }}</td>
|
||||
<td>{{ $peer.PublicKey }}</td>
|
||||
<td title="{{ $peer.ReceivedBytes }} Bytes">{{ $peer.Received }}</td>
|
||||
<td title="{{ $peer.TransmitBytes }} Bytes">{{ $peer.Transmit }}</td>
|
||||
<td title="{{ $peer.ReceivedBytes }} Bytes"><script>document.write(bytesToHumanReadable({{ $peer.ReceivedBytes }}))</script></td>
|
||||
<td title="{{ $peer.TransmitBytes }} Bytes"><script>document.write(bytesToHumanReadable({{ $peer.TransmitBytes }}))</script></td>
|
||||
<td>{{ $peer.Connected }}</td>
|
||||
<td>{{ $peer.LastHandshakeTime }}</td>
|
||||
</tr>
|
||||
|
|
Loading…
Add table
Reference in a new issue