diff --git a/src/plugins/condition/Condition.js b/src/plugins/condition/Condition.js
index 556feb766b..9f87af5029 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 25a3512155..c7249b95a0 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');
@@ -37,19 +37,17 @@ export default class ConditionManager extends EventEmitter {
initialize() {
this.conditionResults = {};
- this.openmct.objects.get(this.domainObject.identifier).then((obj) => {
- this.observeForChanges(obj);
- this.conditionCollection = [];
- if (this.domainObject.configuration.conditionCollection.length) {
- this.domainObject.configuration.conditionCollection.forEach((conditionConfigurationId, index) => {
- this.openmct.objects.get(conditionConfigurationId).then((conditionConfiguration) => {
- this.initCondition(conditionConfiguration, index)
- });
+ this.observeForChanges(this.domainObject);
+ this.conditionCollection = [];
+ if (this.domainObject.configuration.conditionCollection.length) {
+ this.domainObject.configuration.conditionCollection.forEach((conditionConfigurationId, index) => {
+ this.openmct.objects.get(conditionConfigurationId).then((conditionConfiguration) => {
+ this.initCondition(conditionConfiguration, index)
});
- } else {
- this.addCondition(true);
- }
- });
+ });
+ } else {
+ this.addCondition(true);
+ }
}
observeForChanges(domainObject) {
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/inspector/ConditionalStyle.vue b/src/plugins/condition/components/inspector/ConditionalStyle.vue
new file mode 100644
index 0000000000..73848ce498
--- /dev/null
+++ b/src/plugins/condition/components/inspector/ConditionalStyle.vue
@@ -0,0 +1,38 @@
+
+
+
+