diff --git a/src/plugins/condition/ConditionSpec.js b/src/plugins/condition/ConditionSpec.js
index cc32914871..2f58676cef 100644
--- a/src/plugins/condition/ConditionSpec.js
+++ b/src/plugins/condition/ConditionSpec.js
@@ -64,15 +64,17 @@ describe("The condition", function () {
openmct.telemetry.getMetadata.and.returnValue(testTelemetryObject.telemetry.values);
testConditionDefinition = {
- trigger: TRIGGER.ANY,
- criteria: [
- {
- operation: 'equalTo',
- input: false,
- metaDataKey: 'value',
- key: testTelemetryObject.identifier
- }
- ]
+ definition: {
+ trigger: TRIGGER.ANY,
+ criteria: [
+ {
+ operation: 'equalTo',
+ input: false,
+ metaDataKey: 'value',
+ key: testTelemetryObject.identifier
+ }
+ ]
+ }
};
conditionObj = new Condition(
@@ -85,7 +87,7 @@ describe("The condition", function () {
});
it("generates criteria with an id", function () {
- const testCriterion = testConditionDefinition.criteria[0];
+ const testCriterion = testConditionDefinition.definition.criteria[0];
let criterion = conditionObj.generateCriterion(testCriterion);
expect(criterion.id).toBeDefined();
expect(criterion.operation).toEqual(testCriterion.operation);
@@ -101,15 +103,15 @@ describe("The condition", function () {
it("initializes with criteria from the condition definition", function () {
expect(conditionObj.criteria.length).toEqual(1);
let criterion = conditionObj.criteria[0];
+ console.log(criterion);
expect(criterion instanceof TelemetryCriterion).toBeTrue();
- expect(criterion.operator).toEqual(testConditionDefinition.operator);
- expect(criterion.input).toEqual(testConditionDefinition.input);
- expect(criterion.metaDataKey).toEqual(testConditionDefinition.metaDataKey);
- expect(criterion.key).toEqual(testConditionDefinition.key);
+ expect(criterion.operator).toEqual(testConditionDefinition.definition.criteria[0].operator);
+ expect(criterion.input).toEqual(testConditionDefinition.definition.criteria[0].input);
+ expect(criterion.metaDataKey).toEqual(testConditionDefinition.definition.criteria[0].metaDataKey);
});
it("initializes with the trigger from the condition definition", function () {
- expect(conditionObj.trigger).toEqual(testConditionDefinition.trigger);
+ expect(conditionObj.trigger).toEqual(testConditionDefinition.definition.trigger);
});
it("destroys all criteria for a condition", function () {
diff --git a/src/plugins/condition/components/Condition.vue b/src/plugins/condition/components/Condition.vue
index 4ab2e7b909..ae041c6ed2 100644
--- a/src/plugins/condition/components/Condition.vue
+++ b/src/plugins/condition/components/Condition.vue
@@ -2,7 +2,7 @@
@@ -28,7 +28,7 @@ export default {
type: Object,
required: true
},
- isCurrent: {
+ currentConditionIdentifier: {
type: Object,
required: true
}
diff --git a/src/plugins/condition/components/ConditionCollection.vue b/src/plugins/condition/components/ConditionCollection.vue
index e618a8ef1d..e8ffa3438d 100644
--- a/src/plugins/condition/components/ConditionCollection.vue
+++ b/src/plugins/condition/components/ConditionCollection.vue
@@ -35,7 +35,7 @@
>
@@ -88,6 +88,8 @@ export default {
this.conditionCollection = this.domainObject.configuration ? this.domainObject.configuration.conditionCollection : [];
if (!this.conditionCollection.length) {
this.addCondition(null, true);
+ } else {
+ this.updateCurrentCondition(this.conditionCollection[0]);
}
},
methods: {
@@ -98,7 +100,6 @@ export default {
},
updateCurrentConditionId() {
let currentConditionIdentifier = this.conditionCollection[this.conditionCollection.length-1];
-
for (let i=0, ii = this.conditionCollection.length-1; i< ii; i++) {
let conditionIdAsString = this.openmct.objects.makeKeyString(this.conditionCollection[i]);
if (this.conditionResults[conditionIdAsString]) {
diff --git a/src/plugins/condition/components/ConditionEdit.vue b/src/plugins/condition/components/ConditionEdit.vue
index fde3f4f28d..188d91c0f6 100644
--- a/src/plugins/condition/components/ConditionEdit.vue
+++ b/src/plugins/condition/components/ConditionEdit.vue
@@ -1,7 +1,7 @@
{
this.telemetryObject = obj;
this.telemetryMetadata = this.openmct.telemetry.getMetadata(this.telemetryObject).values();
- this.selectedMetaDataKey = this.telemetryMetadata[0].key;
+ this.selectedMetaDataKey = '';
this.selectedTelemetryKey = this.telemetryObject.identifier;
});
} else {
diff --git a/src/plugins/condition/criterion/TelemetryCriterion.js b/src/plugins/condition/criterion/TelemetryCriterion.js
index 8940079abe..d833f25cfc 100644
--- a/src/plugins/condition/criterion/TelemetryCriterion.js
+++ b/src/plugins/condition/criterion/TelemetryCriterion.js
@@ -77,7 +77,9 @@ export default class TelemetryCriterion extends EventEmitter {
let params = [];
let result = false;
params.push(data[this.metaDataKey]);
- params.push(this.input);
+ if (this.input instanceof Array && this.input.length) {
+ params.push(this.input[0]);
+ }
if (typeof comparator === 'function') {
result = comparator(params);
}
diff --git a/src/plugins/condition/criterion/TelemetryCriterionSpec.js b/src/plugins/condition/criterion/TelemetryCriterionSpec.js
index ef823ca45d..123fd600fb 100644
--- a/src/plugins/condition/criterion/TelemetryCriterionSpec.js
+++ b/src/plugins/condition/criterion/TelemetryCriterionSpec.js
@@ -94,17 +94,6 @@ describe("The telemetry criterion", function () {
expect(telemetryCriterion.subscription).toBeDefined();
});
- it("normalizes telemetry data", function () {
- let result = telemetryCriterion.normalizeData({
- key: 'some-key',
- source: 'testSource',
- testSource: 'Hello'
- });
- expect(result).toEqual({
- 'some-key': 'Hello'
- })
- });
-
it("emits update event on new data from telemetry providers", function () {
spyOn(telemetryCriterion, 'emitEvent').and.callThrough();
telemetryCriterion.handleSubscription({