resolve merge

This commit is contained in:
Joel McKinnon 2020-01-29 16:23:13 -08:00
parent 8886a94a01
commit 04a5c8f69f
2 changed files with 24 additions and 36 deletions

View File

@ -78,30 +78,24 @@
<li class="has-local-controls t-condition"> <li class="has-local-controls t-condition">
<label>Match when</label> <label>Match when</label>
<span class="controls"> <span class="controls">
<select> <select v-model="trigger">
<option value="all">all criteria are met</option> <option value="all">all criteria are met</option>
<option value="any">any criteria are met</option> <option value="any">any criteria are met</option>
</select> </select>
</span> </span>
</li> </li>
</ul> </ul>
<<<<<<< HEAD
<ul v-if="telemetry.length" <ul v-if="telemetry.length"
class="t-widget-condition-config"> class="t-widget-condition-config">
<li v-for="(criteria, index) in condition.definition.criteria" <li v-for="(criteria, index) in condition.definition.criteria"
=======
<ul class="t-widget-rule-config"
v-if="telemetry.length">
<li v-for="criteria in condition.definition.criteria"
>>>>>>> f25eebdf3f51d50f1fd180e4350fb0566f02e39f
:key="criteria.key.key" :key="criteria.key.key"
class="has-local-controls t-condition" class="has-local-controls t-condition"
> >
<label>{{ index === 0 ? 'when' : 'and when' }}</label> <label>{{ index === 0 ? 'when' : 'and when' }}</label>
<span class="t-configuration"> <span class="t-configuration">
<span class="controls"> <span class="controls">
<select v-model="selectedTelemetryKey[criteria.key.key]" <select v-model="selectedTelemetryKey"
@change="updateTelemetryMetaData" @change="telemetryChange"
> >
<option value="">- Select Telemetry -</option> <option value="">- Select Telemetry -</option>
<option v-for="telemetryOption in telemetry" <option v-for="telemetryOption in telemetry"
@ -125,7 +119,7 @@
</span> </span>
<span class="controls"> <span class="controls">
<select v-model="selectedOperationKey" <select v-model="selectedOperationKey"
@change="setInputValueVisibility" @change="operationKeyChange"
> >
<option value="">- Select Comparison -</option> <option value="">- Select Comparison -</option>
<option v-for="option in operations" <option v-for="option in operations"
@ -195,6 +189,7 @@ export default {
telemetryObject: this.telemetryObject, telemetryObject: this.telemetryObject,
telemetryMetadata: this.telemetryMetadata, telemetryMetadata: this.telemetryMetadata,
operations: OPERATIONS, operations: OPERATIONS,
trigger: 'all',
selectedMetaDataKey: {}, selectedMetaDataKey: {},
selectedTelemetryKey: {}, selectedTelemetryKey: {},
selectedOperationKey: '', selectedOperationKey: '',
@ -232,8 +227,8 @@ export default {
}, },
updated() { updated() {
//validate telemetry exists, update criteria as needed //validate telemetry exists, update criteria as needed
this.validate(); // this.validate();
this.persist(); // this.persist();
}, },
methods: { methods: {
addCriteria() { addCriteria() {
@ -253,15 +248,6 @@ export default {
this.$emit('set-move-index', Number(e.target.getAttribute('data-condition-index'))); this.$emit('set-move-index', Number(e.target.getAttribute('data-condition-index')));
}, },
initialize() { initialize() {
this.condition.definition.criteria.push({
operation: '',
input: '',
metaDataKey: '',
key: {
namespace: '',
key: uuid()
}
});
if(this.condition.definition.criteria.length) { if(this.condition.definition.criteria.length) {
this.setCurrentCriterion(0); this.setCurrentCriterion(0);
} }
@ -272,6 +258,7 @@ export default {
this.conditionClass.on('conditionResultUpdated', this.handleConditionResult.bind(this)); this.conditionClass.on('conditionResultUpdated', this.handleConditionResult.bind(this));
}, },
setCurrentCriterion(index) { setCurrentCriterion(index) {
console.log('setCurrentCriterion', 'index', index);
this.currentCriteria = this.condition.definition.criteria[index]; this.currentCriteria = this.condition.definition.criteria[index];
}, },
destroy() { destroy() {
@ -336,12 +323,13 @@ export default {
} }
}, },
updateTelemetry() { updateTelemetry() {
console.log('update telemetry - this.currentCriteria.key', this.currentCriteria.key);
if (this.hasTelemetry()) { if (this.hasTelemetry()) {
this.openmct.objects.get(this.currentCriteria.key).then((obj) => { this.openmct.objects.get(this.condition.definition.criteria[0].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.currentCriteria.key] = this.getTelemetryKey(); this.selectedTelemetryKey = this.getTelemetryKey();
}); });
} else { } else {
this.telemetryObject = null; this.telemetryObject = null;
@ -349,33 +337,33 @@ export default {
}, },
getTelemetryMetadataKey() { getTelemetryMetadataKey() {
let index = -1; let index = -1;
if (this.currentCriteria.metaDataKey) { if (this.condition.definition.criteria[0].metaDataKey) {
index = _.findIndex(this.telemetryMetadata, (metadata) => { index = _.findIndex(this.telemetryMetadata, (metadata) => {
return metadata.key === this.currentCriteria.metaDataKey; return metadata.key === this.condition.definition.criteria[0].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.currentCriteria.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);
let conditionKey = this.openmct.objects.makeKeyString(this.currentCriteria.key); let conditionKey = this.openmct.objects.makeKeyString(this.condition.definition.criteria[0].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.currentCriteria && this.currentCriteria.key; return this.condition.definition.criteria.length && this.condition.definition.criteria[0].key;
}, },
updateConditionCriteria() { updateConditionCriteria() {
if (this.currentCriteria) { if (this.condition.definition.criteria.length) {
this.currentCriteria.key = this.selectedTelemetryKey; this.condition.definition.criteria[0].key = this.selectedTelemetryKey;
this.currentCriteria.metaDataKey = this.selectedMetaDataKey; this.condition.definition.criteria[0].metaDataKey = this.selectedMetaDataKey;
this.currentCriteria.operation = this.selectedOperationKey; this.condition.definition.criteria[0].operation = this.selectedOperationKey;
this.currentCriteria.input = [this.operationValue]; this.condition.definition.criteria[0].input = [this.operationValue];
} }
}, },
persist() { persist() {
@ -389,7 +377,7 @@ export default {
this.condition.definition.output = this.selectedOutputKey; this.condition.definition.output = this.selectedOutputKey;
} }
}, },
setInputValueVisibility(ev) { operationKeyChange(ev) {
if (this.selectedOperationKey !== 'isUndefined' && this.selectedOperationKey !== 'isDefined') { if (this.selectedOperationKey !== 'isUndefined' && this.selectedOperationKey !== 'isDefined') {
this.comparisonValueField = true; this.comparisonValueField = true;
} else { } else {
@ -397,7 +385,7 @@ export default {
} }
//find the criterion being updated and set the operation property //find the criterion being updated and set the operation property
}, },
updateTelemetryMetaData() { telemetryChange() {
this.selectedMetaDataKey = ''; this.selectedMetaDataKey = '';
this.updateConditionCriteria(); this.updateConditionCriteria();
this.updateTelemetry(); this.updateTelemetry();

View File

@ -28,7 +28,7 @@
.c-c-button--menu[class*="--minor"], .c-c-button--menu[class*="--minor"],
.c-c-button--menu[class*='is-active'] { .c-c-button--menu[class*='is-active'] {
border: solid 1px #666; border: solid 1px #666;
background-color: #eee; background-color: #fff;
padding: 0.1em 0.4em; padding: 0.1em 0.4em;
margin: 0.4em; margin: 0.4em;
font-weight: normal; font-weight: normal;