mirror of
https://github.com/nasa/openmct.git
synced 2025-05-31 14:40:48 +00:00
condition view with highlighting of current condition, add/remove condition, change name, output and persist
This commit is contained in:
parent
cfd9730055
commit
a8da06033c
@ -2,7 +2,7 @@
|
|||||||
<div v-if="condition"
|
<div v-if="condition"
|
||||||
id="conditionArea"
|
id="conditionArea"
|
||||||
class="c-cs-ui__conditions"
|
class="c-cs-ui__conditions"
|
||||||
:class="['widget-condition', { 'widget-condition--current': isCurrent && (isCurrent.key === conditionIdentifier.key) }]"
|
:class="['widget-condition', { 'widget-condition--current': currentConditionIdentifier && (currentConditionIdentifier.key === conditionIdentifier.key) }]"
|
||||||
>
|
>
|
||||||
<div class="title-bar">
|
<div class="title-bar">
|
||||||
<span class="condition-name">
|
<span class="condition-name">
|
||||||
@ -28,7 +28,7 @@ export default {
|
|||||||
type: Object,
|
type: Object,
|
||||||
required: true
|
required: true
|
||||||
},
|
},
|
||||||
isCurrent: {
|
currentConditionIdentifier: {
|
||||||
type: Object,
|
type: Object,
|
||||||
required: true
|
required: true
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
>
|
>
|
||||||
<div v-if="isEditing">
|
<div v-if="isEditing">
|
||||||
<ConditionEdit :condition-identifier="conditionIdentifier"
|
<ConditionEdit :condition-identifier="conditionIdentifier"
|
||||||
:is-current="currentConditionIdentifier"
|
:current-condition-identifier="currentConditionIdentifier"
|
||||||
@update-current-condition="updateCurrentCondition"
|
@update-current-condition="updateCurrentCondition"
|
||||||
@remove-condition="removeCondition"
|
@remove-condition="removeCondition"
|
||||||
@condition-result-updated="handleConditionResult"
|
@condition-result-updated="handleConditionResult"
|
||||||
@ -43,7 +43,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div v-else>
|
<div v-else>
|
||||||
<Condition :condition-identifier="conditionIdentifier"
|
<Condition :condition-identifier="conditionIdentifier"
|
||||||
:is-current="currentConditionIdentifier"
|
:current-condition-identifier="currentConditionIdentifier"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -80,16 +80,35 @@ export default {
|
|||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.telemetryObjs = [];
|
this.telemetryObjs = [];
|
||||||
|
this.conditionResults = {};
|
||||||
this.instantiate = this.openmct.$injector.get('instantiate');
|
this.instantiate = this.openmct.$injector.get('instantiate');
|
||||||
this.composition = this.openmct.composition.get(this.domainObject);
|
this.composition = this.openmct.composition.get(this.domainObject);
|
||||||
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) {this.addCondition(null, true)}
|
if (!this.conditionCollection.length) {
|
||||||
|
this.addCondition(null, true);
|
||||||
|
} else {
|
||||||
|
this.updateCurrentCondition(this.conditionCollection[0]);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
handleConditionResult(args) {
|
handleConditionResult(args) {
|
||||||
console.log('ConditionCollection: ', args.result);
|
let idAsString = this.openmct.objects.makeKeyString(args.id);
|
||||||
|
this.conditionResults[idAsString] = args.result;
|
||||||
|
this.updateCurrentConditionId();
|
||||||
|
},
|
||||||
|
updateCurrentConditionId() {
|
||||||
|
let currentConditionIdentifier = this.conditionCollection[this.conditionCollection.length-1];
|
||||||
|
for (let i=0, ii = this.conditionCollection.length-1; i< ii; i++) {
|
||||||
|
let conditionIdAsString = this.openmct.objects.makeKeyString(this.conditionCollection[i]);
|
||||||
|
if (this.conditionResults[conditionIdAsString]) {
|
||||||
|
//first condition to be true wins
|
||||||
|
currentConditionIdentifier = this.conditionCollection[i];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.$emit('current-condition-updated', currentConditionIdentifier);
|
||||||
},
|
},
|
||||||
addTelemetry(telemetryDomainObject) {
|
addTelemetry(telemetryDomainObject) {
|
||||||
this.telemetryObjs.push(telemetryDomainObject);
|
this.telemetryObjs.push(telemetryDomainObject);
|
||||||
@ -135,12 +154,14 @@ export default {
|
|||||||
this.conditions[index] = updatedCondition;
|
this.conditions[index] = updatedCondition;
|
||||||
},
|
},
|
||||||
removeCondition(identifier) {
|
removeCondition(identifier) {
|
||||||
console.log('this.conditions', this.conditions);
|
|
||||||
let index = _.findIndex(this.conditionCollection, (condition) => {
|
let index = _.findIndex(this.conditionCollection, (condition) => {
|
||||||
identifier.key === condition.key
|
let conditionId = this.openmct.objects.makeKeyString(condition);
|
||||||
|
let id = this.openmct.objects.makeKeyString(identifier);
|
||||||
|
return conditionId === id;
|
||||||
});
|
});
|
||||||
this.conditionCollection.splice(index + 1, 1);
|
this.conditionCollection.splice(index, 1);
|
||||||
this.persist();
|
this.persist();
|
||||||
|
this.updateCurrentConditionId();
|
||||||
},
|
},
|
||||||
reorder(reorderPlan) {
|
reorder(reorderPlan) {
|
||||||
let oldConditions = this.conditionCollection.slice();
|
let oldConditions = this.conditionCollection.slice();
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div v-if="condition"
|
<div v-if="condition"
|
||||||
class="c-cs-editui__conditions"
|
class="c-cs-editui__conditions"
|
||||||
:class="['widget-condition', { 'widget-condition--current': isCurrent && (isCurrent.key === conditionIdentifier.key) }]"
|
:class="['widget-condition', { 'widget-condition--current': currentConditionIdentifier && (currentConditionIdentifier.key === conditionIdentifier.key) }]"
|
||||||
>
|
>
|
||||||
<div class="title-bar">
|
<div class="title-bar">
|
||||||
<span
|
<span
|
||||||
@ -147,7 +147,7 @@ export default {
|
|||||||
type: Object,
|
type: Object,
|
||||||
required: true
|
required: true
|
||||||
},
|
},
|
||||||
isCurrent: {
|
currentConditionIdentifier: {
|
||||||
type: Object,
|
type: Object,
|
||||||
required: true
|
required: true
|
||||||
}
|
}
|
||||||
@ -160,8 +160,8 @@ export default {
|
|||||||
telemetryMetadata: this.telemetryMetadata,
|
telemetryMetadata: this.telemetryMetadata,
|
||||||
operations: OPERATIONS,
|
operations: OPERATIONS,
|
||||||
selectedMetaDataKey: null,
|
selectedMetaDataKey: null,
|
||||||
selectedTelemetryKey: null,
|
selectedTelemetryKey: '',
|
||||||
selectedOperationKey: null,
|
selectedOperationKey: '',
|
||||||
selectedOutputKey: null,
|
selectedOutputKey: null,
|
||||||
stringOutputField: false,
|
stringOutputField: false,
|
||||||
comparisonValueField: false,
|
comparisonValueField: false,
|
||||||
@ -206,7 +206,7 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
handleConditionResult(args) {
|
handleConditionResult(args) {
|
||||||
console.log('ConditionEdit::Result', args);
|
// console.log('ConditionEdit::Result', args);
|
||||||
this.$emit('condition-result-updated', {
|
this.$emit('condition-result-updated', {
|
||||||
id: this.conditionIdentifier,
|
id: this.conditionIdentifier,
|
||||||
result: args.data.result
|
result: args.data.result
|
||||||
@ -240,7 +240,8 @@ export default {
|
|||||||
this.openmct.objects.get(this.condition.definition.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;
|
||||||
|
this.selectedMetaDataKey = '';
|
||||||
this.selectedTelemetryKey = this.telemetryObject.identifier;
|
this.selectedTelemetryKey = this.telemetryObject.identifier;
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@ -256,6 +257,8 @@ export default {
|
|||||||
checkInputValue() {
|
checkInputValue() {
|
||||||
if (this.selectedOutputKey === this.outputOptions[2].key) {
|
if (this.selectedOutputKey === this.outputOptions[2].key) {
|
||||||
this.condition.definition.output = '';
|
this.condition.definition.output = '';
|
||||||
|
} else {
|
||||||
|
this.condition.definition.output = this.selectedOutputKey;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
operationKeyChange(ev) {
|
operationKeyChange(ev) {
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<CurrentOutput :condition="currentCondition" />
|
<CurrentOutput :condition="currentCondition" />
|
||||||
<TestData :is-editing="isEditing" />
|
<TestData :is-editing="isEditing" />
|
||||||
<ConditionCollection :is-editing="isEditing"
|
<ConditionCollection :is-editing="isEditing"
|
||||||
@update-current-condition="updateCurrentcondition"
|
@current-condition-updated="updateCurrentCondition"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -17,7 +17,6 @@ import CurrentOutput from './CurrentOutput.vue';
|
|||||||
import TestData from './TestData.vue';
|
import TestData from './TestData.vue';
|
||||||
import ConditionCollection from './ConditionCollection.vue';
|
import ConditionCollection from './ConditionCollection.vue';
|
||||||
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
inject: ["openmct", "domainObject"],
|
inject: ["openmct", "domainObject"],
|
||||||
components: {
|
components: {
|
||||||
@ -35,20 +34,19 @@ export default {
|
|||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
let conditionCollection = this.domainObject.configuration.conditionCollection;
|
let conditionCollection = this.domainObject.configuration.conditionCollection;
|
||||||
this.currentConditionIdentifier = conditionCollection.length ? this.domainObject.configuration.conditionCollection[0] : null;
|
this.currentConditionIdentifier = conditionCollection.length ? this.updateCurrentCondition(conditionCollection[0]) : null;
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
setCurrentCondition() {
|
||||||
if (this.currentConditionIdentifier) {
|
if (this.currentConditionIdentifier) {
|
||||||
this.openmct.objects.get(this.currentConditionIdentifier).then((obj) => {
|
this.openmct.objects.get(this.currentConditionIdentifier).then((obj) => {
|
||||||
this.currentCondition = obj;
|
this.currentCondition = obj;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
methods: {
|
updateCurrentCondition(conditionIdentifier) {
|
||||||
updateCurrentcondition(identifier) {
|
this.currentConditionIdentifier = conditionIdentifier;
|
||||||
this.currentConditionIdentifier = identifier;
|
this.setCurrentCondition();
|
||||||
this.openmct.objects.get(this.currentConditionIdentifier).then((obj) => {
|
|
||||||
this.currentCondition = obj;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user