mirror of
https://github.com/nasa/openmct.git
synced 2024-12-19 05:07:52 +00:00
Added support for clicking row to set TOI
This commit is contained in:
parent
b995a8b87b
commit
70c4ce24e4
@ -105,7 +105,8 @@
|
||||
ng-class="{ 'pinned': toi.pinned, 'val-to-right': toi.left < 20 }"
|
||||
ng-style="{'left': toi.left + '%'}">
|
||||
<div class="l-toi">
|
||||
<a class="t-button-unpin icon-button" ng-click="toi.pinned = false"></a>
|
||||
<a class="t-button-unpin icon-button"
|
||||
ng-click="toi.dismiss()"></a>
|
||||
<span class="l-toi-val">{{toi.toiText}}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -94,6 +94,10 @@ define(
|
||||
}
|
||||
};
|
||||
|
||||
ConductorTOIController.prototype.dismiss = function () {
|
||||
this.conductor.timeOfInterest(undefined);
|
||||
};
|
||||
|
||||
ConductorTOIController.prototype.resize = function () {
|
||||
//Do something?
|
||||
};
|
||||
|
@ -2,7 +2,7 @@
|
||||
ng-class="{'loading': loading}">
|
||||
<mct-table
|
||||
headers="headers"
|
||||
time-columns="timeColumns"
|
||||
time-columns="tableController.timeColumns"
|
||||
rows="rows"
|
||||
enableFilter="true"
|
||||
enableSort="true"
|
||||
|
@ -53,7 +53,7 @@
|
||||
<!--ng-click="dummyUnpin()" -->
|
||||
<tr ng-repeat="visibleRow in visibleRows track by visibleRow.rowIndex"
|
||||
ng-class="{ 'l-toi pinned': visibleRow.rowIndex === toiRowIndex }"
|
||||
ng-click="table.onRowClick($event, visibleRow.contents)"
|
||||
ng-click="table.onRowClick($event, visibleRow.rowIndex)"
|
||||
ng-style="{
|
||||
top: visibleRow.offsetY + 'px',
|
||||
}">
|
||||
|
@ -103,24 +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));
|
||||
$scope.$watch("timeColumns", function (timeColumns){
|
||||
if (timeColumns) {
|
||||
this.destroyConductorListeners();
|
||||
|
||||
// If time system defined, set initially
|
||||
if (conductor.timeSystem()) {
|
||||
this.changeTimeSystem(conductor.timeSystem());
|
||||
this.conductor.on('timeSystem', this.changeTimeSystem);
|
||||
this.conductor.on('timeOfInterest', this.setTimeOfInterest);
|
||||
|
||||
// If time system defined, set initially
|
||||
if (conductor.timeSystem()) {
|
||||
this.changeTimeSystem(conductor.timeSystem());
|
||||
}
|
||||
}
|
||||
}
|
||||
}.bind(this));
|
||||
|
||||
$scope.$on('$destroy', this.destroyConductorListeners);
|
||||
}
|
||||
|
||||
MCTTableController.prototype.destroyConductorListeners = function () {
|
||||
this.conductor.off('timeSystem', this.changeTimeSystem);
|
||||
this.conductor.off('timeOfInterest', this.setTimeOfInterest);
|
||||
};
|
||||
|
||||
MCTTableController.prototype.changeTimeSystem = function () {
|
||||
var format = this.conductor.timeSystem().formats()[0];
|
||||
this.toiFormatter = this.formatService.getFormat(format);
|
||||
@ -558,18 +563,50 @@ define(
|
||||
return rowsToFilter.filter(matchRow.bind(null, filters));
|
||||
};
|
||||
|
||||
MCTTableController.prototype.scrollToRow = function (displayRowIndex) {
|
||||
|
||||
var visible = this.$scope.visibleRows.reduce(function (exists, row) {
|
||||
return exists || (row.rowIndex === displayRowIndex)
|
||||
}, false);
|
||||
|
||||
if (!visible) {
|
||||
var scrollTop = displayRowIndex * this.$scope.rowHeight
|
||||
+ this.$scope.headerHeight
|
||||
- (this.scrollable[0].offsetHeight / 2);
|
||||
this.scrollable[0].scrollTop = scrollTop;
|
||||
this.setVisibleRows();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
this.$scope.toiRowIndex = -1;
|
||||
if (this.$scope.timeColumns.indexOf(this.$scope.sortColumn) !== -1
|
||||
&& newTOI
|
||||
&& this.$scope.displayRows.length > 0) {
|
||||
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;
|
||||
this.scrollToRow(this.$scope.toiRowIndex);
|
||||
}
|
||||
};
|
||||
|
||||
MCTTableController.prototype.onRowClick = function (event, rowIndex) {
|
||||
if (this.$scope.timeColumns.indexOf(this.$scope.sortColumn) !== -1) {
|
||||
if (rowIndex === this.$scope.toiRowIndex) {
|
||||
this.conductor.timeOfInterest(undefined);
|
||||
} else {
|
||||
var selectedTime = this.$scope.displayRows[rowIndex][this.$scope.sortColumn].text;
|
||||
if (selectedTime
|
||||
&& this.toiFormatter.validate(selectedTime)
|
||||
&& event.altKey) {
|
||||
this.conductor.timeOfInterest(this.toiFormatter.parse(selectedTime));
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -69,7 +69,7 @@ define(
|
||||
|
||||
// Unsubscribe when the plot is destroyed
|
||||
this.$scope.$on("$destroy", this.destroy);
|
||||
this.$scope.timeColumns = ['Time'];
|
||||
this.$scope.timeColumns = [];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -153,20 +153,32 @@ define(
|
||||
this.setup();
|
||||
};
|
||||
|
||||
TelemetryTableController.prototype.populateColumns = function (telemetryMetadata) {
|
||||
this.table.populateColumns(telemetryMetadata);
|
||||
|
||||
//Identify time columns
|
||||
telemetryMetadata.forEach(function (metadatum) {
|
||||
//Push domains first
|
||||
(metadatum.domains || []).forEach(function (domainMetadata) {
|
||||
this.timeColumns.push(domainMetadata.name);
|
||||
}.bind(this));
|
||||
}.bind(this));
|
||||
};
|
||||
|
||||
/**
|
||||
* Setup table columns based on domain object metadata
|
||||
*/
|
||||
TelemetryTableController.prototype.setup = function () {
|
||||
var handle = this.handle,
|
||||
table = this.table,
|
||||
self = this;
|
||||
|
||||
if (handle) {
|
||||
this.timeColumns = [];
|
||||
handle.promiseTelemetryObjects().then(function () {
|
||||
self.$scope.headers = [];
|
||||
self.$scope.rows = [];
|
||||
table.populateColumns(handle.getMetadata());
|
||||
|
||||
self.populateColumns(handle.getMetadata());
|
||||
self.filterColumns();
|
||||
|
||||
// When table column configuration changes, (due to being
|
||||
|
Loading…
Reference in New Issue
Block a user