Merge branch 'master' of https://github.com/nasa/openmct into fix-telemetryview-styles

This commit is contained in:
Joshi 2020-04-02 10:30:07 -07:00
commit 666459be87
4 changed files with 61 additions and 43 deletions

View File

@ -238,7 +238,7 @@ export default class ConditionManager extends EventEmitter {
} }
requestLADConditionSetOutput() { requestLADConditionSetOutput() {
if (!this.conditionClassCollection.length || this.conditionClassCollection.length === 1) { if (!this.conditionClassCollection.length) {
return Promise.resolve([]); return Promise.resolve([]);
} }

View File

@ -105,36 +105,45 @@ export default {
} }
}, },
getCriterionDescription(criterion, index) { getCriterionDescription(criterion, index) {
this.openmct.objects.get(criterion.telemetry).then((telemetryObject) => { if (!criterion.telemetry) {
if (telemetryObject.type === 'unknown') { let description = `Unknown ${criterion.metadata} ${this.getOperatorText(criterion.operation, criterion.input)}`;
let description = `Unknown ${criterion.metadata} ${this.getOperatorText(criterion.operation, criterion.input)}`; this.criterionDescriptions.splice(index, 0, description);
this.criterionDescriptions.splice(index, 0, description); } else if (criterion.telemetry === 'all' || criterion.telemetry === 'any') {
} else { const telemetryDescription = criterion.telemetry === 'all' ? 'All telemetry' : 'Any telemetry';
let metadataValue = criterion.metadata; let description = `${telemetryDescription} ${criterion.metadata} ${this.getOperatorText(criterion.operation, criterion.input)}`;
let inputValue = criterion.input; this.criterionDescriptions.splice(index, 0, description);
if (criterion.metadata) { } else {
this.telemetryMetadata = this.openmct.telemetry.getMetadata(telemetryObject); this.openmct.objects.get(criterion.telemetry).then((telemetryObject) => {
if (telemetryObject.type === 'unknown') {
let description = `Unknown ${criterion.metadata} ${this.getOperatorText(criterion.operation, criterion.input)}`;
this.criterionDescriptions.splice(index, 0, description);
} else {
let metadataValue = criterion.metadata;
let inputValue = criterion.input;
if (criterion.metadata) {
this.telemetryMetadata = this.openmct.telemetry.getMetadata(telemetryObject);
const metadataObj = this.telemetryMetadata.valueMetadatas.find((metadata) => metadata.key === criterion.metadata); const metadataObj = this.telemetryMetadata.valueMetadatas.find((metadata) => metadata.key === criterion.metadata);
if (metadataObj) { if (metadataObj) {
if (metadataObj.name) { if (metadataObj.name) {
metadataValue = metadataObj.name; metadataValue = metadataObj.name;
} }
if(metadataObj.enumerations && inputValue.length) { if(metadataObj.enumerations && inputValue.length) {
if (metadataObj.enumerations[inputValue[0]] && metadataObj.enumerations[inputValue[0]].string) { if (metadataObj.enumerations[inputValue[0]] && metadataObj.enumerations[inputValue[0]].string) {
inputValue = [metadataObj.enumerations[inputValue[0]].string]; inputValue = [metadataObj.enumerations[inputValue[0]].string];
}
} }
} }
} }
let description = `${telemetryObject.name} ${metadataValue} ${this.getOperatorText(criterion.operation, inputValue)}`;
if (this.criterionDescriptions[index]) {
this.criterionDescriptions[index] = description;
} else {
this.criterionDescriptions.splice(index, 0, description);
}
} }
let description = `${telemetryObject.name} ${metadataValue} ${this.getOperatorText(criterion.operation, inputValue)}`; });
if (this.criterionDescriptions[index]) { }
this.criterionDescriptions[index] = description;
} else {
this.criterionDescriptions.splice(index, 0, description);
}
}
});
}, },
getOperatorText(operationName, values) { getOperatorText(operationName, values) {
const found = OPERATIONS.find((operation) => operation.name === operationName); const found = OPERATIONS.find((operation) => operation.name === operationName);

View File

@ -66,14 +66,23 @@ export default {
} }
}, },
getCriterionErrors(criterion, index) { getCriterionErrors(criterion, index) {
this.openmct.objects.get(criterion.telemetry).then((telemetryObject) => { if (!criterion.telemetry) {
if (telemetryObject.type === 'unknown') { this.conditionErrors.push({
this.conditionErrors.push({ message: ERROR.TELEMETRY_NOT_FOUND,
message: ERROR.TELEMETRY_NOT_FOUND, additionalInfo: ''
additionalInfo: criterion.telemetry ? `Key: ${this.openmct.objects.makeKeyString(criterion.telemetry)}` : '' });
} else {
if (criterion.telemetry !== 'all' && criterion.telemetry !== 'any') {
this.openmct.objects.get(criterion.telemetry).then((telemetryObject) => {
if (telemetryObject.type === 'unknown') {
this.conditionErrors.push({
message: ERROR.TELEMETRY_NOT_FOUND,
additionalInfo: criterion.telemetry ? `Key: ${this.openmct.objects.makeKeyString(criterion.telemetry)}` : ''
});
}
}); });
} }
}); }
} }
} }
} }

View File

@ -137,28 +137,28 @@ export default class TelemetryCriterion extends EventEmitter {
return this.formatData({}, options.telemetryObjects); return this.formatData({}, options.telemetryObjects);
} }
const telemetryRequests = options.telemetryObjects let keys = Object.keys(Object.assign({}, options.telemetryObjects));
.map(telemetryObject => this.telemetryAPI.request( const telemetryRequests = keys
telemetryObject, .map(key => this.telemetryAPI.request(
options.telemetryObjects[key],
options options
)); ));
return Promise.all(telemetryRequests) return Promise.all(telemetryRequests)
.then(telemetryRequestsResults => { .then(telemetryRequestsResults => {
let latestDatum;
telemetryRequestsResults.forEach((results, index) => { telemetryRequestsResults.forEach((results, index) => {
const latestDatum = results.length ? results[results.length - 1] : {}; latestDatum = results.length ? results[results.length - 1] : {};
if (index === telemetryRequestsResults.length-1) { if (index < telemetryRequestsResults.length-1) {
//when the last result is computed, we return the result
return {
id: this.id,
data: this.formatData(latestDatum, options.telemetryObjects)
};
} else {
if (latestDatum) { if (latestDatum) {
this.telemetryDataCache[latestDatum.id] = this.computeResult(latestDatum); this.telemetryDataCache[latestDatum.id] = this.computeResult(latestDatum);
} }
} }
}); });
return {
id: this.id,
data: this.formatData(latestDatum, options.telemetryObjects)
};
}); });
} }