mirror of
https://github.com/nasa/openmct.git
synced 2025-06-18 15:18:12 +00:00
Persists telemetry options correctly and loads them on mount
This commit is contained in:
@ -89,6 +89,7 @@
|
|||||||
<span class="t-configuration">
|
<span class="t-configuration">
|
||||||
<span class="controls">
|
<span class="controls">
|
||||||
<select v-model="selectedTelemetryKey"
|
<select v-model="selectedTelemetryKey"
|
||||||
|
@change="telemetryChange"
|
||||||
>
|
>
|
||||||
<option value="">- Select Telemetry -</option>
|
<option value="">- Select Telemetry -</option>
|
||||||
<option v-for="telemetryOption in telemetry"
|
<option v-for="telemetryOption in telemetry"
|
||||||
@ -169,10 +170,10 @@ export default {
|
|||||||
telemetryObject: this.telemetryObject,
|
telemetryObject: this.telemetryObject,
|
||||||
telemetryMetadata: this.telemetryMetadata,
|
telemetryMetadata: this.telemetryMetadata,
|
||||||
operations: OPERATIONS,
|
operations: OPERATIONS,
|
||||||
selectedMetaDataKey: null,
|
selectedMetaDataKey: '',
|
||||||
selectedTelemetryKey: '',
|
selectedTelemetryKey: '',
|
||||||
selectedOperationKey: '',
|
selectedOperationKey: '',
|
||||||
selectedOutputKey: null,
|
selectedOutputKey: '',
|
||||||
stringOutputField: false,
|
stringOutputField: false,
|
||||||
comparisonValueField: false,
|
comparisonValueField: false,
|
||||||
operationValue: this.operationValue,
|
operationValue: this.operationValue,
|
||||||
@ -210,9 +211,6 @@ export default {
|
|||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
updated() {
|
updated() {
|
||||||
if (this.isCurrent && this.isCurrent.key === this.condition.key) {
|
|
||||||
this.updateCurrentCondition();
|
|
||||||
}
|
|
||||||
this.persist();
|
this.persist();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@ -222,7 +220,7 @@ export default {
|
|||||||
result: args.data.result
|
result: args.data.result
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
removeCondition(ev) { //move this to conditionCollection
|
removeCondition(ev) {
|
||||||
this.$emit('remove-condition', this.conditionIdentifier);
|
this.$emit('remove-condition', this.conditionIdentifier);
|
||||||
},
|
},
|
||||||
setOutput() {
|
setOutput() {
|
||||||
@ -262,32 +260,37 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
getTelemetryMetadataKey() {
|
getTelemetryMetadataKey() {
|
||||||
let index = 0;
|
let index = -1;
|
||||||
if (this.condition.definition.criteria[0].metaDataKey) {
|
if (this.condition.definition.criteria[0].metaDataKey) {
|
||||||
index = _.findIndex(this.telemetryMetadata, (metadata) => {
|
index = _.findIndex(this.telemetryMetadata, (metadata) => {
|
||||||
return metadata.key === this.condition.definition.criteria[0].metaDataKey;
|
return metadata.key === this.condition.definition.criteria[0].metaDataKey;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return this.telemetryMetadata.length ? this.telemetryMetadata[index].key : null;
|
return this.telemetryMetadata.length && index > -1 ? this.telemetryMetadata[index].key : '';
|
||||||
},
|
},
|
||||||
getTelemetryKey() {
|
getTelemetryKey() {
|
||||||
let index = 0;
|
let index = -1;
|
||||||
if (this.condition.definition.criteria[0].key) {
|
if (this.condition.definition.criteria[0].key) {
|
||||||
index = _.findIndex(this.telemetry, (obj) => {
|
index = _.findIndex(this.telemetry, (obj) => {
|
||||||
let key = this.openmct.objects.makeKeyString(obj.identifier);
|
let key = this.openmct.objects.makeKeyString(obj.identifier);
|
||||||
return key === this.condition.definition.criteria[0].key;
|
let conditionKey = this.openmct.objects.makeKeyString(this.condition.definition.criteria[0].key);
|
||||||
|
return key === conditionKey;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return this.telemetry.length ? this.telemetry[index].identifier : null;
|
return this.telemetry.length && index > -1 ? this.telemetry[index].identifier : '';
|
||||||
},
|
},
|
||||||
hasTelemetry() {
|
hasTelemetry() {
|
||||||
return this.condition.definition.criteria.length && this.condition.definition.criteria[0].key;
|
return this.condition.definition.criteria.length && this.condition.definition.criteria[0].key;
|
||||||
},
|
},
|
||||||
persist() {
|
updateConditionCriteria() {
|
||||||
if (this.condition.definition.criteria.length) {
|
if (this.condition.definition.criteria.length) {
|
||||||
|
this.condition.definition.criteria[0].key = this.selectedTelemetryKey;
|
||||||
this.condition.definition.criteria[0].metaDataKey = this.selectedMetaDataKey;
|
this.condition.definition.criteria[0].metaDataKey = this.selectedMetaDataKey;
|
||||||
|
this.condition.definition.criteria[0].operation = this.selectedOperationKey;
|
||||||
this.condition.definition.criteria[0].input = this.operationValue || '';
|
this.condition.definition.criteria[0].input = this.operationValue || '';
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
persist() {
|
||||||
this.openmct.objects.mutate(this.condition, 'definition', this.condition.definition);
|
this.openmct.objects.mutate(this.condition, 'definition', this.condition.definition);
|
||||||
},
|
},
|
||||||
checkInputValue() {
|
checkInputValue() {
|
||||||
@ -298,18 +301,22 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
operationKeyChange(ev) {
|
operationKeyChange(ev) {
|
||||||
if (ev.target.value !== 'isUndefined' && ev.target.value !== 'isDefined') {
|
if (this.selectedOperationKey !== 'isUndefined' && this.selectedOperationKey !== 'isDefined') {
|
||||||
this.comparisonValueField = true;
|
this.comparisonValueField = true;
|
||||||
} else {
|
} else {
|
||||||
this.comparisonValueField = false;
|
this.comparisonValueField = false;
|
||||||
}
|
}
|
||||||
this.condition.definition.criteria[0].operation = this.selectedOperationKey;
|
this.updateConditionCriteria();
|
||||||
this.persist();
|
|
||||||
//find the criterion being updated and set the operation property
|
//find the criterion being updated and set the operation property
|
||||||
},
|
},
|
||||||
|
telemetryChange() {
|
||||||
|
this.selectedMetaDataKey = '';
|
||||||
|
this.updateConditionCriteria();
|
||||||
|
this.updateTelemetry();
|
||||||
|
},
|
||||||
getOperationValue(ev) {
|
getOperationValue(ev) {
|
||||||
this.condition.definition.criteria[0].input = [ev.target.value];
|
// this.condition.definition.criteria[0].input = [ev.target.value];
|
||||||
this.persist();
|
this.updateConditionCriteria();
|
||||||
//find the criterion being updated and set the input property
|
//find the criterion being updated and set the input property
|
||||||
},
|
},
|
||||||
updateCurrentCondition() {
|
updateCurrentCondition() {
|
||||||
|
@ -78,6 +78,7 @@ export default class TelemetryCriterion extends EventEmitter {
|
|||||||
let result = false;
|
let result = false;
|
||||||
params.push(data[this.metaDataKey]);
|
params.push(data[this.metaDataKey]);
|
||||||
params.push(this.input);
|
params.push(this.input);
|
||||||
|
console.log(params);
|
||||||
if (typeof comparator === 'function') {
|
if (typeof comparator === 'function') {
|
||||||
result = comparator(params);
|
result = comparator(params);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user