I've modify the place where I inserted code to minimize the number of files touched. (#131)

This commit is contained in:
Max Pedraza 2021-12-04 09:03:56 +01:00 committed by GitHub
parent e74a3a808f
commit 1da9b8418e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 3 deletions

View File

@ -4,7 +4,9 @@ set -e
DIR=$(dirname "$0")
# install node modules
yarn install --pure-lockfile --production
YARN=yarn
[ -x /usr/bin/lsb_release ] && [ -n "`lsb_release -i | grep Debian`" ] && YARN=yarnpkg
$YARN install --pure-lockfile --production
# Copy admin-lte dist
mkdir -p "${DIR}/assets/dist/js" "${DIR}/assets/dist/css" && \

View File

@ -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>{{ $peer.ReceivedBytes }}</td>
<td>{{ $peer.TransmitBytes }}</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>