diff --git a/API.md b/API.md index a76fc53c5d..587b82f754 100644 --- a/API.md +++ b/API.md @@ -231,7 +231,7 @@ attributes of this object. This is used for specifying an icon to appear next to each object of this type. -The [Open MCT Tutorials](https://github.com/openmct/openmct-tutorial) provide a +The [Open MCT Tutorials](https://github.com/nasa/openmct-tutorial) provide a step-by-step examples of writing code for Open MCT that includes a [section on defining a new object type](https://github.com/nasa/openmct-tutorial#step-3---providing-objects). diff --git a/src/plugins/condition/Condition.js b/src/plugins/condition/Condition.js index d00303e4cf..dc8ae4e638 100644 --- a/src/plugins/condition/Condition.js +++ b/src/plugins/condition/Condition.js @@ -20,7 +20,7 @@ * at runtime from the About dialog for additional information. *****************************************************************************/ -import * as EventEmitter from 'eventemitter3'; +import EventEmitter from 'EventEmitter'; import uuid from 'uuid'; import TelemetryCriterion from "./criterion/TelemetryCriterion"; import { TRIGGER } from "./utils/constants"; diff --git a/src/plugins/condition/ConditionManager.js b/src/plugins/condition/ConditionManager.js index e59d538b8b..f5ee84f626 100644 --- a/src/plugins/condition/ConditionManager.js +++ b/src/plugins/condition/ConditionManager.js @@ -22,13 +22,13 @@ import Condition from "./Condition"; import uuid from "uuid"; -import * as EventEmitter from 'eventemitter3'; +import EventEmitter from 'EventEmitter'; export default class ConditionManager extends EventEmitter { constructor(domainObject, openmct) { super(); - this.domainObject = domainObject; this.openmct = openmct; + this.domainObject = domainObject; this.timeAPI = this.openmct.time; this.latestTimestamp = {}; this.instantiate = this.openmct.$injector.get('instantiate'); diff --git a/src/plugins/condition/StyleRuleManager.js b/src/plugins/condition/StyleRuleManager.js index e69de29bb2..1d5b010c09 100644 --- a/src/plugins/condition/StyleRuleManager.js +++ b/src/plugins/condition/StyleRuleManager.js @@ -0,0 +1,102 @@ +/***************************************************************************** + * 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 EventEmitter from 'EventEmitter'; + +export default class StyleRuleManager extends EventEmitter { + constructor(conditionalStyleConfiguration, openmct) { + super(); + this.openmct = openmct; + if (conditionalStyleConfiguration && conditionalStyleConfiguration.conditionSetIdentifier) { + this.initialize(conditionalStyleConfiguration); + this.subscribeToConditionSet(); + } + } + + initialize(conditionalStyleConfiguration) { + this.conditionSetIdentifier = conditionalStyleConfiguration.conditionSetIdentifier; + this.defaultStyle = conditionalStyleConfiguration.defaultStyle; + this.updateConditionStylesMap(conditionalStyleConfiguration.styles || []); + } + + subscribeToConditionSet() { + if (this.stopProvidingTelemetry) { + this.stopProvidingTelemetry(); + } + this.openmct.objects.get(this.conditionSetIdentifier).then((conditionSetDomainObject) => { + this.stopProvidingTelemetry = this.openmct.telemetry.subscribe(conditionSetDomainObject, output => this.handleConditionSetResultUpdated(output)); + }); + } + + updateConditionalStyleConfig(conditionalStyleConfiguration) { + if (!conditionalStyleConfiguration || !conditionalStyleConfiguration.conditionSetIdentifier) { + this.destroy(); + } else { + let isNewConditionSet = !this.conditionSetIdentifier || + this.openmct.objects.areIdsEqual(this.conditionSetIdentifier, conditionalStyleConfiguration.conditionSetIdentifier); + this.initialize(conditionalStyleConfiguration); + //Only resubscribe if the conditionSet has changed. + if (isNewConditionSet) { + this.subscribeToConditionSet(); + } + } + } + + updateConditionStylesMap(conditionStyles) { + let conditionStyleMap = {}; + conditionStyles.forEach((conditionStyle) => { + const identifier = this.openmct.objects.makeKeyString(conditionStyle.conditionIdentifier); + conditionStyleMap[identifier] = conditionStyle.style; + }); + this.conditionalStyleMap = conditionStyleMap; + } + + handleConditionSetResultUpdated(resultData) { + let identifier = this.openmct.objects.makeKeyString(resultData.conditionId); + let foundStyle = this.conditionalStyleMap[identifier]; + if (foundStyle) { + if (foundStyle !== this.currentStyle) { + this.currentStyle = foundStyle; + } + } else { + if (this.currentStyle !== this.defaultStyle) { + this.currentStyle = this.defaultStyle; + } + } + + this.updateDomainObjectStyle(); + } + + updateDomainObjectStyle() { + this.emit('conditionalStyleUpdated', this.currentStyle) + } + + destroy() { + this.currentStyle = this.defaultStyle; + this.updateDomainObjectStyle(); + if (this.stopProvidingTelemetry) { + this.stopProvidingTelemetry(); + } + this.conditionSetIdentifier = undefined; + } + +} diff --git a/src/plugins/condition/components/Condition.vue b/src/plugins/condition/components/Condition.vue index 407d0acd70..37114f8b26 100644 --- a/src/plugins/condition/components/Condition.vue +++ b/src/plugins/condition/components/Condition.vue @@ -1,178 +1,168 @@ /***************************************************************************** - * 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. - *****************************************************************************/ +* 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. +*****************************************************************************/ @@ -210,7 +200,9 @@ export default { }, data() { return { - domainObject: this.domainObject, + domainObject: { + configuration: {} + }, currentCriteria: this.currentCriteria, expanded: true, trigger: 'all', @@ -262,7 +254,7 @@ export default { dragStart(e) { e.dataTransfer.setData('dragging', e.target); // required for FF to initiate drag e.dataTransfer.effectAllowed = "copyMove"; - e.dataTransfer.setDragImage(e.target.closest('.c-c-container__container'), 0, 0); + e.dataTransfer.setDragImage(e.target.closest('.js-condition-drag-wrapper'), 0, 0); this.$emit('setMoveIndex', this.conditionIndex); }, dragStop(e) { @@ -301,5 +293,3 @@ export default { } } - - diff --git a/src/plugins/condition/components/ConditionCollection.vue b/src/plugins/condition/components/ConditionCollection.vue index 803f18e7b6..25c094a4e6 100644 --- a/src/plugins/condition/components/ConditionCollection.vue +++ b/src/plugins/condition/components/ConditionCollection.vue @@ -22,60 +22,59 @@