From b84590b4332a865293428425f9bcd0bd27bd5086 Mon Sep 17 00:00:00 2001
From: Simon Rettberg
Date: Fri, 8 Feb 2019 15:30:55 +0100
Subject: table.html: Fix bytes/s for counter; design tweaks
---
static/table.html | 46 ++++++++++++++++++++++++++++------------------
1 file changed, 28 insertions(+), 18 deletions(-)
diff --git a/static/table.html b/static/table.html
index ad7835f..eb4ca4c 100644
--- a/static/table.html
+++ b/static/table.html
@@ -25,11 +25,10 @@
.server {
border-spacing: 2px 4px;
background-color: #eee;
- border: 1px solid #888;
flex: 1;
white-space: nowrap;
max-width: 360px;
- margin: 5px;
+ margin: 3px;
}
.first-row {
@@ -38,6 +37,7 @@
.server-ip {
text-align: center;
+ font-size: 150%;
}
.client-label, .client-speed {
@@ -56,20 +56,30 @@
-
+
{{ server.address }} |
Uptime: | {{ formatSeconds(server.uptime) }} |
- Upload speed: | {{ formatSpeed(peak ? server.peakUploadSpeed : server.avgUploadSpeed) }} |
- Download speed: | {{ formatSpeed(peak ? server.peakDownloadSpeed : server.avgDownloadSpeed) }} |
- Total sent: | {{ formatSpeed(server.bytesSent) }} |
- Total received: | {{ formatSpeed(server.bytesReceived) }} |
+
+ Upload speed: |
+
+ {{ formatBytes(peak ? server.peakUploadSpeed : server.avgUploadSpeed) }}/s
+ |
+
+
+ Download speed: |
+
+ {{ formatBytes(peak ? server.peakDownloadSpeed : server.avgDownloadSpeed) }}/s
+ |
+
+ Total sent: | {{ formatBytes(server.bytesSent) }} |
+ Total received: | {{ formatBytes(server.bytesReceived) }} |
Client count: | {{ server.clientCount }} |
Server count: | {{ server.serverCount }} |
{{ client.address.split( ":" )[0] }} |
- {{ formatSpeed(peak ? client.peakUploadSpeed : client.avgUploadSpeed) }}
+ {{ formatBytes(peak ? client.peakUploadSpeed : client.avgUploadSpeed) }}/s
|
@@ -164,12 +174,12 @@ var app = new Vue({
obj.avgDownloadSpeed = (b.bytesReceived - a.bytesReceived) / time
}
},
- formatSpeed (bytes) {
- if (bytes < 1024) return bytes.toFixed(2) + ' B/s'
- else if (bytes < 1048576) return (bytes / 1024).toFixed(2) + ' KiB/s'
- else if (bytes < 1073741824) return (bytes / 1048576).toFixed(2) + ' MiB/s'
- else if (bytes < 1099511627776) return (bytes / 1073741824).toFixed(2) + ' GiB/s'
- else return (bytes / 1099511627776).toFixed(2) + ' TiB/s'
+ formatBytes (bytes) {
+ if (bytes < 1024) return bytes.toFixed(2) + ' B'
+ else if (bytes < 1048576) return (bytes / 1024).toFixed(2) + ' KiB'
+ else if (bytes < 1073741824) return (bytes / 1048576).toFixed(2) + ' MiB'
+ else if (bytes < 1099511627776) return (bytes / 1073741824).toFixed(2) + ' GiB'
+ else return (bytes / 1099511627776).toFixed(2) + ' TiB'
},
formatSeconds (seconds) {
return ( Math.floor(seconds / ( 3600 * 24 ) ) + 'd '
@@ -177,12 +187,12 @@ var app = new Vue({
+ Math.floor(seconds / 60 ) % 60 + 'min' )
},
calcBackgroundStyle (speed) {
- const colors = ['#eee', '#cfc', '#6f6', '#7c0', '#f00', '#f65']
+ const colors = ['#eee', '#cfc', '#6f6', '#70bf30', '#f00', '#f65']
const limits = [1048576, 10485760, 104857600, 1073741824, 10737418240]
for (var i = 0; i < 4; ++i) {
if (speed < limits[i]) break
}
- const percent = Math.round(Math.max(0, Math.min(100, this.logScale(speed) / this.logScale(limits[i]) * 100)))
+ const percent = Math.round(Math.max(0, Math.min(100, speed / limits[i] * 100)))
return { background: `linear-gradient(90deg, ${colors[i+1]} ${percent}%, ${colors[i]} ${percent}%)` }
},
compareObjectIps (obj1, obj2) {
@@ -213,8 +223,8 @@ var app = new Vue({
'millisPerPixel': 300,
'grid': { 'millisPerLine': 30000 },
timestampFormatter: SmoothieChart.timeFormatter,
- yMaxFormatter: this.formatSpeed,
- yMinFormatter: this.formatSpeed,
+ yMaxFormatter: this.formatBytes,
+ yMinFormatter: this.formatBytes,
valueTransformFunction: this.logScale,
minValue: 0,
maxValue: 262144000,
--
cgit v1.2.3-55-g7522