[Time Conductor] Added support for loading and persisting time conductor bounds in URL. Fixes #1231

This commit is contained in:
Henry 2016-11-09 16:25:54 -08:00 committed by Pete Richards
parent 79b4f9a0f4
commit efed5f68af
3 changed files with 28 additions and 7 deletions

View File

@ -67,6 +67,7 @@ define([
"depends": [
"$scope",
"$window",
"$location",
"openmct",
"timeConductorViewService",
"timeSystems[]",

View File

@ -32,7 +32,7 @@ define(
* @memberof platform.features.conductor
* @constructor
*/
function TimeConductorController($scope, $window, openmct, conductorViewService, timeSystems, formatService) {
function TimeConductorController($scope, $window, $location, openmct, conductorViewService, timeSystems, formatService) {
var self = this;
@ -45,6 +45,7 @@ define(
this.$scope = $scope;
this.$window = $window;
this.$location = $location;
this.conductorViewService = conductorViewService;
this.conductor = openmct.conductor;
this.modes = conductorViewService.availableModes();
@ -56,16 +57,22 @@ define(
return timeSystemConstructor();
});
//Set the initial state of the view based on current time conductor
this.initializeScope();
this.conductor.on('bounds', this.changeBounds);
this.conductor.on('timeSystem', this.changeTimeSystem);
// If no mode selected, select fixed as the default
if (!this.conductorViewService.mode()) {
this.setMode('fixed');
}
// set the bounds on the time conductor based on any URL defined
// bounds
this.setBoundsFromLocation();
//Setup bounds in the UI based on those defined on the conductor
this.changeBounds(this.conductor.bounds());
//Respond to any subsequent bounds changes
this.conductor.on('bounds', this.changeBounds);
this.conductor.on('timeSystem', this.changeTimeSystem);
}
/**
@ -101,17 +108,26 @@ define(
}
this.setFormFromBounds(this.conductor.bounds());
// Watch scope for selection of mode or time system by user
this.$scope.$watch('modeModel.selectedKey', this.setMode);
this.conductorViewService.on('pan', this.onPan);
this.conductorViewService.on('pan-stop', this.onPanStop);
//Listen for changes to URL and update bounds if necessary
this.$scope.$on('$routeUpdate', this.setBoundsFromLocation);
this.$scope.$on('$destroy', this.destroy);
};
TimeConductorController.prototype.setBoundsFromLocation = function() {
var startBound = this.$location.search().startBound;
var endBound = this.$location.search().endBound;
if (startBound !== undefined && endBound !== undefined) {
this.conductor.bounds({start: parseInt(startBound), end: parseInt(endBound)});
}
};
/**
* @private
*/
@ -132,6 +148,8 @@ define(
//If a zoom or pan is currently in progress, do not override form values.
if (!this.zooming && !this.panning) {
this.setFormFromBounds(bounds);
this.$location.search('startBound', bounds.start);
this.$location.search('endBound', bounds.end);
}
};

View File

@ -283,6 +283,8 @@ define(
new PlotAxis("ranges", [], AXIS_DEFAULTS[1])
];
changeDisplayBounds(undefined, conductor.bounds(), conductor.follow());
// Watch for changes to the selected axis
$scope.$watch("axes[0].active.key", domainRequery);
$scope.$watch("axes[1].active.key", rangeRequery);