[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);
openmct.objects.mutate(plotObject, 'persisted', Date.now());
let keyString = openmct.objects.makeKeyString(domainObject.identifier);
let clonedComposition = Object.assign([], migratedObject.composition);
clonedComposition.forEach((identifier, index) => {
if (openmct.objects.makeKeyString(identifier) === keyString) {
migratedObject.composition[index] = plotObject.identifier;
}
}); });
} else { }
items.push({ items.push({
width: panel.dimensions[0], width: panel.dimensions[0],
height: panel.dimensions[1], height: panel.dimensions[1],
x: panel.position[0], x: panel.position[0],
y: panel.position[1], y: panel.position[1],
identifier: domainObject.identifier, identifier: identifier || domainObject.identifier,
id: uuid(), id: uuid(),
type: 'subobject-view', type: 'subobject-view',
hasFrame: panel.hasFrame hasFrame: panel.hasFrame
}); });
}
}); });
migratedObject.configuration.items = items; migratedObject.configuration.items = items;