mirror of
https://github.com/nasa/openmct.git
synced 2025-06-16 14:18:16 +00:00
[Telemetry Tables][Plots] Display units where applicable (#3198)
* added unit columns in telemetry tables * added unit column hiding in telemetry tables, added units to lad tables and sets * added units to plots and plot legends
This commit is contained in:
@ -134,6 +134,14 @@ define(['lodash'], function (_) {
|
||||
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) {
|
||||
return selection.filter(selectionPath => {
|
||||
let type = selectionPath[0].context.layoutItem.type;
|
||||
@ -510,6 +518,50 @@ define(['lodash'], function (_) {
|
||||
return allTelemetry;
|
||||
}
|
||||
|
||||
function getToggleUnitsButton(selectedParent, selection) {
|
||||
let applicableItems = getAllOfType(selection, 'telemetry-view');
|
||||
applicableItems = unitsOnly(applicableItems);
|
||||
if (!applicableItems.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
return {
|
||||
control: "toggle-button",
|
||||
domainObject: selectedParent,
|
||||
applicableSelectedItems: applicableItems,
|
||||
property: function (selectionPath) {
|
||||
return getPath(selectionPath) + '.showUnits';
|
||||
},
|
||||
options: [
|
||||
{
|
||||
value: true,
|
||||
icon: 'icon-eye-open',
|
||||
title: "Show units"
|
||||
},
|
||||
{
|
||||
value: false,
|
||||
icon: 'icon-eye-disabled',
|
||||
title: "Hide units"
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
function unitsOnly(items) {
|
||||
let results = items.filter((item) => {
|
||||
let currentItem = item[0];
|
||||
let metadata = this.openmct.telemetry.getMetadata(currentItem.context.item);
|
||||
let hasUnits = metadata
|
||||
.valueMetadatas
|
||||
.filter((metadatum) => metadatum.unit)
|
||||
.length;
|
||||
|
||||
return hasUnits > 0;
|
||||
});
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
function getViewSwitcherMenu(selectedParent, selectionPath, selection) {
|
||||
if (selection.length === 1) {
|
||||
let displayLayoutContext = selectionPath[1].context,
|
||||
@ -594,6 +646,7 @@ define(['lodash'], function (_) {
|
||||
'text-style': [],
|
||||
'position': [],
|
||||
'duplicate': [],
|
||||
'unit-toggle': [],
|
||||
'remove': []
|
||||
};
|
||||
|
||||
@ -663,6 +716,13 @@ define(['lodash'], function (_) {
|
||||
if (toolbar.viewSwitcher.length === 0) {
|
||||
toolbar.viewSwitcher = [getViewSwitcherMenu(selectedParent, selectionPath, selectedObjects)];
|
||||
}
|
||||
|
||||
if (toolbar['unit-toggle'].length === 0) {
|
||||
let toggleUnitsButton = getToggleUnitsButton(selectedParent, selectedObjects);
|
||||
if (toggleUnitsButton) {
|
||||
toolbar['unit-toggle'] = [toggleUnitsButton];
|
||||
}
|
||||
}
|
||||
} else if (layoutItem.type === 'text-view') {
|
||||
if (toolbar['text-style'].length === 0) {
|
||||
toolbar['text-style'] = [
|
||||
|
Reference in New Issue
Block a user