diff --git a/src/plugins/telemetryTable/TelemetryTable.js b/src/plugins/telemetryTable/TelemetryTable.js index 6a4787a55d..9418f94f4a 100644 --- a/src/plugins/telemetryTable/TelemetryTable.js +++ b/src/plugins/telemetryTable/TelemetryTable.js @@ -26,6 +26,7 @@ define([ './collections/BoundedTableRowCollection', './collections/FilteredTableRowCollection', './TelemetryTableRow', + './TelemetryTableColumn', './TelemetryTableConfiguration' ], function ( EventEmitter, @@ -33,6 +34,7 @@ define([ BoundedTableRowCollection, FilteredTableRowCollection, TelemetryTableRow, + TelemetryTableColumn, TelemetryTableConfiguration ) { class TelemetryTable extends EventEmitter { @@ -94,8 +96,6 @@ define([ this.tableComposition.load().then((composition) => { composition = composition.filter(this.isTelemetryObject); - - this.configuration.addColumnsForAllObjects(composition); composition.forEach(this.addTelemetryObject); this.tableComposition.on('add', this.addTelemetryObject); @@ -105,7 +105,7 @@ define([ } addTelemetryObject(telemetryObject) { - this.configuration.addColumnsForObject(telemetryObject, true); + this.addColumnsForObject(telemetryObject, true); this.requestDataFor(telemetryObject); this.subscribeTo(telemetryObject); this.telemetryObjects.push(telemetryObject); @@ -132,6 +132,13 @@ define([ this.emit('object-removed', objectIdentifier); } + /** + * @private + */ + createRow(datum, columnMap, keyString, limitEvaluator) { + return new TelemetryTableRow(datum, columnMap, keyString, limitEvaluator); + } + requestDataFor(telemetryObject) { this.incrementOutstandingRequests(); let requestOptions = this.buildOptionsFromConfiguration(telemetryObject); @@ -145,7 +152,7 @@ define([ let columnMap = this.getColumnMapForObject(keyString); let limitEvaluator = this.openmct.telemetry.limitEvaluator(telemetryObject); - let telemetryRows = telemetryData.map(datum => new TelemetryTableRow(datum, columnMap, keyString, limitEvaluator)); + let telemetryRows = telemetryData.map(datum => this.createRow(datum, columnMap, keyString, limitEvaluator)); this.boundedRows.add(telemetryRows); }).finally(() => { this.decrementOutstandingRequests(); @@ -191,6 +198,19 @@ define([ }, {}); } + addColumnsForObject(telemetryObject) { + let metadataValues = this.openmct.telemetry.getMetadata(telemetryObject).values(); + + metadataValues.forEach(metadatum => { + let column = this.createColumn(metadatum); + this.configuration.addSingleColumnForObject(telemetryObject, column); + }); + } + + createColumn(metadatum) { + return new TelemetryTableColumn(this.openmct, metadatum); + } + subscribeTo(telemetryObject) { let subscribeOptions = this.buildOptionsFromConfiguration(telemetryObject); let keyString = this.openmct.objects.makeKeyString(telemetryObject.identifier); @@ -202,7 +222,7 @@ define([ if (!this.telemetryObjects.includes(telemetryObject)) { return; } - this.boundedRows.add(new TelemetryTableRow(datum, columnMap, keyString, limitEvaluator)); + this.boundedRows.add(this.createRow(datum, columnMap, keyString, limitEvaluator)); }, subscribeOptions); } diff --git a/src/plugins/telemetryTable/TelemetryTableConfiguration.js b/src/plugins/telemetryTable/TelemetryTableConfiguration.js index 6dadb31558..d2c81b8235 100644 --- a/src/plugins/telemetryTable/TelemetryTableConfiguration.js +++ b/src/plugins/telemetryTable/TelemetryTableConfiguration.js @@ -22,9 +22,8 @@ define([ 'lodash', - 'EventEmitter', - './TelemetryTableColumn' -], function (_, EventEmitter, TelemetryTableColumn) { + 'EventEmitter' +], function (_, EventEmitter) { class TelemetryTableConfiguration extends EventEmitter { constructor(domainObject, openmct) { @@ -34,7 +33,6 @@ define([ this.openmct = openmct; this.columns = {}; - this.addColumnsForObject = this.addColumnsForObject.bind(this); this.removeColumnsForObject = this.removeColumnsForObject.bind(this); this.objectMutated = this.objectMutated.bind(this); //Make copy of configuration, otherwise change detection is impossible if shared instance is being modified. @@ -48,6 +46,7 @@ define([ configuration.hiddenColumns = configuration.hiddenColumns || {}; configuration.columnWidths = configuration.columnWidths || {}; configuration.columnOrder = configuration.columnOrder || []; + configuration.cellFormat = configuration.cellFormat || {}; configuration.autosize = configuration.autosize === undefined ? true : configuration.autosize; return configuration; @@ -65,26 +64,18 @@ define([ //Synchronize domain object reference. Duplicate object otherwise change detection becomes impossible. this.domainObject = object; //Was it the configuration that changed? - if (!_.eq(object.configuration, this.oldConfiguration)) { + if (object.configuration !== undefined && !_.eq(object.configuration, this.oldConfiguration)) { //Make copy of configuration, otherwise change detection is impossible if shared instance is being modified. this.oldConfiguration = JSON.parse(JSON.stringify(this.getConfiguration())); this.emit('change', object.configuration); } } - addColumnsForAllObjects(objects) { - objects.forEach(object => this.addColumnsForObject(object, false)); - } - - addColumnsForObject(telemetryObject) { - let metadataValues = this.openmct.telemetry.getMetadata(telemetryObject).values(); + addSingleColumnForObject(telemetryObject, column, position) { let objectKeyString = this.openmct.objects.makeKeyString(telemetryObject.identifier); - this.columns[objectKeyString] = []; - - metadataValues.forEach(metadatum => { - let column = new TelemetryTableColumn(this.openmct, metadatum); - this.columns[objectKeyString].push(column); - }); + this.columns[objectKeyString] = this.columns[objectKeyString] || []; + position = position || this.columns[objectKeyString].length; + this.columns[objectKeyString].splice(position, 0, column); } removeColumnsForObject(objectIdentifier) { diff --git a/src/plugins/telemetryTable/TelemetryTableRow.js b/src/plugins/telemetryTable/TelemetryTableRow.js index 6cb6c22d3d..d60e1ef4b0 100644 --- a/src/plugins/telemetryTable/TelemetryTableRow.js +++ b/src/plugins/telemetryTable/TelemetryTableRow.js @@ -42,12 +42,19 @@ define([], function () { return column && column.getFormattedValue(this.datum[key]); } - getRowLimitClass() { - if (!this.rowLimitClass) { + getCellComponentName(key) { + let column = this.columns[key]; + return column && + column.getCellComponentName && + column.getCellComponentName(); + } + + getRowClass() { + if (!this.rowClass) { let limitEvaluation = this.limitEvaluator.evaluate(this.datum); - this.rowLimitClass = limitEvaluation && limitEvaluation.cssClass; + this.rowClass = limitEvaluation && limitEvaluation.cssClass; } - return this.rowLimitClass; + return this.rowClass; } getCellLimitClasses() { diff --git a/src/plugins/telemetryTable/TelemetryTableViewProvider.js b/src/plugins/telemetryTable/TelemetryTableViewProvider.js index 4314505982..76be4be39a 100644 --- a/src/plugins/telemetryTable/TelemetryTableViewProvider.js +++ b/src/plugins/telemetryTable/TelemetryTableViewProvider.js @@ -22,12 +22,10 @@ define([ './components/table.vue', - '../../exporters/CSVExporter', './TelemetryTable', 'vue' ], function ( TableComponent, - CSVExporter, TelemetryTable, Vue ) { @@ -51,7 +49,6 @@ define([ return domainObject.type === 'table'; }, view(domainObject) { - let csvExporter = new CSVExporter.default(); let table = new TelemetryTable(domainObject, openmct); let component; return { @@ -67,7 +64,6 @@ define([ }, provide: { openmct, - csvExporter, table }, el: element, diff --git a/src/plugins/telemetryTable/components/table-cell.vue b/src/plugins/telemetryTable/components/table-cell.vue new file mode 100644 index 0000000000..d2ca4bacae --- /dev/null +++ b/src/plugins/telemetryTable/components/table-cell.vue @@ -0,0 +1,44 @@ +/***************************************************************************** + * Open MCT, Copyright (c) 2014-2018, United States Government + * as represented by the Administrator of the National Aeronautics and Space + * Administration. All rights reserved. + * + * Open MCT is licensed under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * Open MCT includes source code licensed under additional open source + * licenses. See the Open Source Licenses file (LICENSES.md) included with + * this source code distribution or the Licensing information page available + * at runtime from the About dialog for additional information. + *****************************************************************************/ + + diff --git a/src/plugins/telemetryTable/components/table-configuration.vue b/src/plugins/telemetryTable/components/table-configuration.vue index 6181078396..0c3765306b 100644 --- a/src/plugins/telemetryTable/components/table-configuration.vue +++ b/src/plugins/telemetryTable/components/table-configuration.vue @@ -23,6 +23,8 @@ diff --git a/src/plugins/telemetryTable/components/table.vue b/src/plugins/telemetryTable/components/table.vue index 278cf441cd..c0305e04d5 100644 --- a/src/plugins/telemetryTable/components/table.vue +++ b/src/plugins/telemetryTable/components/table.vue @@ -22,7 +22,8 @@