no current output rendered

This commit is contained in:
Joel McKinnon 2020-01-22 13:15:44 -08:00
parent 73d0507f1f
commit 709c3fff65
4 changed files with 90 additions and 51 deletions

View File

@ -6,15 +6,15 @@
>
<div class="title-bar">
<span class="condition-name">
{{ condition.name }}
{{ condition.definition.name }}
</span>
<span class="condition-output">
Output: {{ condition.output }}
Output: {{ condition.definition.output }}
</span>
</div>
<div class="condition-config">
<span class="condition-description">
{{ condition.description }}
{{ condition.definition.description }}
</span>
</div>
</div>
@ -41,7 +41,7 @@ export default {
mounted() {
this.openmct.objects.get(this.conditionIdentifier).then((obj => {
this.condition = obj;
console.log('this.isCurrent.key', this.isCurrent.key)
console.log('this.isCurrent', this.isCurrent)
}));
}
}

View File

@ -55,7 +55,6 @@
import Condition from '../../condition/components/Condition.vue';
import ConditionEdit from '../../condition/components/ConditionEdit.vue';
import uuid from 'uuid';
import ConditionClass from '../Condition';
export default {
inject: ['openmct', 'domainObject'],
@ -85,12 +84,12 @@ export default {
this.composition.on('add', this.addTelemetry);
this.composition.load();
this.conditionCollection = this.domainObject.configuration ? this.domainObject.configuration.conditionCollection : [];
if (!this.conditionCollection.length) {
this.addCondition(null, true);
}
if (!this.conditionCollection.length) {this.addCondition(null, true)}
},
methods: {
handleConditionResult(args) {
console.log('ConditionCollection: ', args.result);
},
addTelemetry(telemetryDomainObject) {
this.telemetryObjs.push(telemetryDomainObject);
},
@ -98,12 +97,7 @@ export default {
let conditionDO = this.getConditionDomainObject(!!isDefault);
//persist the condition DO 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(conditionDO, 'created', new Date());
this.currentConditionIdentifier = conditionDO.identifier;
this.conditionCollection.unshift(conditionDO.identifier);
let condition = new ConditionClass(conditionDO, this.openmct);
this.conditions.push(condition);
},
updateCurrentCondition(identifier) {
this.currentConditionIdentifier = identifier;
@ -111,20 +105,21 @@ export default {
getConditionDomainObject(isDefault) {
let conditionObj = {
isDefault: isDefault,
isCurrent: true,
identifier: {
namespace: this.domainObject.identifier.namespace,
key: uuid()
},
name: isDefault ? 'Default' : 'Unnamed Condition',
trigger: 'any',
criteria: isDefault ? [] : [{
operation: '',
input: '',
metaDataKey: this.openmct.telemetry.getMetadata(this.telemetryObjs[0]).values()[0].key,
key: this.telemetryObjs.length ? this.openmct.objects.makeKeyString(this.telemetryObjs[0].identifier) : null
}],
output: 'false',
definition: {
name: isDefault ? 'Default' : 'Unnamed Condition',
output: 'false',
trigger: 'any',
criteria: isDefault ? [] : [{
operation: '',
input: '',
metaDataKey: this.openmct.telemetry.getMetadata(this.telemetryObjs[0]).values()[0].key,
key: this.telemetryObjs.length ? this.openmct.objects.makeKeyString(this.telemetryObjs[0].identifier) : null
}]
},
summary: 'summary description'
};
let conditionDOKeyString = this.openmct.objects.makeKeyString(conditionObj.identifier);

View File

@ -15,8 +15,8 @@
@click="expanded = !condition.expanded"
></span>
<div class="condition-summary">
<span class="condition-name">{{ condition.name }}</span>
<span class="condition-description">{{ condition.description }}</span>
<span class="condition-name">{{ condition.definition.name }}</span>
<span class="condition-description">{{ condition.definition.name }}</span>
</div>
<span v-if="!condition.isDefault"
class="is-enabled c-c__duplicate"
@ -39,7 +39,7 @@
<li>
<label>Condition Name</label>
<span class="controls">
<input v-model="condition.name"
<input v-model="condition.definition.name"
class="t-rule-name-input"
type="text"
>
@ -48,19 +48,21 @@
<li>
<label>Output</label>
<span class="controls">
<select ref="outputSelect"
@change="getOutputBoolean"
<select v-model="selectedOutputKey"
@change="checkInputValue"
>
<option value="false">False</option>
<option value="true">True</option>
<option value="string">String</option>
<option value="">- Select Output -</option>
<option v-for="option in outputOptions"
:key="option.key"
:value="option.key"
>
{{ option.text }}
</option>
</select>
<input v-if="stringOutputField"
ref="outputString"
<input v-if="selectedOutputKey === outputOptions[2].key"
v-model="condition.definition.output"
class="t-rule-name-input"
type="text"
:value="condition.output"
@keyup="getOutputString"
>
</span>
</li>
@ -132,6 +134,7 @@
<script>
import { OPERATIONS } from '../utils/operations';
import ConditionClass from "@/plugins/condition/Condition";
export default {
inject: ['openmct', 'domainObject'],
@ -153,22 +156,41 @@ export default {
telemetryMetadata: this.telemetryMetadata,
operations: OPERATIONS,
selectedMetaDataKey: null,
selectedTelemetryKey: null,
selectedOperationKey: null,
stringOutputField: false,
comparisonValueField: false
selectedOutputKey: null,
comparisonValueField: false,
outputOptions: [
{
key: 'false',
text: 'False'
},
{
key: 'true',
text: 'True'
},
{
key: 'string',
text: 'String'
}
]
};
},
destroyed() {
if (this.conditionClass && typeof this.conditionClass.destroy === 'function') {
this.conditionClass.destroy();
}
},
mounted() {
this.openmct.objects.get(this.conditionIdentifier).then((obj => {
this.condition = obj;
if (this.condition.output !== 'false' && this.condition.output !== 'true') {
this.$refs.outputSelect.value = 'string';
this.stringOutputField = true;
}
console.log('this.isCurrent.key', this.isCurrent.key)
this.conditionClass = new ConditionClass(this.condition, this.openmct);
this.conditionClass.on('conditionResultUpdated', this.handleConditionResult.bind(this))
this.setOutput();
this.updateTelemetry();
}));
this.updateCurrentCondition();
},
updated() {
if (this.isCurrent && this.isCurrent.key === this.condition.key) {
@ -177,12 +199,32 @@ export default {
this.persist();
},
methods: {
handleConditionResult(args) {
console.log('ConditionEdit::Result', args);
this.$emit('condition-result-updated', {
id: this.conditionIdentifier,
result: args.data.result
})
},
removeCondition() {
this.$emit('remove-condition', this.conditionIdentifier);
},
setOutput() {
if (this.condition.definition.output !== 'false' && this.condition.definition.output !== 'true') {
// this.$refs.outputSelect.value = 'string';
this.selectedOutputKey = this.outputOptions[2].key;
// this.stringOutputField = true;
} else {
if (this.condition.definition.output === 'true') {
this.selectedOutputKey = this.outputOptions[1].key;
} else {
this.selectedOutputKey = this.outputOptions[0].key;
}
}
},
updateTelemetry() {
if (this.hasTelemetry()) {
this.openmct.objects.get(this.condition.criteria[0].key).then((obj) => {
this.openmct.objects.get(this.condition.definition.criteria[0].key).then((obj) => {
this.telemetryObject = obj;
this.telemetryMetadata = this.openmct.telemetry.getMetadata(this.telemetryObject).values();
this.selectedMetaDataKey = this.telemetryMetadata[0].key;
@ -192,13 +234,10 @@ export default {
}
},
hasTelemetry() {
return this.condition.criteria.length && this.condition.criteria[0].key;
return this.condition.definition.criteria.length && this.condition.definition.criteria[0].key;
},
persist() {
this.openmct.objects.mutate(this.domainObject, 'isCurrent', this.condition.isCurrent);
this.openmct.objects.mutate(this.condition, 'name', this.condition.name);
this.openmct.objects.mutate(this.condition, 'output', this.condition.output);
this.openmct.objects.mutate(this.condition, 'definition', this.condition.definition);
},
updateCurrentCondition() {
this.$emit('update-current-condition', this.conditionIdentifier);
@ -210,11 +249,15 @@ export default {
} else {
this.stringOutputField = true
}
this.updateCurrentCondition();
},
getOutputString(ev) {
this.condition.output = ev.target.value;
},
checkInputValue() {
if (this.selectedOutputKey === this.outputOptions[2].key) {
this.condition.definition.output = '';
}
},
getOperationKey(ev) {
if (ev.target.value !== 'isUndefined' && ev.target.value !== 'isDefined') {
this.comparisonValueField = true;
@ -222,6 +265,8 @@ export default {
this.comparisonValueField = false;
}
this.selectedOperationKey = ev.target.value;
this.condition.definition.operator = this.selectedOperationKey;
this.persist();
},
getOperationValue(ev) {
this.selectedOperationKey = ev.target.value;

View File

@ -30,7 +30,6 @@ export default {
},
data() {
return {
conditionCollection: this.conditionCollection,
currentCondition: this.currentCondition
}
},