Browse Source

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

master
Max Pedraza 2 months ago
committed by GitHub
parent
commit
1da9b8418e
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      prepare_assets.sh
  2. 18
      templates/status.html

4
prepare_assets.sh

@ -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" && \

18
templates/status.html

@ -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>

Loading…
Cancel
Save