From 23c71b7218a8c9392bda20c595b4b2e17fc7947d Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Wed, 25 May 2016 12:12:11 -0700 Subject: [PATCH] [Timeline] Include units for utilizations --- platform/features/timeline/bundle.js | 3 +-- .../features/timeline/src/actions/UtilizationColumn.js | 10 +++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/platform/features/timeline/bundle.js b/platform/features/timeline/bundle.js index b8754f4916..4663a37fae 100644 --- a/platform/features/timeline/bundle.js +++ b/platform/features/timeline/bundle.js @@ -557,8 +557,7 @@ define([ { "key": "comms", "name": "Comms", - "units": "Kbps", - "foo": "Kb" + "units": "Kbps" }, { "key": "battery", diff --git a/platform/features/timeline/src/actions/UtilizationColumn.js b/platform/features/timeline/src/actions/UtilizationColumn.js index e9e88a5896..7da7b6c890 100644 --- a/platform/features/timeline/src/actions/UtilizationColumn.js +++ b/platform/features/timeline/src/actions/UtilizationColumn.js @@ -34,6 +34,14 @@ define([], function () { this.resource = resource; } + UtilizationColumn.prototype.getUnits = function () { + var instantaneousUnits = this.resource.units; + return { + "Kbps": "Kb", + "Watts": "joules", + }[instantaneousUnits] || "unknown units"; + }; + UtilizationColumn.prototype.name = function () { return this.resource.name; }; @@ -57,7 +65,7 @@ define([], function () { return utilizations.map(getCost).reduce(function (a, b) { return a + b; - }, 0); + }, 0) + " (" + this.getUnits() + ")"; } return !domainObject.hasCapability('utilization') ?