Skip to content

Commit 70c4ce2

Browse files
committed
Added support for clicking row to set TOI
1 parent b995a8b commit 70c4ce2

File tree

6 files changed

+76
-22
lines changed

6 files changed

+76
-22
lines changed

Diff for: platform/features/conductor-v2/conductor/res/templates/time-conductor.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@
105105
ng-class="{ 'pinned': toi.pinned, 'val-to-right': toi.left < 20 }"
106106
ng-style="{'left': toi.left + '%'}">
107107
<div class="l-toi">
108-
<a class="t-button-unpin icon-button" ng-click="toi.pinned = false"></a>
108+
<a class="t-button-unpin icon-button"
109+
ng-click="toi.dismiss()"></a>
109110
<span class="l-toi-val">{{toi.toiText}}</span>
110111
</div>
111112
</div>

Diff for: platform/features/conductor-v2/conductor/src/ui/ConductorTOIController.js

+4
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ define(
9494
}
9595
};
9696

97+
ConductorTOIController.prototype.dismiss = function () {
98+
this.conductor.timeOfInterest(undefined);
99+
};
100+
97101
ConductorTOIController.prototype.resize = function () {
98102
//Do something?
99103
};

Diff for: platform/features/table/res/templates/historical-table.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
ng-class="{'loading': loading}">
33
<mct-table
44
headers="headers"
5-
time-columns="timeColumns"
5+
time-columns="tableController.timeColumns"
66
rows="rows"
77
enableFilter="true"
88
enableSort="true"

Diff for: platform/features/table/res/templates/mct-table.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
<!--ng-click="dummyUnpin()" -->
5454
<tr ng-repeat="visibleRow in visibleRows track by visibleRow.rowIndex"
5555
ng-class="{ 'l-toi pinned': visibleRow.rowIndex === toiRowIndex }"
56-
ng-click="table.onRowClick($event, visibleRow.contents)"
56+
ng-click="table.onRowClick($event, visibleRow.rowIndex)"
5757
ng-style="{
5858
top: visibleRow.offsetY + 'px',
5959
}">

Diff for: platform/features/table/src/controllers/MCTTableController.js

+53-16
Original file line numberDiff line numberDiff line change
@@ -103,24 +103,29 @@ define(
103103
*/
104104
$scope.resize = this.setElementSizes.bind(this);
105105

106-
107106
// Time conductor integration
108-
if (this.$scope.timeColumns) {
109-
this.conductor.on('timeSystem', this.changeTimeSystem);
110-
this.conductor.on('timeOfInterest', this.setTimeOfInterest);
111-
$scope.$on('$destroy', function () {
112-
this.conductor.off('timeSystem', this.changeTimeSystem);
113-
this.conductor.off('timeOfInterest', this.setTimeOfInterest);
114-
}.bind(this));
115-
116-
// If time system defined, set initially
117-
if (conductor.timeSystem()) {
118-
this.changeTimeSystem(conductor.timeSystem());
107+
$scope.$watch("timeColumns", function (timeColumns){
108+
if (timeColumns) {
109+
this.destroyConductorListeners();
110+
111+
this.conductor.on('timeSystem', this.changeTimeSystem);
112+
this.conductor.on('timeOfInterest', this.setTimeOfInterest);
113+
114+
// If time system defined, set initially
115+
if (conductor.timeSystem()) {
116+
this.changeTimeSystem(conductor.timeSystem());
117+
}
119118
}
120-
}
119+
}.bind(this));
121120

121+
$scope.$on('$destroy', this.destroyConductorListeners);
122122
}
123123

124+
MCTTableController.prototype.destroyConductorListeners = function () {
125+
this.conductor.off('timeSystem', this.changeTimeSystem);
126+
this.conductor.off('timeOfInterest', this.setTimeOfInterest);
127+
};
128+
124129
MCTTableController.prototype.changeTimeSystem = function () {
125130
var format = this.conductor.timeSystem().formats()[0];
126131
this.toiFormatter = this.formatService.getFormat(format);
@@ -558,18 +563,50 @@ define(
558563
return rowsToFilter.filter(matchRow.bind(null, filters));
559564
};
560565

566+
MCTTableController.prototype.scrollToRow = function (displayRowIndex) {
567+
568+
var visible = this.$scope.visibleRows.reduce(function (exists, row) {
569+
return exists || (row.rowIndex === displayRowIndex)
570+
}, false);
571+
572+
if (!visible) {
573+
var scrollTop = displayRowIndex * this.$scope.rowHeight
574+
+ this.$scope.headerHeight
575+
- (this.scrollable[0].offsetHeight / 2);
576+
this.scrollable[0].scrollTop = scrollTop;
577+
this.setVisibleRows();
578+
}
579+
};
580+
561581
/**
562582
* Update rows with new data. If filtering is enabled, rows
563583
* will be sorted before display.
564584
*/
565585
MCTTableController.prototype.setTimeOfInterest = function (newTOI) {
566-
if (this.$scope.timeColumns.indexOf(this.$scope.sortColumn) !== -1) {
586+
this.$scope.toiRowIndex = -1;
587+
if (this.$scope.timeColumns.indexOf(this.$scope.sortColumn) !== -1
588+
&& newTOI
589+
&& this.$scope.displayRows.length > 0) {
567590
var formattedTOI = this.toiFormatter.format(newTOI);
568591
var rowsLength = this.$scope.displayRows.length;
569592
// searchElement, min, max
570593
this.$scope.toiRowIndex = this.binarySearch(this.$scope.displayRows, formattedTOI, 0, rowsLength);
571-
} else {
572-
this.$scope.toiRowIndex = -1;
594+
this.scrollToRow(this.$scope.toiRowIndex);
595+
}
596+
};
597+
598+
MCTTableController.prototype.onRowClick = function (event, rowIndex) {
599+
if (this.$scope.timeColumns.indexOf(this.$scope.sortColumn) !== -1) {
600+
if (rowIndex === this.$scope.toiRowIndex) {
601+
this.conductor.timeOfInterest(undefined);
602+
} else {
603+
var selectedTime = this.$scope.displayRows[rowIndex][this.$scope.sortColumn].text;
604+
if (selectedTime
605+
&& this.toiFormatter.validate(selectedTime)
606+
&& event.altKey) {
607+
this.conductor.timeOfInterest(this.toiFormatter.parse(selectedTime));
608+
}
609+
}
573610
}
574611
};
575612

Diff for: platform/features/table/src/controllers/TelemetryTableController.js

+15-3
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ define(
6969

7070
// Unsubscribe when the plot is destroyed
7171
this.$scope.$on("$destroy", this.destroy);
72-
this.$scope.timeColumns = ['Time'];
72+
this.$scope.timeColumns = [];
7373
}
7474

7575
/**
@@ -153,20 +153,32 @@ define(
153153
this.setup();
154154
};
155155

156+
TelemetryTableController.prototype.populateColumns = function (telemetryMetadata) {
157+
this.table.populateColumns(telemetryMetadata);
158+
159+
//Identify time columns
160+
telemetryMetadata.forEach(function (metadatum) {
161+
//Push domains first
162+
(metadatum.domains || []).forEach(function (domainMetadata) {
163+
this.timeColumns.push(domainMetadata.name);
164+
}.bind(this));
165+
}.bind(this));
166+
};
167+
156168
/**
157169
* Setup table columns based on domain object metadata
158170
*/
159171
TelemetryTableController.prototype.setup = function () {
160172
var handle = this.handle,
161-
table = this.table,
162173
self = this;
163174

164175
if (handle) {
176+
this.timeColumns = [];
165177
handle.promiseTelemetryObjects().then(function () {
166178
self.$scope.headers = [];
167179
self.$scope.rows = [];
168-
table.populateColumns(handle.getMetadata());
169180

181+
self.populateColumns(handle.getMetadata());
170182
self.filterColumns();
171183

172184
// When table column configuration changes, (due to being

0 commit comments

Comments
 (0)