From 138067dca9c7fe3c1ca935c130e16aea50b73dee Mon Sep 17 00:00:00 2001 From: Pegah Sarram Date: Fri, 26 Apr 2019 11:19:07 -0700 Subject: [PATCH] [Migration] convert telemetry points to overlay plot (#2388) * Replace telemetry point objects with overlay plot when migrating display layouts. * Persist plot object --- src/plugins/objectMigration/Migrations.js | 60 +++++++++++++---------- 1 file changed, 35 insertions(+), 25 deletions(-) diff --git a/src/plugins/objectMigration/Migrations.js b/src/plugins/objectMigration/Migrations.js index 4407ac3495..cc035096b6 100644 --- a/src/plugins/objectMigration/Migrations.js +++ b/src/plugins/objectMigration/Migrations.js @@ -64,35 +64,45 @@ define([ Object.keys(panels).forEach(key => { let panel = panels[key]; let domainObject = childObjects[key]; + let identifier = undefined; if (isTelemetry(domainObject)) { - items.push({ - width: panel.dimensions[0], - height: panel.dimensions[1], - x: panel.position[0], - y: panel.position[1], - identifier: domainObject.identifier, - id: uuid(), - type: 'telemetry-view', - displayMode: 'all', - value: openmct.telemetry.getMetadata(domainObject).getDefaultDisplayValue(), - stroke: "transparent", - fill: "", - color: "", - size: "13px" - }); - } else { - items.push({ - width: panel.dimensions[0], - height: panel.dimensions[1], - x: panel.position[0], - y: panel.position[1], - identifier: domainObject.identifier, - id: uuid(), - type: 'subobject-view', - hasFrame: panel.hasFrame + // If object is a telemetry point, convert it to a plot and + // replace the object in migratedObject composition with the plot. + identifier = { + key: uuid(), + namespace: migratedObject.identifier.namespace + }; + let plotObject = { + identifier: identifier, + location: domainObject.location, + name: domainObject.name, + type: "telemetry.plot.overlay" + }; + let plotType = openmct.types.get('telemetry.plot.overlay'); + 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; + } }); } + + 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;