Skip to content

Commit

Permalink
Fixed TOI not showing
Browse files Browse the repository at this point in the history
  • Loading branch information
akhenry committed Nov 4, 2016
1 parent 099c56c commit d0906ba
Show file tree
Hide file tree
Showing 13 changed files with 100 additions and 105 deletions.
2 changes: 1 addition & 1 deletion platform/commonUI/formats/src/UTCTimeFormat.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ define([
["Milliseconds", function (r) {
return true;
}]
].filter(function (row){
].filter(function (row) {
return row[1](momentified);
})[0][0];
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ define([
d3
) {
describe("The ConductorAxisController", function () {
var directive,
var controller,
mockConductor,
mockConductorViewService,
mockFormatService,
Expand All @@ -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];
}
Expand Down Expand Up @@ -89,7 +89,7 @@ define([

element = $('<div style="width: 100px;"><div style="width: 100%;"></div></div>');
$(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",
Expand All @@ -106,73 +106,71 @@ 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();
});

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);
});

});
Expand Down
56 changes: 27 additions & 29 deletions platform/features/conductor-v2/conductor/src/ui/MctConductorAxis.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: '<div class="l-axis-holder" ' +
' mct-drag-down="axis.panStart()"' +
' mct-drag-up="axis.panStop(delta)"' +
' mct-drag="axis.pan(delta)"' +
' mct-resize="axis.resize()"></div>'
}
}

return MctConductorAxis;
template: '<div class="l-axis-holder" ' +
' mct-drag-down="axis.panStart()"' +
' mct-drag-up="axis.panStop(delta)"' +
' mct-drag="axis.pan(delta)"' +
' mct-resize="axis.resize()"></div>'
};
}
);

return MctConductorAxis;
});
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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', [
Expand All @@ -81,7 +81,6 @@ define(['./TimeConductorController'], function (TimeConductorController) {
}

describe("when time conductor state changes", function () {
var mockFormat;
var mockDeltaFormat;
var defaultBounds;
var defaultDeltas;
Expand Down Expand Up @@ -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
Expand All @@ -179,7 +178,7 @@ define(['./TimeConductorController'], function (TimeConductorController) {
max: 0
};

function exponentializer (rawValue){
function exponentializer(rawValue) {
return 1 - Math.pow(rawValue, 1 / 4);
}

Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ define(['./TimeOfInterestController'], function (TimeOfInterestController) {
mockFormatService.getFormat.andReturn(mockFormat);

mockTimeSystem = {
formats: function() {
formats: function () {
return ["mockFormat"];
}
};

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];
Expand Down Expand Up @@ -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();
Expand All @@ -109,7 +109,7 @@ define(['./TimeOfInterestController'], function (TimeOfInterestController) {
toiCallback(toi);
expect(mockScope.pinned).toBe(true);
});
})
});

});
});
24 changes: 12 additions & 12 deletions platform/features/plot/src/PlotController.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;

Expand Down
Loading

0 comments on commit d0906ba

Please sign in to comment.