From d0906baccfd2b33c9cf198799be3786fc9221018 Mon Sep 17 00:00:00 2001 From: Henry Date: Fri, 4 Nov 2016 10:48:05 -0700 Subject: [PATCH] Fixed TOI not showing --- .../commonUI/formats/src/UTCTimeFormat.js | 2 +- .../src/ui/ConductorAxisController.js | 2 +- .../src/ui/ConductorAxisControllerSpec.js | 54 +++++++++--------- .../conductor/src/ui/MctConductorAxis.js | 56 +++++++++---------- .../src/ui/TimeConductorController.js | 4 +- .../src/ui/TimeConductorControllerSpec.js | 9 ++- .../conductor/src/ui/TimeConductorMode.js | 4 +- .../src/ui/TimeOfInterestControllerSpec.js | 8 +-- platform/features/plot/src/PlotController.js | 24 ++++---- .../src/controllers/MCTTableController.js | 24 +++++--- .../HistoricalTableControllerSpec.js | 4 +- .../controllers/MCTTableControllerSpec.js | 8 +-- src/api/TimeConductor.js | 6 -- 13 files changed, 100 insertions(+), 105 deletions(-) diff --git a/platform/commonUI/formats/src/UTCTimeFormat.js b/platform/commonUI/formats/src/UTCTimeFormat.js index a31194f0b33..e1366a831b6 100644 --- a/platform/commonUI/formats/src/UTCTimeFormat.js +++ b/platform/commonUI/formats/src/UTCTimeFormat.js @@ -129,7 +129,7 @@ define([ ["Milliseconds", function (r) { return true; }] - ].filter(function (row){ + ].filter(function (row) { return row[1](momentified); })[0][0]; }; diff --git a/platform/features/conductor-v2/conductor/src/ui/ConductorAxisController.js b/platform/features/conductor-v2/conductor/src/ui/ConductorAxisController.js index 9db3efc3a14..300cb65a289 100644 --- a/platform/features/conductor-v2/conductor/src/ui/ConductorAxisController.js +++ b/platform/features/conductor-v2/conductor/src/ui/ConductorAxisController.js @@ -58,7 +58,7 @@ define( this.conductor.off('timeSystem', this.changeTimeSystem); this.conductor.off('bounds', this.changeBounds); this.conductorViewService.off("zoom", this.onZoom); - this.conductorViewService.off("zoom-stop", this.onZoomStop) + this.conductorViewService.off("zoom-stop", this.onZoomStop); }; /** diff --git a/platform/features/conductor-v2/conductor/src/ui/ConductorAxisControllerSpec.js b/platform/features/conductor-v2/conductor/src/ui/ConductorAxisControllerSpec.js index f508b33fa68..2dbbb42c4b9 100644 --- a/platform/features/conductor-v2/conductor/src/ui/ConductorAxisControllerSpec.js +++ b/platform/features/conductor-v2/conductor/src/ui/ConductorAxisControllerSpec.js @@ -30,7 +30,7 @@ define([ d3 ) { describe("The ConductorAxisController", function () { - var directive, + var controller, mockConductor, mockConductorViewService, mockFormatService, @@ -43,7 +43,7 @@ define([ mockFormat; function getCallback(target, name) { - return target.calls.filter(function (call){ + return target.calls.filter(function (call) { return call.args[0] === name; })[0].args[1]; } @@ -89,7 +89,7 @@ define([ element = $('
'); $(document).find('body').append(element); - directive = new ConductorAxisController({conductor: mockConductor}, mockFormatService, mockConductorViewService, mockScope, element); + controller = new ConductorAxisController({conductor: mockConductor}, mockFormatService, mockConductorViewService, mockScope, element); mockTimeSystem = jasmine.createSpyObj("timeSystem", [ "formats", @@ -106,21 +106,21 @@ define([ }); it("listens for changes to time system and bounds", function () { - expect(mockConductor.on).toHaveBeenCalledWith("timeSystem", directive.changeTimeSystem); - expect(mockConductor.on).toHaveBeenCalledWith("bounds", directive.changeBounds); + expect(mockConductor.on).toHaveBeenCalledWith("timeSystem", controller.changeTimeSystem); + expect(mockConductor.on).toHaveBeenCalledWith("bounds", controller.changeBounds); }); it("on scope destruction, deregisters listeners", function () { - expect(mockScope.$on).toHaveBeenCalledWith("$destroy", directive.destroy); - directive.destroy(); - expect(mockConductor.off).toHaveBeenCalledWith("timeSystem", directive.changeTimeSystem); - expect(mockConductor.off).toHaveBeenCalledWith("bounds", directive.changeBounds); + expect(mockScope.$on).toHaveBeenCalledWith("$destroy", controller.destroy); + controller.destroy(); + expect(mockConductor.off).toHaveBeenCalledWith("timeSystem", controller.changeTimeSystem); + expect(mockConductor.off).toHaveBeenCalledWith("bounds", controller.changeBounds); }); describe("when the time system changes", function () { it("uses a UTC scale for UTC time systems", function () { mockTimeSystem.isUTCBased.andReturn(true); - directive.changeTimeSystem(mockTimeSystem); + controller.changeTimeSystem(mockTimeSystem); expect(d3.scaleUtc).toHaveBeenCalled(); expect(d3.scaleLinear).not.toHaveBeenCalled(); @@ -128,51 +128,49 @@ define([ it("uses a linear scale for non-UTC time systems", function () { mockTimeSystem.isUTCBased.andReturn(false); - directive.changeTimeSystem(mockTimeSystem); + controller.changeTimeSystem(mockTimeSystem); expect(d3.scaleLinear).toHaveBeenCalled(); expect(d3.scaleUtc).not.toHaveBeenCalled(); }); it("sets axis domain to time conductor bounds", function () { mockTimeSystem.isUTCBased.andReturn(false); - directive.setScale(); - expect(directive.xScale.domain()).toEqual([mockBounds.start, mockBounds.end]); + controller.setScale(); + expect(controller.xScale.domain()).toEqual([mockBounds.start, mockBounds.end]); }); it("uses the format specified by the time system to format tick" + " labels", function () { - - directive.changeTimeSystem(mockTimeSystem); + controller.changeTimeSystem(mockTimeSystem); expect(mockFormat.format).toHaveBeenCalled(); - }); it('responds to zoom events', function () { - expect(mockConductorViewService.on).toHaveBeenCalledWith("zoom", directive.onZoom); + expect(mockConductorViewService.on).toHaveBeenCalledWith("zoom", controller.onZoom); var cb = getCallback(mockConductorViewService.on, "zoom"); - spyOn(directive, 'setScale').andCallThrough(); + spyOn(controller, 'setScale').andCallThrough(); cb({bounds: {start: 0, end: 100}}); - expect(directive.setScale).toHaveBeenCalled(); + expect(controller.setScale).toHaveBeenCalled(); }); it('adjusts scale on pan', function () { - spyOn(directive, 'setScale').andCallThrough(); - directive.pan(100); - expect(directive.setScale).toHaveBeenCalled(); + spyOn(controller, 'setScale').andCallThrough(); + controller.pan(100); + expect(controller.setScale).toHaveBeenCalled(); }); it('emits event on pan', function () { - spyOn(directive,'setScale').andCallThrough(); - directive.pan(100); + spyOn(controller, 'setScale').andCallThrough(); + controller.pan(100); expect(mockConductorViewService.emit).toHaveBeenCalledWith("pan", jasmine.any(Object)); }); it('cleans up listeners on destruction', function () { - directive.destroy(); - expect(mockConductor.off).toHaveBeenCalledWith("bounds", directive.changeBounds); - expect(mockConductor.off).toHaveBeenCalledWith("timeSystem", directive.changeTimeSystem); + controller.destroy(); + expect(mockConductor.off).toHaveBeenCalledWith("bounds", controller.changeBounds); + expect(mockConductor.off).toHaveBeenCalledWith("timeSystem", controller.changeTimeSystem); - expect(mockConductorViewService.off).toHaveBeenCalledWith("zoom", directive.onZoom); + expect(mockConductorViewService.off).toHaveBeenCalledWith("zoom", controller.onZoom); }); }); diff --git a/platform/features/conductor-v2/conductor/src/ui/MctConductorAxis.js b/platform/features/conductor-v2/conductor/src/ui/MctConductorAxis.js index 27d4826c93c..7484d6b35f0 100644 --- a/platform/features/conductor-v2/conductor/src/ui/MctConductorAxis.js +++ b/platform/features/conductor-v2/conductor/src/ui/MctConductorAxis.js @@ -21,36 +21,34 @@ *****************************************************************************/ define(['./ConductorAxisController'], function (ConductorAxisController) { + function MctConductorAxis() { + /** + * The mct-conductor-axis renders a horizontal axis with regular + * labelled 'ticks'. It requires 'start' and 'end' integer values to + * be specified as attributes. + */ - function MctConductorAxis() { - /** - * The mct-conductor-axis renders a horizontal axis with regular - * labelled 'ticks'. It requires 'start' and 'end' integer values to - * be specified as attributes. - */ + return { + controller: [ + 'openmct', + 'formatService', + 'timeConductorViewService', + '$scope', + '$element', + ConductorAxisController + ], + controllerAs: 'axis', - return { - controller: [ - 'openmct', - 'formatService', - 'timeConductorViewService', - '$scope', - '$element', - ConductorAxisController - ], - controllerAs: 'axis', + restrict: 'E', + priority: 1000, - restrict: 'E', - priority: 1000, - - template: '
' - } - } - - return MctConductorAxis; + template: '
' + }; } -); + + return MctConductorAxis; +}); diff --git a/platform/features/conductor-v2/conductor/src/ui/TimeConductorController.js b/platform/features/conductor-v2/conductor/src/ui/TimeConductorController.js index 016fd3c0a19..9509316b884 100644 --- a/platform/features/conductor-v2/conductor/src/ui/TimeConductorController.js +++ b/platform/features/conductor-v2/conductor/src/ui/TimeConductorController.js @@ -142,7 +142,7 @@ define( * @param {TimeConductorBounds} */ TimeConductorController.prototype.setFormFromBounds = function (bounds) { - if (!this.zooming && ! this.panning) { + if (!this.zooming && !this.panning) { this.$scope.boundsModel.start = bounds.start; this.$scope.boundsModel.end = bounds.end; @@ -313,7 +313,7 @@ define( * is released. * @param bounds */ - TimeConductorController.prototype.onZoom = function(sliderValue) { + TimeConductorController.prototype.onZoom = function (sliderValue) { var zoomDefaults = this.conductor.timeSystem().defaults().zoom; var timeSpan = Math.pow((1 - sliderValue), 4) * (zoomDefaults.min - zoomDefaults.max); diff --git a/platform/features/conductor-v2/conductor/src/ui/TimeConductorControllerSpec.js b/platform/features/conductor-v2/conductor/src/ui/TimeConductorControllerSpec.js index 938a80fc8aa..7d0c76564c0 100644 --- a/platform/features/conductor-v2/conductor/src/ui/TimeConductorControllerSpec.js +++ b/platform/features/conductor-v2/conductor/src/ui/TimeConductorControllerSpec.js @@ -63,7 +63,7 @@ define(['./TimeConductorController'], function (TimeConductorController) { mockConductorViewService.availableModes.andReturn([]); mockConductorViewService.availableTimeSystems.andReturn([]); - mockFormatService = jasmine.createSpyObj('formatService',[ + mockFormatService = jasmine.createSpyObj('formatService', [ 'getFormat' ]); mockFormat = jasmine.createSpyObj('format', [ @@ -81,7 +81,6 @@ define(['./TimeConductorController'], function (TimeConductorController) { } describe("when time conductor state changes", function () { - var mockFormat; var mockDeltaFormat; var defaultBounds; var defaultDeltas; @@ -169,7 +168,7 @@ define(['./TimeConductorController'], function (TimeConductorController) { expect(mockScope.timeSystemModel.maxZoom).toBe(mockDefaults.zoom.max); }); - it("when bounds change, sets the correct zoom slider value", function() { + it("when bounds change, sets the correct zoom slider value", function () { var bounds = { start: 0, end: 50 @@ -179,7 +178,7 @@ define(['./TimeConductorController'], function (TimeConductorController) { max: 0 }; - function exponentializer (rawValue){ + function exponentializer(rawValue) { return 1 - Math.pow(rawValue, 1 / 4); } @@ -366,7 +365,7 @@ define(['./TimeConductorController'], function (TimeConductorController) { expect(mockTimeConductor.timeSystem).toHaveBeenCalledWith(timeSystem, defaultBounds); }); - it("updates form bounds during pan events", function() { + it("updates form bounds during pan events", function () { var testBounds = { start: 10, end: 20 diff --git a/platform/features/conductor-v2/conductor/src/ui/TimeConductorMode.js b/platform/features/conductor-v2/conductor/src/ui/TimeConductorMode.js index d48dd8dbd3b..24395114ad8 100644 --- a/platform/features/conductor-v2/conductor/src/ui/TimeConductorMode.js +++ b/platform/features/conductor-v2/conductor/src/ui/TimeConductorMode.js @@ -179,7 +179,7 @@ define( if (arguments.length !== 0) { var bounds = this.calculateBoundsFromDeltas(deltas); this.dlts = deltas; - if (this.metadata().key!=='fixed') { + if (this.metadata().key !== 'fixed') { this.conductor.bounds(bounds); } } @@ -216,7 +216,7 @@ define( // If a tick source is defined, then the concept of 'now' is // important. Calculate zoom based on 'now'. - if (this.tickSource()){ + if (this.tickSource()) { zoom.deltas = { start: timeSpan, end: this.dlts.end diff --git a/platform/features/conductor-v2/conductor/src/ui/TimeOfInterestControllerSpec.js b/platform/features/conductor-v2/conductor/src/ui/TimeOfInterestControllerSpec.js index 899e17af014..0062ec79b8c 100644 --- a/platform/features/conductor-v2/conductor/src/ui/TimeOfInterestControllerSpec.js +++ b/platform/features/conductor-v2/conductor/src/ui/TimeOfInterestControllerSpec.js @@ -50,7 +50,7 @@ define(['./TimeOfInterestController'], function (TimeOfInterestController) { mockFormatService.getFormat.andReturn(mockFormat); mockTimeSystem = { - formats: function() { + formats: function () { return ["mockFormat"]; } }; @@ -58,7 +58,7 @@ define(['./TimeOfInterestController'], function (TimeOfInterestController) { controller = new TimeOfInterestController(mockScope, {conductor: mockConductor}, mockFormatService); }); - function getCallback(target, event){ + function getCallback(target, event) { return target.calls.filter(function (call) { return call.args[0] === event; })[0].args[1]; @@ -94,7 +94,7 @@ define(['./TimeOfInterestController'], function (TimeOfInterestController) { mockFormat.format.andReturn(formattedTOI); }); it("Uses the time system formatter to produce TOI text", function () { - var toiCallback = getCallback(mockConductor.on, "timeOfInterest"); + toiCallback = getCallback(mockConductor.on, "timeOfInterest"); //Set TOI toiCallback(toi); expect(mockFormat.format).toHaveBeenCalled(); @@ -109,7 +109,7 @@ define(['./TimeOfInterestController'], function (TimeOfInterestController) { toiCallback(toi); expect(mockScope.pinned).toBe(true); }); - }) + }); }); }); diff --git a/platform/features/plot/src/PlotController.js b/platform/features/plot/src/PlotController.js index c11e2e44f87..6089358684c 100644 --- a/platform/features/plot/src/PlotController.js +++ b/platform/features/plot/src/PlotController.js @@ -183,6 +183,18 @@ define( } } + function changeTimeOfInterest(timeOfInterest) { + if (timeOfInterest !== undefined) { + var bounds = conductor.bounds(); + var range = bounds.end - bounds.start; + $scope.toiPerc = ((timeOfInterest - bounds.start) / range) * 100; + $scope.toiPinned = true; + } else { + $scope.toiPerc = undefined; + $scope.toiPinned = false; + } + } + // Create a new subscription; telemetrySubscriber gets // to do the meaningful work here. function subscribe(domainObject) { @@ -251,18 +263,6 @@ define( changeTimeOfInterest(conductor.timeOfInterest()); } - function changeTimeOfInterest(timeOfInterest) { - if (timeOfInterest !== undefined){ - var bounds = conductor.bounds(); - var range = bounds.end - bounds.start; - $scope.toiPerc = ((timeOfInterest - bounds.start) / range) * 100; - $scope.toiPinned = true; - } else { - $scope.toiPerc = undefined; - $scope.toiPinned = false; - } - } - this.modeOptions = new PlotModeOptions([], subPlotFactory); this.updateValues = updateValues; diff --git a/platform/features/table/src/controllers/MCTTableController.js b/platform/features/table/src/controllers/MCTTableController.js index dcf04901ce3..3ab1887c29c 100644 --- a/platform/features/table/src/controllers/MCTTableController.js +++ b/platform/features/table/src/controllers/MCTTableController.js @@ -52,6 +52,9 @@ define( scope.sortColumn = undefined; scope.sortDirection = undefined; } + if (scope.sortColumn !== undefined) { + scope.sortDirection = "asc"; + } } setDefaults($scope); @@ -78,6 +81,9 @@ define( } else if ($scope.sortDirection === 'desc') { $scope.sortColumn = undefined; $scope.sortDirection = undefined; + } else if ($scope.sortColumn !== undefined && + $scope.sortDirection === undefined) { + $scope.sortDirection = 'asc'; } self.setRows($scope.rows); self.setTimeOfInterest(self.conductor.timeOfInterest()); @@ -114,7 +120,7 @@ define( * attribute on the MctTable tag. Indicates which columns, while * sorted, can be used for indicated time of interest. */ - $scope.$watch("timeColumns", function (timeColumns){ + $scope.$watch("timeColumns", function (timeColumns) { if (timeColumns) { this.destroyConductorListeners(); @@ -561,7 +567,7 @@ define( //Timeout following setVisibleRows to allow digest to // perform DOM changes, otherwise scrollTo won't work. .then(this.$timeout) - .then(function() { + .then(function () { //If TOI specified, scroll to it var timeOfInterest = this.conductor.timeOfInterest(); if (timeOfInterest) { @@ -617,9 +623,9 @@ define( var visible = displayRowIndex > this.firstVisible() && displayRowIndex < this.lastVisible(); if (!visible) { - var scrollTop = displayRowIndex * this.$scope.rowHeight - + this.$scope.headerHeight - - (this.scrollable[0].offsetHeight / 2); + var scrollTop = displayRowIndex * this.$scope.rowHeight + + this.$scope.headerHeight - + (this.scrollable[0].offsetHeight / 2); this.scrollable[0].scrollTop = scrollTop; this.setVisibleRows(); } @@ -655,7 +661,7 @@ define( * On zoom, pan, etc. reset TOI * @param bounds */ - MCTTableController.prototype.changeBounds = function(bounds) { + MCTTableController.prototype.changeBounds = function (bounds) { this.setTimeOfInterest(this.conductor.timeOfInterest()); }; @@ -665,9 +671,9 @@ define( MCTTableController.prototype.onRowClick = function (event, rowIndex) { if (this.$scope.timeColumns.indexOf(this.$scope.sortColumn) !== -1) { var selectedTime = this.$scope.displayRows[rowIndex][this.$scope.sortColumn].text; - if (selectedTime - && this.toiFormatter.validate(selectedTime) - && event.altKey) { + if (selectedTime && + this.toiFormatter.validate(selectedTime) && + event.altKey) { this.conductor.timeOfInterest(this.toiFormatter.parse(selectedTime)); } } diff --git a/platform/features/table/test/controllers/HistoricalTableControllerSpec.js b/platform/features/table/test/controllers/HistoricalTableControllerSpec.js index 962bff9542c..39f7d1a8f58 100644 --- a/platform/features/table/test/controllers/HistoricalTableControllerSpec.js +++ b/platform/features/table/test/controllers/HistoricalTableControllerSpec.js @@ -49,7 +49,7 @@ define( } function getCallback(target, event) { - return target.calls.filter(function (call){ + return target.calls.filter(function (call) { return call.args[0] === event; })[0].args[1]; } @@ -252,7 +252,7 @@ define( describe('After populating columns', function () { var metadata; beforeEach(function () { - metadata = [{domains: [{name: 'time domain 1'}, {name:'time domain 2'}]}, {domains: [{name: 'time domain 3'}, {name: 'time domain 4'}]} ]; + metadata = [{domains: [{name: 'time domain 1'}, {name: 'time domain 2'}]}, {domains: [{name: 'time domain 3'}, {name: 'time domain 4'}]}]; controller.populateColumns(metadata); }); diff --git a/platform/features/table/test/controllers/MCTTableControllerSpec.js b/platform/features/table/test/controllers/MCTTableControllerSpec.js index 1cbf3b4954d..61e4a2eece8 100644 --- a/platform/features/table/test/controllers/MCTTableControllerSpec.js +++ b/platform/features/table/test/controllers/MCTTableControllerSpec.js @@ -114,7 +114,7 @@ define( expect(mockScope.$watch).toHaveBeenCalledWith('rows', jasmine.any(Function)); }); - it('destroys listeners on destruction', function() { + it('destroys listeners on destruction', function () { expect(mockScope.$on).toHaveBeenCalledWith('$destroy', controller.destroyConductorListeners); getCallback(mockScope.$on, '$destroy')(); @@ -123,7 +123,7 @@ define( expect(mockConductor.off).toHaveBeenCalledWith('bounds', controller.changeBounds); }); - describe('The time of interest', function() { + describe('The time of interest', function () { var rowsAsc = []; var rowsDesc = []; beforeEach(function () { @@ -328,9 +328,9 @@ define( describe('sorting', function () { var sortedRows; - beforeEach(function() { + beforeEach(function () { sortedRows = []; - }) + }); it('Sorts rows ascending', function () { mockScope.sortColumn = 'col1'; diff --git a/src/api/TimeConductor.js b/src/api/TimeConductor.js index ed5c2285518..470d16b4e2b 100644 --- a/src/api/TimeConductor.js +++ b/src/api/TimeConductor.js @@ -75,12 +75,6 @@ define(['EventEmitter'], function (EventEmitter) { return true; }; - function throwOnError(validationResult) { - if (validationResult !== true) { - throw new Error(validationResult); - } - } - /** * Get or set the follow mode of the time conductor. In follow mode the * time conductor ticks, regularly updating the bounds from a timing