Handle telemetry removal

This commit is contained in:
Joshi 2020-01-26 23:30:19 -08:00
parent d6a422fbdb
commit f42ec7e2c5
2 changed files with 46 additions and 10 deletions

View File

@ -87,6 +87,7 @@ export default {
this.instantiate = this.openmct.$injector.get('instantiate');
this.composition = this.openmct.composition.get(this.domainObject);
this.composition.on('add', this.addTelemetry);
this.composition.on('remove', this.removeTelemetry);
this.composition.load();
this.conditionCollection = this.domainObject.configuration ? this.domainObject.configuration.conditionCollection : [];
if (!this.conditionCollection.length) {
@ -116,6 +117,16 @@ export default {
addTelemetry(telemetryDomainObject) {
this.telemetryObjs.push(telemetryDomainObject);
},
removeTelemetry(telemetryDomainObjectIdentifier) {
let index = _.findIndex(this.telemetryObjs, (obj) => {
let objId = this.openmct.objects.makeKeyString(obj.identifier);
let id = this.openmct.objects.makeKeyString(telemetryDomainObjectIdentifier);
return objId === id;
});
if (index > -1) {
this.telemetryObjs.splice(index, 1);
}
},
addCondition(event, isDefault) {
let conditionDO = this.getConditionDomainObject(!!isDefault);
//persist the condition DO so that we can do an openmct.objects.get on it and only persist the identifier in the conditionCollection of conditionSet

View File

@ -194,25 +194,49 @@ export default {
};
},
destroyed() {
this.conditionClass.off('conditionResultUpdated', this.handleConditionResult.bind(this));
if (this.conditionClass && typeof this.conditionClass.destroy === 'function') {
this.conditionClass.destroy();
}
this.destroy();
},
mounted() {
this.openmct.objects.get(this.conditionIdentifier).then((obj => {
this.condition = obj;
this.initialize();
}));
},
updated() {
//validate telemetry exists, update criteria as needed
this.validate();
this.persist();
},
methods: {
initialize() {
this.setOutput();
this.setOperation();
this.updateTelemetry();
this.conditionClass = new ConditionClass(this.condition, this.openmct);
this.conditionClass.on('conditionResultUpdated', this.handleConditionResult.bind(this));
}));
},
updated() {
this.persist();
},
methods: {
},
destroy() {
this.conditionClass.off('conditionResultUpdated', this.handleConditionResult.bind(this));
if (this.conditionClass && typeof this.conditionClass.destroy === 'function') {
this.conditionClass.destroy();
delete this.conditionClass;
}
},
reset() {
this.selectedMetaDataKey = '';
this.selectedTelemetryKey = '';
this.selectedOperationKey = '';
this.operationValue = '';
},
validate() {
if (this.hasTelemetry() && !this.getTelemetryKey()) {
this.reset();
} else {
if (!this.conditionClass) {
this.initialize();
}
}
},
handleConditionResult(args) {
this.$emit('condition-result-updated', {
id: this.conditionIdentifier,
@ -310,6 +334,7 @@ export default {
},
telemetryChange() {
this.selectedMetaDataKey = '';
this.updateConditionCriteria();
this.updateTelemetry();
},
updateCurrentCondition() {