Fixing condition output

This commit is contained in:
Joshi 2020-02-18 16:04:14 -08:00
parent dc08877bbb
commit f4468a8233
4 changed files with 16 additions and 11 deletions

View File

@ -73,7 +73,7 @@ export default class ConditionClass extends EventEmitter {
update(newDomainObject) { update(newDomainObject) {
this.updateTrigger(newDomainObject.configuration.trigger); this.updateTrigger(newDomainObject.configuration.trigger);
// this.updateCriteria(newDomainObject.configuration.criteria); this.updateCriteria(newDomainObject.configuration.criteria);
} }
updateTrigger(trigger) { updateTrigger(trigger) {
@ -84,13 +84,14 @@ export default class ConditionClass extends EventEmitter {
} }
generateCriterion(criterionConfiguration) { generateCriterion(criterionConfiguration) {
console.log('Identifier', criterionConfiguration);
return { return {
id: uuid(), id: uuid(),
telemetry: criterionConfiguration.telemetry || '', telemetry: criterionConfiguration.telemetry || '',
operation: criterionConfiguration.operation || '', operation: criterionConfiguration.operation || '',
input: criterionConfiguration.input === undefined ? [] : criterionConfiguration.input, input: criterionConfiguration.input === undefined ? [] : criterionConfiguration.input,
metadata: criterionConfiguration.metadata || '', metadata: criterionConfiguration.metadata || '',
key: criterionConfiguration.key || '' identifier: criterionConfiguration.identifier || ''
}; };
} }
@ -187,7 +188,6 @@ export default class ConditionClass extends EventEmitter {
if (found) { if (found) {
this.criteria[found.index] = criterion.data; this.criteria[found.index] = criterion.data;
//Most likely don't need this. //Most likely don't need this.
console.log('conditiion subscribe')
this.subscribe(); this.subscribe();
this.emitEvent('conditionUpdated', { this.emitEvent('conditionUpdated', {
trigger: this.trigger, trigger: this.trigger,

View File

@ -144,7 +144,7 @@ import Criterion from '../../condition/components/Criterion.vue';
import uuid from 'uuid'; import uuid from 'uuid';
export default { export default {
inject: ['openmct', 'domainObject'], inject: ['openmct'],
components: { components: {
Criterion Criterion
}, },
@ -198,7 +198,7 @@ export default {
}, },
updated() { updated() {
//validate telemetry exists, update criteria as needed //validate telemetry exists, update criteria as needed
this.persist(); // this.persist();
}, },
methods: { methods: {
initialize() { initialize() {
@ -218,16 +218,18 @@ export default {
namespace: '', namespace: '',
key: uuid() key: uuid()
} }
} };
this.domainObject.configuration.criteria.push(criteriaObject); this.domainObject.configuration.criteria.push(criteriaObject);
}, },
dragStart(e) { dragStart(e) {
this.$emit('set-move-index', Number(e.target.getAttribute('data-condition-index'))); this.$emit('set-move-index', Number(e.target.getAttribute('data-condition-index')));
}, },
destroy() { destroy() {
// this.conditionClass.off('conditionResultUpdated', this.handleConditionResult.bind(this)); if (this.conditionClass) {
if (this.conditionClass && typeof this.conditionClass.destroy === 'function') { this.conditionClass.off('conditionResultUpdated', this.handleConditionResult.bind(this));
this.conditionClass.destroy(); if (typeof this.conditionClass.destroy === 'function') {
this.conditionClass.destroy();
}
delete this.conditionClass; delete this.conditionClass;
} }
}, },

View File

@ -44,6 +44,7 @@
v-model="criterion.input" v-model="criterion.input"
class="t-condition-name-input" class="t-condition-name-input"
type="text" type="text"
@blur="persist"
> >
</span> </span>
</span> </span>
@ -100,6 +101,7 @@ export default {
this.telemetryMetadata = this.openmct.telemetry.getMetadata(telemetryObject).values(); this.telemetryMetadata = this.openmct.telemetry.getMetadata(telemetryObject).values();
}); });
} }
this.persist();
}, },
updateOperationInputVisibility() { updateOperationInputVisibility() {
for (let i=0; i < this.operations.length; i++) { for (let i=0; i < this.operations.length; i++) {
@ -108,9 +110,10 @@ export default {
if (!this.isInputOperation) {this.criterion.input = ''} if (!this.isInputOperation) {this.criterion.input = ''}
} }
} }
this.persist();
}, },
updateMetadataSelection() { updateMetadataSelection() {
this.comparisonInputValue = ''; this.updateOperationInputVisibility();
}, },
persist() { persist() {
this.$emit('persist', this.criterion); this.$emit('persist', this.criterion);

View File

@ -46,7 +46,7 @@ export default class TelemetryCriterion extends EventEmitter {
this.subscription = null; this.subscription = null;
this.telemetryMetadata = null; this.telemetryMetadata = null;
this.telemetryObjectIdAsString = null; this.telemetryObjectIdAsString = null;
this.objectAPI.get(this.objectAPI.makeKeyString(telemetryDomainObjectDefinition.key)).then((obj) => this.initialize(obj)); this.objectAPI.get(this.objectAPI.makeKeyString(this.telemetry)).then((obj) => this.initialize(obj));
} }
initialize(obj) { initialize(obj) {