mirror of
https://github.com/nasa/openmct.git
synced 2025-01-02 19:36:41 +00:00
WIP - Adding criteria using this.currentCriteria
This commit is contained in:
parent
6f6fb859d6
commit
f25eebdf3f
@ -81,14 +81,16 @@
|
|||||||
</span>
|
</span>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<ul class="t-widget-rule-config">
|
<ul class="t-widget-rule-config"
|
||||||
<li v-if="telemetry.length"
|
v-if="telemetry.length">
|
||||||
|
<li v-for="criteria in condition.definition.criteria"
|
||||||
|
:key="criteria.key.key"
|
||||||
class="has-local-controls t-condition"
|
class="has-local-controls t-condition"
|
||||||
>
|
>
|
||||||
<label>when</label>
|
<label>when</label>
|
||||||
<span class="t-configuration">
|
<span class="t-configuration">
|
||||||
<span class="controls">
|
<span class="controls">
|
||||||
<select v-model="selectedTelemetryKey"
|
<select v-model="selectedTelemetryKey[criteria.key.key]"
|
||||||
@change="updateTelemetryMetaData"
|
@change="updateTelemetryMetaData"
|
||||||
>
|
>
|
||||||
<option value="">- Select Telemetry -</option>
|
<option value="">- Select Telemetry -</option>
|
||||||
@ -144,6 +146,7 @@
|
|||||||
<script>
|
<script>
|
||||||
import { OPERATIONS } from '../utils/operations';
|
import { OPERATIONS } from '../utils/operations';
|
||||||
import ConditionClass from "@/plugins/condition/Condition";
|
import ConditionClass from "@/plugins/condition/Condition";
|
||||||
|
import uuid from 'uuid';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
inject: ['openmct', 'domainObject'],
|
inject: ['openmct', 'domainObject'],
|
||||||
@ -169,8 +172,8 @@ export default {
|
|||||||
telemetryObject: this.telemetryObject,
|
telemetryObject: this.telemetryObject,
|
||||||
telemetryMetadata: this.telemetryMetadata,
|
telemetryMetadata: this.telemetryMetadata,
|
||||||
operations: OPERATIONS,
|
operations: OPERATIONS,
|
||||||
selectedMetaDataKey: '',
|
selectedMetaDataKey: {},
|
||||||
selectedTelemetryKey: '',
|
selectedTelemetryKey: {},
|
||||||
selectedOperationKey: '',
|
selectedOperationKey: '',
|
||||||
selectedOutputKey: '',
|
selectedOutputKey: '',
|
||||||
stringOutputField: false,
|
stringOutputField: false,
|
||||||
@ -209,12 +212,27 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
initialize() {
|
initialize() {
|
||||||
|
this.condition.definition.criteria.push({
|
||||||
|
operation: '',
|
||||||
|
input: '',
|
||||||
|
metaDataKey: '',
|
||||||
|
key: {
|
||||||
|
namespace: '',
|
||||||
|
key: uuid()
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if(this.condition.definition.criteria.length) {
|
||||||
|
this.setCurrentCriterion(0);
|
||||||
|
}
|
||||||
this.setOutput();
|
this.setOutput();
|
||||||
this.setOperation();
|
this.setOperation();
|
||||||
this.updateTelemetry();
|
this.updateTelemetry();
|
||||||
this.conditionClass = new ConditionClass(this.condition, this.openmct);
|
this.conditionClass = new ConditionClass(this.condition, this.openmct);
|
||||||
this.conditionClass.on('conditionResultUpdated', this.handleConditionResult.bind(this));
|
this.conditionClass.on('conditionResultUpdated', this.handleConditionResult.bind(this));
|
||||||
},
|
},
|
||||||
|
setCurrentCriterion(index) {
|
||||||
|
this.currentCriteria = this.condition.definition.criteria[index];
|
||||||
|
},
|
||||||
destroy() {
|
destroy() {
|
||||||
this.conditionClass.off('conditionResultUpdated', this.handleConditionResult.bind(this));
|
this.conditionClass.off('conditionResultUpdated', this.handleConditionResult.bind(this));
|
||||||
if (this.conditionClass && typeof this.conditionClass.destroy === 'function') {
|
if (this.conditionClass && typeof this.conditionClass.destroy === 'function') {
|
||||||
@ -223,8 +241,8 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
reset() {
|
reset() {
|
||||||
this.selectedMetaDataKey = '';
|
this.selectedMetaDataKey = {};
|
||||||
this.selectedTelemetryKey = '';
|
this.selectedTelemetryKey = {};
|
||||||
this.selectedOperationKey = '';
|
this.selectedOperationKey = '';
|
||||||
this.operationValue = '';
|
this.operationValue = '';
|
||||||
},
|
},
|
||||||
@ -258,13 +276,13 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
setOperation() {
|
setOperation() {
|
||||||
if (this.condition.definition.criteria.length && this.condition.definition.criteria[0].operation) {
|
if (this.currentCriteria && this.currentCriteria.operation) {
|
||||||
for (let i=0, ii=this.operations.length; i < ii; i++) {
|
for (let i=0, ii=this.operations.length; i < ii; i++) {
|
||||||
if (this.condition.definition.criteria[0].operation === this.operations[i].name) {
|
if (this.currentCriteria.operation === this.operations[i].name) {
|
||||||
this.selectedOperationKey = this.operations[i].name;
|
this.selectedOperationKey = this.operations[i].name;
|
||||||
this.comparisonValueField = this.operations[i].inputCount > 0;
|
this.comparisonValueField = this.operations[i].inputCount > 0;
|
||||||
if (this.comparisonValueField) {
|
if (this.comparisonValueField) {
|
||||||
this.operationValue = this.condition.definition.criteria[0].input[0];
|
this.operationValue = this.currentCriteria.input[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -272,11 +290,11 @@ export default {
|
|||||||
},
|
},
|
||||||
updateTelemetry() {
|
updateTelemetry() {
|
||||||
if (this.hasTelemetry()) {
|
if (this.hasTelemetry()) {
|
||||||
this.openmct.objects.get(this.condition.definition.criteria[0].key).then((obj) => {
|
this.openmct.objects.get(this.currentCriteria.key).then((obj) => {
|
||||||
this.telemetryObject = obj;
|
this.telemetryObject = obj;
|
||||||
this.telemetryMetadata = this.openmct.telemetry.getMetadata(this.telemetryObject).values();
|
this.telemetryMetadata = this.openmct.telemetry.getMetadata(this.telemetryObject).values();
|
||||||
this.selectedMetaDataKey = this.getTelemetryMetadataKey();
|
this.selectedMetaDataKey = this.getTelemetryMetadataKey();
|
||||||
this.selectedTelemetryKey = this.getTelemetryKey();
|
this.selectedTelemetryKey[this.currentCriteria.key] = this.getTelemetryKey();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.telemetryObject = null;
|
this.telemetryObject = null;
|
||||||
@ -284,33 +302,33 @@ export default {
|
|||||||
},
|
},
|
||||||
getTelemetryMetadataKey() {
|
getTelemetryMetadataKey() {
|
||||||
let index = -1;
|
let index = -1;
|
||||||
if (this.condition.definition.criteria[0].metaDataKey) {
|
if (this.currentCriteria.metaDataKey) {
|
||||||
index = _.findIndex(this.telemetryMetadata, (metadata) => {
|
index = _.findIndex(this.telemetryMetadata, (metadata) => {
|
||||||
return metadata.key === this.condition.definition.criteria[0].metaDataKey;
|
return metadata.key === this.currentCriteria.metaDataKey;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return this.telemetryMetadata.length && index > -1 ? this.telemetryMetadata[index].key : '';
|
return this.telemetryMetadata.length && index > -1 ? this.telemetryMetadata[index].key : '';
|
||||||
},
|
},
|
||||||
getTelemetryKey() {
|
getTelemetryKey() {
|
||||||
let index = -1;
|
let index = -1;
|
||||||
if (this.condition.definition.criteria[0].key) {
|
if (this.currentCriteria.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);
|
||||||
let conditionKey = this.openmct.objects.makeKeyString(this.condition.definition.criteria[0].key);
|
let conditionKey = this.openmct.objects.makeKeyString(this.currentCriteria.key);
|
||||||
return key === conditionKey;
|
return key === conditionKey;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return this.telemetry.length && index > -1 ? this.telemetry[index].identifier : '';
|
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.currentCriteria && this.currentCriteria.key;
|
||||||
},
|
},
|
||||||
updateConditionCriteria() {
|
updateConditionCriteria() {
|
||||||
if (this.condition.definition.criteria.length) {
|
if (this.currentCriteria) {
|
||||||
this.condition.definition.criteria[0].key = this.selectedTelemetryKey;
|
this.currentCriteria.key = this.selectedTelemetryKey;
|
||||||
this.condition.definition.criteria[0].metaDataKey = this.selectedMetaDataKey;
|
this.currentCriteria.metaDataKey = this.selectedMetaDataKey;
|
||||||
this.condition.definition.criteria[0].operation = this.selectedOperationKey;
|
this.currentCriteria.operation = this.selectedOperationKey;
|
||||||
this.condition.definition.criteria[0].input = [this.operationValue];
|
this.currentCriteria.input = [this.operationValue];
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
persist() {
|
persist() {
|
||||||
|
Loading…
Reference in New Issue
Block a user