From b56ab0aac2202cae27b2a26844e5c042d0d4bbdd Mon Sep 17 00:00:00 2001 From: Henry Date: Wed, 19 Oct 2016 16:30:26 -0700 Subject: [PATCH] [Time Conductor] Implement default sort, fix unpredictable positioning using % left, set TOI on conductor init. #1193 --- example/generator/bundle.js | 2 +- example/msl/bundle.js | 2 +- .../res/templates/time-conductor.html | 5 ++--- .../src/ui/ConductorTOIController.js | 5 +++++ platform/features/table/bundle.js | 4 ++-- .../table/res/templates/historical-table.html | 1 + .../controllers/HistoricalTableController.js | 4 ++-- .../src/controllers/MCTTableController.js | 15 ++++++++----- .../controllers/TelemetryTableController.js | 22 +++++++++++++++++++ .../features/table/src/directives/MCTTable.js | 3 ++- 10 files changed, 48 insertions(+), 15 deletions(-) diff --git a/example/generator/bundle.js b/example/generator/bundle.js index 0eadfad5e9e..076a04ac8d0 100644 --- a/example/generator/bundle.js +++ b/example/generator/bundle.js @@ -99,7 +99,7 @@ define([ "source": "generator", "domains": [ { - "key": "time", + "key": "utc", "name": "Time" }, { diff --git a/example/msl/bundle.js b/example/msl/bundle.js index aefc3ffc168..76688680315 100644 --- a/example/msl/bundle.js +++ b/example/msl/bundle.js @@ -61,7 +61,7 @@ define([ "domains": [ { "name": "Time", - "key": "timestamp", + "key": "utc", "format": "utc" } ] diff --git a/platform/features/conductor-v2/conductor/res/templates/time-conductor.html b/platform/features/conductor-v2/conductor/res/templates/time-conductor.html index 04befb7507e..817da5c19b8 100644 --- a/platform/features/conductor-v2/conductor/res/templates/time-conductor.html +++ b/platform/features/conductor-v2/conductor/res/templates/time-conductor.html @@ -85,10 +85,9 @@
+ ng-controller="ConductorTOIController as toi"> -
+
diff --git a/platform/features/table/src/controllers/HistoricalTableController.js b/platform/features/table/src/controllers/HistoricalTableController.js index d8af8060de6..7ce63de054f 100644 --- a/platform/features/table/src/controllers/HistoricalTableController.js +++ b/platform/features/table/src/controllers/HistoricalTableController.js @@ -36,7 +36,7 @@ define( * @param telemetryFormatter * @constructor */ - function HistoricalTableController($scope, telemetryHandler, telemetryFormatter, $timeout) { + function HistoricalTableController($scope, telemetryHandler, telemetryFormatter, $timeout, conductor) { var self = this; this.$timeout = $timeout; @@ -49,7 +49,7 @@ define( } }); - TableController.call(this, $scope, telemetryHandler, telemetryFormatter); + TableController.call(this, $scope, telemetryHandler, telemetryFormatter, conductor); } HistoricalTableController.prototype = Object.create(TableController.prototype); diff --git a/platform/features/table/src/controllers/MCTTableController.js b/platform/features/table/src/controllers/MCTTableController.js index d196e9ba438..1e5b99fa62b 100644 --- a/platform/features/table/src/controllers/MCTTableController.js +++ b/platform/features/table/src/controllers/MCTTableController.js @@ -89,19 +89,24 @@ define( $scope.$watchCollection('filters', function () { self.setRows($scope.rows); }); - $scope.$watch('headers', this.setHeaders.bind(this)); - $scope.$watch('rows', this.setRows.bind(this)); + $scope.$watch('headers', this.setHeaders); + $scope.$watch('rows', this.setRows); /* * Listen for rows added individually (eg. for real-time tables) */ - $scope.$on('add:row', this.addRow.bind(this)); - $scope.$on('remove:row', this.removeRow.bind(this)); + $scope.$on('add:row', this.addRow); + $scope.$on('remove:row', this.removeRow); + + $scope.$watch('defaultSort', function (defaultSort) { + $scope.sortColumn = defaultSort; + $scope.sortDirection = 'asc'; + }); /* * Listen for resize events to trigger recalculation of table width */ - $scope.resize = this.setElementSizes.bind(this); + $scope.resize = this.setElementSizes; // Time conductor integration $scope.$watch("timeColumns", function (timeColumns){ diff --git a/platform/features/table/src/controllers/TelemetryTableController.js b/platform/features/table/src/controllers/TelemetryTableController.js index 761f77483d3..f366c5d7d76 100644 --- a/platform/features/table/src/controllers/TelemetryTableController.js +++ b/platform/features/table/src/controllers/TelemetryTableController.js @@ -70,8 +70,25 @@ define( // Unsubscribe when the plot is destroyed this.$scope.$on("$destroy", this.destroy); this.$scope.timeColumns = []; + + + this.sortByTimeSystem = this.sortByTimeSystem.bind(this); + conductor.on('timeSystem', this.sortByTimeSystem); + conductor.off('timeSystem', this.sortByTimeSystem); } + TelemetryTableController.prototype.sortByTimeSystem = function (timeSystem) { + var scope = this.$scope; + scope.defaultSort = undefined; + if (timeSystem) { + this.table.columns.forEach(function (column) { + if (column.domainMetadata && column.domainMetadata.key === timeSystem.metadata.key) { + scope.defaultSort = column.getTitle(); + } + }); + } + }; + /** * @private */ @@ -163,6 +180,11 @@ define( this.timeColumns.push(domainMetadata.name); }.bind(this)); }.bind(this)); + + var timeSystem = this.conductor.timeSystem(); + if (timeSystem) { + this.sortByTimeSystem(timeSystem); + } }; /** diff --git a/platform/features/table/src/directives/MCTTable.js b/platform/features/table/src/directives/MCTTable.js index 529b22d024c..50e68d38e4f 100644 --- a/platform/features/table/src/directives/MCTTable.js +++ b/platform/features/table/src/directives/MCTTable.js @@ -97,7 +97,8 @@ define( enableFilter: "=?", enableSort: "=?", autoScroll: "=?", - timeColumns: "=?" + timeColumns: "=?", + defaultSort: "=?" } }; }