From f22d52ef416c76ff6a776f19e4a2af0798075d97 Mon Sep 17 00:00:00 2001 From: Grant Patterson Date: Tue, 5 May 2015 17:17:42 -0700 Subject: [PATCH 1/2] Fix sMAP Direct when there are no readings for a stream A simple fix to at least keep the page from breaking when a stream doesn't have any readings. "current value" is "undefined" and "local time" is "Invalid Date" in this case: not pretty, but again, it doesn't break. --- python/smap/data/index.html | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/python/smap/data/index.html b/python/smap/data/index.html index 540948c..d6b35de 100644 --- a/python/smap/data/index.html +++ b/python/smap/data/index.html @@ -54,9 +54,15 @@ }); function latest(r) { + if (!r.length) { + return undefined; + } return r.slice(-1)[0][1]; } function latestts(r) { + if (!r.length) { + return undefined; + } return r.slice(-1)[0][0]; } function resetUpdater() { From aba56aadc1916d0346112f0fab3e3a05bcac0de1 Mon Sep 17 00:00:00 2001 From: Grant Patterson Date: Tue, 5 May 2015 17:19:47 -0700 Subject: [PATCH 2/2] Add space between value and units in sMAP Direct Seems more readable to me. --- python/smap/data/index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/smap/data/index.html b/python/smap/data/index.html index d6b35de..f7f8530 100644 --- a/python/smap/data/index.html +++ b/python/smap/data/index.html @@ -180,8 +180,8 @@ function makeTimeseries(path, meta) { console.log(meta); if (meta['Actuator'] === undefined) { - return latest(meta["Readings"]) + - meta ["Properties"]["UnitofMeasure"]; + return latest(meta["Readings"]) + " " + + meta["Properties"]["UnitofMeasure"]; } else if (meta['Actuator']['Model'] == 'binary') { return makeBinaryActuator(path, meta); } else if (meta['Actuator']['Model'] == 'discrete') {