From 70c4ce24e488580f3fba4c5db369674acd44b74f Mon Sep 17 00:00:00 2001 From: Henry Date: Fri, 7 Oct 2016 17:57:14 -0700 Subject: [PATCH] Added support for clicking row to set TOI --- .../res/templates/time-conductor.html | 3 +- .../src/ui/ConductorTOIController.js | 4 ++ .../table/res/templates/historical-table.html | 2 +- .../table/res/templates/mct-table.html | 2 +- .../src/controllers/MCTTableController.js | 69 ++++++++++++++----- .../controllers/TelemetryTableController.js | 18 ++++- 6 files changed, 76 insertions(+), 22 deletions(-) diff --git a/platform/features/conductor-v2/conductor/res/templates/time-conductor.html b/platform/features/conductor-v2/conductor/res/templates/time-conductor.html index 849b72d21dc..3cfcdca77e0 100644 --- a/platform/features/conductor-v2/conductor/res/templates/time-conductor.html +++ b/platform/features/conductor-v2/conductor/res/templates/time-conductor.html @@ -105,7 +105,8 @@ ng-class="{ 'pinned': toi.pinned, 'val-to-right': toi.left < 20 }" ng-style="{'left': toi.left + '%'}">
- + {{toi.toiText}}
diff --git a/platform/features/conductor-v2/conductor/src/ui/ConductorTOIController.js b/platform/features/conductor-v2/conductor/src/ui/ConductorTOIController.js index 61ba17cd109..ac9c77b7a00 100644 --- a/platform/features/conductor-v2/conductor/src/ui/ConductorTOIController.js +++ b/platform/features/conductor-v2/conductor/src/ui/ConductorTOIController.js @@ -94,6 +94,10 @@ define( } }; + ConductorTOIController.prototype.dismiss = function () { + this.conductor.timeOfInterest(undefined); + }; + ConductorTOIController.prototype.resize = function () { //Do something? }; diff --git a/platform/features/table/res/templates/historical-table.html b/platform/features/table/res/templates/historical-table.html index f0176d16494..5b93055df2c 100644 --- a/platform/features/table/res/templates/historical-table.html +++ b/platform/features/table/res/templates/historical-table.html @@ -2,7 +2,7 @@ ng-class="{'loading': loading}"> diff --git a/platform/features/table/src/controllers/MCTTableController.js b/platform/features/table/src/controllers/MCTTableController.js index 6e37e7e46a2..a8d6e0a3a06 100644 --- a/platform/features/table/src/controllers/MCTTableController.js +++ b/platform/features/table/src/controllers/MCTTableController.js @@ -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)); - - // If time system defined, set initially - if (conductor.timeSystem()) { - this.changeTimeSystem(conductor.timeSystem()); + $scope.$watch("timeColumns", function (timeColumns){ + if (timeColumns) { + this.destroyConductorListeners(); + + 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)); + } + } } }; diff --git a/platform/features/table/src/controllers/TelemetryTableController.js b/platform/features/table/src/controllers/TelemetryTableController.js index 1f105fb75d2..761f77483d3 100644 --- a/platform/features/table/src/controllers/TelemetryTableController.js +++ b/platform/features/table/src/controllers/TelemetryTableController.js @@ -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