Handles remove telemetry from condition set - this resets criterion properties (#2791)

Handles remove condition from a condition set that's being used in a conditional style.
Fixes a small bug with stye rule manager request lad results
This commit is contained in:
Shefali Joshi 2020-03-26 13:12:22 -07:00 committed by GitHub
parent 4172fdf1d5
commit 53440c31d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 40 additions and 8 deletions

View File

@ -77,8 +77,10 @@ export default class ConditionSetTelemetryProvider {
* can be called manually for views that only request but do not subscribe to data
*/
destroyConditionManager(id) {
this.conditionManagerPool[id].off('conditionSetResultUpdated');
this.conditionManagerPool[id].destroy();
delete this.conditionManagerPool[id];
if (this.conditionManagerPool[id]) {
this.conditionManagerPool[id].off('conditionSetResultUpdated');
this.conditionManagerPool[id].destroy();
delete this.conditionManagerPool[id];
}
}
}

View File

@ -49,7 +49,11 @@ export default class StyleRuleManager extends EventEmitter {
}
this.openmct.objects.get(this.conditionSetIdentifier).then((conditionSetDomainObject) => {
this.openmct.telemetry.request(conditionSetDomainObject)
.then(output => this.handleConditionSetResultUpdated(output));
.then(output => {
if (output && output.length) {
this.handleConditionSetResultUpdated(output[0]);
}
});
this.stopProvidingTelemetry = this.openmct.telemetry.subscribe(conditionSetDomainObject, output => this.handleConditionSetResultUpdated(output));
});
}
@ -60,7 +64,7 @@ export default class StyleRuleManager extends EventEmitter {
this.destroy();
} else {
let isNewConditionSet = !this.conditionSetIdentifier ||
this.openmct.objects.areIdsEqual(this.conditionSetIdentifier, styleConfiguration.conditionSetIdentifier);
!this.openmct.objects.areIdsEqual(this.conditionSetIdentifier, styleConfiguration.conditionSetIdentifier);
this.initialize(styleConfiguration);
//Only resubscribe if the conditionSet has changed.
if (isNewConditionSet) {

View File

@ -119,7 +119,7 @@
</select>
</span>
<template v-if="telemetry.length">
<template v-if="telemetry.length || condition.configuration.criteria.length">
<div v-for="(criterion, index) in condition.configuration.criteria"
:key="index"
class="c-cdef__criteria"

View File

@ -118,6 +118,14 @@ export default {
inputTypes: INPUT_TYPES
}
},
watch: {
telemetry: {
handler(newTelemetry, oldTelemetry) {
this.checkTelemetry();
},
deep: true
}
},
computed: {
setRowLabel: function () {
let operator = this.trigger === 'all' ? 'and ': 'or ';
@ -145,6 +153,17 @@ export default {
this.updateMetadataOptions();
},
methods: {
checkTelemetry() {
if(this.criterion.telemetry &&
!this.telemetry.find((telemetryObj) => this.openmct.objects.areIdsEqual(this.criterion.telemetry, telemetryObj.identifier))) {
//telemetry being used was removed. So reset this criterion.
this.criterion.telemetry = '';
this.criterion.metadata = '';
this.criterion.input = [];
this.criterion.operation = '';
this.persist();
}
},
getOperationFormat() {
this.enumerations = [];
this.telemetryMetadata.valueMetadatas.forEach((value, index) => {

View File

@ -262,18 +262,22 @@ export default {
if (!this.conditions) {
this.conditions = {};
}
let conditionalStyles = [];
this.conditionSetDomainObject.configuration.conditionCollection.forEach((conditionConfiguration, index) => {
this.conditions[conditionConfiguration.id] = conditionConfiguration;
let foundStyle = this.findStyleByConditionId(conditionConfiguration.id);
if (foundStyle) {
foundStyle.style = Object.assign((this.canHide ? { isStyleInvisible: '' } : {}), this.initialStyles, foundStyle.style);
conditionalStyles.push(foundStyle);
} else {
this.conditionalStyles.splice(index, 0, {
conditionalStyles.splice(index, 0, {
conditionId: conditionConfiguration.id,
style: Object.assign((this.canHide ? { isStyleInvisible: '' } : {}), this.initialStyles)
});
}
});
//we're doing this so that we remove styles for any conditions that have been removed from the condition set
this.conditionalStyles = conditionalStyles;
this.conditionsLoaded = true;
this.persist(this.getDomainObjectConditionalStyle());
},

View File

@ -120,7 +120,10 @@ export default class TelemetryCriterion extends EventEmitter {
);
if (!this.isValid()) {
return this.formatData({});
return {
id: this.id,
data: this.formatData({})
};
}
return this.telemetryAPI.request(