fix NaN on graph

This commit is contained in:
Daan 2020-08-29 17:00:15 +02:00
parent 0e02df2345
commit a863b83065
2 changed files with 11 additions and 3 deletions

View file

@ -1,6 +1,6 @@
{ {
"name": "vuetorrent", "name": "vuetorrent",
"version": "0.1.3", "version": "0.2.0",
"private": true, "private": true,
"scripts": { "scripts": {
"serve": "vue-cli-service serve", "serve": "vue-cli-service serve",

View file

@ -8,12 +8,20 @@ export default class Status {
this.upspeed = this.formatBytes(data.up_info_speed, 1) this.upspeed = this.formatBytes(data.up_info_speed, 1)
this.freeDiskSpace = this.formatBytes(data.free_space_on_disk) this.freeDiskSpace = this.formatBytes(data.free_space_on_disk)
this.altSpeed = data.use_alt_speed_limits this.altSpeed = data.use_alt_speed_limits
this.dlspeedRaw = Math.round(data.dl_info_speed / 1000) this.dlspeedRaw = this.formatSpeed(data.dl_info_speed)
this.upspeedRaw = Math.round(data.up_info_speed / 1000) this.upspeedRaw = this.formatSpeed(data.up_info_speed)
this.tags = tags this.tags = tags
} }
} }
formatSpeed(value) {
if (!value) {
return 0
}
return Math.round(value / 1000)
}
formatBytes(a, b) { formatBytes(a, b) {
if (!a) return '0 Bytes' if (!a) return '0 Bytes'
if (a == 0) return '0 Bytes' if (a == 0) return '0 Bytes'