mirror of
https://github.com/nasa/openmct.git
synced 2024-12-25 15:51:04 +00:00
unit coluns in telem tables, need to add config options for those columns
This commit is contained in:
parent
0d9558b891
commit
d7c266d70f
@ -41,6 +41,7 @@ define([
|
|||||||
{
|
{
|
||||||
key: "sin",
|
key: "sin",
|
||||||
name: "Sine",
|
name: "Sine",
|
||||||
|
unit: "Hz",
|
||||||
formatString: '%0.2f',
|
formatString: '%0.2f',
|
||||||
hints: {
|
hints: {
|
||||||
range: 1
|
range: 1
|
||||||
@ -49,6 +50,7 @@ define([
|
|||||||
{
|
{
|
||||||
key: "cos",
|
key: "cos",
|
||||||
name: "Cosine",
|
name: "Cosine",
|
||||||
|
unit: "deg",
|
||||||
formatString: '%0.2f',
|
formatString: '%0.2f',
|
||||||
hints: {
|
hints: {
|
||||||
range: 2
|
range: 2
|
||||||
|
@ -134,6 +134,13 @@ define(['lodash'], function (_) {
|
|||||||
return `configuration.items[${selectionPath[0].context.index}]`;
|
return `configuration.items[${selectionPath[0].context.index}]`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getAllOfType(selection, specificType) {
|
||||||
|
return selection.filter(selectionPath => {
|
||||||
|
let type = selectionPath[0].context.layoutItem.type;
|
||||||
|
return type === specificType;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function getAllTypes(selection) {
|
function getAllTypes(selection) {
|
||||||
return selection.filter(selectionPath => {
|
return selection.filter(selectionPath => {
|
||||||
let type = selectionPath[0].context.layoutItem.type;
|
let type = selectionPath[0].context.layoutItem.type;
|
||||||
@ -506,6 +513,32 @@ define(['lodash'], function (_) {
|
|||||||
return allTelemetry;
|
return allTelemetry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getToggleUnitsButton(selectedParent, selection) {
|
||||||
|
let applicableItems = getAllOfType(selection, 'telemetry-view');
|
||||||
|
return {
|
||||||
|
control: "toggle-button",
|
||||||
|
domainObject: selectedParent,
|
||||||
|
applicableSelectedItems: applicableItems,
|
||||||
|
contextMethod: 'toggleUnits',
|
||||||
|
property: function (selectionPath) {
|
||||||
|
console.log('path', selectionPath, getPath(selectionPath) + '.showUnits');
|
||||||
|
return getPath(selectionPath) + '.showUnits';
|
||||||
|
},
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
value: true,
|
||||||
|
icon: 'icon-eye-open',
|
||||||
|
title: "Show units"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: false,
|
||||||
|
icon: 'icon-eye-disabled',
|
||||||
|
title: "Hide units"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
function getViewSwitcherMenu(selectedParent, selectionPath, selection) {
|
function getViewSwitcherMenu(selectedParent, selectionPath, selection) {
|
||||||
if (selection.length === 1) {
|
if (selection.length === 1) {
|
||||||
let displayLayoutContext = selectionPath[1].context,
|
let displayLayoutContext = selectionPath[1].context,
|
||||||
@ -589,6 +622,7 @@ define(['lodash'], function (_) {
|
|||||||
'text-style': [],
|
'text-style': [],
|
||||||
'position': [],
|
'position': [],
|
||||||
'duplicate': [],
|
'duplicate': [],
|
||||||
|
'unit-toggle': [],
|
||||||
'remove': []
|
'remove': []
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -649,6 +683,9 @@ define(['lodash'], function (_) {
|
|||||||
if (toolbar.viewSwitcher.length === 0) {
|
if (toolbar.viewSwitcher.length === 0) {
|
||||||
toolbar.viewSwitcher = [getViewSwitcherMenu(selectedParent, selectionPath, selectedObjects)];
|
toolbar.viewSwitcher = [getViewSwitcherMenu(selectedParent, selectionPath, selectedObjects)];
|
||||||
}
|
}
|
||||||
|
if (toolbar['unit-toggle'].length === 0) {
|
||||||
|
toolbar['unit-toggle'] = [getToggleUnitsButton(selectedParent, selectedObjects)];
|
||||||
|
}
|
||||||
} else if (layoutItem.type === 'text-view') {
|
} else if (layoutItem.type === 'text-view') {
|
||||||
if (toolbar['text-style'].length === 0) {
|
if (toolbar['text-style'].length === 0) {
|
||||||
toolbar['text-style'] = [
|
toolbar['text-style'] = [
|
||||||
|
@ -52,6 +52,12 @@
|
|||||||
>
|
>
|
||||||
<div class="c-telemetry-view__value-text">
|
<div class="c-telemetry-view__value-text">
|
||||||
{{ telemetryValue }}
|
{{ telemetryValue }}
|
||||||
|
<span
|
||||||
|
v-if="unit && showUnits"
|
||||||
|
class="c-telemetry-view__value-text__unit"
|
||||||
|
>
|
||||||
|
{{ unit }}
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -117,7 +123,8 @@ export default {
|
|||||||
datum: undefined,
|
datum: undefined,
|
||||||
formats: undefined,
|
formats: undefined,
|
||||||
domainObject: undefined,
|
domainObject: undefined,
|
||||||
currentObjectPath: undefined
|
currentObjectPath: undefined,
|
||||||
|
showUnits: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@ -129,6 +136,11 @@ export default {
|
|||||||
let displayMode = this.item.displayMode;
|
let displayMode = this.item.displayMode;
|
||||||
return displayMode === 'all' || displayMode === 'value';
|
return displayMode === 'all' || displayMode === 'value';
|
||||||
},
|
},
|
||||||
|
unit() {
|
||||||
|
let value = this.item.value,
|
||||||
|
unit = this.metadata.value(value).unit;
|
||||||
|
return unit;
|
||||||
|
},
|
||||||
styleObject() {
|
styleObject() {
|
||||||
return Object.assign({}, {
|
return Object.assign({}, {
|
||||||
fontSize: this.item.size
|
fontSize: this.item.size
|
||||||
@ -248,7 +260,9 @@ export default {
|
|||||||
item: domainObject,
|
item: domainObject,
|
||||||
layoutItem: this.item,
|
layoutItem: this.item,
|
||||||
index: this.index,
|
index: this.index,
|
||||||
updateTelemetryFormat: this.updateTelemetryFormat
|
updateTelemetryFormat: this.updateTelemetryFormat,
|
||||||
|
toggleUnits: this.toggleUnits,
|
||||||
|
showUnits: this.showUnits
|
||||||
};
|
};
|
||||||
this.removeSelectable = this.openmct.selection.selectable(
|
this.removeSelectable = this.openmct.selection.selectable(
|
||||||
this.$el, this.context, this.immediatelySelect || this.initSelect);
|
this.$el, this.context, this.immediatelySelect || this.initSelect);
|
||||||
@ -259,6 +273,9 @@ export default {
|
|||||||
},
|
},
|
||||||
showContextMenu(event) {
|
showContextMenu(event) {
|
||||||
this.openmct.contextMenu._showContextMenuForObjectPath(this.currentObjectPath, event.x, event.y, CONTEXT_MENU_ACTIONS);
|
this.openmct.contextMenu._showContextMenuForObjectPath(this.currentObjectPath, event.x, event.y, CONTEXT_MENU_ACTIONS);
|
||||||
|
},
|
||||||
|
toggleUnits(show) {
|
||||||
|
this.showUnits = show;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@ define([
|
|||||||
'./collections/FilteredTableRowCollection',
|
'./collections/FilteredTableRowCollection',
|
||||||
'./TelemetryTableRow',
|
'./TelemetryTableRow',
|
||||||
'./TelemetryTableColumn',
|
'./TelemetryTableColumn',
|
||||||
|
'./TelemetryTableUnitColumn',
|
||||||
'./TelemetryTableConfiguration'
|
'./TelemetryTableConfiguration'
|
||||||
], function (
|
], function (
|
||||||
EventEmitter,
|
EventEmitter,
|
||||||
@ -35,6 +36,7 @@ define([
|
|||||||
FilteredTableRowCollection,
|
FilteredTableRowCollection,
|
||||||
TelemetryTableRow,
|
TelemetryTableRow,
|
||||||
TelemetryTableColumn,
|
TelemetryTableColumn,
|
||||||
|
TelemetryTableUnitColumn,
|
||||||
TelemetryTableConfiguration
|
TelemetryTableConfiguration
|
||||||
) {
|
) {
|
||||||
class TelemetryTable extends EventEmitter {
|
class TelemetryTable extends EventEmitter {
|
||||||
@ -206,10 +208,14 @@ define([
|
|||||||
|
|
||||||
addColumnsForObject(telemetryObject) {
|
addColumnsForObject(telemetryObject) {
|
||||||
let metadataValues = this.openmct.telemetry.getMetadata(telemetryObject).values();
|
let metadataValues = this.openmct.telemetry.getMetadata(telemetryObject).values();
|
||||||
|
|
||||||
metadataValues.forEach(metadatum => {
|
metadataValues.forEach(metadatum => {
|
||||||
let column = this.createColumn(metadatum);
|
let column = this.createColumn(metadatum);
|
||||||
this.configuration.addSingleColumnForObject(telemetryObject, column);
|
this.configuration.addSingleColumnForObject(telemetryObject, column);
|
||||||
|
// add units column if available
|
||||||
|
if(metadatum.unit !== undefined) {
|
||||||
|
let unitColumn = this.createUnitColumn(metadatum);
|
||||||
|
this.configuration.addSingleColumnForObject(telemetryObject, unitColumn);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -217,6 +223,47 @@ define([
|
|||||||
return new TelemetryTableColumn(this.openmct, metadatum);
|
return new TelemetryTableColumn(this.openmct, metadatum);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
createUnitColumn(metadatum) {
|
||||||
|
return new TelemetryTableUnitColumn(this.openmct, metadatum);
|
||||||
|
// let unitColumn = {
|
||||||
|
// isUnit: true,
|
||||||
|
// metadatum,
|
||||||
|
// titleValue: metadatum.name + ' Unit',
|
||||||
|
// selectable: false,
|
||||||
|
// formatter: {
|
||||||
|
// format(telemetryDatum) {
|
||||||
|
// return metadatum.unit;
|
||||||
|
// },
|
||||||
|
// parse(telemetryDatum) {
|
||||||
|
// return metadatum.unit;
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
// getKey() {
|
||||||
|
// return this.metadatum.key + '-unit';
|
||||||
|
// },
|
||||||
|
// getTitle() {
|
||||||
|
// return this.titleValue;
|
||||||
|
// },
|
||||||
|
// getMetadatum() {
|
||||||
|
// return this.metadatum;
|
||||||
|
// },
|
||||||
|
// hasValueForDatum(telemetryDatum) {
|
||||||
|
// return telemetryDatum.hasOwnProperty(this.metadatum.source);
|
||||||
|
// },
|
||||||
|
// getRawValue(telemetryDatum) {
|
||||||
|
// return this.metadatum.unit;
|
||||||
|
// },
|
||||||
|
// getFormattedValue(telemetryDatum) {
|
||||||
|
// return this.formatter.format(telemetryDatum);
|
||||||
|
// },
|
||||||
|
// getParsedValue(telemetryDatum) {
|
||||||
|
// return this.formatter.parse(telemetryDatum);
|
||||||
|
// }
|
||||||
|
// };
|
||||||
|
// return unitColumn;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
subscribeTo(telemetryObject) {
|
subscribeTo(telemetryObject) {
|
||||||
let subscribeOptions = this.buildOptionsFromConfiguration(telemetryObject);
|
let subscribeOptions = this.buildOptionsFromConfiguration(telemetryObject);
|
||||||
let keyString = this.openmct.objects.makeKeyString(telemetryObject.identifier);
|
let keyString = this.openmct.objects.makeKeyString(telemetryObject.identifier);
|
||||||
|
@ -65,8 +65,10 @@ define([], function () {
|
|||||||
getCellLimitClasses() {
|
getCellLimitClasses() {
|
||||||
if (!this.cellLimitClasses) {
|
if (!this.cellLimitClasses) {
|
||||||
this.cellLimitClasses = Object.values(this.columns).reduce((alarmStateMap, column) => {
|
this.cellLimitClasses = Object.values(this.columns).reduce((alarmStateMap, column) => {
|
||||||
let limitEvaluation = this.limitEvaluator.evaluate(this.datum, column.getMetadatum());
|
if(!column.isUnit) {
|
||||||
alarmStateMap[column.getKey()] = limitEvaluation && limitEvaluation.cssClass;
|
let limitEvaluation = this.limitEvaluator.evaluate(this.datum, column.getMetadatum());
|
||||||
|
alarmStateMap[column.getKey()] = limitEvaluation && limitEvaluation.cssClass;
|
||||||
|
}
|
||||||
|
|
||||||
return alarmStateMap;
|
return alarmStateMap;
|
||||||
}, {});
|
}, {});
|
||||||
|
64
src/plugins/telemetryTable/TelemetryTableUnitColumn.js
Normal file
64
src/plugins/telemetryTable/TelemetryTableUnitColumn.js
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* 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.
|
||||||
|
*****************************************************************************/
|
||||||
|
define([
|
||||||
|
'./TelemetryTableColumn.js'
|
||||||
|
], function (
|
||||||
|
TelemetryTableColumn
|
||||||
|
) {
|
||||||
|
class TelemetryTableUnitColumn extends TelemetryTableColumn {
|
||||||
|
constructor(openmct, metadatum) {
|
||||||
|
super(openmct, metadatum);
|
||||||
|
this.isUnit = true;
|
||||||
|
this.titleValue += ' Unit';
|
||||||
|
this.formatter = {
|
||||||
|
format(datum) {
|
||||||
|
return metadatum.unit;
|
||||||
|
},
|
||||||
|
parse(datum) {
|
||||||
|
return metadatum.unit;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
getKey() {
|
||||||
|
return this.metadatum.key + '-unit';
|
||||||
|
}
|
||||||
|
|
||||||
|
getTitle() {
|
||||||
|
return this.metadatum.name + ' Unit';
|
||||||
|
}
|
||||||
|
|
||||||
|
getRawValue(telemetryDatum) {
|
||||||
|
return this.metadatum.unit;
|
||||||
|
}
|
||||||
|
|
||||||
|
getFormattedValue(telemetryDatum) {
|
||||||
|
return this.formatter.format(telemetryDatum);
|
||||||
|
}
|
||||||
|
|
||||||
|
getParsedValue(telemetryDatum) {
|
||||||
|
return this.formatter.parse(telemetryDatum);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return TelemetryTableUnitColumn;
|
||||||
|
});
|
@ -80,6 +80,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
console.log('table-config mounted');
|
||||||
this.unlisteners = [];
|
this.unlisteners = [];
|
||||||
this.openmct.editor.on('isEditing', this.toggleEdit);
|
this.openmct.editor.on('isEditing', this.toggleEdit);
|
||||||
let compositionCollection = this.openmct.composition.get(this.tableConfiguration.domainObject);
|
let compositionCollection = this.openmct.composition.get(this.tableConfiguration.domainObject);
|
||||||
@ -131,7 +132,7 @@ export default {
|
|||||||
},
|
},
|
||||||
addColumnsForObject(telemetryObject) {
|
addColumnsForObject(telemetryObject) {
|
||||||
let metadataValues = this.openmct.telemetry.getMetadata(telemetryObject).values();
|
let metadataValues = this.openmct.telemetry.getMetadata(telemetryObject).values();
|
||||||
|
console.log(metadataValues);
|
||||||
metadataValues.forEach(metadatum => {
|
metadataValues.forEach(metadatum => {
|
||||||
let column = new TelemetryTableColumn(this.openmct, metadatum);
|
let column = new TelemetryTableColumn(this.openmct, metadatum);
|
||||||
this.tableConfiguration.addSingleColumnForObject(telemetryObject, column);
|
this.tableConfiguration.addSingleColumnForObject(telemetryObject, column);
|
||||||
|
@ -134,7 +134,6 @@ export default {
|
|||||||
value = this.getFormValue(domainObject, toolbarItem);
|
value = this.getFormValue(domainObject, toolbarItem);
|
||||||
} else {
|
} else {
|
||||||
let values = [];
|
let values = [];
|
||||||
|
|
||||||
if (applicableSelectedItems) {
|
if (applicableSelectedItems) {
|
||||||
applicableSelectedItems.forEach(selectionPath => {
|
applicableSelectedItems.forEach(selectionPath => {
|
||||||
values.push(this.getPropertyValue(domainObject, toolbarItem, selectionPath));
|
values.push(this.getPropertyValue(domainObject, toolbarItem, selectionPath));
|
||||||
@ -160,7 +159,6 @@ export default {
|
|||||||
if (formKey) {
|
if (formKey) {
|
||||||
property = property + "." + formKey;
|
property = property + "." + formKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
return _.get(domainObject, property);
|
return _.get(domainObject, property);
|
||||||
},
|
},
|
||||||
getFormValue(domainObject, toolbarItem) {
|
getFormValue(domainObject, toolbarItem) {
|
||||||
@ -204,7 +202,6 @@ export default {
|
|||||||
},
|
},
|
||||||
updateObjectValue(value, item) {
|
updateObjectValue(value, item) {
|
||||||
let changedItemId = this.openmct.objects.makeKeyString(item.domainObject.identifier);
|
let changedItemId = this.openmct.objects.makeKeyString(item.domainObject.identifier);
|
||||||
|
|
||||||
this.structure = this.structure.map(toolbarItem => {
|
this.structure = this.structure.map(toolbarItem => {
|
||||||
if (toolbarItem.domainObject) {
|
if (toolbarItem.domainObject) {
|
||||||
let id = this.openmct.objects.makeKeyString(toolbarItem.domainObject.identifier);
|
let id = this.openmct.objects.makeKeyString(toolbarItem.domainObject.identifier);
|
||||||
@ -234,7 +231,13 @@ export default {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
if (item.applicableSelectedItems) {
|
if(item.contextMethod) {
|
||||||
|
let method = item.contextMethod;
|
||||||
|
item.applicableSelectedItems.forEach(selectionPath => {
|
||||||
|
this.mutateObject(item, value, selectionPath);
|
||||||
|
selectionPath[0].context[method](value);
|
||||||
|
});
|
||||||
|
} else if (item.applicableSelectedItems) {
|
||||||
item.applicableSelectedItems.forEach(selectionPath => {
|
item.applicableSelectedItems.forEach(selectionPath => {
|
||||||
this.mutateObject(item, value, selectionPath);
|
this.mutateObject(item, value, selectionPath);
|
||||||
});
|
});
|
||||||
@ -249,7 +252,6 @@ export default {
|
|||||||
if (formKey) {
|
if (formKey) {
|
||||||
property = property + "." + formKey;
|
property = property + "." + formKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.openmct.objects.mutate(item.domainObject, property, value);
|
this.openmct.objects.mutate(item.domainObject, property, value);
|
||||||
},
|
},
|
||||||
triggerMethod(item, event) {
|
triggerMethod(item, event) {
|
||||||
|
Loading…
Reference in New Issue
Block a user