fixed merge conflicts

This commit is contained in:
Joel McKinnon 2020-02-19 13:29:14 -08:00
commit d425bd564c
9 changed files with 49 additions and 72 deletions

View File

@ -38,8 +38,7 @@ import {computeCondition} from "@/plugins/condition/utils/evaluator";
* telemetry: '',
* operation: '',
* input: '',
* metadata: '',
* key: 'someTelemetryObjectKey'
* metadata: ''
* }
* ]
* }
@ -73,7 +72,7 @@ export default class ConditionClass extends EventEmitter {
update(newDomainObject) {
this.updateTrigger(newDomainObject.configuration.trigger);
// this.updateCriteria(newDomainObject.configuration.criteria);
this.updateCriteria(newDomainObject.configuration.criteria);
}
updateTrigger(trigger) {
@ -89,8 +88,7 @@ export default class ConditionClass extends EventEmitter {
telemetry: criterionConfiguration.telemetry || '',
operation: criterionConfiguration.operation || '',
input: criterionConfiguration.input === undefined ? [] : criterionConfiguration.input,
metadata: criterionConfiguration.metadata || '',
key: criterionConfiguration.key || ''
metadata: criterionConfiguration.metadata || ''
};
}
@ -110,7 +108,6 @@ export default class ConditionClass extends EventEmitter {
*/
addCriterion(criterionConfiguration) {
let criterionConfigurationWithId = this.generateCriterion(criterionConfiguration || null);
console.log('condition class addCriterion criterionConfigurationWithId', criterionConfigurationWithId );
let criterion = new TelemetryCriterion(criterionConfigurationWithId, this.openmct);
criterion.on('criterionUpdated', (obj) => this.handleCriterionUpdated(obj));
criterion.on('criterionResultUpdated', (obj) => this.handleCriterionResult(obj));
@ -118,8 +115,6 @@ export default class ConditionClass extends EventEmitter {
this.criteria = [];
}
this.criteria.push(criterion);
//Do we need this here?
this.handleConditionUpdated();
return criterionConfigurationWithId.id;
}
@ -141,8 +136,8 @@ export default class ConditionClass extends EventEmitter {
updateCriterion(id, criterionConfiguration) {
let found = this.findCriterion(id);
if (found) {
const newcriterionConfiguration = this.generateCriterion(criterionConfiguration);
let newCriterion = new TelemetryCriterion(newcriterionConfiguration, this.openmct);
const newCriterionConfiguration = this.generateCriterion(criterionConfiguration);
let newCriterion = new TelemetryCriterion(newCriterionConfiguration, this.openmct);
newCriterion.on('criterionUpdated', (obj) => this.handleCriterionUpdated(obj));
newCriterion.on('criterionResultUpdated', (obj) => this.handleCriterionResult(obj));
@ -154,7 +149,6 @@ export default class ConditionClass extends EventEmitter {
if (this.criteriaResults[criterion.id] !== undefined) {
delete this.criteriaResults[criterion.id];
}
this.handleConditionUpdated();
}
}
@ -185,8 +179,6 @@ export default class ConditionClass extends EventEmitter {
let found = this.findCriterion(criterion.id);
if (found) {
this.criteria[found.index] = criterion.data;
//Most likely don't need this.
console.log('conditiion subscribe')
this.subscribe();
this.emitEvent('conditionUpdated', {
trigger: this.trigger,
@ -207,7 +199,9 @@ export default class ConditionClass extends EventEmitter {
subscribe() {
this.criteria.forEach((criterion) => {
criterion.subscribe();
if (criterion.isValid()) {
criterion.subscribe();
}
})
}
@ -230,7 +224,6 @@ export default class ConditionClass extends EventEmitter {
return success;
}
//TODO: implement as part of the evaluator class task.
evaluate() {
this.result = computeCondition(this.criteriaResults, this.trigger === TRIGGER.ALL);
}

View File

@ -64,14 +64,14 @@ describe("The condition", function () {
openmct.telemetry.getMetadata.and.returnValue(testTelemetryObject.telemetry.values);
testConditionDefinition = {
definition: {
configuration: {
trigger: TRIGGER.ANY,
criteria: [
{
operation: 'equalTo',
input: false,
metaDataKey: 'value',
key: testTelemetryObject.identifier
metadata: 'value',
telemetry: testTelemetryObject.identifier
}
]
}
@ -87,13 +87,13 @@ describe("The condition", function () {
});
it("generates criteria with an id", function () {
const testCriterion = testConditionDefinition.definition.criteria[0];
const testCriterion = testConditionDefinition.configuration.criteria[0];
let criterion = conditionObj.generateCriterion(testCriterion);
expect(criterion.id).toBeDefined();
expect(criterion.operation).toEqual(testCriterion.operation);
expect(criterion.input).toEqual(testCriterion.input);
expect(criterion.metaDataKey).toEqual(testCriterion.metaDataKey);
expect(criterion.key).toEqual(testCriterion.key);
expect(criterion.metadata).toEqual(testCriterion.metadata);
expect(criterion.telemetry).toEqual(testCriterion.telemetry);
});
it("initializes with an id", function () {
@ -104,13 +104,13 @@ describe("The condition", function () {
expect(conditionObj.criteria.length).toEqual(1);
let criterion = conditionObj.criteria[0];
expect(criterion instanceof TelemetryCriterion).toBeTrue();
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);
expect(criterion.operator).toEqual(testConditionDefinition.configuration.criteria[0].operator);
expect(criterion.input).toEqual(testConditionDefinition.configuration.criteria[0].input);
expect(criterion.metadata).toEqual(testConditionDefinition.configuration.criteria[0].metadata);
});
it("initializes with the trigger from the condition definition", function () {
expect(conditionObj.trigger).toEqual(testConditionDefinition.definition.trigger);
expect(conditionObj.trigger).toEqual(testConditionDefinition.configuration.trigger);
});
it("destroys all criteria for a condition", function () {

View File

@ -68,6 +68,7 @@
v-model="domainObject.configuration.output"
class="t-condition-name-input"
type="text"
@blur="persist"
>
</span>
</li>
@ -141,10 +142,9 @@
<script>
import ConditionClass from "@/plugins/condition/Condition";
import Criterion from '../../condition/components/Criterion.vue';
import uuid from 'uuid';
export default {
inject: ['openmct', 'domainObject'],
inject: ['openmct'],
components: {
Criterion
},
@ -196,10 +196,6 @@ export default {
this.initialize();
}));
},
updated() {
//validate telemetry exists, update criteria as needed
this.persist();
},
methods: {
initialize() {
this.setOutput();
@ -213,21 +209,19 @@ export default {
telemetry: '',
operation: '',
input: '',
metadata: '',
key: {
namespace: '',
key: uuid()
}
}
metadata: ''
};
this.domainObject.configuration.criteria.push(criteriaObject);
},
dragStart(e) {
this.$emit('set-move-index', Number(e.target.getAttribute('data-condition-index')));
},
destroy() {
// this.conditionClass.off('conditionResultUpdated', this.handleConditionResult.bind(this));
if (this.conditionClass && typeof this.conditionClass.destroy === 'function') {
this.conditionClass.destroy();
if (this.conditionClass) {
this.conditionClass.off('conditionResultUpdated', this.handleConditionResult.bind(this));
if (typeof this.conditionClass.destroy === 'function') {
this.conditionClass.destroy();
}
delete this.conditionClass;
}
},
@ -260,21 +254,13 @@ export default {
this.openmct.objects.mutate(this.domainObject, 'configuration', this.domainObject.configuration);
},
checkInputValue() {
if (this.selectedOutputOption === 'string') {
if (this.selectedOutputKey === 'string') {
this.domainObject.configuration.output = '';
} else {
this.domainObject.configuration.output = this.selectedOutputOption;
}
},
updateOutputOption(ev) {
if (this.selectedOutputOption === 'string') {
this.domainObject.configuration.output = '';
} else {
this.domainObject.configuration.output = this.selectedOutputOption;
this.domainObject.configuration.output = this.selectedOutputKey;
}
},
updateCurrentCondition() {
console.log('condition this.currentConditionIdentifier', this.currentConditionIdentifier);
this.$emit('updateCurrentCondition', this.currentConditionIdentifier);
},
hasTelemetry(identifier) {

View File

@ -184,7 +184,6 @@ export default {
break;
}
}
// console.log('conditioncollection before emit currentConditionIdentifier', currentConditionIdentifier)
this.$emit('currentConditionUpdated', currentConditionIdentifier);
},
addTelemetryObject(domainObject) {
@ -213,16 +212,17 @@ export default {
addCondition(event, isDefault) {
let conditionDomainObject = this.createConditionDomainObject(!!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
this.openmct.objects.mutate(conditionDomainObject, 'created', conditionDomainObject.created);
this.conditionCollection.unshift(conditionDomainObject.identifier);
this.persist();
},
updateCurrentCondition(identifier) {
this.currentConditionIdentifier = identifier;
// console.log('conditionCollection this.conditionIdentifier', this.currentConditionIdentifier);
},
createConditionDomainObject(isDefault) {
let conditionObj = {
isDefault: isDefault,
type: 'condition',
name: isDefault ? 'Default' : 'Unnamed Condition',
identifier: {
namespace: this.domainObject.identifier.namespace,
@ -236,11 +236,7 @@ export default {
telemetry: '',
operation: '',
input: '',
metadata: '',
identifier: {
namespace: '',
key: ''
}
metadata: ''
}]
},
summary: 'summary description',

View File

@ -55,7 +55,6 @@ export default {
mounted() {
let conditionCollection = this.domainObject.configuration.conditionCollection;
this.currentConditionIdentifier = conditionCollection.length ? this.updateCurrentCondition(conditionCollection[0]) : null;
// console.log('conditionCollection[0]', conditionCollection[0]);
},
methods: {
setCurrentCondition() {
@ -66,8 +65,6 @@ export default {
}
},
updateCurrentCondition(conditionIdentifier) {
// console.log('conditionIdentifier', conditionIdentifier);
this.currentConditionIdentifier = conditionIdentifier;
this.setCurrentCondition();
}

View File

@ -20,7 +20,7 @@
<option value="">- Select Field -</option>
<option v-for="option in telemetryMetadata"
:key="option.key"
:value="option"
:value="option.key"
>
{{ option.name }}
</option>
@ -42,6 +42,7 @@
v-model="criterion.input"
class="t-condition-name-input"
type="text"
@blur="persist"
>
</span>
</span>
@ -98,6 +99,7 @@ export default {
this.telemetryMetadata = this.openmct.telemetry.getMetadata(telemetryObject).values();
});
}
this.persist();
},
updateOperationInputVisibility() {
for (let i=0; i < this.operations.length; i++) {
@ -106,6 +108,10 @@ export default {
if (!this.isInputOperation) {this.criterion.input = ''}
}
}
this.persist();
},
updateMetadataSelection() {
this.updateOperationInputVisibility();
},
persist() {
this.$emit('persist', this.criterion);

View File

@ -58,7 +58,6 @@ export default {
}
},
mounted() {
// console.log('this.condition', this.condition);
},
updated() {

View File

@ -29,7 +29,7 @@ export default class TelemetryCriterion extends EventEmitter {
* Subscribes/Unsubscribes to telemetry and emits the result
* of operations performed on the telemetry data returned and a given input value.
* @constructor
* @param telemetryDomainObjectDefinition {id: uuid, operation: enum, input: Array, metaDataKey: string, key: {domainObject.identifier} }
* @param telemetryDomainObjectDefinition {id: uuid, operation: enum, input: Array, metadata: string, key: {domainObject.identifier} }
* @param openmct
*/
constructor(telemetryDomainObjectDefinition, openmct) {
@ -44,15 +44,13 @@ export default class TelemetryCriterion extends EventEmitter {
this.input = telemetryDomainObjectDefinition.input;
this.metadata = telemetryDomainObjectDefinition.metadata;
this.subscription = null;
this.telemetryMetadata = 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) {
this.telemetryObject = obj;
this.telemetryObjectIdAsString = this.objectAPI.makeKeyString(this.telemetryObject.identifier);
this.telemetryMetadata = this.telemetryAPI.getMetadata(this.telemetryObject.identifier);
this.emitEvent('criterionUpdated', this);
}
@ -77,9 +75,11 @@ export default class TelemetryCriterion extends EventEmitter {
let comparator = this.findOperation(this.operation);
let params = [];
let result = false;
params.push(data[this.metaDataKey]);
params.push(data[this.metadata]);
if (this.input instanceof Array && this.input.length) {
params.push(this.input[0]);
} else if (this.input) {
params.push(this.input);
}
if (typeof comparator === 'function') {
result = comparator(params);
@ -94,12 +94,15 @@ export default class TelemetryCriterion extends EventEmitter {
});
}
isValid() {
return this.telemetryObject && this.metadata && this.operation;
}
/**
* Subscribes to the telemetry object and returns an unsubscribe function
*/
subscribe() {
this.unsubscribe();
console.log('criteria class subscribe this.telemetryObject', this.telemetryObject);
this.subscription = this.telemetryAPI.subscribe(this.telemetryObject, (datum) => {
this.handleSubscription(datum);
});
@ -121,6 +124,5 @@ export default class TelemetryCriterion extends EventEmitter {
this.emitEvent('criterionRemoved');
delete this.telemetryObjectIdAsString;
delete this.telemetryObject;
delete this.telemetryMetadata;
}
}

View File

@ -64,7 +64,7 @@ describe("The telemetry criterion", function () {
testCriterionDefinition = {
id: 'test-criterion-id',
key: openmct.objects.makeKeyString(testTelemetryObject.identifier)
telemetry: openmct.objects.makeKeyString(testTelemetryObject.identifier)
};
mockListener = jasmine.createSpy('listener');
@ -85,7 +85,6 @@ describe("The telemetry criterion", function () {
it("initializes with a telemetry objectId as string", function () {
telemetryCriterion.initialize(testTelemetryObject);
expect(telemetryCriterion.telemetryObjectIdAsString).toEqual(testTelemetryObject.identifier.key);
expect(telemetryCriterion.telemetryMetadata.length).toEqual(2);
expect(mockListener2).toHaveBeenCalled();
});
@ -112,7 +111,6 @@ describe("The telemetry criterion", function () {
expect(telemetryCriterion.subscription).toBeUndefined();
expect(telemetryCriterion.telemetryObjectIdAsString).toBeUndefined();
expect(telemetryCriterion.telemetryObject).toBeUndefined();
expect(telemetryCriterion.telemetryMetadata).toBeUndefined();
});
});