summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUdo Walter2019-02-26 21:57:38 +0100
committerUdo Walter2019-02-26 21:57:38 +0100
commit32ea4fdf3df79a1717a86d2349ab9d9f194e1005 (patch)
treed9850a2971485d8a87281984d07d5b050bbd63d2
parenttable.html: improve average-speed calculation (diff)
downloaddnbd3-status-32ea4fdf3df79a1717a86d2349ab9d9f194e1005.tar.gz
dnbd3-status-32ea4fdf3df79a1717a86d2349ab9d9f194e1005.tar.xz
dnbd3-status-32ea4fdf3df79a1717a86d2349ab9d9f194e1005.zip
table.html: bug fix
-rw-r--r--static/table.html14
1 files changed, 8 insertions, 6 deletions
diff --git a/static/table.html b/static/table.html
index c9fd8f6..84dc81d 100644
--- a/static/table.html
+++ b/static/table.html
@@ -102,7 +102,7 @@ var app = new Vue({
data: {
rawData: {},
serverMap: {},
- timespan: 120,
+ maxTimespan: 120,
firstTimestamp: undefined,
peak: false,
ports: false,
@@ -128,7 +128,10 @@ var app = new Vue({
return servers
},
timespanStartTime () {
- return Math.min(this.firstTimestamp, this.rawData.timestamp - this.timespan * 1000)
+ return Math.max(this.firstTimestamp, this.rawData.timestamp - this.maxTimespan * 1000)
+ },
+ timespan () {
+ return (this.rawData.timestamp - this.timespanStartTime) / 1000
}
},
watch: {
@@ -221,10 +224,9 @@ var app = new Vue({
objData.peakDownloadSpeed = Math.max(...obj.log.map(x => x.downloadSpeed || 0))
// Calculate average speeds
- time = (this.rawData.timestamp - this.timespanStartTime) / 1000
a = obj.log[0]
- objData.avgUploadSpeed = (b.bytesSent - a.bytesSent) / time
- objData.avgDownloadSpeed = (b.bytesReceived - a.bytesReceived) / time
+ objData.avgUploadSpeed = (b.bytesSent - a.bytesSent) / this.timespan
+ objData.avgDownloadSpeed = (b.bytesReceived - a.bytesReceived) / this.timespan
Object.assign(obj, objData)
},
@@ -267,7 +269,7 @@ var app = new Vue({
},
created () {
const urlParams = new URLSearchParams(window.location.search)
- this.timespan = parseInt(urlParams.get('timespan')) || 120
+ this.maxTimespan = parseInt(urlParams.get('timespan')) || 120
this.peak = urlParams.get('peak') === 'true' || urlParams.get('peak') === ''
this.ports = urlParams.get('ports') === 'true' || urlParams.get('ports') === ''
this.updateData()