Skip to content

Commit 1da9b84

Browse files
I've modify the place where I inserted code to minimize the number of files touched. (ngoduykhanh#131)
1 parent e74a3a8 commit 1da9b84

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

prepare_assets.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ set -e
44
DIR=$(dirname "$0")
55

66
# install node modules
7-
yarn install --pure-lockfile --production
7+
YARN=yarn
8+
[ -x /usr/bin/lsb_release ] && [ -n "`lsb_release -i | grep Debian`" ] && YARN=yarnpkg
9+
$YARN install --pure-lockfile --production
810

911
# Copy admin-lte dist
1012
mkdir -p "${DIR}/assets/dist/js" "${DIR}/assets/dist/css" && \

templates/status.html

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,20 @@
1414
{{end}}
1515

1616
{{define "page_content"}}
17+
<script>
18+
function bytesToHumanReadable(temporal) {
19+
const units = [" ", " K", " M", " G", " T", " P", " E", " Z", " Y"]
20+
let pow = 0
21+
22+
while (temporal > 1024) {
23+
temporal /= 1024
24+
pow ++
25+
if (pow == units.length-1) break
26+
}
27+
28+
return parseFloat(temporal.toFixed(3)) + units[pow]+"Bytes"
29+
}
30+
</script>
1731
<section class="content">
1832
<div class="container-fluid">
1933
{{ if .error }}
@@ -41,8 +55,8 @@
4155
<td>{{ $peer.Name }}</td>
4256
<td>{{ $peer.Email }}</td>
4357
<td>{{ $peer.PublicKey }}</td>
44-
<td>{{ $peer.ReceivedBytes }}</td>
45-
<td>{{ $peer.TransmitBytes }}</td>
58+
<td title="{{ $peer.ReceivedBytes }} Bytes"><script>document.write(bytesToHumanReadable({{ $peer.ReceivedBytes }}))</script></td>
59+
<td title="{{ $peer.TransmitBytes }} Bytes"><script>document.write(bytesToHumanReadable({{ $peer.TransmitBytes }}))</script></td>
4660
<td>{{ $peer.Connected }}</td>
4761
<td>{{ $peer.LastHandshakeTime }}</td>
4862
</tr>

0 commit comments

Comments
 (0)