From 0b0cee3afb6be83327d2c53f8cc3e3f99a3b4726 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Wed, 23 Sep 2015 16:43:58 -0700 Subject: [PATCH 01/16] [Example] Add domain Add a second domain to example telemetry, to support addition of a domain selector to the time conductor; nasa/openmctweb#115 --- example/generator/bundle.json | 6 +++++- example/generator/src/SinewaveTelemetrySeries.js | 7 ++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/example/generator/bundle.json b/example/generator/bundle.json index a13bbdc8f8..cdb4736957 100644 --- a/example/generator/bundle.json +++ b/example/generator/bundle.json @@ -34,6 +34,10 @@ { "key": "time", "name": "Time" + }, + { + "key": "yesterday", + "name": "Yesterday" } ], "ranges": [ @@ -61,4 +65,4 @@ } ] } -} \ No newline at end of file +} diff --git a/example/generator/src/SinewaveTelemetrySeries.js b/example/generator/src/SinewaveTelemetrySeries.js index 5b7914a867..dbab6dcac5 100644 --- a/example/generator/src/SinewaveTelemetrySeries.js +++ b/example/generator/src/SinewaveTelemetrySeries.js @@ -29,7 +29,8 @@ define( function () { "use strict"; - var firstObservedTime = Math.floor(Date.now() / 1000); + var ONE_DAY = 1000 * 60 * 60 * 24, + firstObservedTime = Math.floor(Date.now() / 1000); /** * @@ -56,8 +57,8 @@ define( }; generatorData.getDomainValue = function (i, domain) { - return (i + offset) * 1000 + - (domain !== 'delta' ? (firstObservedTime * 1000) : 0); + return (i + offset) * 1000 + firstObservedTime * 1000 - + (domain === 'yesterday' ? ONE_DAY : 0); }; generatorData.getRangeValue = function (i, range) { From 5d5a7c26c585e90c8f97883119a51144b773c397 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Wed, 23 Sep 2015 16:53:12 -0700 Subject: [PATCH 02/16] [Time Conductor] Maintain domain state Maintain domain state in the time conductor; add a default list of domains to choose from. --- platform/features/conductor/bundle.json | 12 +++++++- .../conductor/src/ConductorService.js | 9 ++++-- .../features/conductor/src/TimeConductor.js | 30 ++++++++++++++++++- 3 files changed, 46 insertions(+), 5 deletions(-) diff --git a/platform/features/conductor/bundle.json b/platform/features/conductor/bundle.json index b230f9d370..0b62d74762 100644 --- a/platform/features/conductor/bundle.json +++ b/platform/features/conductor/bundle.json @@ -18,7 +18,17 @@ { "key": "conductorService", "implementation": "ConductorService.js", - "depends": [ "now" ] + "depends": [ "now", "TIME_CONDUCTOR_DOMAINS" ] + } + ], + "contants": [ + { + "key": "TIME_CONDUCTOR_DOMAINS", + "value": [ + { "key": "time", "name": "Time" }, + { "key": "yesterday", "name": "Yesterday" } + ], + "comment": "Placeholder; to be replaced by inspection of available domains." } ] } diff --git a/platform/features/conductor/src/ConductorService.js b/platform/features/conductor/src/ConductorService.js index 59cfa95e3c..3e281d2c1d 100644 --- a/platform/features/conductor/src/ConductorService.js +++ b/platform/features/conductor/src/ConductorService.js @@ -39,12 +39,15 @@ define( * @param {Function} now a function which returns the current time * as a UNIX timestamp, in milliseconds */ - function ConductorService(now) { + function ConductorService(now, domains) { var initialEnd = Math.ceil(now() / SIX_HOURS_IN_MS) * SIX_HOURS_IN_MS; - this.conductor = - new TimeConductor(initialEnd - ONE_DAY_IN_MS, initialEnd); + this.conductor = new TimeConductor( + initialEnd - ONE_DAY_IN_MS, + initialEnd, + domains + ); } /** diff --git a/platform/features/conductor/src/TimeConductor.js b/platform/features/conductor/src/TimeConductor.js index fcf8dbae04..3ce9c369ff 100644 --- a/platform/features/conductor/src/TimeConductor.js +++ b/platform/features/conductor/src/TimeConductor.js @@ -40,9 +40,11 @@ define( * @param {number} start the initial start time * @param {number} end the initial end time */ - function TimeConductor(start, end) { + function TimeConductor(start, end, domains) { this.inner = { start: start, end: end }; this.outer = { start: start, end: end }; + this.domains = domains; + this.domain = domains[0]; } /** @@ -94,6 +96,32 @@ define( return this.inner.end; }; + /** + * Get available domain options which can be used to bound time + * selection. + * @returns {TelemetryDomain[]} available domains + */ + TimeConductor.prototype.domainOptions = function () { + return this.domains; + }; + + /** + * Get or set (if called with an argument) the active domain. + * @param {string} [key] the key identifying the domain choice + * @returns {TelemetryDomain} the active telemetry domain + */ + TimeConductor.prototype.activeDomain = function (key) { + var i; + if (arguments.length > 0) { + for (i = 0; i < this.domains.length; i += 1) { + if (this.domains[i].key === key) { + this.domain = this.domains[i]; + } + } + } + return this.domain; + }; + return TimeConductor; } ); From d238b669a5da3cffb5bca20c1c244fc5c514c490 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Wed, 23 Sep 2015 17:09:38 -0700 Subject: [PATCH 03/16] [Time Conductor] Show domain options --- platform/features/conductor/bundle.json | 8 +++- .../res/templates/time-conductor.html | 8 ++++ .../conductor/src/ConductorRepresenter.js | 42 ++++++++++++++----- .../features/conductor/src/TimeConductor.js | 14 ++++--- 4 files changed, 55 insertions(+), 17 deletions(-) create mode 100644 platform/features/conductor/res/templates/time-conductor.html diff --git a/platform/features/conductor/bundle.json b/platform/features/conductor/bundle.json index 0b62d74762..3a0cf12f92 100644 --- a/platform/features/conductor/bundle.json +++ b/platform/features/conductor/bundle.json @@ -21,7 +21,13 @@ "depends": [ "now", "TIME_CONDUCTOR_DOMAINS" ] } ], - "contants": [ + "templates": [ + { + "key": "time-conductor", + "templateUrl": "templates/time-conductor.html" + } + ], + "constants": [ { "key": "TIME_CONDUCTOR_DOMAINS", "value": [ diff --git a/platform/features/conductor/res/templates/time-conductor.html b/platform/features/conductor/res/templates/time-conductor.html new file mode 100644 index 0000000000..c597bf33c3 --- /dev/null +++ b/platform/features/conductor/res/templates/time-conductor.html @@ -0,0 +1,8 @@ + + + + diff --git a/platform/features/conductor/src/ConductorRepresenter.js b/platform/features/conductor/src/ConductorRepresenter.js index b1b35477b6..9ca7d4f228 100644 --- a/platform/features/conductor/src/ConductorRepresenter.js +++ b/platform/features/conductor/src/ConductorRepresenter.js @@ -32,7 +32,7 @@ define( '"position: absolute; bottom: 0; width: 100%; ', 'overflow: hidden; ', 'height: ' + CONDUCTOR_HEIGHT + '">', - "", + "", "", '' ].join(''), @@ -68,8 +68,8 @@ define( // Update the time conductor from the scope function wireScope(conductor, conductorScope, repScope) { function updateConductorOuter() { - conductor.queryStart(conductorScope.conductor.outer.start); - conductor.queryEnd(conductorScope.conductor.outer.end); + conductor.queryStart(conductorScope.ngModel.conductor.outer.start); + conductor.queryEnd(conductorScope.ngModel.conductor.outer.end); repScope.$broadcast( 'telemetry:query:bounds', bounds(conductor.queryStart(), conductor.queryEnd()) @@ -77,27 +77,49 @@ define( } function updateConductorInner() { - conductor.displayStart(conductorScope.conductor.inner.start); - conductor.displayEnd(conductorScope.conductor.inner.end); + conductor.displayStart(conductorScope.ngModel.conductor.inner.start); + conductor.displayEnd(conductorScope.ngModel.conductor.inner.end); repScope.$broadcast( 'telemetry:display:bounds', bounds(conductor.displayStart(), conductor.displayEnd()) ); } - conductorScope.conductor = { + function updateDomain(value) { + conductor.activeDomain(value); + repScope.$broadcast( + 'telemetry:query:bounds', + bounds(conductor.queryStart(), conductor.queryEnd()) + ); + } + + // telemetry domain metadata -> option for a select control + function makeOption(domainOption) { + return { + name: domainOption.name, + value: domainOption.key + }; + } + + conductorScope.ngModel = {}; + conductorScope.ngModel.conductor = { outer: bounds(conductor.queryStart(), conductor.queryEnd()), inner: bounds(conductor.displayStart(), conductor.displayEnd()) }; + conductorScope.ngModel.options = + conductor.domainOptions().map(makeOption); + conductorScope.ngModel.domain = conductor.activeDomain(); conductorScope - .$watch('conductor.outer.start', updateConductorOuter); + .$watch('ngModel.conductor.outer.start', updateConductorOuter); conductorScope - .$watch('conductor.outer.end', updateConductorOuter); + .$watch('ngModel.conductor.outer.end', updateConductorOuter); conductorScope - .$watch('conductor.inner.start', updateConductorInner); + .$watch('ngModel.conductor.inner.start', updateConductorInner); conductorScope - .$watch('conductor.inner.end', updateConductorInner); + .$watch('ngModel.conductor.inner.end', updateConductorInner); + conductorScope + .$watch('ngModel.domain', updateDomain); repScope.$on('telemetry:view', updateConductorInner); } diff --git a/platform/features/conductor/src/TimeConductor.js b/platform/features/conductor/src/TimeConductor.js index 3ce9c369ff..b8e07d051d 100644 --- a/platform/features/conductor/src/TimeConductor.js +++ b/platform/features/conductor/src/TimeConductor.js @@ -44,7 +44,7 @@ define( this.inner = { start: start, end: end }; this.outer = { start: start, end: end }; this.domains = domains; - this.domain = domains[0]; + this.domain = domains[0].key; } /** @@ -111,13 +111,15 @@ define( * @returns {TelemetryDomain} the active telemetry domain */ TimeConductor.prototype.activeDomain = function (key) { - var i; + function matchesKey(domain) { + return domain.key === key; + } + if (arguments.length > 0) { - for (i = 0; i < this.domains.length; i += 1) { - if (this.domains[i].key === key) { - this.domain = this.domains[i]; - } + if (!this.domains.some(matchesKey)) { + throw new Error("Unknown domain " + key); } + this.domain = key; } return this.domain; }; From f182d1f2c42810291b9dd466fdbde092a6eeedb9 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Wed, 23 Sep 2015 17:14:40 -0700 Subject: [PATCH 04/16] [Time Conductor] Include domain selection in requests ...as well as use as default in a telemetry series. --- .../features/conductor/src/ConductorTelemetryDecorator.js | 4 +++- platform/features/conductor/src/ConductorTelemetrySeries.js | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/platform/features/conductor/src/ConductorTelemetryDecorator.js b/platform/features/conductor/src/ConductorTelemetryDecorator.js index 9c8126c33f..0038c7ccd9 100644 --- a/platform/features/conductor/src/ConductorTelemetryDecorator.js +++ b/platform/features/conductor/src/ConductorTelemetryDecorator.js @@ -71,12 +71,14 @@ define( ConductorTelemetryDecorator.prototype.amendRequests = function (requests) { var conductor = this.conductorService.getConductor(), start = conductor.displayStart(), - end = conductor.displayEnd(); + end = conductor.displayEnd(), + domain = conductor.activeDomain(); function amendRequest(request) { request = request || {}; request.start = start; request.end = end; + request.domain = domain; return request; } diff --git a/platform/features/conductor/src/ConductorTelemetrySeries.js b/platform/features/conductor/src/ConductorTelemetrySeries.js index aa6ec0ec63..98cebe0907 100644 --- a/platform/features/conductor/src/ConductorTelemetrySeries.js +++ b/platform/features/conductor/src/ConductorTelemetrySeries.js @@ -52,6 +52,7 @@ define( this.startIndex = binSearch(0, max, conductor.displayStart()); this.endIndex = binSearch(0, max, conductor.displayEnd()); this.series = series; + this.domain = conductor.activeDomain(); } ConductorTelemetrySeries.prototype.getPointCount = function () { @@ -59,6 +60,7 @@ define( }; ConductorTelemetrySeries.prototype.getDomainValue = function (i, d) { + d = d || this.domain; return this.series.getDomainValue(i + this.startIndex, d); }; From 928e31b5488b1aff4a87d31c48c70aab1565a36b Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Wed, 23 Sep 2015 17:22:32 -0700 Subject: [PATCH 05/16] [Common UI] Avoid apply-in-a-digest Don't invoke from mct-resize when first observing an element's size during linking; observed issue in the context of adding domain selector to time conductor. --- platform/commonUI/general/src/directives/MCTResize.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/platform/commonUI/general/src/directives/MCTResize.js b/platform/commonUI/general/src/directives/MCTResize.js index 7f2d722803..f0fd8e0a69 100644 --- a/platform/commonUI/general/src/directives/MCTResize.js +++ b/platform/commonUI/general/src/directives/MCTResize.js @@ -58,6 +58,7 @@ define( // Link; start listening for changes to an element's size function link(scope, element, attrs) { var lastBounds, + linking = true, active = true; // Determine how long to wait before the next update @@ -74,7 +75,9 @@ define( lastBounds.width !== bounds.width || lastBounds.height !== bounds.height) { scope.$eval(attrs.mctResize, { bounds: bounds }); - scope.$apply(); // Trigger a digest + if (!linking) { // Avoid apply-in-a-digest + scope.$apply(); + } lastBounds = bounds; } } @@ -101,6 +104,9 @@ define( // Handle the initial callback onInterval(); + + // Trigger scope.$apply on subsequent changes + linking = false; } return { From 3d8aec2d010bb4c27a3d954984e509b35e42d1d3 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Wed, 23 Sep 2015 17:26:56 -0700 Subject: [PATCH 06/16] [Time Conductor] Pass domain with events --- .../conductor/src/ConductorRepresenter.js | 33 ++++++++++--------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/platform/features/conductor/src/ConductorRepresenter.js b/platform/features/conductor/src/ConductorRepresenter.js index 9ca7d4f228..0da32965bc 100644 --- a/platform/features/conductor/src/ConductorRepresenter.js +++ b/platform/features/conductor/src/ConductorRepresenter.js @@ -60,9 +60,9 @@ define( this.$compile = $compile; } - // Combine start/end times into a single object - function bounds(start, end) { - return { start: start, end: end }; + // Combine start/end times & domain into a single object + function bounds(start, end, domain) { + return { start: start, end: end, domain: domain }; } // Update the time conductor from the scope @@ -70,27 +70,30 @@ define( function updateConductorOuter() { conductor.queryStart(conductorScope.ngModel.conductor.outer.start); conductor.queryEnd(conductorScope.ngModel.conductor.outer.end); - repScope.$broadcast( - 'telemetry:query:bounds', - bounds(conductor.queryStart(), conductor.queryEnd()) - ); + repScope.$broadcast('telemetry:query:bounds', bounds( + conductor.queryStart(), + conductor.queryEnd(), + conductor.activeDomain() + )); } function updateConductorInner() { conductor.displayStart(conductorScope.ngModel.conductor.inner.start); conductor.displayEnd(conductorScope.ngModel.conductor.inner.end); - repScope.$broadcast( - 'telemetry:display:bounds', - bounds(conductor.displayStart(), conductor.displayEnd()) - ); + repScope.$broadcast('telemetry:display:bounds', bounds( + conductor.displayStart(), + conductor.displayEnd(), + conductor.activeDomain() + )); } function updateDomain(value) { conductor.activeDomain(value); - repScope.$broadcast( - 'telemetry:query:bounds', - bounds(conductor.queryStart(), conductor.queryEnd()) - ); + repScope.$broadcast('telemetry:display:bounds', bounds( + conductor.displayStart(), + conductor.displayEnd(), + conductor.activeDomain() + )); } // telemetry domain metadata -> option for a select control From 0c7de981950b7bad0f59679da6ff4527b1960d6d Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Thu, 24 Sep 2015 12:18:47 -0700 Subject: [PATCH 07/16] [Time Conductor] Use active domain in binary search --- .../features/conductor/src/ConductorTelemetrySeries.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/platform/features/conductor/src/ConductorTelemetrySeries.js b/platform/features/conductor/src/ConductorTelemetrySeries.js index 98cebe0907..d2f7c874cc 100644 --- a/platform/features/conductor/src/ConductorTelemetrySeries.js +++ b/platform/features/conductor/src/ConductorTelemetrySeries.js @@ -38,13 +38,14 @@ define( * @implements {TelemetrySeries} */ function ConductorTelemetrySeries(series, conductor) { - var max = series.getPointCount() - 1; + var max = series.getPointCount() - 1, + domain = conductor.activeDomain(); function binSearch(min, max, value) { var mid = Math.floor((min + max) / 2); return min > max ? min : - series.getDomainValue(mid) < value ? + series.getDomainValue(mid, domain) < value ? binSearch(mid + 1, max, value) : binSearch(min, mid - 1, value); } @@ -52,7 +53,7 @@ define( this.startIndex = binSearch(0, max, conductor.displayStart()); this.endIndex = binSearch(0, max, conductor.displayEnd()); this.series = series; - this.domain = conductor.activeDomain(); + this.domain = domain; } ConductorTelemetrySeries.prototype.getPointCount = function () { From 13525a67c202e39daed7e5f9c2f3ff16d53c33a0 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Thu, 24 Sep 2015 12:48:07 -0700 Subject: [PATCH 08/16] [Time Conductor] Fix domain-based calculations ...in example telemetry, to support development work on time conductor. --- .../generator/src/SinewaveTelemetrySeries.js | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/example/generator/src/SinewaveTelemetrySeries.js b/example/generator/src/SinewaveTelemetrySeries.js index dbab6dcac5..1e84034766 100644 --- a/example/generator/src/SinewaveTelemetrySeries.js +++ b/example/generator/src/SinewaveTelemetrySeries.js @@ -29,24 +29,25 @@ define( function () { "use strict"; - var ONE_DAY = 1000 * 60 * 60 * 24, - firstObservedTime = Math.floor(Date.now() / 1000); + var ONE_DAY = 60 * 60 * 24, + firstObservedTime = Math.floor(Date.now() / 1000) - ONE_DAY; /** * * @constructor */ function SinewaveTelemetrySeries(request) { - var latestObservedTime = Math.floor(Date.now() / 1000), + var timeOffset = (request.domain === 'yesterday') ? ONE_DAY : 0, + latestTime = Math.floor(Date.now() / 1000) - timeOffset, + firstTime = firstObservedTime - timeOffset, endTime = (request.end !== undefined) ? - Math.floor(request.end / 1000) : latestObservedTime, - count = - Math.min(endTime, latestObservedTime) - firstObservedTime, - period = request.period || 30, + Math.floor(request.end / 1000) : latestTime, + count = Math.min(endTime, latestTime) - firstTime, + period = +request.period || 30, generatorData = {}, - offset = (request.start !== undefined) ? - Math.floor(request.start / 1000) - firstObservedTime : - 0; + requestStart = (request.start === undefined) ? firstTime : + Math.max(Math.floor(request.start / 1000), firstTime), + offset = requestStart - firstTime; if (request.size !== undefined) { offset = Math.max(offset, count - request.size); @@ -57,8 +58,8 @@ define( }; generatorData.getDomainValue = function (i, domain) { - return (i + offset) * 1000 + firstObservedTime * 1000 - - (domain === 'yesterday' ? ONE_DAY : 0); + return (i + offset) * 1000 + firstTime * 1000 - + (domain === 'yesterday' ? ONE_DAY : 0); }; generatorData.getRangeValue = function (i, range) { From 4ced6c44a6d2b986e8e71f48aed2715712960acd Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Thu, 24 Sep 2015 17:01:50 -0700 Subject: [PATCH 09/16] [Time Conductor] Ignore empty series ...when updating Fixed Position view. --- platform/features/layout/src/FixedController.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/platform/features/layout/src/FixedController.js b/platform/features/layout/src/FixedController.js index f608f490f8..77c655e2cb 100644 --- a/platform/features/layout/src/FixedController.js +++ b/platform/features/layout/src/FixedController.js @@ -105,11 +105,13 @@ define( index ); - setDisplayedValue( - telemetryObject, - telemetrySeries.getRangeValue(index), - limit && datum && limit.evaluate(datum) - ); + if (index >= 0) { + setDisplayedValue( + telemetryObject, + telemetrySeries.getRangeValue(index), + limit && datum && limit.evaluate(datum) + ); + } } // Update the displayed value for this object From ff1fd26efccf67e5f2085336e55758816b08baac Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Thu, 24 Sep 2015 17:05:08 -0700 Subject: [PATCH 10/16] [Time Conductor] Change method name Prefer simpler method names for public API. --- .../features/conductor/src/ConductorRepresenter.js | 10 +++++----- .../conductor/src/ConductorTelemetryDecorator.js | 2 +- .../features/conductor/src/ConductorTelemetrySeries.js | 2 +- platform/features/conductor/src/TimeConductor.js | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/platform/features/conductor/src/ConductorRepresenter.js b/platform/features/conductor/src/ConductorRepresenter.js index 0da32965bc..eecae45aa9 100644 --- a/platform/features/conductor/src/ConductorRepresenter.js +++ b/platform/features/conductor/src/ConductorRepresenter.js @@ -73,7 +73,7 @@ define( repScope.$broadcast('telemetry:query:bounds', bounds( conductor.queryStart(), conductor.queryEnd(), - conductor.activeDomain() + conductor.domain() )); } @@ -83,16 +83,16 @@ define( repScope.$broadcast('telemetry:display:bounds', bounds( conductor.displayStart(), conductor.displayEnd(), - conductor.activeDomain() + conductor.domain() )); } function updateDomain(value) { - conductor.activeDomain(value); + conductor.domain(value); repScope.$broadcast('telemetry:display:bounds', bounds( conductor.displayStart(), conductor.displayEnd(), - conductor.activeDomain() + conductor.domain() )); } @@ -111,7 +111,7 @@ define( }; conductorScope.ngModel.options = conductor.domainOptions().map(makeOption); - conductorScope.ngModel.domain = conductor.activeDomain(); + conductorScope.ngModel.domain = conductor.domain(); conductorScope .$watch('ngModel.conductor.outer.start', updateConductorOuter); diff --git a/platform/features/conductor/src/ConductorTelemetryDecorator.js b/platform/features/conductor/src/ConductorTelemetryDecorator.js index 0038c7ccd9..e629ee0cde 100644 --- a/platform/features/conductor/src/ConductorTelemetryDecorator.js +++ b/platform/features/conductor/src/ConductorTelemetryDecorator.js @@ -72,7 +72,7 @@ define( var conductor = this.conductorService.getConductor(), start = conductor.displayStart(), end = conductor.displayEnd(), - domain = conductor.activeDomain(); + domain = conductor.domain(); function amendRequest(request) { request = request || {}; diff --git a/platform/features/conductor/src/ConductorTelemetrySeries.js b/platform/features/conductor/src/ConductorTelemetrySeries.js index d2f7c874cc..6797b87e7b 100644 --- a/platform/features/conductor/src/ConductorTelemetrySeries.js +++ b/platform/features/conductor/src/ConductorTelemetrySeries.js @@ -39,7 +39,7 @@ define( */ function ConductorTelemetrySeries(series, conductor) { var max = series.getPointCount() - 1, - domain = conductor.activeDomain(); + domain = conductor.domain(); function binSearch(min, max, value) { var mid = Math.floor((min + max) / 2); diff --git a/platform/features/conductor/src/TimeConductor.js b/platform/features/conductor/src/TimeConductor.js index b8e07d051d..6caa1e6d65 100644 --- a/platform/features/conductor/src/TimeConductor.js +++ b/platform/features/conductor/src/TimeConductor.js @@ -44,7 +44,7 @@ define( this.inner = { start: start, end: end }; this.outer = { start: start, end: end }; this.domains = domains; - this.domain = domains[0].key; + this.activeDomain = domains[0].key; } /** @@ -110,7 +110,7 @@ define( * @param {string} [key] the key identifying the domain choice * @returns {TelemetryDomain} the active telemetry domain */ - TimeConductor.prototype.activeDomain = function (key) { + TimeConductor.prototype.domain = function (key) { function matchesKey(domain) { return domain.key === key; } From cbaf45afe9e2a7ebfce00e11e5c9f81edc082346 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Fri, 25 Sep 2015 10:40:19 -0700 Subject: [PATCH 11/16] [Time Conductor] Update specs nasa/openmctweb#115 --- .../features/conductor/src/TimeConductor.js | 4 +- .../test/ConductorRepresenterSpec.js | 79 +++++++++++++--- .../conductor/test/ConductorServiceSpec.js | 8 +- .../test/ConductorTelemetryDecoratorSpec.js | 92 ++++++++++++++----- .../test/ConductorTelemetrySeriesSpec.js | 9 +- .../conductor/test/TestTimeConductor.js | 48 ++++++++++ .../conductor/test/TimeConductorSpec.js | 29 +++++- 7 files changed, 215 insertions(+), 54 deletions(-) create mode 100644 platform/features/conductor/test/TestTimeConductor.js diff --git a/platform/features/conductor/src/TimeConductor.js b/platform/features/conductor/src/TimeConductor.js index 6caa1e6d65..df30040b7f 100644 --- a/platform/features/conductor/src/TimeConductor.js +++ b/platform/features/conductor/src/TimeConductor.js @@ -119,9 +119,9 @@ define( if (!this.domains.some(matchesKey)) { throw new Error("Unknown domain " + key); } - this.domain = key; + this.activeDomain = key; } - return this.domain; + return this.activeDomain; }; return TimeConductor; diff --git a/platform/features/conductor/test/ConductorRepresenterSpec.js b/platform/features/conductor/test/ConductorRepresenterSpec.js index 2b1003f3c7..b0cf23745f 100644 --- a/platform/features/conductor/test/ConductorRepresenterSpec.js +++ b/platform/features/conductor/test/ConductorRepresenterSpec.js @@ -21,12 +21,9 @@ *****************************************************************************/ /*global define,describe,it,expect,beforeEach,waitsFor,afterEach,jasmine*/ -/** - * EventSpec. Created by vwoeltje on 11/6/14. Modified by shale on 06/23/2015. - */ define( - ["../src/ConductorRepresenter"], - function (ConductorRepresenter) { + ["../src/ConductorRepresenter", "./TestTimeConductor"], + function (ConductorRepresenter, TestTimeConductor) { "use strict"; var SCOPE_METHODS = [ @@ -75,10 +72,7 @@ define( testViews = [ { someKey: "some value" } ]; mockScope = jasmine.createSpyObj('scope', SCOPE_METHODS); mockElement = jasmine.createSpyObj('element', ELEMENT_METHODS); - mockConductor = jasmine.createSpyObj( - 'conductor', - [ 'queryStart', 'queryEnd', 'displayStart', 'displayEnd' ] - ); + mockConductor = new TestTimeConductor(); mockCompiledTemplate = jasmine.createSpy('template'); mockNewScope = jasmine.createSpyObj('newScope', SCOPE_METHODS); mockNewElement = jasmine.createSpyObj('newElement', ELEMENT_METHODS); @@ -133,7 +127,7 @@ define( mockConductor.displayEnd.andReturn(1984); representer.represent(testViews[0], {}); - expect(mockNewScope.conductor).toEqual({ + expect(mockNewScope.ngModel.conductor).toEqual({ inner: { start: 1977, end: 1984 }, outer: { start: 42, end: 12321 } }); @@ -147,21 +141,76 @@ define( representer.represent(testViews[0], {}); - mockNewScope.conductor = testState; + mockNewScope.ngModel.conductor = testState; - fireWatch(mockNewScope, 'conductor.inner.start', testState.inner.start); + fireWatch( + mockNewScope, + 'ngModel.conductor.inner.start', + testState.inner.start + ); expect(mockConductor.displayStart).toHaveBeenCalledWith(42); - fireWatch(mockNewScope, 'conductor.inner.end', testState.inner.end); + fireWatch( + mockNewScope, + 'ngModel.conductor.inner.end', + testState.inner.end + ); expect(mockConductor.displayEnd).toHaveBeenCalledWith(1984); - fireWatch(mockNewScope, 'conductor.outer.start', testState.outer.start); + fireWatch( + mockNewScope, + 'ngModel.conductor.outer.start', + testState.outer.start + ); expect(mockConductor.queryStart).toHaveBeenCalledWith(-1977); - fireWatch(mockNewScope, 'conductor.outer.end', testState.outer.end); + fireWatch( + mockNewScope, + 'ngModel.conductor.outer.end', + testState.outer.end + ); expect(mockConductor.queryEnd).toHaveBeenCalledWith(12321); }); + it("exposes domain selection in scope", function () { + representer.represent(testViews[0], null); + + expect(mockNewScope.ngModel.domain) + .toEqual(mockConductor.domain()); + }); + + it("exposes domain options in scope", function () { + representer.represent(testViews[0], null); + + mockConductor.domainOptions().forEach(function (option, i) { + expect(mockNewScope.ngModel.options[i].value) + .toEqual(option.key); + expect(mockNewScope.ngModel.options[i].name) + .toEqual(option.name); + }); + }); + + it("updates domain selection from scope", function () { + var choice; + representer.represent(testViews[0], null); + + // Choose a domain that isn't currently selected + mockNewScope.ngModel.options.forEach(function (option) { + if (option.value !== mockNewScope.ngModel.domain) { + choice = option.value; + } + }); + + expect(mockConductor.domain) + .not.toHaveBeenCalledWith(choice); + + mockNewScope.ngModel.domain = choice; + fireWatch(mockNewScope, "ngModel.domain", choice); + + expect(mockConductor.domain) + .toHaveBeenCalledWith(choice); + }); + }); } ); diff --git a/platform/features/conductor/test/ConductorServiceSpec.js b/platform/features/conductor/test/ConductorServiceSpec.js index 5146ca5f42..4d6fb12f12 100644 --- a/platform/features/conductor/test/ConductorServiceSpec.js +++ b/platform/features/conductor/test/ConductorServiceSpec.js @@ -21,9 +21,6 @@ *****************************************************************************/ /*global define,describe,it,expect,beforeEach,waitsFor,jasmine*/ -/** - * EventSpec. Created by vwoeltje on 11/6/14. Modified by shale on 06/23/2015. - */ define( ["../src/ConductorService"], function (ConductorService) { @@ -38,7 +35,10 @@ define( beforeEach(function () { mockNow = jasmine.createSpy('now'); mockNow.andReturn(TEST_NOW); - conductorService = new ConductorService(mockNow); + conductorService = new ConductorService(mockNow, [ + { key: "d1", name: "Domain #1" }, + { key: "d2", name: "Domain #2" } + ]); }); it("initializes a time conductor around the current time", function () { diff --git a/platform/features/conductor/test/ConductorTelemetryDecoratorSpec.js b/platform/features/conductor/test/ConductorTelemetryDecoratorSpec.js index 84812b541a..7145682bf3 100644 --- a/platform/features/conductor/test/ConductorTelemetryDecoratorSpec.js +++ b/platform/features/conductor/test/ConductorTelemetryDecoratorSpec.js @@ -23,8 +23,8 @@ define( - ["../src/ConductorTelemetryDecorator"], - function (ConductorTelemetryDecorator) { + ["../src/ConductorTelemetryDecorator", "./TestTimeConductor"], + function (ConductorTelemetryDecorator, TestTimeConductor) { "use strict"; describe("ConductorTelemetryDecorator", function () { @@ -54,10 +54,7 @@ define( 'conductorService', ['getConductor'] ); - mockConductor = jasmine.createSpyObj( - 'conductor', - [ 'queryStart', 'queryEnd', 'displayStart', 'displayEnd' ] - ); + mockConductor = new TestTimeConductor(); mockPromise = jasmine.createSpyObj( 'promise', ['then'] @@ -82,6 +79,7 @@ define( mockConductor.queryEnd.andReturn(-12321); mockConductor.displayStart.andReturn(42); mockConductor.displayEnd.andReturn(1977); + mockConductor.domain.andReturn("testDomain"); decorator = new ConductorTelemetryDecorator( mockConductorService, @@ -89,26 +87,74 @@ define( ); }); - it("adds display start/end times to historical requests", function () { - decorator.requestTelemetry([{ someKey: "some value" }]); - expect(mockTelemetryService.requestTelemetry) - .toHaveBeenCalledWith([{ - someKey: "some value", - start: mockConductor.displayStart(), - end: mockConductor.displayEnd() - }]); + + describe("decorates historical requests", function () { + var request; + + beforeEach(function () { + decorator.requestTelemetry([{ someKey: "some value" }]); + request = mockTelemetryService.requestTelemetry + .mostRecentCall.args[0][0]; + }); + + it("with start times", function () { + expect(request.start).toEqual(mockConductor.displayStart()); + }); + + it("with end times", function () { + expect(request.end).toEqual(mockConductor.displayEnd()); + }); + + it("with domain selection", function () { + expect(request.domain).toEqual(mockConductor.domain()); + }); }); - it("adds display start/end times to subscription requests", function () { - var mockCallback = jasmine.createSpy('callback'); - decorator.subscribe(mockCallback, [{ someKey: "some value" }]); - expect(mockTelemetryService.subscribe) - .toHaveBeenCalledWith(jasmine.any(Function), [{ - someKey: "some value", - start: mockConductor.displayStart(), - end: mockConductor.displayEnd() - }]); + describe("decorates subscription requests", function () { + var request; + + beforeEach(function () { + var mockCallback = jasmine.createSpy('callback'); + decorator.subscribe(mockCallback, [{ someKey: "some value" }]); + request = mockTelemetryService.subscribe + .mostRecentCall.args[1][0]; + }); + + it("with start times", function () { + expect(request.start).toEqual(mockConductor.displayStart()); + }); + + it("with end times", function () { + expect(request.end).toEqual(mockConductor.displayEnd()); + }); + + it("with domain selection", function () { + expect(request.domain).toEqual(mockConductor.domain()); + }); }); +// +// it("adds display start/end times & domain selection to historical requests", function () { +// decorator.requestTelemetry([{ someKey: "some value" }]); +// expect(mockTelemetryService.requestTelemetry) +// .toHaveBeenCalledWith([{ +// someKey: "some value", +// start: mockConductor.displayStart(), +// end: mockConductor.displayEnd(), +// domain: jasmine.any(String) +// }]); +// }); +// +// it("adds display start/end times & domain selection to subscription requests", function () { +// var mockCallback = jasmine.createSpy('callback'); +// decorator.subscribe(mockCallback, [{ someKey: "some value" }]); +// expect(mockTelemetryService.subscribe) +// .toHaveBeenCalledWith(jasmine.any(Function), [{ +// someKey: "some value", +// start: mockConductor.displayStart(), +// end: mockConductor.displayEnd(), +// domain: jasmine.any(String) +// }]); +// }); it("prunes historical values to the displayable range", function () { var packagedTelemetry; diff --git a/platform/features/conductor/test/ConductorTelemetrySeriesSpec.js b/platform/features/conductor/test/ConductorTelemetrySeriesSpec.js index ea884f74f3..9ce485d7d2 100644 --- a/platform/features/conductor/test/ConductorTelemetrySeriesSpec.js +++ b/platform/features/conductor/test/ConductorTelemetrySeriesSpec.js @@ -22,8 +22,8 @@ /*global define,describe,it,expect,beforeEach,waitsFor,jasmine*/ define( - ["../src/ConductorTelemetrySeries"], - function (ConductorTelemetrySeries) { + ["../src/ConductorTelemetrySeries", "./TestTimeConductor"], + function (ConductorTelemetrySeries, TestTimeConductor) { "use strict"; describe("ConductorTelemetrySeries", function () { @@ -39,10 +39,7 @@ define( 'series', [ 'getPointCount', 'getDomainValue', 'getRangeValue' ] ); - mockConductor = jasmine.createSpyObj( - 'conductor', - [ 'queryStart', 'queryEnd', 'displayStart', 'displayEnd' ] - ); + mockConductor = new TestTimeConductor(); mockSeries.getPointCount.andCallFake(function () { return testArray.length; diff --git a/platform/features/conductor/test/TestTimeConductor.js b/platform/features/conductor/test/TestTimeConductor.js new file mode 100644 index 0000000000..5c8b95896f --- /dev/null +++ b/platform/features/conductor/test/TestTimeConductor.js @@ -0,0 +1,48 @@ +/***************************************************************************** + * Open MCT Web, Copyright (c) 2014-2015, United States Government + * as represented by the Administrator of the National Aeronautics and Space + * Administration. All rights reserved. + * + * Open MCT Web is licensed under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * Open MCT Web includes source code licensed under additional open source + * licenses. See the Open Source Licenses file (LICENSES.md) included with + * this source code distribution or the Licensing information page available + * at runtime from the About dialog for additional information. + *****************************************************************************/ +/*global define,describe,it,expect,beforeEach,waitsFor,jasmine,spyOn*/ + +define( + ["../src/TimeConductor"], + function (TimeConductor) { + function TestTimeConductor() { + var self = this; + + TimeConductor.apply(this, [ + 402514200000, + 444546000000, + [ + { key: "domain0", name: "Domain #1" }, + { key: "domain1", name: "Domain #2" } + ] + ]); + + Object.keys(TimeConductor.prototype).forEach(function (method) { + spyOn(self, method).andCallThrough(); + }); + } + + TestTimeConductor.prototype = TimeConductor.prototype; + + return TestTimeConductor; + } +); diff --git a/platform/features/conductor/test/TimeConductorSpec.js b/platform/features/conductor/test/TimeConductorSpec.js index 558322329e..27e9aad93f 100644 --- a/platform/features/conductor/test/TimeConductorSpec.js +++ b/platform/features/conductor/test/TimeConductorSpec.js @@ -21,9 +21,6 @@ *****************************************************************************/ /*global define,describe,it,expect,beforeEach,waitsFor,jasmine*/ -/** - * EventSpec. Created by vwoeltje on 11/6/14. Modified by shale on 06/23/2015. - */ define( ["../src/TimeConductor"], function (TimeConductor) { @@ -32,12 +29,17 @@ define( describe("TimeConductor", function () { var testStart, testEnd, + testDomains, conductor; beforeEach(function () { testStart = 42; testEnd = 12321; - conductor = new TimeConductor(testStart, testEnd); + testDomains = [ + { key: "d1", name: "Domain #1" }, + { key: "d2", name: "Domain #2" } + ] + conductor = new TimeConductor(testStart, testEnd, testDomains); }); it("provides accessors for query/display start/end times", function () { @@ -58,6 +60,25 @@ define( expect(conductor.displayEnd()).toEqual(4); }); + it("exposes domain options", function () { + expect(conductor.domainOptions()).toEqual(testDomains); + }); + + it("exposes the current domain choice", function () { + expect(conductor.domain()).toEqual(testDomains[0].key); + }); + + it("allows the domain choice to be changed", function () { + conductor.domain(testDomains[1].key); + expect(conductor.domain()).toEqual(testDomains[1].key); + }); + + it("throws an error on attempts to set an invalid domain", function () { + expect(function () { + conductor.domain("invalid-domain"); + }).toThrow(); + }); + }); } ); From 2848a8458b042cbb9ff3eb1d282a3258e790727d Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Fri, 25 Sep 2015 11:05:13 -0700 Subject: [PATCH 12/16] [Time Conductor] Avoid exception Avoid exception when trying to generate a single datum in cases where there is no data yet available. --- platform/telemetry/src/TelemetryHandle.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/platform/telemetry/src/TelemetryHandle.js b/platform/telemetry/src/TelemetryHandle.js index ae25fd9bfa..ff77d7b9e0 100644 --- a/platform/telemetry/src/TelemetryHandle.js +++ b/platform/telemetry/src/TelemetryHandle.js @@ -110,20 +110,23 @@ define( * Get the latest telemetry datum for this domain object. This * will be from real-time telemetry, unless an index is specified, * in which case it will be pulled from the historical telemetry - * series at the specified index. + * series at the specified index. If there is no latest available + * datum, this will return undefined. * * @param {DomainObject} domainObject the object of interest * @param {number} [index] the index of the data of interest * @returns {TelemetryDatum} the most recent datum */ self.getDatum = function (telemetryObject, index) { + function makeNewDatum(series) { + return series ? + subscription.makeDatum(telemetryObject, series, index) : + undefined; + } + return typeof index !== 'number' ? subscription.getDatum(telemetryObject) : - subscription.makeDatum( - telemetryObject, - this.getSeries(telemetryObject), - index - ); + makeNewDatum(this.getSeries(telemetryObject)); }; return self; From 00ac249ee204f7c9546fece1c8d9f83208e999f8 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Fri, 25 Sep 2015 16:06:11 -0700 Subject: [PATCH 13/16] [Time Conductor] Position domain selector nasa/openmtweb#115 --- .../conductor/res/templates/time-conductor.html | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/platform/features/conductor/res/templates/time-conductor.html b/platform/features/conductor/res/templates/time-conductor.html index c597bf33c3..4126652d5b 100644 --- a/platform/features/conductor/res/templates/time-conductor.html +++ b/platform/features/conductor/res/templates/time-conductor.html @@ -1,8 +1,10 @@ - - + + From 28c42fcd4cf546864fdd86d7eee4385ef113be89 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Fri, 9 Oct 2015 11:06:41 -0700 Subject: [PATCH 14/16] [Time Conductor] Fix merge issues Fix merge issues not addressed during conflict resolution. --- platform/features/conductor/src/ConductorRepresenter.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/platform/features/conductor/src/ConductorRepresenter.js b/platform/features/conductor/src/ConductorRepresenter.js index bce7f8841e..c6d18c9266 100644 --- a/platform/features/conductor/src/ConductorRepresenter.js +++ b/platform/features/conductor/src/ConductorRepresenter.js @@ -28,7 +28,7 @@ define( var CONDUCTOR_HEIGHT = "100px", TEMPLATE = [ - "", + "", "" ].join(''), THROTTLE_MS = 200, @@ -90,8 +90,9 @@ define( } function updateConductorInner() { - conductor.displayStart(conductorScope.conductor.inner.start); - conductor.displayEnd(conductorScope.conductor.inner.end); + var innerBounds = conductorScope.ngModel.conductor.inner; + conductor.displayStart(innerBounds.start); + conductor.displayEnd(innerBounds.end); lastObservedBounds = lastObservedBounds || bounds(); broadcastBounds(); } From 2accf21518ebae01295be23788c928d2143edffd Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Fri, 9 Oct 2015 11:08:02 -0700 Subject: [PATCH 15/16] [Time Conductor] Add missing semicolon ...to pass code style checks. --- platform/features/conductor/test/TimeConductorSpec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/features/conductor/test/TimeConductorSpec.js b/platform/features/conductor/test/TimeConductorSpec.js index 20769bf7da..c9336a93b0 100644 --- a/platform/features/conductor/test/TimeConductorSpec.js +++ b/platform/features/conductor/test/TimeConductorSpec.js @@ -38,7 +38,7 @@ define( testDomains = [ { key: "d1", name: "Domain #1" }, { key: "d2", name: "Domain #2" } - ] + ]; conductor = new TimeConductor(testStart, testEnd, testDomains); }); From 5763511ec87145ded37e177de601897fa4075f37 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Fri, 9 Oct 2015 11:17:57 -0700 Subject: [PATCH 16/16] [Time Conductor] Update specs Update specs to reflect merge of latest from master into topic branch for nasa/openmctweb#115, domain selector. --- .../test/ConductorRepresenterSpec.js | 27 ++++++----- .../test/ConductorTelemetryDecoratorSpec.js | 48 +++++++++---------- .../conductor/test/TestTimeConductor.js | 2 + 3 files changed, 40 insertions(+), 37 deletions(-) diff --git a/platform/features/conductor/test/ConductorRepresenterSpec.js b/platform/features/conductor/test/ConductorRepresenterSpec.js index 0f152077d2..5d78c8a720 100644 --- a/platform/features/conductor/test/ConductorRepresenterSpec.js +++ b/platform/features/conductor/test/ConductorRepresenterSpec.js @@ -129,11 +129,12 @@ define( it("exposes conductor state in scope", function () { mockConductor.displayStart.andReturn(1977); mockConductor.displayEnd.andReturn(1984); + mockConductor.domain.andReturn('d'); representer.represent(testViews[0], {}); expect(mockNewScope.ngModel.conductor).toEqual({ - inner: { start: 1977, end: 1984 }, - outer: { start: 1977, end: 1984 } + inner: { start: 1977, end: 1984, domain: 'd' }, + outer: { start: 1977, end: 1984, domain: 'd' } }); }); @@ -163,7 +164,9 @@ define( }); describe("when bounds are changing", function () { - var mockThrottledFn = jasmine.createSpy('throttledFn'), + var startWatch = "ngModel.conductor.inner.start", + endWatch = "ngModel.conductor.inner.end", + mockThrottledFn = jasmine.createSpy('throttledFn'), testBounds; function fireThrottledFn() { @@ -174,7 +177,7 @@ define( mockThrottle.andReturn(mockThrottledFn); representer.represent(testViews[0], {}); testBounds = { start: 0, end: 1000 }; - mockNewScope.conductor.inner = testBounds; + mockNewScope.ngModel.conductor.inner = testBounds; mockConductor.displayStart.andCallFake(function () { return testBounds.start; }); @@ -186,14 +189,14 @@ define( it("does not broadcast while bounds are changing", function () { expect(mockScope.$broadcast).not.toHaveBeenCalled(); testBounds.start = 100; - fireWatch(mockNewScope, 'conductor.inner.start', testBounds.start); + fireWatch(mockNewScope, startWatch, testBounds.start); testBounds.end = 500; - fireWatch(mockNewScope, 'conductor.inner.end', testBounds.end); + fireWatch(mockNewScope, endWatch, testBounds.end); fireThrottledFn(); testBounds.start = 200; - fireWatch(mockNewScope, 'conductor.inner.start', testBounds.start); + fireWatch(mockNewScope, startWatch, testBounds.start); testBounds.end = 400; - fireWatch(mockNewScope, 'conductor.inner.end', testBounds.end); + fireWatch(mockNewScope, endWatch, testBounds.end); fireThrottledFn(); expect(mockScope.$broadcast).not.toHaveBeenCalled(); }); @@ -201,12 +204,12 @@ define( it("does broadcast when bounds have stabilized", function () { expect(mockScope.$broadcast).not.toHaveBeenCalled(); testBounds.start = 100; - fireWatch(mockNewScope, 'conductor.inner.start', testBounds.start); + fireWatch(mockNewScope, startWatch, testBounds.start); testBounds.end = 500; - fireWatch(mockNewScope, 'conductor.inner.end', testBounds.end); + fireWatch(mockNewScope, endWatch, testBounds.end); fireThrottledFn(); - fireWatch(mockNewScope, 'conductor.inner.start', testBounds.start); - fireWatch(mockNewScope, 'conductor.inner.end', testBounds.end); + fireWatch(mockNewScope, startWatch, testBounds.start); + fireWatch(mockNewScope, endWatch, testBounds.end); fireThrottledFn(); expect(mockScope.$broadcast).toHaveBeenCalled(); }); diff --git a/platform/features/conductor/test/ConductorTelemetryDecoratorSpec.js b/platform/features/conductor/test/ConductorTelemetryDecoratorSpec.js index a99bcabcd0..6e768419c1 100644 --- a/platform/features/conductor/test/ConductorTelemetryDecoratorSpec.js +++ b/platform/features/conductor/test/ConductorTelemetryDecoratorSpec.js @@ -75,8 +75,6 @@ define( return j * j * j; }); - mockConductor.queryStart.andReturn(-12321); - mockConductor.queryEnd.andReturn(-12321); mockConductor.displayStart.andReturn(42); mockConductor.displayEnd.andReturn(1977); mockConductor.domain.andReturn("testDomain"); @@ -132,29 +130,29 @@ define( expect(request.domain).toEqual(mockConductor.domain()); }); }); -// -// it("adds display start/end times & domain selection to historical requests", function () { -// decorator.requestTelemetry([{ someKey: "some value" }]); -// expect(mockTelemetryService.requestTelemetry) -// .toHaveBeenCalledWith([{ -// someKey: "some value", -// start: mockConductor.displayStart(), -// end: mockConductor.displayEnd(), -// domain: jasmine.any(String) -// }]); -// }); -// -// it("adds display start/end times & domain selection to subscription requests", function () { -// var mockCallback = jasmine.createSpy('callback'); -// decorator.subscribe(mockCallback, [{ someKey: "some value" }]); -// expect(mockTelemetryService.subscribe) -// .toHaveBeenCalledWith(jasmine.any(Function), [{ -// someKey: "some value", -// start: mockConductor.displayStart(), -// end: mockConductor.displayEnd(), -// domain: jasmine.any(String) -// }]); -// }); + + it("adds display start/end times & domain selection to historical requests", function () { + decorator.requestTelemetry([{ someKey: "some value" }]); + expect(mockTelemetryService.requestTelemetry) + .toHaveBeenCalledWith([{ + someKey: "some value", + start: mockConductor.displayStart(), + end: mockConductor.displayEnd(), + domain: jasmine.any(String) + }]); + }); + + it("adds display start/end times & domain selection to subscription requests", function () { + var mockCallback = jasmine.createSpy('callback'); + decorator.subscribe(mockCallback, [{ someKey: "some value" }]); + expect(mockTelemetryService.subscribe) + .toHaveBeenCalledWith(jasmine.any(Function), [{ + someKey: "some value", + start: mockConductor.displayStart(), + end: mockConductor.displayEnd(), + domain: jasmine.any(String) + }]); + }); }); diff --git a/platform/features/conductor/test/TestTimeConductor.js b/platform/features/conductor/test/TestTimeConductor.js index 5c8b95896f..01fed0c8fd 100644 --- a/platform/features/conductor/test/TestTimeConductor.js +++ b/platform/features/conductor/test/TestTimeConductor.js @@ -24,6 +24,8 @@ define( ["../src/TimeConductor"], function (TimeConductor) { + 'use strict'; + function TestTimeConductor() { var self = this;