mirror of
https://github.com/nasa/openmct.git
synced 2025-06-17 14:48:13 +00:00
fixing implementation for telemetry view items in display layout
This commit is contained in:
@ -515,11 +515,14 @@ define(['lodash'], function (_) {
|
|||||||
|
|
||||||
function getToggleUnitsButton(selectedParent, selection) {
|
function getToggleUnitsButton(selectedParent, selection) {
|
||||||
let applicableItems = getAllOfType(selection, 'telemetry-view');
|
let applicableItems = getAllOfType(selection, 'telemetry-view');
|
||||||
|
applicableItems = unitsOnly(applicableItems);
|
||||||
|
if(!applicableItems.length) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
control: "toggle-button",
|
control: "toggle-button",
|
||||||
domainObject: selectedParent,
|
domainObject: selectedParent,
|
||||||
applicableSelectedItems: applicableItems,
|
applicableSelectedItems: applicableItems,
|
||||||
contextMethod: 'toggleUnits',
|
|
||||||
property: function (selectionPath) {
|
property: function (selectionPath) {
|
||||||
return getPath(selectionPath) + '.showUnits';
|
return getPath(selectionPath) + '.showUnits';
|
||||||
},
|
},
|
||||||
@ -538,6 +541,20 @@ define(['lodash'], function (_) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
console.log('hasUnits', hasUnits);
|
||||||
|
return hasUnits > 0;
|
||||||
|
});
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
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,
|
||||||
@ -683,7 +700,10 @@ define(['lodash'], function (_) {
|
|||||||
toolbar.viewSwitcher = [getViewSwitcherMenu(selectedParent, selectionPath, selectedObjects)];
|
toolbar.viewSwitcher = [getViewSwitcherMenu(selectedParent, selectionPath, selectedObjects)];
|
||||||
}
|
}
|
||||||
if (toolbar['unit-toggle'].length === 0) {
|
if (toolbar['unit-toggle'].length === 0) {
|
||||||
toolbar['unit-toggle'] = [getToggleUnitsButton(selectedParent, selectedObjects)];
|
let toggleUnitsButton = getToggleUnitsButton(selectedParent, selectedObjects);
|
||||||
|
if(toggleUnitsButton) {
|
||||||
|
toolbar['unit-toggle'] = [toggleUnitsButton];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (layoutItem.type === 'text-view') {
|
} else if (layoutItem.type === 'text-view') {
|
||||||
if (toolbar['text-style'].length === 0) {
|
if (toolbar['text-style'].length === 0) {
|
||||||
|
@ -59,7 +59,7 @@
|
|||||||
<div class="c-telemetry-view__value-text">
|
<div class="c-telemetry-view__value-text">
|
||||||
{{ telemetryValue }}
|
{{ telemetryValue }}
|
||||||
<span
|
<span
|
||||||
v-if="unit && showUnits"
|
v-if="unit && item.showUnits"
|
||||||
class="c-telemetry-view__value-text__unit"
|
class="c-telemetry-view__value-text__unit"
|
||||||
>
|
>
|
||||||
{{ unit }}
|
{{ unit }}
|
||||||
@ -129,8 +129,7 @@ export default {
|
|||||||
datum: undefined,
|
datum: undefined,
|
||||||
formats: undefined,
|
formats: undefined,
|
||||||
domainObject: undefined,
|
domainObject: undefined,
|
||||||
currentObjectPath: undefined,
|
currentObjectPath: undefined
|
||||||
showUnits: true
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@ -279,9 +278,6 @@ 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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -231,13 +231,7 @@ export default {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
if(item.contextMethod) {
|
if (item.applicableSelectedItems) {
|
||||||
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);
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user