mirror of
https://github.com/nasa/openmct.git
synced 2025-03-11 06:54:01 +00:00
Merge branch 'conditionSet-view' of https://github.com/nasa/openmct into conditionSet-with-classes
This commit is contained in:
commit
9fd720777b
@ -30,7 +30,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="condition-collection">
|
<div class="condition-collection">
|
||||||
<div v-for="condition in conditionCollection"
|
<div v-for="condition in conditionCollection"
|
||||||
:key="condition.id"
|
:key="condition.identifier.key"
|
||||||
class="conditionArea"
|
class="conditionArea"
|
||||||
>
|
>
|
||||||
<div v-if="isEditing">
|
<div v-if="isEditing">
|
||||||
@ -94,6 +94,7 @@ export default {
|
|||||||
getConditionDomainObject(isDefault) {
|
getConditionDomainObject(isDefault) {
|
||||||
let conditionObj = {
|
let conditionObj = {
|
||||||
isDefault: isDefault,
|
isDefault: isDefault,
|
||||||
|
isCurrent: true,
|
||||||
identifier: {
|
identifier: {
|
||||||
namespace: "",
|
namespace: "",
|
||||||
key: uuid()
|
key: uuid()
|
||||||
@ -106,8 +107,8 @@ export default {
|
|||||||
metaDataKey: this.openmct.telemetry.getMetadata(this.telemetryObjs[0]).values()[0].key,
|
metaDataKey: this.openmct.telemetry.getMetadata(this.telemetryObjs[0]).values()[0].key,
|
||||||
key: this.telemetryObjs.length ? this.openmct.objects.makeKeyString(this.telemetryObjs[0].identifier) : null
|
key: this.telemetryObjs.length ? this.openmct.objects.makeKeyString(this.telemetryObjs[0].identifier) : null
|
||||||
}],
|
}],
|
||||||
output: 'Default test',
|
output: 'false',
|
||||||
type: 'condition'
|
summary: 'summary description'
|
||||||
};
|
};
|
||||||
let conditionDOKeyString = this.openmct.objects.makeKeyString(conditionObj.identifier);
|
let conditionDOKeyString = this.openmct.objects.makeKeyString(conditionObj.identifier);
|
||||||
let newDO = this.instantiate(conditionObj, conditionDOKeyString);
|
let newDO = this.instantiate(conditionObj, conditionDOKeyString);
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
<div>
|
<div>
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
<label>Condition Names</label>
|
<label>Condition Name</label>
|
||||||
<span class="controls">
|
<span class="controls">
|
||||||
<input v-model="condition.name"
|
<input v-model="condition.name"
|
||||||
class="t-rule-name-input"
|
class="t-rule-name-input"
|
||||||
@ -44,19 +44,41 @@
|
|||||||
>
|
>
|
||||||
</span>
|
</span>
|
||||||
</li>
|
</li>
|
||||||
<li v-if="telemetryObject">
|
<li v-if="telemetryObject && telemetryMetadata">
|
||||||
<label>when</label>
|
<label>when</label>
|
||||||
<span class="controls">
|
<span class="controls">
|
||||||
<select class="">
|
<select class="">
|
||||||
<option :value="telemetryObject.key">@{{ telemetryObject.name }}</option>
|
<option :value="telemetryObject.key">{{ telemetryObject.name }}</option>
|
||||||
|
</select>
|
||||||
|
</span>
|
||||||
|
<span class="controls">
|
||||||
|
<select v-model="selectedMetaDataKey">
|
||||||
|
<option v-for="option in telemetryMetadata"
|
||||||
|
:key="option.key"
|
||||||
|
:value="option.key"
|
||||||
|
>
|
||||||
|
{{ option.name }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<span class="controls">
|
||||||
|
<select v-model="selectedOperationKey">
|
||||||
|
<option v-for="option in operations"
|
||||||
|
:key="option.name"
|
||||||
|
:value="option.name"
|
||||||
|
>
|
||||||
|
{{ option.text }}
|
||||||
|
</option>
|
||||||
</select>
|
</select>
|
||||||
</span>
|
</span>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<label>Output</label>
|
<label>Output</label>
|
||||||
<span class="controls">
|
<span class="controls">
|
||||||
<select class="">
|
<select v-model="condition.output">
|
||||||
<option value="false">false</option>
|
<option value="false">false</option>
|
||||||
|
<option value="true">true</option>
|
||||||
</select>
|
</select>
|
||||||
</span>
|
</span>
|
||||||
</li>
|
</li>
|
||||||
@ -70,6 +92,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import { OPERATIONS } from '../utils/operations';
|
||||||
export default {
|
export default {
|
||||||
inject: ['openmct', 'domainObject'],
|
inject: ['openmct', 'domainObject'],
|
||||||
props: {
|
props: {
|
||||||
@ -79,20 +102,26 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
|
let conditionCollection = this.domainObject.configuration.conditionCollection;
|
||||||
return {
|
return {
|
||||||
expanded: true,
|
expanded: true,
|
||||||
name: this.condition.name,
|
name: this.condition.name,
|
||||||
description: this.condition.description,
|
description: this.condition.description,
|
||||||
telemetryObject: this.telemetryObject
|
conditionCollection,
|
||||||
|
telemetryObject: this.telemetryObject,
|
||||||
|
telemetryMetadata: this.telemetryMetadata,
|
||||||
|
operations: OPERATIONS,
|
||||||
|
selectedMetaDataKey: null,
|
||||||
|
selectedOperationKey: null
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.updateTelemetry();
|
this.updateTelemetry();
|
||||||
},
|
},
|
||||||
updated() {
|
updated() {
|
||||||
console.log('updated');
|
console.log('updated conditionEdit');
|
||||||
this.persist();
|
this.updateCurrentCondition();
|
||||||
// this.updateTelemetry();
|
this.persist()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
removeCondition(ev) {
|
removeCondition(ev) {
|
||||||
@ -103,11 +132,16 @@ export default {
|
|||||||
this.domainObject.configuration.conditionCollection.splice(index, 1);
|
this.domainObject.configuration.conditionCollection.splice(index, 1);
|
||||||
},
|
},
|
||||||
updateTelemetry() {
|
updateTelemetry() {
|
||||||
this.telemetryObject = this.hasTelemetry() ? this.openmct.objects.get(this.condition.criteria[0].key) : null;
|
if (this.hasTelemetry()) {
|
||||||
if (this.telemetryObject) {
|
this.openmct.objects.get(this.condition.criteria[0].key).then((obj) => {
|
||||||
this.telemetryMetadata = this.openmct.telemetry.getMetadata().values();
|
this.telemetryObject = obj;
|
||||||
|
this.telemetryMetadata = this.openmct.telemetry.getMetadata(this.telemetryObject).values();
|
||||||
|
this.selectedMetaDataKey = this.telemetryMetadata[0].key;
|
||||||
|
console.log('ConditionEdit', this.telemetryObject, this.telemetryMetadata);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.telemetryObject = null;
|
||||||
}
|
}
|
||||||
console.log('ConditionEdit', this.telemetryObject);
|
|
||||||
},
|
},
|
||||||
hasTelemetry() {
|
hasTelemetry() {
|
||||||
return this.condition.criteria.length && this.condition.criteria[0].key;
|
return this.condition.criteria.length && this.condition.criteria[0].key;
|
||||||
@ -118,6 +152,16 @@ export default {
|
|||||||
} else {
|
} else {
|
||||||
this.openmct.objects.mutate(this.domainObject, 'configuration.conditionCollection', this.domainObject.configuration.conditionCollection);
|
this.openmct.objects.mutate(this.domainObject, 'configuration.conditionCollection', this.domainObject.configuration.conditionCollection);
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
updateCurrentCondition() {
|
||||||
|
// TODO: replace based on telemetry
|
||||||
|
if (this.conditionCollection.length > 1) {
|
||||||
|
this.conditionCollection.forEach((condition, index) => {
|
||||||
|
index === 0 ? condition.isCurrent = true : condition.isCurrent = false
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.conditionCollection[0].isCurrent = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<div class="c-object-view u-contents">
|
<div class="c-object-view u-contents">
|
||||||
<div class="c-cs-edit w-condition-set">
|
<div class="c-cs-edit w-condition-set">
|
||||||
<div class="c-sw-edit__ui holder">
|
<div class="c-sw-edit__ui holder">
|
||||||
<CurrentOutput :current-output="mockCurrentOutput" />
|
<CurrentOutput :condition-collection="domainObject.conditionCollection" />
|
||||||
<TestData :is-editing="isEditing" />
|
<TestData :is-editing="isEditing" />
|
||||||
<ConditionCollection :is-editing="isEditing"
|
<ConditionCollection :is-editing="isEditing"
|
||||||
:condition-collection="domainObject.conditionCollection"
|
:condition-collection="domainObject.conditionCollection"
|
||||||
@ -28,21 +28,10 @@ export default {
|
|||||||
isEditing: Boolean
|
isEditing: Boolean
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
|
let conditionCollection = this.domainObject.configuration.conditionCollection;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
mockCurrentOutput: 'Data_Present'
|
conditionCollection
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
persist(index) {
|
|
||||||
if (index) {
|
|
||||||
this.openmct.objects.mutate(this.domainObject, `configuration.conditionCollection[${index}]`, this.conditionCollection[index]);
|
|
||||||
} else {
|
|
||||||
this.openmct.objects.mutate(this.domainObject, 'configuration.conditionCollection', this.conditionCollection);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
},
|
|
||||||
addCondition() {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
class="c-cs__ui_content"
|
class="c-cs__ui_content"
|
||||||
>
|
>
|
||||||
<div>
|
<div>
|
||||||
<span class="current-output">{{ currentOutput }}</span>
|
<span class="current-output">{{ conditionCollection[currentConditionIndex].output }}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
@ -20,21 +20,33 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
inject: ['openmct'],
|
inject: ['openmct', 'domainObject'],
|
||||||
props: {
|
props: {
|
||||||
currentOutput: {
|
|
||||||
type: String,
|
|
||||||
default: ''
|
|
||||||
},
|
|
||||||
isEditing: Boolean
|
isEditing: Boolean
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
|
let conditionCollection = this.domainObject.configuration.conditionCollection;
|
||||||
|
let currentConditionIndex = 0;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
expanded: true
|
expanded: true,
|
||||||
};
|
conditionCollection,
|
||||||
|
currentConditionIndex
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.currentConditionIndex = this.getCurrentConditionIndex();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
getCurrentConditionIndex() {
|
||||||
|
let currentConditionIndex;
|
||||||
|
this.conditionCollection.forEach((condition, index) => {
|
||||||
|
if (condition.isCurrent) {
|
||||||
|
currentConditionIndex = index;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return currentConditionIndex;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
206
src/plugins/condition/utils/operations.js
Normal file
206
src/plugins/condition/utils/operations.js
Normal file
@ -0,0 +1,206 @@
|
|||||||
|
export const OPERATIONS = [
|
||||||
|
{
|
||||||
|
name: 'equalTo',
|
||||||
|
operation: function (input) {
|
||||||
|
return input[0] === input[1];
|
||||||
|
},
|
||||||
|
text: 'is equal to',
|
||||||
|
appliesTo: ['number'],
|
||||||
|
inputCount: 1,
|
||||||
|
getDescription: function (values) {
|
||||||
|
return ' == ' + values[0];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'notEqualTo',
|
||||||
|
operation: function (input) {
|
||||||
|
return input[0] !== input[1];
|
||||||
|
},
|
||||||
|
text: 'is not equal to',
|
||||||
|
appliesTo: ['number'],
|
||||||
|
inputCount: 1,
|
||||||
|
getDescription: function (values) {
|
||||||
|
return ' != ' + values[0];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'greaterThan',
|
||||||
|
operation: function (input) {
|
||||||
|
return input[0] > input[1];
|
||||||
|
},
|
||||||
|
text: 'is greater than',
|
||||||
|
appliesTo: ['number'],
|
||||||
|
inputCount: 1,
|
||||||
|
getDescription: function (values) {
|
||||||
|
return ' > ' + values[0];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'lessThan',
|
||||||
|
operation: function (input) {
|
||||||
|
return input[0] < input[1];
|
||||||
|
},
|
||||||
|
text: 'is less than',
|
||||||
|
appliesTo: ['number'],
|
||||||
|
inputCount: 1,
|
||||||
|
getDescription: function (values) {
|
||||||
|
return ' < ' + values[0];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'greaterThanOrEq',
|
||||||
|
operation: function (input) {
|
||||||
|
return input[0] >= input[1];
|
||||||
|
},
|
||||||
|
text: 'is greater than or equal to',
|
||||||
|
appliesTo: ['number'],
|
||||||
|
inputCount: 1,
|
||||||
|
getDescription: function (values) {
|
||||||
|
return ' >= ' + values[0];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'lessThanOrEq',
|
||||||
|
operation: function (input) {
|
||||||
|
return input[0] <= input[1];
|
||||||
|
},
|
||||||
|
text: 'is less than or equal to',
|
||||||
|
appliesTo: ['number'],
|
||||||
|
inputCount: 1,
|
||||||
|
getDescription: function (values) {
|
||||||
|
return ' <= ' + values[0];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'between',
|
||||||
|
operation: function (input) {
|
||||||
|
return input[0] > input[1] && input[0] < input[2];
|
||||||
|
},
|
||||||
|
text: 'is between',
|
||||||
|
appliesTo: ['number'],
|
||||||
|
inputCount: 2,
|
||||||
|
getDescription: function (values) {
|
||||||
|
return ' between ' + values[0] + ' and ' + values[1];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'notBetween',
|
||||||
|
operation: function (input) {
|
||||||
|
return input[0] < input[1] || input[0] > input[2];
|
||||||
|
},
|
||||||
|
text: 'is not between',
|
||||||
|
appliesTo: ['number'],
|
||||||
|
inputCount: 2,
|
||||||
|
getDescription: function (values) {
|
||||||
|
return ' not between ' + values[0] + ' and ' + values[1];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'textContains',
|
||||||
|
operation: function (input) {
|
||||||
|
return input[0] && input[1] && input[0].includes(input[1]);
|
||||||
|
},
|
||||||
|
text: 'text contains',
|
||||||
|
appliesTo: ['string'],
|
||||||
|
inputCount: 1,
|
||||||
|
getDescription: function (values) {
|
||||||
|
return ' contains ' + values[0];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'textDoesNotContain',
|
||||||
|
operation: function (input) {
|
||||||
|
return input[0] && input[1] && !input[0].includes(input[1]);
|
||||||
|
},
|
||||||
|
text: 'text does not contain',
|
||||||
|
appliesTo: ['string'],
|
||||||
|
inputCount: 1,
|
||||||
|
getDescription: function (values) {
|
||||||
|
return ' does not contain ' + values[0];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'textStartsWith',
|
||||||
|
operation: function (input) {
|
||||||
|
return input[0].startsWith(input[1]);
|
||||||
|
},
|
||||||
|
text: 'text starts with',
|
||||||
|
appliesTo: ['string'],
|
||||||
|
inputCount: 1,
|
||||||
|
getDescription: function (values) {
|
||||||
|
return ' starts with ' + values[0];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'textEndsWith',
|
||||||
|
operation: function (input) {
|
||||||
|
return input[0].endsWith(input[1]);
|
||||||
|
},
|
||||||
|
text: 'text ends with',
|
||||||
|
appliesTo: ['string'],
|
||||||
|
inputCount: 1,
|
||||||
|
getDescription: function (values) {
|
||||||
|
return ' ends with ' + values[0];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'textIsExactly',
|
||||||
|
operation: function (input) {
|
||||||
|
return input[0] === input[1];
|
||||||
|
},
|
||||||
|
text: 'text is exactly',
|
||||||
|
appliesTo: ['string'],
|
||||||
|
inputCount: 1,
|
||||||
|
getDescription: function (values) {
|
||||||
|
return ' is exactly ' + values[0];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'isUndefined',
|
||||||
|
operation: function (input) {
|
||||||
|
return typeof input[0] === 'undefined';
|
||||||
|
},
|
||||||
|
text: 'is undefined',
|
||||||
|
appliesTo: ['string', 'number', 'enum'],
|
||||||
|
inputCount: 0,
|
||||||
|
getDescription: function () {
|
||||||
|
return ' is undefined';
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'isDefined',
|
||||||
|
operation: function (input) {
|
||||||
|
return typeof input[0] !== 'undefined';
|
||||||
|
},
|
||||||
|
text: 'is defined',
|
||||||
|
appliesTo: ['string', 'number', 'enum'],
|
||||||
|
inputCount: 0,
|
||||||
|
getDescription: function () {
|
||||||
|
return ' is defined';
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'enumValueIs',
|
||||||
|
operation: function (input) {
|
||||||
|
return input[0] === input[1];
|
||||||
|
},
|
||||||
|
text: 'is',
|
||||||
|
appliesTo: ['enum'],
|
||||||
|
inputCount: 1,
|
||||||
|
getDescription: function (values) {
|
||||||
|
return ' == ' + values[0];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'enumValueIsNot',
|
||||||
|
operation: function (input) {
|
||||||
|
return input[0] !== input[1];
|
||||||
|
},
|
||||||
|
text: 'is not',
|
||||||
|
appliesTo: ['enum'],
|
||||||
|
inputCount: 1,
|
||||||
|
getDescription: function (values) {
|
||||||
|
return ' != ' + values[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
];
|
Loading…
x
Reference in New Issue
Block a user