mirror of
https://github.com/nasa/openmct.git
synced 2025-06-02 23:50:49 +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.stopProvidingTelemetry();
|
||||||
}
|
}
|
||||||
this.openmct.objects.get(this.conditionSetIdentifier).then((conditionSetDomainObject) => {
|
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));
|
this.stopProvidingTelemetry = this.openmct.telemetry.subscribe(conditionSetDomainObject, output => this.handleConditionSetResultUpdated(output));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -115,6 +117,7 @@ export default class StyleRuleManager extends EventEmitter {
|
|||||||
if (this.stopProvidingTelemetry) {
|
if (this.stopProvidingTelemetry) {
|
||||||
this.stopProvidingTelemetry();
|
this.stopProvidingTelemetry();
|
||||||
}
|
}
|
||||||
|
delete this.stopProvidingTelemetry;
|
||||||
this.conditionSetIdentifier = undefined;
|
this.conditionSetIdentifier = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,14 +98,23 @@ export default {
|
|||||||
this.criterionDescriptions.splice(index, 0, description);
|
this.criterionDescriptions.splice(index, 0, description);
|
||||||
} else {
|
} else {
|
||||||
let metadataValue = criterion.metadata;
|
let metadataValue = criterion.metadata;
|
||||||
|
let inputValue = criterion.input;
|
||||||
if (criterion.metadata) {
|
if (criterion.metadata) {
|
||||||
this.telemetryMetadata = this.openmct.telemetry.getMetadata(telemetryObject);
|
this.telemetryMetadata = this.openmct.telemetry.getMetadata(telemetryObject);
|
||||||
|
|
||||||
const metadataObj = this.telemetryMetadata.valueMetadatas.find((metadata) => metadata.key === criterion.metadata);
|
const metadataObj = this.telemetryMetadata.valueMetadatas.find((metadata) => metadata.key === criterion.metadata);
|
||||||
if (metadataObj && metadataObj.name) {
|
if (metadataObj) {
|
||||||
metadataValue = metadataObj.name;
|
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]) {
|
if (this.criterionDescriptions[index]) {
|
||||||
this.criterionDescriptions[index] = description;
|
this.criterionDescriptions[index] = description;
|
||||||
} else {
|
} else {
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
<span class="c-cdef__label">{{ setRowLabel }}</span>
|
<span class="c-cdef__label">{{ setRowLabel }}</span>
|
||||||
<span class="c-cdef__controls">
|
<span class="c-cdef__controls">
|
||||||
<span class="c-cdef__control">
|
<span class="c-cdef__control">
|
||||||
<select v-model="criterion.telemetry"
|
<select ref="telemetrySelect"
|
||||||
class="js-telemetry-select"
|
v-model="criterion.telemetry"
|
||||||
@change="updateMetadataOptions"
|
@change="updateMetadataOptions"
|
||||||
>
|
>
|
||||||
<option value="">- Select Telemetry -</option>
|
<option value="">- Select Telemetry -</option>
|
||||||
@ -20,8 +20,8 @@
|
|||||||
<span v-if="criterion.telemetry"
|
<span v-if="criterion.telemetry"
|
||||||
class="c-cdef__control"
|
class="c-cdef__control"
|
||||||
>
|
>
|
||||||
<select v-model="criterion.metadata"
|
<select ref="metadataSelect"
|
||||||
class="js-metadata-select"
|
v-model="criterion.metadata"
|
||||||
@change="updateOperations"
|
@change="updateOperations"
|
||||||
>
|
>
|
||||||
<option value="">- Select Field -</option>
|
<option value="">- Select Field -</option>
|
||||||
@ -182,7 +182,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
updateOperations(ev) {
|
updateOperations(ev) {
|
||||||
if (ev) {
|
if (ev.target === this.$ref.telemetrySelect) {
|
||||||
this.clearDependentFields(ev.target);
|
this.clearDependentFields(ev.target);
|
||||||
this.persist();
|
this.persist();
|
||||||
}
|
}
|
||||||
@ -202,10 +202,10 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
clearDependentFields(el) {
|
clearDependentFields(el) {
|
||||||
if (el.classList.contains('js-telemetry-select')) {
|
if (el === this.$ref.telemetrySelect) {
|
||||||
this.criterion.metadata = '';
|
this.criterion.metadata = '';
|
||||||
this.criterion.operation = '';
|
this.criterion.operation = '';
|
||||||
} else if (el.classList.contains('js-metadata-select')) {
|
} else if (el === this.$ref.metadataSelect) {
|
||||||
this.criterion.operation = '';
|
this.criterion.operation = '';
|
||||||
}
|
}
|
||||||
this.criterion.input = [];
|
this.criterion.input = [];
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import _ from 'lodash';
|
||||||
|
|
||||||
export const OPERATIONS = [
|
export const OPERATIONS = [
|
||||||
{
|
{
|
||||||
name: 'equalTo',
|
name: 'equalTo',
|
||||||
@ -202,6 +204,39 @@ export const OPERATIONS = [
|
|||||||
getDescription: function (values) {
|
getDescription: function (values) {
|
||||||
return ' is not ' + values.join(', ');
|
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…
x
Reference in New Issue
Block a user