Merge branch 'conditionSet-view' of https://github.com/nasa/openmct into conditionSet-with-classes

This commit is contained in:
Joshi 2020-01-15 11:28:18 -08:00
commit 9fd720777b
5 changed files with 291 additions and 39 deletions

View File

@ -30,7 +30,7 @@
</div>
<div class="condition-collection">
<div v-for="condition in conditionCollection"
:key="condition.id"
:key="condition.identifier.key"
class="conditionArea"
>
<div v-if="isEditing">
@ -94,6 +94,7 @@ export default {
getConditionDomainObject(isDefault) {
let conditionObj = {
isDefault: isDefault,
isCurrent: true,
identifier: {
namespace: "",
key: uuid()
@ -106,8 +107,8 @@ export default {
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: 'Default test',
type: 'condition'
output: 'false',
summary: 'summary description'
};
let conditionDOKeyString = this.openmct.objects.makeKeyString(conditionObj.identifier);
let newDO = this.instantiate(conditionObj, conditionDOKeyString);

View File

@ -36,7 +36,7 @@
<div>
<ul>
<li>
<label>Condition Names</label>
<label>Condition Name</label>
<span class="controls">
<input v-model="condition.name"
class="t-rule-name-input"
@ -44,19 +44,41 @@
>
</span>
</li>
<li v-if="telemetryObject">
<li v-if="telemetryObject && telemetryMetadata">
<label>when</label>
<span class="controls">
<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>
</span>
</li>
<li>
<label>Output</label>
<span class="controls">
<select class="">
<select v-model="condition.output">
<option value="false">false</option>
<option value="true">true</option>
</select>
</span>
</li>
@ -70,6 +92,7 @@
</template>
<script>
import { OPERATIONS } from '../utils/operations';
export default {
inject: ['openmct', 'domainObject'],
props: {
@ -79,20 +102,26 @@ export default {
}
},
data() {
let conditionCollection = this.domainObject.configuration.conditionCollection;
return {
expanded: true,
name: this.condition.name,
description: this.condition.description,
telemetryObject: this.telemetryObject
conditionCollection,
telemetryObject: this.telemetryObject,
telemetryMetadata: this.telemetryMetadata,
operations: OPERATIONS,
selectedMetaDataKey: null,
selectedOperationKey: null
};
},
mounted() {
this.updateTelemetry();
},
updated() {
console.log('updated');
this.persist();
// this.updateTelemetry();
console.log('updated conditionEdit');
this.updateCurrentCondition();
this.persist()
},
methods: {
removeCondition(ev) {
@ -103,11 +132,16 @@ export default {
this.domainObject.configuration.conditionCollection.splice(index, 1);
},
updateTelemetry() {
this.telemetryObject = this.hasTelemetry() ? this.openmct.objects.get(this.condition.criteria[0].key) : null;
if (this.telemetryObject) {
this.telemetryMetadata = this.openmct.telemetry.getMetadata().values();
if (this.hasTelemetry()) {
this.openmct.objects.get(this.condition.criteria[0].key).then((obj) => {
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() {
return this.condition.criteria.length && this.condition.criteria[0].key;
@ -118,6 +152,16 @@ export default {
} else {
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;
}
}
}
}

View File

@ -2,7 +2,7 @@
<div class="c-object-view u-contents">
<div class="c-cs-edit w-condition-set">
<div class="c-sw-edit__ui holder">
<CurrentOutput :current-output="mockCurrentOutput" />
<CurrentOutput :condition-collection="domainObject.conditionCollection" />
<TestData :is-editing="isEditing" />
<ConditionCollection :is-editing="isEditing"
:condition-collection="domainObject.conditionCollection"
@ -28,21 +28,10 @@ export default {
isEditing: Boolean
},
data() {
let conditionCollection = this.domainObject.configuration.conditionCollection;
return {
mockCurrentOutput: 'Data_Present'
}
},
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() {
conditionCollection
}
}
};

View File

@ -12,7 +12,7 @@
class="c-cs__ui_content"
>
<div>
<span class="current-output">{{ currentOutput }}</span>
<span class="current-output">{{ conditionCollection[currentConditionIndex].output }}</span>
</div>
</div>
</section>
@ -20,21 +20,33 @@
<script>
export default {
inject: ['openmct'],
inject: ['openmct', 'domainObject'],
props: {
currentOutput: {
type: String,
default: ''
},
isEditing: Boolean
},
data() {
let conditionCollection = this.domainObject.configuration.conditionCollection;
let currentConditionIndex = 0;
return {
expanded: true
};
expanded: true,
conditionCollection,
currentConditionIndex
}
},
mounted() {
this.currentConditionIndex = this.getCurrentConditionIndex();
},
methods: {
getCurrentConditionIndex() {
let currentConditionIndex;
this.conditionCollection.forEach((condition, index) => {
if (condition.isCurrent) {
currentConditionIndex = index;
}
});
return currentConditionIndex;
}
}
}
</script>

View 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];
}
}
];