From 4ccfe23aff9b9233e3db6a324b10782fc455c0b3 Mon Sep 17 00:00:00 2001 From: Gabriela Barrozo Guedes Date: Fri, 20 Mar 2020 19:15:36 -0300 Subject: [PATCH 1/2] Fix bug on last reading time Signed-off-by: Gabriela Barrozo Guedes --- src/pages/Transducer.vue | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pages/Transducer.vue b/src/pages/Transducer.vue index dfca317..48e53ea 100644 --- a/src/pages/Transducer.vue +++ b/src/pages/Transducer.vue @@ -151,7 +151,8 @@ export default { r: Math.round(res.data[0].total_reactive_power), t: Math.round(res.data[0].total_power_factor) } - this.lastReading = this.getTime(res.data.collection_time) + + this.lastReading = this.getTime(res.data[0].collection_date) this.hasMeasurements = true }) .catch(err => { From e82320637cf2e723e28b63df1354164f47f33e25 Mon Sep 17 00:00:00 2001 From: Gabriela Barrozo Guedes Date: Fri, 20 Mar 2020 19:25:00 -0300 Subject: [PATCH 2/2] Check if time exists, so it doesnt show 'Agora' on undefned or null times Signed-off-by: Gabriela Barrozo Guedes --- src/pages/Transducer.vue | 2 +- src/utils/timePassed.js | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pages/Transducer.vue b/src/pages/Transducer.vue index 48e53ea..6e13d09 100644 --- a/src/pages/Transducer.vue +++ b/src/pages/Transducer.vue @@ -212,7 +212,7 @@ export default { }, getTime (d) { let ans = timePassed(d) - if (ans !== 'agora') { + if (ans !== 'agora' && ans !== 'indeterminado') { ans = 'há ' + ans } return ans diff --git a/src/utils/timePassed.js b/src/utils/timePassed.js index 71e6169..1736409 100644 --- a/src/utils/timePassed.js +++ b/src/utils/timePassed.js @@ -14,7 +14,9 @@ export default function timePassed (time) { return h + 'h ' + m + 'min' } } - } else { + } else if (time !== undefined && time !== null) { return 'agora' + } else { + return 'indeterminado' } }