mirror of
https://github.com/nasa/openmct.git
synced 2025-05-31 06:31:04 +00:00
added computed property and method to get description
This commit is contained in:
parent
27a09239e3
commit
8900072239
@ -44,7 +44,7 @@
|
||||
<span class="c-condition__name">{{ domainObject.configuration.name }}</span>
|
||||
<!-- TODO: description should be derived from criteria -->
|
||||
<span class="c-condition__summary">
|
||||
Description/summary goes here {{ domainObject.configuration.description }}
|
||||
<!-- {{ getDescription }} -->
|
||||
</span>
|
||||
|
||||
<div class="c-condition__buttons">
|
||||
@ -162,13 +162,14 @@
|
||||
</span>
|
||||
</div>
|
||||
<div class="c-condition__summary">
|
||||
Description/summary goes here {{ domainObject.configuration.description }}
|
||||
<!-- {{ getDescription }} -->
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Criterion from './Criterion.vue';
|
||||
import { OPERATIONS } from '../utils/operations';
|
||||
|
||||
export default {
|
||||
inject: ['openmct'],
|
||||
@ -211,6 +212,38 @@ export default {
|
||||
criterionIndex: 0
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
getDescription: function () {
|
||||
let config = this.domainObject.configuration;
|
||||
|
||||
if (!config.criteria.length) {
|
||||
return 'When all else fails';
|
||||
} else {
|
||||
let description = '';
|
||||
if (config.criteria.length === 1 && config.criteria[0].telemetry) {
|
||||
if (config.criteria[0].operation && config.criteria[0].input.length) {
|
||||
description += `When ${config.criteria[0].telemetry.name} value ${this.findDescription(config.criteria[0].operation, config.criteria[0].input)}`
|
||||
} else {
|
||||
description = 'No criteria specified'
|
||||
}
|
||||
} else {
|
||||
let conjunction = '';
|
||||
config.criteria.forEach((criterion, index) => {
|
||||
if (criterion.operation && criterion.input.length) {
|
||||
if (index !== config.criteria.length - 1 && (criterion.operation && criterion.input.length)) {
|
||||
conjunction = config.trigger === 'all' ? 'and ' : 'or ';
|
||||
} else {
|
||||
conjunction = '';
|
||||
}
|
||||
description += `${criterion.telemetry.name} value ${this.findDescription(criterion.operation, criterion.input)} ${conjunction}`
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return description;
|
||||
}
|
||||
}
|
||||
},
|
||||
destroyed() {
|
||||
this.destroy();
|
||||
},
|
||||
@ -224,6 +257,15 @@ export default {
|
||||
initialize() {
|
||||
this.setOutputSelection();
|
||||
},
|
||||
findDescription(operation, values) {
|
||||
for (let i=0, ii= OPERATIONS.length; i < ii; i++) {
|
||||
if (operation === OPERATIONS[i].name) {
|
||||
console.log('OPERATIONS[i].getDescription()', OPERATIONS[i].getDescription(values));
|
||||
return OPERATIONS[i].getDescription(values);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
},
|
||||
setOutputSelection() {
|
||||
let conditionOutput = this.domainObject.configuration.output;
|
||||
if (conditionOutput) {
|
||||
|
@ -130,6 +130,7 @@ export default {
|
||||
if (ev) {this.clearInputs()}
|
||||
if (this.criterion.telemetry) {
|
||||
this.openmct.objects.get(this.criterion.telemetry).then((telemetryObject) => {
|
||||
this.criterion.telemetry.name = telemetryObject.name;
|
||||
this.telemetryMetadata = this.openmct.telemetry.getMetadata(telemetryObject);
|
||||
this.telemetryMetadataOptions = this.telemetryMetadata.values();
|
||||
this.updateOperations();
|
||||
|
@ -8,7 +8,7 @@ export const OPERATIONS = [
|
||||
appliesTo: ['number'],
|
||||
inputCount: 1,
|
||||
getDescription: function (values) {
|
||||
return ' == ' + values[0];
|
||||
return ' is ' + values[0];
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -20,7 +20,7 @@ export const OPERATIONS = [
|
||||
appliesTo: ['number'],
|
||||
inputCount: 1,
|
||||
getDescription: function (values) {
|
||||
return ' != ' + values[0];
|
||||
return ' is not ' + values[0];
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -80,7 +80,7 @@ export const OPERATIONS = [
|
||||
appliesTo: ['number'],
|
||||
inputCount: 2,
|
||||
getDescription: function (values) {
|
||||
return ' between ' + values[0] + ' and ' + values[1];
|
||||
return ' is between ' + values[0] + ' and ' + values[1];
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -92,7 +92,7 @@ export const OPERATIONS = [
|
||||
appliesTo: ['number'],
|
||||
inputCount: 2,
|
||||
getDescription: function (values) {
|
||||
return ' not between ' + values[0] + ' and ' + values[1];
|
||||
return ' is not between ' + values[0] + ' and ' + values[1];
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -188,7 +188,7 @@ export const OPERATIONS = [
|
||||
appliesTo: ['enum'],
|
||||
inputCount: 1,
|
||||
getDescription: function (values) {
|
||||
return ' == ' + values[0];
|
||||
return ' is ' + values[0];
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -200,7 +200,7 @@ export const OPERATIONS = [
|
||||
appliesTo: ['enum'],
|
||||
inputCount: 1,
|
||||
getDescription: function (values) {
|
||||
return ' != ' + values[0];
|
||||
return ' is not ' + values[0];
|
||||
}
|
||||
}
|
||||
];
|
||||
|
Loading…
x
Reference in New Issue
Block a user