From efed5f68afbfccf972094a9d3b72022f7b9b167f Mon Sep 17 00:00:00 2001 From: Henry Date: Wed, 9 Nov 2016 16:25:54 -0800 Subject: [PATCH] [Time Conductor] Added support for loading and persisting time conductor bounds in URL. Fixes #1231 --- .../features/conductor-v2/conductor/bundle.js | 1 + .../src/ui/TimeConductorController.js | 32 +++++++++++++++---- platform/features/plot/src/PlotController.js | 2 ++ 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/platform/features/conductor-v2/conductor/bundle.js b/platform/features/conductor-v2/conductor/bundle.js index 506c0f52ba..d701142fdd 100644 --- a/platform/features/conductor-v2/conductor/bundle.js +++ b/platform/features/conductor-v2/conductor/bundle.js @@ -67,6 +67,7 @@ define([ "depends": [ "$scope", "$window", + "$location", "openmct", "timeConductorViewService", "timeSystems[]", diff --git a/platform/features/conductor-v2/conductor/src/ui/TimeConductorController.js b/platform/features/conductor-v2/conductor/src/ui/TimeConductorController.js index d95632391c..d1c8fdeb45 100644 --- a/platform/features/conductor-v2/conductor/src/ui/TimeConductorController.js +++ b/platform/features/conductor-v2/conductor/src/ui/TimeConductorController.js @@ -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); } }; diff --git a/platform/features/plot/src/PlotController.js b/platform/features/plot/src/PlotController.js index 6089358684..8c3e4e3529 100644 --- a/platform/features/plot/src/PlotController.js +++ b/platform/features/plot/src/PlotController.js @@ -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);