mirror of
https://github.com/nasa/openmct.git
synced 2025-01-20 03:36:44 +00:00
resolved merge conflict
This commit is contained in:
commit
7c200df4c4
@ -48,6 +48,8 @@ export default class StyleRuleManager extends EventEmitter {
|
||||
this.stopProvidingTelemetry();
|
||||
}
|
||||
this.openmct.objects.get(this.conditionSetIdentifier).then((conditionSetDomainObject) => {
|
||||
this.openmct.telemetry.request(conditionSetDomainObject)
|
||||
.then(output => this.handleConditionSetResultUpdated(output));
|
||||
this.stopProvidingTelemetry = this.openmct.telemetry.subscribe(conditionSetDomainObject, output => this.handleConditionSetResultUpdated(output));
|
||||
});
|
||||
}
|
||||
@ -115,6 +117,7 @@ export default class StyleRuleManager extends EventEmitter {
|
||||
if (this.stopProvidingTelemetry) {
|
||||
this.stopProvidingTelemetry();
|
||||
}
|
||||
delete this.stopProvidingTelemetry;
|
||||
this.conditionSetIdentifier = undefined;
|
||||
}
|
||||
|
||||
|
@ -98,14 +98,23 @@ export default {
|
||||
this.criterionDescriptions.splice(index, 0, description);
|
||||
} else {
|
||||
let metadataValue = criterion.metadata;
|
||||
let inputValue = criterion.input;
|
||||
if (criterion.metadata) {
|
||||
this.telemetryMetadata = this.openmct.telemetry.getMetadata(telemetryObject);
|
||||
|
||||
const metadataObj = this.telemetryMetadata.valueMetadatas.find((metadata) => metadata.key === criterion.metadata);
|
||||
if (metadataObj && metadataObj.name) {
|
||||
metadataValue = metadataObj.name;
|
||||
if (metadataObj) {
|
||||
if (metadataObj.name) {
|
||||
metadataValue = metadataObj.name;
|
||||
}
|
||||
if(metadataObj.enumerations && inputValue.length) {
|
||||
if (metadataObj.enumerations[inputValue[0]] && metadataObj.enumerations[inputValue[0]].string) {
|
||||
inputValue = [metadataObj.enumerations[inputValue[0]].string];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
let description = `${telemetryObject.name} ${metadataValue} ${this.getOperatorText(criterion.operation, criterion.input)}`;
|
||||
let description = `${telemetryObject.name} ${metadataValue} ${this.getOperatorText(criterion.operation, inputValue)}`;
|
||||
if (this.criterionDescriptions[index]) {
|
||||
this.criterionDescriptions[index] = description;
|
||||
} else {
|
||||
|
@ -4,8 +4,8 @@
|
||||
<span class="c-cdef__label">{{ setRowLabel }}</span>
|
||||
<span class="c-cdef__controls">
|
||||
<span class="c-cdef__control">
|
||||
<select v-model="criterion.telemetry"
|
||||
class="js-telemetry-select"
|
||||
<select ref="telemetrySelect"
|
||||
v-model="criterion.telemetry"
|
||||
@change="updateMetadataOptions"
|
||||
>
|
||||
<option value="">- Select Telemetry -</option>
|
||||
@ -20,8 +20,8 @@
|
||||
<span v-if="criterion.telemetry"
|
||||
class="c-cdef__control"
|
||||
>
|
||||
<select v-model="criterion.metadata"
|
||||
class="js-metadata-select"
|
||||
<select ref="metadataSelect"
|
||||
v-model="criterion.metadata"
|
||||
@change="updateOperations"
|
||||
>
|
||||
<option value="">- Select Field -</option>
|
||||
@ -182,7 +182,7 @@ export default {
|
||||
}
|
||||
},
|
||||
updateOperations(ev) {
|
||||
if (ev) {
|
||||
if (ev.target === this.$ref.telemetrySelect) {
|
||||
this.clearDependentFields(ev.target);
|
||||
this.persist();
|
||||
}
|
||||
@ -202,10 +202,10 @@ export default {
|
||||
}
|
||||
},
|
||||
clearDependentFields(el) {
|
||||
if (el.classList.contains('js-telemetry-select')) {
|
||||
if (el === this.$ref.telemetrySelect) {
|
||||
this.criterion.metadata = '';
|
||||
this.criterion.operation = '';
|
||||
} else if (el.classList.contains('js-metadata-select')) {
|
||||
} else if (el === this.$ref.metadataSelect) {
|
||||
this.criterion.operation = '';
|
||||
}
|
||||
this.criterion.input = [];
|
||||
|
@ -1,3 +1,5 @@
|
||||
import _ from 'lodash';
|
||||
|
||||
export const OPERATIONS = [
|
||||
{
|
||||
name: 'equalTo',
|
||||
@ -202,6 +204,39 @@ export const OPERATIONS = [
|
||||
getDescription: function (values) {
|
||||
return ' is not ' + values.join(', ');
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'valueIs',
|
||||
operation: function (input) {
|
||||
if (input[1]) {
|
||||
const values = input[1].split(',');
|
||||
return values.find((value) => input[0].toString() === _.trim(value.toString()));
|
||||
}
|
||||
return false;
|
||||
},
|
||||
text: 'is one of',
|
||||
appliesTo: ["string", "number"],
|
||||
inputCount: 1,
|
||||
getDescription: function (values) {
|
||||
return ' is one of ' + values[0];
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'valueIsNot',
|
||||
operation: function (input) {
|
||||
if (input[1]) {
|
||||
const values = input[1].split(',');
|
||||
const found = values.find((value) => input[0].toString() === _.trim(value.toString()));
|
||||
return !found;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
text: 'is not one of',
|
||||
appliesTo: ["string", "number"],
|
||||
inputCount: 1,
|
||||
getDescription: function (values) {
|
||||
return ' is not one of ' + values[0];
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
|
68
src/plugins/condition/utils/operationsSpec.js
Normal file
68
src/plugins/condition/utils/operationsSpec.js
Normal file
@ -0,0 +1,68 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2020, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* Open MCT includes source code licensed under additional open source
|
||||
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
|
||||
import { OPERATIONS } from "./operations";
|
||||
let isOneOfOperation = OPERATIONS.find((operation) => operation.name === 'valueIs');
|
||||
let isNotOneOfOperation = OPERATIONS.find((operation) => operation.name === 'valueIsNot');
|
||||
|
||||
describe('Is one of and is not one of operations', function () {
|
||||
|
||||
it('should evaluate isOneOf to true for number inputs', () => {
|
||||
const inputs = [45, "5,6,45,8"];
|
||||
expect(!!isOneOfOperation.operation(inputs)).toBeTrue();
|
||||
});
|
||||
|
||||
it('should evaluate isOneOf to true for string inputs', () => {
|
||||
const inputs = ["45", " 45, 645, 4,8 "];
|
||||
expect(!!isOneOfOperation.operation(inputs)).toBeTrue();
|
||||
});
|
||||
|
||||
it('should evaluate isNotOneOf to true for number inputs', () => {
|
||||
const inputs = [45, "5,6,4,8"];
|
||||
expect(!!isNotOneOfOperation.operation(inputs)).toBeTrue();
|
||||
});
|
||||
|
||||
it('should evaluate isNotOneOf to true for string inputs', () => {
|
||||
const inputs = ["45", " 5,645, 4,8 "];
|
||||
expect(!!isNotOneOfOperation.operation(inputs)).toBeTrue();
|
||||
});
|
||||
|
||||
it('should evaluate isOneOf to false for number inputs', () => {
|
||||
const inputs = [4, "5, 6, 7, 8"];
|
||||
expect(!!isOneOfOperation.operation(inputs)).toBeFalse();
|
||||
});
|
||||
|
||||
it('should evaluate isOneOf to false for string inputs', () => {
|
||||
const inputs = ["4", "5,645 ,7,8"];
|
||||
expect(!!isOneOfOperation.operation(inputs)).toBeFalse();
|
||||
});
|
||||
|
||||
it('should evaluate isNotOneOf to false for number inputs', () => {
|
||||
const inputs = [4, "5,4, 7,8"];
|
||||
expect(!!isNotOneOfOperation.operation(inputs)).toBeFalse();
|
||||
});
|
||||
|
||||
it('should evaluate isNotOneOf to false for string inputs', () => {
|
||||
const inputs = ["4", "5,46,4,8"];
|
||||
expect(!!isNotOneOfOperation.operation(inputs)).toBeFalse();
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user