[Migration] convert telemetry points to overlay plot (#2388)

* Replace telemetry point objects with overlay plot when migrating display layouts.

* Persist plot object
This commit is contained in:
Pegah Sarram 2019-04-26 11:19:07 -07:00 committed by Andrew Henry
parent 844280eaa5
commit 138067dca9

View File

@ -64,35 +64,45 @@ define([
Object.keys(panels).forEach(key => { Object.keys(panels).forEach(key => {
let panel = panels[key]; let panel = panels[key];
let domainObject = childObjects[key]; let domainObject = childObjects[key];
let identifier = undefined;
if (isTelemetry(domainObject)) { if (isTelemetry(domainObject)) {
items.push({ // If object is a telemetry point, convert it to a plot and
width: panel.dimensions[0], // replace the object in migratedObject composition with the plot.
height: panel.dimensions[1], identifier = {
x: panel.position[0], key: uuid(),
y: panel.position[1], namespace: migratedObject.identifier.namespace
identifier: domainObject.identifier, };
id: uuid(), let plotObject = {
type: 'telemetry-view', identifier: identifier,
displayMode: 'all', location: domainObject.location,
value: openmct.telemetry.getMetadata(domainObject).getDefaultDisplayValue(), name: domainObject.name,
stroke: "transparent", type: "telemetry.plot.overlay"
fill: "", };
color: "", let plotType = openmct.types.get('telemetry.plot.overlay');
size: "13px" plotType.definition.initialize(plotObject);
}); plotObject.composition.push(domainObject.identifier);
} else { openmct.objects.mutate(plotObject, 'persisted', Date.now());
items.push({
width: panel.dimensions[0], let keyString = openmct.objects.makeKeyString(domainObject.identifier);
height: panel.dimensions[1], let clonedComposition = Object.assign([], migratedObject.composition);
x: panel.position[0], clonedComposition.forEach((identifier, index) => {
y: panel.position[1], if (openmct.objects.makeKeyString(identifier) === keyString) {
identifier: domainObject.identifier, migratedObject.composition[index] = plotObject.identifier;
id: uuid(), }
type: 'subobject-view',
hasFrame: panel.hasFrame
}); });
} }
items.push({
width: panel.dimensions[0],
height: panel.dimensions[1],
x: panel.position[0],
y: panel.position[1],
identifier: identifier || domainObject.identifier,
id: uuid(),
type: 'subobject-view',
hasFrame: panel.hasFrame
});
}); });
migratedObject.configuration.items = items; migratedObject.configuration.items = items;