mirror of
https://github.com/nasa/openmct.git
synced 2024-12-20 21:53:08 +00:00
[Time Conductor] Refactored time of interest as optional generic behavior of MctTable
This commit is contained in:
parent
dfbbc3b0c5
commit
51a95575f7
@ -2,6 +2,7 @@
|
||||
ng-class="{'loading': loading}">
|
||||
<mct-table
|
||||
headers="headers"
|
||||
time-columns="timeColumns"
|
||||
rows="rows"
|
||||
enableFilter="true"
|
||||
enableSort="true"
|
||||
|
@ -52,7 +52,7 @@
|
||||
<!--ng-class="{ 'l-toi pinned': false }"-->
|
||||
<!--ng-click="dummyUnpin()" -->
|
||||
<tr ng-repeat="visibleRow in visibleRows track by visibleRow.rowIndex"
|
||||
class="{{visibleRow.contents.cssClass}}"
|
||||
ng-class="{ 'l-toi pinned': visibleRow.rowIndex === toiRowIndex }"
|
||||
ng-click="table.onRowClick($event, visibleRow.contents)"
|
||||
ng-style="{
|
||||
top: visibleRow.offsetY + 'px',
|
||||
|
@ -36,7 +36,7 @@ define(
|
||||
* @param telemetryFormatter
|
||||
* @constructor
|
||||
*/
|
||||
function HistoricalTableController($scope, telemetryHandler, telemetryFormatter, $timeout, conductor) {
|
||||
function HistoricalTableController($scope, telemetryHandler, telemetryFormatter, $timeout) {
|
||||
var self = this;
|
||||
|
||||
this.$timeout = $timeout;
|
||||
@ -49,7 +49,7 @@ define(
|
||||
}
|
||||
});
|
||||
|
||||
TableController.call(this, $scope, telemetryHandler, telemetryFormatter, conductor);
|
||||
TableController.call(this, $scope, telemetryHandler, telemetryFormatter);
|
||||
}
|
||||
|
||||
HistoricalTableController.prototype = Object.create(TableController.prototype);
|
||||
@ -59,7 +59,6 @@ define(
|
||||
* @private
|
||||
*/
|
||||
HistoricalTableController.prototype.doneProcessing = function (rowData) {
|
||||
//Set table rows to formatted data;
|
||||
this.$scope.rows = rowData;
|
||||
this.$scope.loading = false;
|
||||
};
|
||||
@ -110,9 +109,8 @@ define(
|
||||
|
||||
//Process rows in a batch with size not exceeding a maximum length
|
||||
for (; i < end; i++) {
|
||||
var datum = this.handle.makeDatum(telemetryObject, series, i);
|
||||
this.data.push(datum);
|
||||
rowData.push(this.table.getRowValues(telemetryObject, datum));
|
||||
rowData.push(this.table.getRowValues(telemetryObject,
|
||||
this.handle.makeDatum(telemetryObject, series, i)));
|
||||
}
|
||||
|
||||
//Done processing all rows for this object.
|
||||
@ -125,7 +123,7 @@ define(
|
||||
// before continuing processing
|
||||
this.timeoutHandle = this.$timeout(this.processTelemetryObjects.bind(this, objects, offset, end, rowData));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Populates historical data on scope when it becomes available from
|
||||
* the telemetry API
|
||||
@ -134,7 +132,7 @@ define(
|
||||
if (this.timeoutHandle) {
|
||||
this.$timeout.cancel(this.timeoutHandle);
|
||||
}
|
||||
this.data = [];
|
||||
|
||||
this.timeoutHandle = this.$timeout(this.processTelemetryObjects.bind(this, this.handle.getTelemetryObjects(), 0, 0, []));
|
||||
};
|
||||
|
||||
|
@ -12,7 +12,7 @@ define(
|
||||
* @param element
|
||||
* @constructor
|
||||
*/
|
||||
function MCTTableController($scope, $timeout, element, exportService) {
|
||||
function MCTTableController($scope, $timeout, element, exportService, formatService, conductor) {
|
||||
var self = this;
|
||||
|
||||
this.$scope = $scope;
|
||||
@ -24,6 +24,9 @@ define(
|
||||
this.thead = element.find('thead');
|
||||
this.tbody = element.find('tbody');
|
||||
this.$scope.sizingRow = {};
|
||||
this.conductor = conductor;
|
||||
this.toiFormatter = undefined;
|
||||
this.formatService = formatService;
|
||||
|
||||
//Bind all class functions to 'this'
|
||||
Object.keys(MCTTableController.prototype).filter(function (key) {
|
||||
@ -77,6 +80,7 @@ define(
|
||||
$scope.sortDirection = undefined;
|
||||
}
|
||||
self.setRows($scope.rows);
|
||||
self.setTimeOfInterest(self.conductor.timeOfInterest());
|
||||
};
|
||||
|
||||
/*
|
||||
@ -99,8 +103,29 @@ define(
|
||||
*/
|
||||
$scope.resize = this.setElementSizes.bind(this);
|
||||
|
||||
|
||||
// Time conductor integration
|
||||
if (this.$scope.timeColumns) {
|
||||
this.conductor.on('timeSystem', this.changeTimeSystem);
|
||||
this.conductor.on('timeOfInterest', this.setTimeOfInterest);
|
||||
$scope.$on('$destroy', function () {
|
||||
this.conductor.off('timeSystem', this.changeTimeSystem);
|
||||
this.conductor.off('timeOfInterest', this.setTimeOfInterest);
|
||||
}.bind(this));
|
||||
|
||||
// If time system defined, set initially
|
||||
if (conductor.timeSystem()) {
|
||||
this.changeTimeSystem(conductor.timeSystem());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
MCTTableController.prototype.changeTimeSystem = function () {
|
||||
var format = this.conductor.timeSystem().formats()[0];
|
||||
this.toiFormatter = this.formatService.getFormat(format);
|
||||
};
|
||||
|
||||
/**
|
||||
* If auto-scroll is enabled, this function will scroll to the
|
||||
* bottom of the page
|
||||
@ -308,7 +333,7 @@ define(
|
||||
return min; // Element is not in array, min gives direction
|
||||
}
|
||||
|
||||
switch (this.sortComparator(searchElement[this.$scope.sortColumn].text,
|
||||
switch (this.sortComparator(searchElement,
|
||||
searchArray[sampleAt][this.$scope.sortColumn].text)) {
|
||||
case -1:
|
||||
return this.binarySearch(searchArray, searchElement, min,
|
||||
@ -332,7 +357,7 @@ define(
|
||||
index = array.length;
|
||||
} else {
|
||||
//Sort is enabled, perform binary search to find insertion point
|
||||
index = this.binarySearch(array, element, 0, array.length - 1);
|
||||
index = this.binarySearch(array, element[this.$scope.sortColumn].text, 0, array.length - 1);
|
||||
}
|
||||
if (index === -1) {
|
||||
array.unshift(element);
|
||||
@ -496,11 +521,6 @@ define(
|
||||
this.resize(newRows).then(this.setVisibleRows.bind(this));
|
||||
};
|
||||
|
||||
MCTTableController.prototype.onRowClick = function (event, row) {
|
||||
var index = this.$scope.rows.indexOf(row);
|
||||
this.$scope.onRowClick({event: event, rowIndex:index, sortColumn: this.$scope.sortColumn, sortDirection: this.$scope.sortDirection});
|
||||
};
|
||||
|
||||
/**
|
||||
* Applies user defined filters to rows. These filters are based on
|
||||
* the text entered in the search areas in each column.
|
||||
@ -538,6 +558,20 @@ define(
|
||||
return rowsToFilter.filter(matchRow.bind(null, filters));
|
||||
};
|
||||
|
||||
/**
|
||||
* Update rows with new data. If filtering is enabled, rows
|
||||
* will be sorted before display.
|
||||
*/
|
||||
MCTTableController.prototype.setTimeOfInterest = function (newTOI) {
|
||||
if (this.$scope.timeColumns.indexOf(this.$scope.sortColumn) !== -1) {
|
||||
var formattedTOI = this.toiFormatter.format(newTOI);
|
||||
var rowsLength = this.$scope.displayRows.length;
|
||||
// searchElement, min, max
|
||||
this.$scope.toiRowIndex = this.binarySearch(this.$scope.displayRows, formattedTOI, 0, rowsLength);
|
||||
} else {
|
||||
this.$scope.toiRowIndex = -1;
|
||||
}
|
||||
};
|
||||
|
||||
return MCTTableController;
|
||||
}
|
||||
|
@ -26,10 +26,9 @@
|
||||
*/
|
||||
define(
|
||||
[
|
||||
'../TableConfiguration',
|
||||
'../DomainColumn'
|
||||
'../TableConfiguration'
|
||||
],
|
||||
function (TableConfiguration, DomainColumn) {
|
||||
function (TableConfiguration) {
|
||||
|
||||
/**
|
||||
* The TableController is responsible for getting data onto the page
|
||||
@ -57,7 +56,6 @@ define(
|
||||
telemetryFormatter);
|
||||
this.changeListeners = [];
|
||||
this.conductor = conductor;
|
||||
this.data = [];
|
||||
|
||||
$scope.rows = [];
|
||||
|
||||
@ -67,28 +65,13 @@ define(
|
||||
self.registerChangeListeners();
|
||||
});
|
||||
|
||||
this.destroy = this.destroy.bind(this);
|
||||
|
||||
// Unsubscribe when the plot is destroyed
|
||||
this.$scope.$on("$destroy", this.destroy);
|
||||
this.$scope.timeColumns = ['Time'];
|
||||
}
|
||||
|
||||
TelemetryTableController.prototype.onRowClick = function (event, rowIndex, sortBy, sortOrder) {
|
||||
var datum = this.data[rowIndex];
|
||||
|
||||
if (event.altKey) {
|
||||
console.log("selected: " + this.$scope.rows[rowIndex]);
|
||||
//Is column one that we can use to set time of interest?
|
||||
var domainColumn = this.table.columns.filter(function (column) {
|
||||
return column instanceof DomainColumn &&
|
||||
column.getTitle() === sortBy;
|
||||
})[0];
|
||||
if (domainColumn) {
|
||||
var timeOfInterest = datum[domainColumn.domainMetadata.key];
|
||||
this.conductor.timeOfInterest(timeOfInterest);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
@ -210,10 +193,6 @@ define(
|
||||
});
|
||||
};
|
||||
|
||||
TelemetryTableController.prototype.changeTimeOfInterest = function (toi) {
|
||||
|
||||
}
|
||||
|
||||
return TelemetryTableController;
|
||||
}
|
||||
);
|
||||
|
@ -86,6 +86,8 @@ define(
|
||||
'$timeout',
|
||||
'$element',
|
||||
'exportService',
|
||||
'formatService',
|
||||
'timeConductor',
|
||||
MCTTableController
|
||||
],
|
||||
controllerAs: "table",
|
||||
@ -95,7 +97,7 @@ define(
|
||||
enableFilter: "=?",
|
||||
enableSort: "=?",
|
||||
autoScroll: "=?",
|
||||
onRowClick: "&"
|
||||
timeColumns: "=?"
|
||||
}
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user