Display layout fixes 062320 (#3111)

* fix for persisting new domainObject

* convert stacked plot to alpha
This commit is contained in:
Deep Tailor
2020-06-25 11:03:31 -07:00
committed by GitHub
parent 8e54b8a819
commit 3748927e87
3 changed files with 75 additions and 34 deletions

View File

@ -1,6 +1,6 @@
# Open MCT License # Open MCT License
Open MCT, Copyright (c) 2014-2019, United States Government as represented by the Administrator of the National Aeronautics and Space Administration. All rights reserved. Open MCT, Copyright (c) 2014-2020, 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. 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.

View File

@ -73,7 +73,7 @@ define(['lodash'], function (_) {
] ]
} }
}, },
viewTypes = { VIEW_TYPES = {
'telemetry-view': { 'telemetry-view': {
value: 'telemetry-view', value: 'telemetry-view',
name: 'Alphanumeric', name: 'Alphanumeric',
@ -95,28 +95,34 @@ define(['lodash'], function (_) {
class: 'icon-tabular-realtime' class: 'icon-tabular-realtime'
} }
}, },
applicableViews = { APPLICABLE_VIEWS = {
'telemetry-view': [ 'telemetry-view': [
viewTypes['telemetry.plot.overlay'], VIEW_TYPES['telemetry.plot.overlay'],
viewTypes.table VIEW_TYPES['telemetry.plot.stacked'],
VIEW_TYPES.table
], ],
'telemetry.plot.overlay': [ 'telemetry.plot.overlay': [
viewTypes['telemetry.plot.stacked'], VIEW_TYPES['telemetry.plot.stacked'],
viewTypes.table, VIEW_TYPES.table,
viewTypes['telemetry-view'] VIEW_TYPES['telemetry-view']
],
'telemetry.plot.stacked': [
VIEW_TYPES['telemetry.plot.overlay'],
VIEW_TYPES.table,
VIEW_TYPES['telemetry-view']
], ],
'table': [ 'table': [
viewTypes['telemetry.plot.overlay'], VIEW_TYPES['telemetry.plot.overlay'],
viewTypes['telemetry.plot.stacked'], VIEW_TYPES['telemetry.plot.stacked'],
viewTypes['telemetry-view'] VIEW_TYPES['telemetry-view']
], ],
'telemetry-view-multi': [ 'telemetry-view-multi': [
viewTypes['telemetry.plot.overlay'], VIEW_TYPES['telemetry.plot.overlay'],
viewTypes['telemetry.plot.stacked'], VIEW_TYPES['telemetry.plot.stacked'],
viewTypes.table VIEW_TYPES.table
], ],
'telemetry.plot.overlay-multi': [ 'telemetry.plot.overlay-multi': [
viewTypes['telemetry.plot.stacked'] VIEW_TYPES['telemetry.plot.stacked']
] ]
}; };
@ -510,7 +516,7 @@ define(['lodash'], function (_) {
selectedItemType = 'telemetry-view'; selectedItemType = 'telemetry-view';
} }
let viewOptions = applicableViews[selectedItemType]; let viewOptions = APPLICABLE_VIEWS[selectedItemType];
if (viewOptions) { if (viewOptions) {
return { return {
@ -533,7 +539,7 @@ define(['lodash'], function (_) {
domainObject: selectedParent, domainObject: selectedParent,
icon: "icon-object", icon: "icon-object",
title: "Merge into a telemetry table or plot", title: "Merge into a telemetry table or plot",
options: applicableViews['telemetry-view-multi'], options: APPLICABLE_VIEWS['telemetry-view-multi'],
method: function (option) { method: function (option) {
displayLayoutContext.mergeMultipleTelemetryViews(selection, option.value); displayLayoutContext.mergeMultipleTelemetryViews(selection, option.value);
} }
@ -546,7 +552,7 @@ define(['lodash'], function (_) {
domainObject: selectedParent, domainObject: selectedParent,
icon: "icon-object", icon: "icon-object",
title: "Merge into a stacked plot", title: "Merge into a stacked plot",
options: applicableViews['telemetry.plot.overlay-multi'], options: APPLICABLE_VIEWS['telemetry.plot.overlay-multi'],
method: function (option) { method: function (option) {
displayLayoutContext.mergeMultipleOverlayPlots(selection, option.value); displayLayoutContext.mergeMultipleOverlayPlots(selection, option.value);
} }

View File

@ -78,6 +78,30 @@ import ImageView from './ImageView.vue'
import EditMarquee from './EditMarquee.vue' import EditMarquee from './EditMarquee.vue'
import _ from 'lodash' import _ from 'lodash'
const TELEMETRY_IDENTIFIER_FUNCTIONS = {
'table': (domainObject) => {
return Promise.resolve(domainObject.composition);
},
'telemetry.plot.overlay': (domainObject) => {
return Promise.resolve(domainObject.composition);
},
'telemetry.plot.stacked': (domainObject, openmct) => {
let composition = openmct.composition.get(domainObject);
return composition.load().then((objects) => {
let identifiers = [];
objects.forEach(object => {
if (object.type === 'telemetry.plot.overlay') {
identifiers.push(...object.composition);
} else {
identifiers.push(object.identifier);
}
});
return Promise.resolve(identifiers);
});
}
}
const ITEM_TYPE_VIEW_MAP = { const ITEM_TYPE_VIEW_MAP = {
'subobject-view': SubobjectView, 'subobject-view': SubobjectView,
'telemetry-view': TelemetryView, 'telemetry-view': TelemetryView,
@ -549,7 +573,7 @@ export default {
object.identifier = identifier; object.identifier = identifier;
object.location = parentKeyString; object.location = parentKeyString;
this.openmct.objects.mutate(object, 'persisted', Date.now()); this.openmct.objects.mutate(object, 'created', Date.now());
return object; return object;
}, },
@ -671,31 +695,42 @@ export default {
this.removeItem(selection); this.removeItem(selection);
this.initSelectIndex = this.layoutItems.length - 1; this.initSelectIndex = this.layoutItems.length - 1;
}, },
getTelemetryIdentifiers(domainObject) {
let method = TELEMETRY_IDENTIFIER_FUNCTIONS[domainObject.type];
if (method) {
return method(domainObject, this.openmct);
} else {
throw 'No method identified for domainObject type';
}
},
switchViewType(context, viewType, selection) { switchViewType(context, viewType, selection) {
let domainObject = context.item, let domainObject = context.item,
layoutItem = context.layoutItem, layoutItem = context.layoutItem,
position = [layoutItem.x, layoutItem.y], position = [layoutItem.x, layoutItem.y],
newDomainObject,
layoutType = 'subobject-view'; layoutType = 'subobject-view';
if (layoutItem.type === 'telemetry-view') { if (layoutItem.type === 'telemetry-view') {
newDomainObject = this.createNewDomainObject(domainObject, [domainObject.identifier], viewType); let newDomainObject = this.createNewDomainObject(domainObject, [domainObject.identifier], viewType);
} else {
if (viewType !== 'telemetry-view') {
newDomainObject = this.createNewDomainObject(domainObject, domainObject.composition, viewType);
} else {
domainObject.composition.forEach((identifier , index) => {
let positionX = position[0] + (index * DUPLICATE_OFFSET),
positionY = position[1] + (index * DUPLICATE_OFFSET);
this.convertToTelemetryView(identifier, [positionX, positionY]);
});
}
}
if (newDomainObject) {
this.composition.add(newDomainObject); this.composition.add(newDomainObject);
this.addItem(layoutType, newDomainObject, position); this.addItem(layoutType, newDomainObject, position);
} else {
this.getTelemetryIdentifiers(domainObject).then((identifiers) => {
if (viewType === 'telemetry-view') {
identifiers.forEach((identifier, index) => {
let positionX = position[0] + (index * DUPLICATE_OFFSET),
positionY = position[1] + (index * DUPLICATE_OFFSET);
this.convertToTelemetryView(identifier, [positionX, positionY]);
});
} else {
let newDomainObject = this.createNewDomainObject(domainObject, identifiers, viewType);
this.composition.add(newDomainObject);
this.addItem(layoutType, newDomainObject, position);
}
});
} }
this.removeItem(selection); this.removeItem(selection);