mirror of
https://github.com/nasa/openmct.git
synced 2025-06-19 15:43:48 +00:00
vue style render of description
This commit is contained in:
@ -42,8 +42,28 @@
|
|||||||
|
|
||||||
<span class="c-condition__name">{{ condition.configuration.name }}</span>
|
<span class="c-condition__name">{{ condition.configuration.name }}</span>
|
||||||
<!-- TODO: description should be derived from criteria -->
|
<!-- TODO: description should be derived from criteria -->
|
||||||
<span class="c-condition__summary">
|
<span v-if="condition.isDefault"
|
||||||
{{ getSummary }}
|
class="c-condition__summary"
|
||||||
|
>
|
||||||
|
When all else fails
|
||||||
|
</span>
|
||||||
|
<span v-else
|
||||||
|
class="c-condition__summary"
|
||||||
|
>
|
||||||
|
<template v-if="!condition.configuration.criteria[condition.configuration.criteria.length - 1].telemetry">
|
||||||
|
Specify criteria
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
When
|
||||||
|
<span v-for="(criterion, index) in condition.configuration.criteria"
|
||||||
|
:key="index"
|
||||||
|
>
|
||||||
|
{{ getRule(criterion, index) }}
|
||||||
|
<template v-if="index !== condition.configuration.criteria.length - 1">
|
||||||
|
{{ condition.configuration.trigger === 'all' ? 'and' : 'or' }}
|
||||||
|
</template>
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<div class="c-condition__buttons">
|
<div class="c-condition__buttons">
|
||||||
@ -159,8 +179,28 @@
|
|||||||
Output: {{ condition.configuration.output }}
|
Output: {{ condition.configuration.output }}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="c-condition__summary">
|
<div v-if="condition.isDefault"
|
||||||
{{ getSummary }}
|
class="c-condition__summary"
|
||||||
|
>
|
||||||
|
When all else fails
|
||||||
|
</div>
|
||||||
|
<div v-else
|
||||||
|
class="c-condition__summary"
|
||||||
|
>
|
||||||
|
<template v-if="!condition.configuration.criteria[condition.configuration.criteria.length - 1].telemetry">
|
||||||
|
Specify criteria
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
When
|
||||||
|
<span v-for="(criterion, index) in condition.configuration.criteria"
|
||||||
|
:key="index"
|
||||||
|
>
|
||||||
|
{{ getRule(criterion, index) }}
|
||||||
|
<template v-if="index !== condition.configuration.criteria.length - 1">
|
||||||
|
{{ condition.configuration.trigger === 'all' ? 'and' : 'or' }}
|
||||||
|
</template>
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@ -203,28 +243,6 @@ export default {
|
|||||||
criterionIndex: 0
|
criterionIndex: 0
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
|
||||||
getSummary: function () {
|
|
||||||
if (!this.condition.configuration.criteria.length) {
|
|
||||||
return 'When all else fails'
|
|
||||||
}
|
|
||||||
let config = this.condition.configuration;
|
|
||||||
let summary = '';
|
|
||||||
if (config.criteria.length === 1 &&
|
|
||||||
config.criteria[0].telemetry &&
|
|
||||||
config.criteria[0].operation) {
|
|
||||||
summary = this.getRules(config.criteria[0]);
|
|
||||||
} else {
|
|
||||||
config.criteria.forEach((criterion, index) => {
|
|
||||||
if (criterion.telemetry &&
|
|
||||||
criterion.operation) {
|
|
||||||
summary += this.getRules(criterion, index);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return summary;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
destroyed() {
|
destroyed() {
|
||||||
this.destroy();
|
this.destroy();
|
||||||
},
|
},
|
||||||
@ -232,16 +250,23 @@ export default {
|
|||||||
this.setOutputSelection();
|
this.setOutputSelection();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getRules(criterion, index) {
|
getRule(criterion, index) {
|
||||||
let adverb = criterion.input.length === 1 && index === 0 ? 'When ' : '';
|
|
||||||
let conjunction = (this.condition.configuration.criteria.length - 1 === index) ?
|
|
||||||
(this.condition.configuration.trigger === 'all' ? ' and ' : ' or ') : '';
|
|
||||||
if (criterion.operation) {
|
if (criterion.operation) {
|
||||||
if (criterion.input.length ||
|
// this.openmct.objects.get(criterion.telemetry).then((telemetryObject) => {
|
||||||
(criterion.operation === 'isDefined' ||
|
// this.telemetryMetadata = this.openmct.telemetry.getMetadata(telemetryObject);
|
||||||
criterion.operation === 'isUndefined')) {
|
// this.telemetryMetadataOptions = this.telemetryMetadata.values();
|
||||||
return `${adverb}${conjunction}${criterion.telemetry.name} ${criterion.metadata} value ${this.findDescription(criterion.operation, criterion.input)}`;
|
// let metadataName = '';
|
||||||
}
|
// for (let i = 0; i < this.telemetryMetadataOptions.length; i++) {
|
||||||
|
// if (criterion.metadata === this.telemetryMetadataOptions[i].key) {
|
||||||
|
// metadataName = this.telemetryMetadataOptions[i].name;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
if (criterion.input.length ||
|
||||||
|
(criterion.operation === 'isDefined' ||
|
||||||
|
criterion.operation === 'isUndefined')) {
|
||||||
|
return `${criterion.telemetry.name} ${criterion.metadata} ${this.findDescription(criterion.operation, criterion.input)}`;
|
||||||
|
}
|
||||||
|
// });
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
findDescription(operation, values) {
|
findDescription(operation, values) {
|
||||||
|
Reference in New Issue
Block a user