mirror of
https://github.com/nasa/openmct.git
synced 2025-03-22 03:55:31 +00:00
reverting changes brought over from other issue
This commit is contained in:
parent
2b78e7ce04
commit
f665c5e71b
@ -95,7 +95,6 @@ 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;
|
||||
@ -116,17 +115,6 @@ 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)
|
||||
@ -594,14 +582,4 @@ 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);
|
||||
}
|
||||
}
|
||||
|
@ -284,27 +284,6 @@ export default class TelemetryAPI {
|
||||
return value;
|
||||
}
|
||||
|
||||
hasNumericTelemetry(domainObject) {
|
||||
if (!Object.prototype.hasOwnProperty.call(domainObject, 'telemetry')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let metadata = this.openmct.telemetry.getMetadata(domainObject);
|
||||
|
||||
return metadata.values().length > 0 && this.#hasDomainAndNumericRange(metadata);
|
||||
}
|
||||
|
||||
#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')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a numeric hash value for an options object. The hash is consistent
|
||||
* for equivalent option objects regardless of property order.
|
||||
|
@ -89,17 +89,6 @@ export default class TypeRegistry {
|
||||
get(typeKey) {
|
||||
return this.types[typeKey] || UNKNOWN_TYPE;
|
||||
}
|
||||
/**
|
||||
* List all registered types.
|
||||
* @returns {Type[]} all registered types
|
||||
*/
|
||||
getTypes() {
|
||||
return this.types;
|
||||
}
|
||||
/**
|
||||
* Import legacy types.
|
||||
* @param {TypeDefinition[]} types the types to import
|
||||
*/
|
||||
importLegacyTypes(types) {
|
||||
types
|
||||
.filter((t) => this.get(t.key) === UNKNOWN_TYPE)
|
||||
|
@ -21,10 +21,28 @@
|
||||
*****************************************************************************/
|
||||
|
||||
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 openmct.telemetry.hasNumericTelemetry(child);
|
||||
return hasNumericTelemetry(child);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -63,14 +63,6 @@ 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;
|
||||
},
|
||||
|
@ -91,15 +91,6 @@ export default function StylesInspectorViewProvider(openmct) {
|
||||
);
|
||||
_destroy = destroy;
|
||||
},
|
||||
showTab: function () {
|
||||
const objectSelection = selection?.[0];
|
||||
const objectContext = objectSelection?.[0]?.context;
|
||||
const layoutItem = objectContext?.layoutItem;
|
||||
const domainObject = objectContext?.item;
|
||||
const hasStyles = domainObject?.configuration?.objectStyles;
|
||||
|
||||
return layoutItem || hasStyles;
|
||||
},
|
||||
priority: function () {
|
||||
return openmct.priority.DEFAULT;
|
||||
},
|
||||
|
@ -28,7 +28,6 @@ export default class NotebookType {
|
||||
this.description = description;
|
||||
this.cssClass = icon;
|
||||
this.creatable = true;
|
||||
this.annotatable = true;
|
||||
this.form = [
|
||||
{
|
||||
key: 'defaultSort',
|
||||
|
@ -25,6 +25,27 @@ 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');
|
||||
|
||||
@ -36,7 +57,7 @@ export default function PlotViewProvider(openmct) {
|
||||
name: 'Plot',
|
||||
cssClass: 'icon-telemetry',
|
||||
canView(domainObject, objectPath) {
|
||||
return openmct.telemetry.hasNumericTelemetry(domainObject);
|
||||
return hasNumericTelemetry(domainObject);
|
||||
},
|
||||
|
||||
view: function (domainObject, objectPath) {
|
||||
|
@ -1,10 +1,25 @@
|
||||
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' &&
|
||||
!openmct.telemetry.hasNumericTelemetry(child)
|
||||
) {
|
||||
if (parent.type === 'telemetry.plot.overlay' && hasNumericTelemetry(child) === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,22 @@
|
||||
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;
|
||||
@ -38,7 +54,7 @@ export default function TimelineCompositionPolicy(openmct) {
|
||||
|
||||
if (
|
||||
!DISALLOWED_TYPES.includes(child.type) &&
|
||||
(openmct.telemetry.hasNumericTelemetry(child) ||
|
||||
(hasNumericTelemetry(child, metadata) ||
|
||||
hasImageTelemetry(child, metadata) ||
|
||||
ALLOWED_TYPES.includes(child.type))
|
||||
) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user