alt-click to select TOI from table

This commit is contained in:
Henry
2016-10-06 10:23:42 -07:00
18 changed files with 213 additions and 175 deletions

View File

@ -109,7 +109,7 @@ define([
{
"key": "HistoricalTableController",
"implementation": HistoricalTableController,
"depends": ["$scope", "telemetryHandler", "telemetryFormatter", "$timeout"]
"depends": ["$scope", "telemetryHandler", "telemetryFormatter", "$timeout", "timeConductor"]
},
{
"key": "RealtimeTableController",

View File

@ -1,9 +1,11 @@
<div ng-controller="HistoricalTableController" ng-class="{'loading': loading}">
<div ng-controller="HistoricalTableController as tableController"
ng-class="{'loading': loading}">
<mct-table
headers="headers"
rows="rows"
enableFilter="true"
enableSort="true"
on-row-click="tableController.onRowClick(event, rowIndex, sortColumn, sortDirection)"
class="tabular-holder has-control-bar">
</mct-table>
</div>

View File

@ -49,20 +49,23 @@
</tr>
</thead>
<tbody>
<!--ng-class="{ 'l-toi pinned': false }"-->
<!--ng-click="dummyUnpin()" -->
<tr ng-repeat="visibleRow in visibleRows track by visibleRow.rowIndex"
ng-class="{ 'l-toi active pinned': false }"
ng-style="{
top: visibleRow.offsetY + 'px',
}">
<td ng-repeat="header in displayHeaders"
ng-style=" {
width: columnWidths[$index] + 'px',
'max-width': columnWidths[$index] + 'px',
}"
class="{{visibleRow.contents[header].cssClass}}">
{{ visibleRow.contents[header].text }}
</td>
</tr>
</tbody>
</table>
class="{{visibleRow.contents.cssClass}}"
ng-click="table.onRowClick($event, visibleRow.contents)"
ng-style="{
top: visibleRow.offsetY + 'px',
}">
<td ng-repeat="header in displayHeaders"
ng-style=" {
width: columnWidths[$index] + 'px',
'max-width': columnWidths[$index] + 'px',
}"
class="{{visibleRow.contents[header].cssClass}}">
{{ visibleRow.contents[header].text }}
</td>
</tr>
</tbody>
</table>
</div>

View File

@ -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);
@ -59,6 +59,7 @@ define(
* @private
*/
HistoricalTableController.prototype.doneProcessing = function (rowData) {
//Set table rows to formatted data;
this.$scope.rows = rowData;
this.$scope.loading = false;
};
@ -109,8 +110,9 @@ define(
//Process rows in a batch with size not exceeding a maximum length
for (; i < end; i++) {
rowData.push(this.table.getRowValues(telemetryObject,
this.handle.makeDatum(telemetryObject, series, i)));
var datum = this.handle.makeDatum(telemetryObject, series, i);
this.data.push(datum);
rowData.push(this.table.getRowValues(telemetryObject, datum));
}
//Done processing all rows for this object.
@ -123,7 +125,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
@ -132,7 +134,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, []));
};

View File

@ -25,6 +25,13 @@ define(
this.tbody = element.find('tbody');
this.$scope.sizingRow = {};
//Bind all class functions to 'this'
Object.keys(MCTTableController.prototype).filter(function (key) {
return typeof MCTTableController.prototype[key] === 'function';
}).forEach(function (key) {
this[key] = MCTTableController.prototype[key].bind(this);
}.bind(this));
this.scrollable.on('scroll', this.onScroll.bind(this));
$scope.visibleRows = [];
@ -294,37 +301,38 @@ define(
/**
* @private
*/
MCTTableController.prototype.insertSorted = function (array, element) {
var index = -1,
self = this,
sortKey = this.$scope.sortColumn;
MCTTableController.prototype.binarySearch = function (searchArray, searchElement, min, max) {
var sampleAt = Math.floor((max - min) / 2) + min;
function binarySearch(searchArray, searchElement, min, max) {
var sampleAt = Math.floor((max - min) / 2) + min;
if (max < min) {
return min; // Element is not in array, min gives direction
}
switch (self.sortComparator(searchElement[sortKey].text,
searchArray[sampleAt][sortKey].text)) {
case -1:
return binarySearch(searchArray, searchElement, min,
sampleAt - 1);
case 0 :
return sampleAt;
case 1 :
return binarySearch(searchArray, searchElement,
sampleAt + 1, max);
}
if (max < min) {
return min; // Element is not in array, min gives direction
}
switch (this.sortComparator(searchElement[this.$scope.sortColumn].text,
searchArray[sampleAt][this.$scope.sortColumn].text)) {
case -1:
return this.binarySearch(searchArray, searchElement, min,
sampleAt - 1);
case 0 :
return sampleAt;
case 1 :
return this.binarySearch(searchArray, searchElement,
sampleAt + 1, max);
}
};
/**
* @private
*/
MCTTableController.prototype.insertSorted = function (array, element) {
var index = -1;
if (!this.$scope.sortColumn || !this.$scope.sortDirection) {
//No sorting applied, push it on the end.
index = array.length;
} else {
//Sort is enabled, perform binary search to find insertion point
index = binarySearch(array, element, 0, array.length - 1);
index = this.binarySearch(array, element, 0, array.length - 1);
}
if (index === -1) {
array.unshift(element);
@ -488,6 +496,11 @@ 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.

View File

@ -26,9 +26,10 @@
*/
define(
[
'../TableConfiguration'
'../TableConfiguration',
'../DomainColumn'
],
function (TableConfiguration) {
function (TableConfiguration, DomainColumn) {
/**
* The TableController is responsible for getting data onto the page
@ -43,7 +44,8 @@ define(
function TelemetryTableController(
$scope,
telemetryHandler,
telemetryFormatter
telemetryFormatter,
conductor
) {
var self = this;
@ -54,6 +56,8 @@ define(
this.table = new TableConfiguration($scope.domainObject,
telemetryFormatter);
this.changeListeners = [];
this.conductor = conductor;
this.data = [];
$scope.rows = [];
@ -64,9 +68,27 @@ define(
});
// Unsubscribe when the plot is destroyed
this.$scope.$on("$destroy", this.destroy.bind(this));
this.$scope.$on("$destroy", this.destroy);
}
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
*/
@ -188,6 +210,10 @@ define(
});
};
TelemetryTableController.prototype.changeTimeOfInterest = function (toi) {
}
return TelemetryTableController;
}
);

View File

@ -88,12 +88,14 @@ define(
'exportService',
MCTTableController
],
controllerAs: "table",
scope: {
headers: "=",
rows: "=",
enableFilter: "=?",
enableSort: "=?",
autoScroll: "=?"
autoScroll: "=?",
onRowClick: "&"
}
};
}