mirror of
https://github.com/nasa/openmct.git
synced 2025-06-01 23:20:50 +00:00
Table migration (#2327)
* Added table migration code * First working version * Fixed issues with objects missing from composition
This commit is contained in:
parent
c7ffcbf7e0
commit
e3f4da19f9
@ -25,6 +25,26 @@ define([
|
||||
], function (
|
||||
uuid
|
||||
) {
|
||||
return function Migrations(openmct) {
|
||||
function getColumnNameKeyMap(domainObject) {
|
||||
let composition = openmct.composition.get(domainObject);
|
||||
if (composition) {
|
||||
return composition.load().then(composees => {
|
||||
return composees.reduce((nameKeyMap, composee) => {
|
||||
let metadata = openmct.telemetry.getMetadata(composee);
|
||||
if (metadata !== undefined) {
|
||||
metadata.values().forEach(value => {
|
||||
nameKeyMap[value.name] = value.key;
|
||||
});
|
||||
}
|
||||
return nameKeyMap;
|
||||
}, {});
|
||||
});
|
||||
} else {
|
||||
return Promise.resolve([]);
|
||||
}
|
||||
}
|
||||
|
||||
function isTelemetry(domainObject) {
|
||||
if (openmct.telemetry.isTelemetryObject(domainObject)
|
||||
&& domainObject.type !== 'summary-widget'
|
||||
@ -158,7 +178,7 @@ define([
|
||||
.then(function () {
|
||||
return migrateDisplayLayout(domainObject, childObjects);
|
||||
});
|
||||
},
|
||||
}
|
||||
},
|
||||
{
|
||||
check(domainObject) {
|
||||
@ -195,6 +215,30 @@ define([
|
||||
return newLayoutObject;
|
||||
});
|
||||
}
|
||||
},
|
||||
{
|
||||
check(domainObject) {
|
||||
return domainObject.type === 'table' &&
|
||||
domainObject.configuration.table;
|
||||
},
|
||||
migrate(domainObject) {
|
||||
let currentTableConfiguration = domainObject.configuration.table || {};
|
||||
let currentColumnConfiguration = currentTableConfiguration.columns || {};
|
||||
return getColumnNameKeyMap(domainObject).then(nameKeyMap => {
|
||||
let hiddenColumns = Object.keys(currentColumnConfiguration).filter(columnName => {
|
||||
return currentColumnConfiguration[columnName] === false;
|
||||
}).reduce((hiddenColumnsMap, hiddenColumnName) => {
|
||||
let key = nameKeyMap[hiddenColumnName];
|
||||
hiddenColumnsMap[key] = true;
|
||||
return hiddenColumnsMap;
|
||||
}, {});
|
||||
|
||||
domainObject.configuration.hiddenColumns = hiddenColumns;
|
||||
delete domainObject.configuration.table;
|
||||
return domainObject;
|
||||
});
|
||||
}
|
||||
}
|
||||
];
|
||||
}
|
||||
});
|
||||
|
@ -20,9 +20,12 @@
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
|
||||
import migrations from './Migrations.js'
|
||||
import Migrations from './Migrations.js'
|
||||
|
||||
export default function () {
|
||||
return function (openmct) {
|
||||
let migrations = Migrations(openmct);
|
||||
|
||||
function needsMigration(domainObject) {
|
||||
return migrations.some(m => m.check(domainObject));
|
||||
}
|
||||
@ -32,7 +35,6 @@ export default function () {
|
||||
.migrate(domainObject);
|
||||
}
|
||||
|
||||
return function (openmct) {
|
||||
let wrappedFunction = openmct.objects.get;
|
||||
openmct.objects.get = function migrate(identifier) {
|
||||
return wrappedFunction.apply(openmct.objects, [identifier])
|
||||
|
Loading…
x
Reference in New Issue
Block a user