mirror of
https://github.com/nasa/openmct.git
synced 2025-03-21 19:45:23 +00:00
updated types api to return all types, updated annotations api to return annotatable types, cleaned up use of hasNumericTelemetry elsewhere in the code
This commit is contained in:
parent
128f4827df
commit
1326693643
src
api
plugins
charts/scatter
gauge
inspectorViews/annotations
plot
timeline
@ -95,6 +95,7 @@ export default class AnnotationAPI extends EventEmitter {
|
||||
this.availableTags = {};
|
||||
this.namespaceToSaveAnnotations = '';
|
||||
this.#targetComparatorMap = new Map();
|
||||
this.annotatableTypes = [];
|
||||
|
||||
this.ANNOTATION_TYPES = ANNOTATION_TYPES;
|
||||
this.ANNOTATION_TYPE = ANNOTATION_TYPE;
|
||||
@ -115,6 +116,17 @@ export default class AnnotationAPI extends EventEmitter {
|
||||
domainObject.annotationType = domainObject.annotationType || 'plotspatial';
|
||||
}
|
||||
});
|
||||
|
||||
this.openmct.on('start', () => {
|
||||
const types = this.openmct.types.getTypes();
|
||||
const typeKeys = Object.keys(types);
|
||||
|
||||
typeKeys.forEach((key) => {
|
||||
if (types[key].definition.annotatable) {
|
||||
this.annotatableTypes.push(key);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Creates an annotation on a given domain object (e.g., a plot) and a set of targets (e.g., telemetry objects)
|
||||
@ -582,4 +594,14 @@ export default class AnnotationAPI extends EventEmitter {
|
||||
_.isEqual(targets, otherTargets)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the given type is annotatable
|
||||
* @param {string} type The type to check
|
||||
* @returns {boolean} Returns true if the type is annotatable
|
||||
*/
|
||||
isAnnotatableType(type) {
|
||||
console.log('type', type, this.annotatableTypes);
|
||||
return this.annotatableTypes.some((annotatableType) => annotatableType === type);
|
||||
}
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ export default class TypeRegistry {
|
||||
* @returns {Type[]} all registered types
|
||||
*/
|
||||
getTypes() {
|
||||
return Object.values(this.types);
|
||||
return this.types;
|
||||
}
|
||||
/**
|
||||
* Import legacy types.
|
||||
|
@ -40,6 +40,7 @@ export default function () {
|
||||
cssClass: 'icon-plot-scatter',
|
||||
description: 'View data as a scatter plot.',
|
||||
creatable: true,
|
||||
annotatable: true,
|
||||
initialize: function (domainObject) {
|
||||
domainObject.composition = [];
|
||||
domainObject.configuration = {
|
||||
|
@ -21,28 +21,10 @@
|
||||
*****************************************************************************/
|
||||
|
||||
export default function GaugeCompositionPolicy(openmct) {
|
||||
function hasNumericTelemetry(domainObject) {
|
||||
const hasTelemetry = openmct.telemetry.isTelemetryObject(domainObject);
|
||||
if (!hasTelemetry) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const metadata = openmct.telemetry.getMetadata(domainObject);
|
||||
|
||||
return metadata.values().length > 0 && hasDomainAndRange(metadata);
|
||||
}
|
||||
|
||||
function hasDomainAndRange(metadata) {
|
||||
return (
|
||||
metadata.valuesForHints(['range']).length > 0 &&
|
||||
metadata.valuesForHints(['domain']).length > 0
|
||||
);
|
||||
}
|
||||
|
||||
return {
|
||||
allow: function (parent, child) {
|
||||
if (parent.type === 'gauge') {
|
||||
return hasNumericTelemetry(child);
|
||||
return openmct.telemetry.hasNumericTelemetry(child);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -63,6 +63,14 @@ export default function AnnotationsViewProvider(openmct) {
|
||||
);
|
||||
_destroy = destroy;
|
||||
},
|
||||
showTab: function () {
|
||||
const isAnnotatableType = openmct.annotation.isAnnotatableType(domainObject.type);
|
||||
const metadata = openmct.telemetry.getMetadata(domainObject);
|
||||
const hasImagery = metadata?.valuesForHints(['image']).length > 0;
|
||||
const hasNumericTelemetry = openmct.telemetry.hasNumericTelemetry(domainObject);
|
||||
|
||||
return isAnnotatableType || hasImagery || hasNumericTelemetry;
|
||||
},
|
||||
priority: function () {
|
||||
return openmct.priority.DEFAULT;
|
||||
},
|
||||
|
@ -25,27 +25,6 @@ import mount from 'utils/mount';
|
||||
import Plot from './PlotView.vue';
|
||||
|
||||
export default function PlotViewProvider(openmct) {
|
||||
function hasNumericTelemetry(domainObject) {
|
||||
if (!Object.prototype.hasOwnProperty.call(domainObject, 'telemetry')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let metadata = openmct.telemetry.getMetadata(domainObject);
|
||||
|
||||
return metadata.values().length > 0 && hasDomainAndNumericRange(metadata);
|
||||
}
|
||||
|
||||
function hasDomainAndNumericRange(metadata) {
|
||||
const rangeValues = metadata.valuesForHints(['range']);
|
||||
const domains = metadata.valuesForHints(['domain']);
|
||||
|
||||
return (
|
||||
domains.length > 0 &&
|
||||
rangeValues.length > 0 &&
|
||||
!rangeValues.every((value) => value.format === 'string')
|
||||
);
|
||||
}
|
||||
|
||||
function isCompactView(objectPath) {
|
||||
let isChildOfTimeStrip = objectPath.find((object) => object.type === 'time-strip');
|
||||
|
||||
@ -57,7 +36,7 @@ export default function PlotViewProvider(openmct) {
|
||||
name: 'Plot',
|
||||
cssClass: 'icon-telemetry',
|
||||
canView(domainObject, objectPath) {
|
||||
return hasNumericTelemetry(domainObject);
|
||||
return openmct.telemetry.hasNumericTelemetry(domainObject);
|
||||
},
|
||||
|
||||
view: function (domainObject, objectPath) {
|
||||
|
@ -1,25 +1,10 @@
|
||||
export default function OverlayPlotCompositionPolicy(openmct) {
|
||||
function hasNumericTelemetry(domainObject) {
|
||||
const hasTelemetry = openmct.telemetry.isTelemetryObject(domainObject);
|
||||
if (!hasTelemetry) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let metadata = openmct.telemetry.getMetadata(domainObject);
|
||||
|
||||
return metadata.values().length > 0 && hasDomainAndRange(metadata);
|
||||
}
|
||||
|
||||
function hasDomainAndRange(metadata) {
|
||||
return (
|
||||
metadata.valuesForHints(['range']).length > 0 &&
|
||||
metadata.valuesForHints(['domain']).length > 0
|
||||
);
|
||||
}
|
||||
|
||||
return {
|
||||
allow: function (parent, child) {
|
||||
if (parent.type === 'telemetry.plot.overlay' && hasNumericTelemetry(child) === false) {
|
||||
if (
|
||||
parent.type === 'telemetry.plot.overlay' &&
|
||||
!openmct.telemetry.hasNumericTelemetry(child)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -23,22 +23,6 @@
|
||||
const ALLOWED_TYPES = ['telemetry.plot.overlay', 'telemetry.plot.stacked', 'plan', 'gantt-chart'];
|
||||
const DISALLOWED_TYPES = ['telemetry.plot.bar-graph', 'telemetry.plot.scatter-plot'];
|
||||
export default function TimelineCompositionPolicy(openmct) {
|
||||
function hasNumericTelemetry(domainObject, metadata) {
|
||||
const hasTelemetry = openmct.telemetry.isTelemetryObject(domainObject);
|
||||
if (!hasTelemetry || !metadata) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return metadata.values().length > 0 && hasDomainAndRange(metadata);
|
||||
}
|
||||
|
||||
function hasDomainAndRange(metadata) {
|
||||
return (
|
||||
metadata.valuesForHints(['range']).length > 0 &&
|
||||
metadata.valuesForHints(['domain']).length > 0
|
||||
);
|
||||
}
|
||||
|
||||
function hasImageTelemetry(domainObject, metadata) {
|
||||
if (!metadata) {
|
||||
return false;
|
||||
@ -54,7 +38,7 @@ export default function TimelineCompositionPolicy(openmct) {
|
||||
|
||||
if (
|
||||
!DISALLOWED_TYPES.includes(child.type) &&
|
||||
(hasNumericTelemetry(child, metadata) ||
|
||||
(openmct.telemetry.hasNumericTelemetry(child) ||
|
||||
hasImageTelemetry(child, metadata) ||
|
||||
ALLOWED_TYPES.includes(child.type))
|
||||
) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user