From a863b8306595b984fd7c4322a11963ad319140d0 Mon Sep 17 00:00:00 2001 From: Daan Date: Sat, 29 Aug 2020 17:00:15 +0200 Subject: [PATCH] fix NaN on graph --- package.json | 2 +- src/models/Status.js | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 528e2ceb..6fc010e9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vuetorrent", - "version": "0.1.3", + "version": "0.2.0", "private": true, "scripts": { "serve": "vue-cli-service serve", diff --git a/src/models/Status.js b/src/models/Status.js index d4340e17..4e2a9ddd 100644 --- a/src/models/Status.js +++ b/src/models/Status.js @@ -8,12 +8,20 @@ export default class Status { this.upspeed = this.formatBytes(data.up_info_speed, 1) this.freeDiskSpace = this.formatBytes(data.free_space_on_disk) this.altSpeed = data.use_alt_speed_limits - this.dlspeedRaw = Math.round(data.dl_info_speed / 1000) - this.upspeedRaw = Math.round(data.up_info_speed / 1000) + this.dlspeedRaw = this.formatSpeed(data.dl_info_speed) + this.upspeedRaw = this.formatSpeed(data.up_info_speed) this.tags = tags } } + formatSpeed(value) { + if (!value) { + return 0 + } + + return Math.round(value / 1000) + } + formatBytes(a, b) { if (!a) return '0 Bytes' if (a == 0) return '0 Bytes'