add condition no errors

This commit is contained in:
Joel McKinnon 2020-02-01 10:07:40 -08:00
parent 7ac7a40b1b
commit 096d6371f1
2 changed files with 39 additions and 37 deletions

View File

@ -67,26 +67,21 @@
:condition-index="index"
:telemetry="telemetryObjs"
@update-current-condition="updateCurrentCondition"
@remove-condition="removeCondition"
@condition-result-updated="handleConditionResult"
@set-move-index="setMoveIndex"
@removeCondition="removeCondition"
@conditionResultUpdated="handleConditionResult"
@setMoveIndex="setMoveIndex"
/>
</div>
<div v-else>
<Condition :condition-identifier="conditionIdentifier"
:current-condition-identifier="currentConditionIdentifier"
@update-current-condition="updateCurrentCondition"
@remove-condition="removeCondition"
@condition-result-updated="handleConditionResult"
/>
</div>
<div v-else>
<Condition :condition-identifier="conditionIdentifier"
:current-condition-identifier="currentConditionIdentifier"
@condition-result-updated="handleConditionResult"
/>
</div>
</div>
@updateCurrentCondition="updateCurrentCondition"
@removeCondition="removeCondition"
@conditionResultUpdated="handleConditionResult"
/>
</div>
</li>
</ul>
</div>
</div>
</section>
@ -110,6 +105,7 @@ export default {
data() {
return {
expanded: true,
telemetryObjs: this.telemetryObjs,
parentKeyString: this.openmct.objects.makeKeyString(this.domainObject.identifier),
conditionCollection: [],
conditions: [],
@ -127,6 +123,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) {
@ -202,6 +199,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 conditionDomainObject = this.getConditionDomainObject(!!isDefault);
//persist the condition domain object so that we can do an openmct.objects.get on it and only persist the identifier in the conditionCollection of conditionSet
@ -226,8 +233,8 @@ export default {
criteria: isDefault ? [] : [{
operation: '',
input: '',
metaDataKey: this.openmct.telemetry.getMetadata(this.telemetryObjs[0]).values()[0].key,
key: this.telemetryObjs.length ? this.openmct.objects.makeKeyString(this.telemetryObjs[0].identifier) : null
metaDataKey: '',
key: ''
}]
},
summary: 'summary description'

View File

@ -187,6 +187,7 @@ export default {
condition: this.condition,
currentCriteria: this.currentCriteria,
expanded: true,
trigger: 'any',
telemetryObject: this.telemetryObject,
telemetryMetadata: this.telemetryMetadata,
operations: OPERATIONS,
@ -196,7 +197,7 @@ export default {
selectedOutputKey: '',
stringOutputField: false,
comparisonValueField: false,
operationValue: {},
operationValue: this.operationValue,
outputOptions: [
{
key: 'false',
@ -245,18 +246,17 @@ export default {
this.$emit('set-move-index', Number(e.target.getAttribute('data-condition-index')));
},
initialize() {
//if (!this.condition.definition.criteria.length) {
this.setCurrentCriterion();
//}
this.setOutput();
this.setOperation();
this.updateTelemetry();
this.conditionClass = new ConditionClass(this.condition, this.openmct);
this.conditionClass.on('conditionResultUpdated', this.handleConditionResult.bind(this));
if (this.condition.definition.criteria.length) {
this.setCurrentCriterion(0);
this.setOutput();
this.setOperation();
this.updateTelemetry();
this.conditionClass = new ConditionClass(this.condition, this.openmct);
this.conditionClass.on('conditionResultUpdated', this.handleConditionResult.bind(this));
}
},
setCurrentCriterion(index) {
this.currentCriteria = this.condition.definition.criteria;
console.log('setCurrentCriterion() this.currentCriteria', this.currentCriteria[0].key);
this.currentCriteria = this.condition.definition.criteria[index];
},
destroy() {
this.conditionClass.off('conditionResultUpdated', this.handleConditionResult.bind(this));
@ -321,17 +321,14 @@ export default {
}
},
updateTelemetry() {
// console.log('this.hasTelemetry()', this.hasTelemetry())
if (this.hasTelemetry()) {
this.openmct.objects.get(this.currentCriteria.key).then((obj) => {
console.log('this.openmct.telemetry.getMetadata(this.telemetryObject).values()', this.openmct.telemetry.getMetadata(this.telemetryObject).values());
this.telemetryObject = obj;
this.telemetryMetadata[this.currentCriteria.key.key] = this.openmct.telemetry.getMetadata(this.telemetryObject).values();
this.selectedMetaDataKey[this.currentCriteria.key.key] = this.getTelemetryMetadataKey();
this.selectedTelemetryKey[this.currentCriteria.key.key] = this.getTelemetryKey();
// console.log('selectedTelemetryKey', this.selectedTelemetryKey);
this.telemetryMetadata[this.currentCriteria.key] = this.openmct.telemetry.getMetadata(this.telemetryObject).values();
this.selectedMetaDataKey[this.currentCriteria.key] = this.getTelemetryMetadataKey();
this.selectedTelemetryKey[this.currentCriteria.key] = this.getTelemetryKey();
});
} else {
this.telemetryObject = null;
}
},
getTelemetryMetadataKey() {
@ -358,8 +355,6 @@ export default {
return this.telemetry.length && index > -1 ? this.telemetry[index].identifier : '';
},
hasTelemetry() {
// console.log('hasTelemetry() this.currentCriteria', this.currentCriteria)
// return this.currentCriteria && this.currentCriteria.key;
return this.currentCriteria && this.currentCriteria.key;
},
updateConditionCriteria() {