Skip to content

Commit

Permalink
[Time Conductor] Implement default sort, fix unpredictable positionin…
Browse files Browse the repository at this point in the history
…g using % left, set TOI on conductor init. #1193
  • Loading branch information
akhenry committed Oct 19, 2016
1 parent d12ae77 commit b56ab0a
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 15 deletions.
2 changes: 1 addition & 1 deletion example/generator/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ define([
"source": "generator",
"domains": [
{
"key": "time",
"key": "utc",
"name": "Time"
},
{
Expand Down
2 changes: 1 addition & 1 deletion example/msl/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ define([
"domains": [
{
"name": "Time",
"key": "timestamp",
"key": "utc",
"format": "utc"
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,9 @@

<!-- Holds data visualization, time of interest -->
<div class="l-data-visualization-holder l-row-elem flex-elem"
ng-controller="ConductorTOIController as toi"
ng-click="toi.click($event)">
ng-controller="ConductorTOIController as toi">
<a class="l-page-button s-icon-button icon-pointer-left"></a>
<div class="l-data-visualization">
<div class="l-data-visualization" ng-click="toi.click($event)">
<mct-include key="'time-of-interest'"
class="l-toi-holder show-val"
ng-class="{ pinned: toi.pinned, 'val-to-left': toi.left > 80 }"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ define(
this.conductorViewService.on('pan', this.setOffsetFromBounds);
this.conductor.on('timeSystem', this.changeTimeSystem);

var timeOfInterest = this.conductor.timeOfInterest();
if (timeOfInterest) {
this.changeTimeOfInterest(timeOfInterest);
}

$scope.$on('$destroy', this.destroy);

}
Expand Down
4 changes: 2 additions & 2 deletions platform/features/table/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,12 @@ define([
{
"key": "HistoricalTableController",
"implementation": HistoricalTableController,
"depends": ["$scope", "telemetryHandler", "telemetryFormatter", "$timeout", "timeConductor"]
"depends": ["$scope", "telemetryHandler", "telemetryFormatter", "$timeout", "timeConductor", "timeConductor"]
},
{
"key": "RealtimeTableController",
"implementation": RealtimeTableController,
"depends": ["$scope", "telemetryHandler", "telemetryFormatter"]
"depends": ["$scope", "telemetryHandler", "telemetryFormatter", "timeConductor"]
},
{
"key": "TableOptionsController",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
rows="rows"
enableFilter="true"
enableSort="true"
default-sort="defaultSort"
on-row-click="tableController.onRowClick(event, rowIndex, sortColumn, sortDirection)"
class="tabular-holder has-control-bar">
</mct-table>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -49,7 +49,7 @@ define(
}
});

TableController.call(this, $scope, telemetryHandler, telemetryFormatter);
TableController.call(this, $scope, telemetryHandler, telemetryFormatter, conductor);
}

HistoricalTableController.prototype = Object.create(TableController.prototype);
Expand Down
15 changes: 10 additions & 5 deletions platform/features/table/src/controllers/MCTTableController.js
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -163,6 +180,11 @@ define(
this.timeColumns.push(domainMetadata.name);
}.bind(this));
}.bind(this));

var timeSystem = this.conductor.timeSystem();
if (timeSystem) {
this.sortByTimeSystem(timeSystem);
}
};

/**
Expand Down
3 changes: 2 additions & 1 deletion platform/features/table/src/directives/MCTTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ define(
enableFilter: "=?",
enableSort: "=?",
autoScroll: "=?",
timeColumns: "=?"
timeColumns: "=?",
defaultSort: "=?"
}
};
}
Expand Down

0 comments on commit b56ab0a

Please sign in to comment.