add styles get interceptor for overlay plots

This commit is contained in:
Jamie V 2025-03-03 14:05:25 -08:00
parent c385c90395
commit 97ae8db9d1
4 changed files with 51 additions and 12 deletions

View File

@ -26,9 +26,11 @@ export default function conditionWidgetStylesInterceptor(openmct) {
return identifier.key === 'conditionWidget' && !domainObject.configuration?.objectStyles;
},
invoke: (identifier, domainObject) => {
domainObject.configuration = {
objectStyles: {}
};
if (!domainObject.configuration) {
domainObject.configuration = {};
}
domainObject.configuration.objectStyles = {};
openmct.objects.save(domainObject);

View File

@ -173,15 +173,6 @@ export default {
created() {
eventHelpers.extend(this);
this.imageExporter = new ImageExporter(this.openmct);
// Initialize objectStyles for overlay plot if it doesn't exist
if (
this.domainObject.type === 'telemetry.plot.overlay' &&
!this.domainObject.configuration.objectStyles
) {
this.domainObject.configuration.objectStyles = {};
}
this.loadComposition();
this.setupClockChangedEvent((domainObject) => {
this.triggerUnsubscribeFromStaleness(domainObject);

View File

@ -0,0 +1,43 @@
/*****************************************************************************
* Open MCT, Copyright (c) 2014-2024, 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.
*****************************************************************************/
export default function overlayPlotStylesInterceptor(openmct) {
return {
appliesTo: (identifier, domainObject) => {
return (
identifier.key === 'telemetry.plot.overlay' && !domainObject.configuration?.objectStyles
);
},
invoke: (identifier, domainObject) => {
if (!domainObject.configuration) {
domainObject.configuration = {};
}
domainObject.configuration.objectStyles = {};
openmct.objects.save(domainObject);
return domainObject;
},
priority: openmct.priority.DEFAULT
};
}

View File

@ -23,6 +23,7 @@ import PlotViewActions from './actions/ViewActions.js';
import PlotsInspectorViewProvider from './inspector/PlotsInspectorViewProvider.js';
import StackedPlotsInspectorViewProvider from './inspector/StackedPlotsInspectorViewProvider.js';
import OverlayPlotCompositionPolicy from './overlayPlot/OverlayPlotCompositionPolicy.js';
import overlayPlotStylesInterceptor from './overlayPlot/overlayPlotStylesInterceptor.js';
import OverlayPlotViewProvider from './overlayPlot/OverlayPlotViewProvider.js';
import PlotViewProvider from './PlotViewProvider.js';
import StackedPlotCompositionPolicy from './stackedPlot/StackedPlotCompositionPolicy.js';
@ -31,6 +32,8 @@ import StackedPlotViewProvider from './stackedPlot/StackedPlotViewProvider.js';
export default function () {
return function install(openmct) {
openmct.objects.addGetInterceptor(overlayPlotStylesInterceptor(openmct));
openmct.types.addType('telemetry.plot.overlay', {
key: 'telemetry.plot.overlay',
name: 'Overlay Plot',