diff --git a/.jshintrc b/.jshintrc index dc2b733533..ec94c41acd 100644 --- a/.jshintrc +++ b/.jshintrc @@ -14,7 +14,8 @@ "nonew": true, "predef": [ "define", - "Promise" + "Promise", + "WeakMap" ], "shadow": "outer", "strict": "implied", diff --git a/src/api/telemetry/LegacyTelemetryProvider.js b/src/api/telemetry/LegacyTelemetryProvider.js index 55cb904f27..672fb9c83f 100644 --- a/src/api/telemetry/LegacyTelemetryProvider.js +++ b/src/api/telemetry/LegacyTelemetryProvider.js @@ -44,25 +44,29 @@ define([ utils.makeKeyString(domainObject.identifier)).hasCapability("telemetry"); }; - function createDatum(metadata, legacySeries, i) { + function createDatum(domainObject, metadata, legacySeries, i) { var datum = {}; - metadata.domains.reduce(function (telemetryObject, domain) { - datum[domain.key] = legacySeries.getDomainValue(i, domain.key); + metadata.domains.reduce(function (d, domain) { + d[domain.key] = legacySeries.getDomainValue(i, domain.key); + return d; }, datum); - metadata.ranges.reduce(function (telemetryObject, range) { - datum[range.key] = legacySeries.getRangeValue(i, range.key); + metadata.ranges.reduce(function (d, range) { + d[range.key] = legacySeries.getRangeValue(i, range.key); + return d; }, datum); + datum.name = domainObject.name; + return datum; } - function adaptSeries(metadata, legacySeries) { + function adaptSeries(domainObject, metadata, legacySeries) { var series = []; - for (var i=0; i < legacySeries.getPointCount(); i++) { - series.push(createDatum(metadata, legacySeries, i)); + for (var i = 0; i < legacySeries.getPointCount(); i++) { + series.push(createDatum(domainObject, metadata, legacySeries, i)); } return series; @@ -90,7 +94,7 @@ define([ var capability = oldObject.getCapability("telemetry"); return capability.requestData(request).then(function (telemetrySeries) { - return Promise.resolve(adaptSeries(capability.getMetadata(), telemetrySeries)); + return Promise.resolve(adaptSeries(domainObject, capability.getMetadata(), telemetrySeries)); }).catch(function (error) { return Promise.reject(error); }); @@ -114,8 +118,8 @@ define([ var oldObject = this.instantiate(utils.toOldFormat(domainObject), utils.makeKeyString(domainObject.identifier)); var capability = oldObject.getCapability("telemetry"); - function callbackWrapper(series){ - callback(createDatum(capability.getMetadata(), series, series.getPointCount()-1)); + function callbackWrapper(series) { + callback(createDatum(domainObject, capability.getMetadata(), series, series.getPointCount() - 1)); } return capability.subscribe(callbackWrapper, request); @@ -125,13 +129,13 @@ define([ var oldObject = this.instantiate( utils.toOldFormat(domainObject), utils.makeKeyString(domainObject.identifier)); - var limitEvaluator = oldObject.getCapability('limit'); + var limitEvaluator = oldObject.getCapability("limit"); return { evaluate: function (datum, property) { return limitEvaluator.evaluate(datum, property.key); } - } + }; }; return function (openmct, instantiate) { @@ -141,4 +145,4 @@ define([ new LegacyTelemetryProvider(instantiate)); }; -}); \ No newline at end of file +}); diff --git a/src/api/telemetry/TelemetryAPI.js b/src/api/telemetry/TelemetryAPI.js index dc78e2e9e0..183432eb95 100644 --- a/src/api/telemetry/TelemetryAPI.js +++ b/src/api/telemetry/TelemetryAPI.js @@ -286,7 +286,9 @@ define([ }); return results; }); - var sortKeys = hints.map(function (h) { return 'hints.' + h; }); + var sortKeys = hints.map(function (h) { + return 'hints.' + h; + }); return _.sortByAll(options, sortKeys); }; diff --git a/src/api/telemetry/TelemetryMetadataManager.js b/src/api/telemetry/TelemetryMetadataManager.js index 1c99f25a8c..db0e6d3b0a 100644 --- a/src/api/telemetry/TelemetryMetadataManager.js +++ b/src/api/telemetry/TelemetryMetadataManager.js @@ -30,11 +30,16 @@ define([ function valueMetadatasFromOldFormat(metadata) { var valueMetadatas = []; + valueMetadatas.push({ + key: 'name', + name: 'Name' + }); + metadata.domains.forEach(function (domain, index) { var valueMetadata = _.clone(domain); valueMetadata.hints = { - x: index, - domain: index + x: index + 1, + domain: index + 1 }; valueMetadatas.push(valueMetadata); }); @@ -44,7 +49,7 @@ define([ valueMetadata.hints = { y: index, range: index, - priority: index + metadata.domains.length + priority: index + metadata.domains.length + 1 }; if (valueMetadata.type === 'enum') { @@ -61,7 +66,7 @@ define([ valueMetadata.values = _.pluck(valueMetadata.enumerations, 'value'); valueMetadata.max = _.max(valueMetadata.values); valueMetadata.min = _.min(valueMetadata.values); - }; + } valueMetadatas.push(valueMetadata); }); @@ -106,7 +111,7 @@ define([ */ TelemetryMetadataManager.prototype.value = function (key) { return this.valueMetadatas.filter(function (metadata) { - return metadata.key === key + return metadata.key === key; })[0]; }; @@ -126,6 +131,7 @@ define([ hints ) { function hasHint(hint) { + /*jshint validthis: true */ return this.hints.hasOwnProperty(hint); } function hasHints(metadata) { diff --git a/src/api/telemetry/TelemetryValueFormatter.js b/src/api/telemetry/TelemetryValueFormatter.js index 432da7dc81..801aee1176 100644 --- a/src/api/telemetry/TelemetryValueFormatter.js +++ b/src/api/telemetry/TelemetryValueFormatter.js @@ -37,9 +37,15 @@ define([ } catch (e) { // TODO: Better formatting this.formatter = { - parse: function (x) { return Number(x); }, - format: function (x) { return x; }, - validate: function (x) { return true; } + parse: function (x) { + return Number(x); + }, + format: function (x) { + return x; + }, + validate: function (x) { + return true; + } }; }