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

View File

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

View File

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