+
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: "=?"
}
};
}