mirror of
https://github.com/nasa/openmct.git
synced 2025-06-18 23:28:14 +00:00
New eslint rules auto fix (#3058)
* no-implicit-coercion and no-unneeded-ternary * End every line with a semicolon * Spacing and formatting * Enabled semi-spacing * Applies npm run lint:fix to code after master merge * Fix merge issues * Switched operator-linebreak to 'before' Co-authored-by: Joshi <simplyrender@gmail.com>
This commit is contained in:
@ -63,6 +63,7 @@ export default class Condition extends EventEmitter {
|
||||
if (conditionConfiguration.configuration.criteria) {
|
||||
this.createCriteria(conditionConfiguration.configuration.criteria);
|
||||
}
|
||||
|
||||
this.trigger = conditionConfiguration.configuration.trigger;
|
||||
this.description = '';
|
||||
}
|
||||
@ -70,6 +71,7 @@ export default class Condition extends EventEmitter {
|
||||
getResult(datum) {
|
||||
if (!datum || !datum.id) {
|
||||
console.log('no data received');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -149,24 +151,27 @@ export default class Condition extends EventEmitter {
|
||||
} else {
|
||||
criterion = new TelemetryCriterion(criterionConfigurationWithId, this.openmct);
|
||||
}
|
||||
|
||||
criterion.on('criterionUpdated', (obj) => this.handleCriterionUpdated(obj));
|
||||
criterion.on('telemetryIsStale', (obj) => this.handleStaleCriterion(obj));
|
||||
if (!this.criteria) {
|
||||
this.criteria = [];
|
||||
}
|
||||
|
||||
this.criteria.push(criterion);
|
||||
|
||||
return criterionConfigurationWithId.id;
|
||||
}
|
||||
|
||||
findCriterion(id) {
|
||||
let criterion;
|
||||
|
||||
for (let i=0, ii=this.criteria.length; i < ii; i ++) {
|
||||
for (let i = 0, ii = this.criteria.length; i < ii; i++) {
|
||||
if (this.criteria[i].id === id) {
|
||||
criterion = {
|
||||
item: this.criteria[i],
|
||||
index: i
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@ -206,6 +211,7 @@ export default class Condition extends EventEmitter {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -236,6 +242,7 @@ export default class Condition extends EventEmitter {
|
||||
if (!index) {
|
||||
description = `Match if ${triggerDescription.prefix}`;
|
||||
}
|
||||
|
||||
description = `${description} ${criterion.getDescription()} ${(index < this.criteria.length - 1) ? triggerDescription.conjunction : ''}`;
|
||||
});
|
||||
this.description = description;
|
||||
@ -260,8 +267,9 @@ export default class Condition extends EventEmitter {
|
||||
results.forEach(resultObj => {
|
||||
const { id, data, data: { result } } = resultObj;
|
||||
if (this.findCriterion(id)) {
|
||||
criteriaResults[id] = !!result;
|
||||
criteriaResults[id] = Boolean(result);
|
||||
}
|
||||
|
||||
latestTimestamp = getLatestTimestamp(
|
||||
latestTimestamp,
|
||||
data,
|
||||
@ -269,6 +277,7 @@ export default class Condition extends EventEmitter {
|
||||
this.openmct.time.timeSystem()
|
||||
);
|
||||
});
|
||||
|
||||
return {
|
||||
id: this.id,
|
||||
data: Object.assign(
|
||||
@ -287,9 +296,10 @@ export default class Condition extends EventEmitter {
|
||||
destroyCriteria() {
|
||||
let success = true;
|
||||
//looping through the array backwards since destroyCriterion modifies the criteria array
|
||||
for (let i=this.criteria.length-1; i >= 0; i--) {
|
||||
for (let i = this.criteria.length - 1; i >= 0; i--) {
|
||||
success = success && this.destroyCriterion(this.criteria[i].id);
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,10 @@ export default class ConditionManager extends EventEmitter {
|
||||
this.compositionLoad = this.composition.load();
|
||||
this.subscriptions = {};
|
||||
this.telemetryObjects = {};
|
||||
this.testData = {conditionTestData: [], applied: false};
|
||||
this.testData = {
|
||||
conditionTestData: [],
|
||||
applied: false
|
||||
};
|
||||
this.initialize();
|
||||
|
||||
this.stopObservingForChanges = this.openmct.objects.observe(this.conditionSetDomainObject, '*', (newDomainObject) => {
|
||||
@ -50,8 +53,10 @@ export default class ConditionManager extends EventEmitter {
|
||||
const id = this.openmct.objects.makeKeyString(endpoint.identifier);
|
||||
if (this.subscriptions[id]) {
|
||||
console.log('subscription already exists');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
this.telemetryObjects[id] = Object.assign({}, endpoint, {telemetryMetaData: this.openmct.telemetry.getMetadata(endpoint).valueMetadatas});
|
||||
this.subscriptions[id] = this.openmct.telemetry.subscribe(
|
||||
endpoint,
|
||||
@ -64,6 +69,7 @@ export default class ConditionManager extends EventEmitter {
|
||||
const id = this.openmct.objects.makeKeyString(endpointIdentifier);
|
||||
if (!this.subscriptions[id]) {
|
||||
console.log('no subscription to remove');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -189,6 +195,7 @@ export default class ConditionManager extends EventEmitter {
|
||||
} else {
|
||||
this.conditionSetDomainObject.configuration.conditionCollection.unshift(newCondition);
|
||||
}
|
||||
|
||||
this.initCondition(newCondition, index);
|
||||
this.persistConditions();
|
||||
}
|
||||
@ -218,10 +225,10 @@ export default class ConditionManager extends EventEmitter {
|
||||
|
||||
getCurrentCondition() {
|
||||
const conditionCollection = this.conditionSetDomainObject.configuration.conditionCollection;
|
||||
let currentCondition = conditionCollection[conditionCollection.length-1];
|
||||
let currentCondition = conditionCollection[conditionCollection.length - 1];
|
||||
|
||||
for (let i = 0; i < conditionCollection.length - 1; i++) {
|
||||
const condition = this.findConditionById(conditionCollection[i].id)
|
||||
const condition = this.findConditionById(conditionCollection[i].id);
|
||||
if (condition.result) {
|
||||
//first condition to be true wins
|
||||
currentCondition = conditionCollection[i];
|
||||
@ -234,7 +241,7 @@ export default class ConditionManager extends EventEmitter {
|
||||
|
||||
getCurrentConditionLAD(conditionResults) {
|
||||
const conditionCollection = this.conditionSetDomainObject.configuration.conditionCollection;
|
||||
let currentCondition = conditionCollection[conditionCollection.length-1];
|
||||
let currentCondition = conditionCollection[conditionCollection.length - 1];
|
||||
|
||||
for (let i = 0; i < conditionCollection.length - 1; i++) {
|
||||
if (conditionResults[conditionCollection[i].id]) {
|
||||
@ -243,6 +250,7 @@ export default class ConditionManager extends EventEmitter {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return currentCondition;
|
||||
}
|
||||
|
||||
@ -262,8 +270,9 @@ export default class ConditionManager extends EventEmitter {
|
||||
results.forEach(resultObj => {
|
||||
const { id, data, data: { result } } = resultObj;
|
||||
if (this.findConditionById(id)) {
|
||||
conditionResults[id] = !!result;
|
||||
conditionResults[id] = Boolean(result);
|
||||
}
|
||||
|
||||
latestTimestamp = getLatestTimestamp(
|
||||
latestTimestamp,
|
||||
data,
|
||||
@ -294,7 +303,7 @@ export default class ConditionManager extends EventEmitter {
|
||||
isTelemetryUsed(endpoint) {
|
||||
const id = this.openmct.objects.makeKeyString(endpoint.identifier);
|
||||
|
||||
for(const condition of this.conditions) {
|
||||
for (const condition of this.conditions) {
|
||||
if (condition.isTelemetryUsed(id)) {
|
||||
return true;
|
||||
}
|
||||
@ -332,7 +341,7 @@ export default class ConditionManager extends EventEmitter {
|
||||
},
|
||||
timestamp
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
getTestData(metadatum) {
|
||||
@ -343,6 +352,7 @@ export default class ConditionManager extends EventEmitter {
|
||||
data = found.value;
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
@ -353,7 +363,8 @@ export default class ConditionManager extends EventEmitter {
|
||||
const normalizedDatum = Object.values(metadata).reduce((datum, metadatum) => {
|
||||
const testValue = this.getTestData(metadatum);
|
||||
const formatter = this.openmct.telemetry.getValueFormatter(metadatum);
|
||||
datum[metadatum.key] = testValue !== undefined ? formatter.parse(testValue) : formatter.parse(telemetryDatum[metadatum.source]);
|
||||
datum[metadatum.key] = testValue !== undefined ? formatter.parse(testValue) : formatter.parse(telemetryDatum[metadatum.source]);
|
||||
|
||||
return datum;
|
||||
}, {});
|
||||
|
||||
@ -377,12 +388,12 @@ export default class ConditionManager extends EventEmitter {
|
||||
Object.values(this.subscriptions).forEach(unsubscribe => unsubscribe());
|
||||
delete this.subscriptions;
|
||||
|
||||
if(this.stopObservingForChanges) {
|
||||
if (this.stopObservingForChanges) {
|
||||
this.stopObservingForChanges();
|
||||
}
|
||||
|
||||
this.conditions.forEach((condition) => {
|
||||
condition.destroy();
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,7 @@
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
|
||||
import ConditionManager from './ConditionManager';
|
||||
import ConditionManager from './ConditionManager';
|
||||
|
||||
describe('ConditionManager', () => {
|
||||
|
||||
@ -93,6 +93,7 @@ describe('ConditionManager', () => {
|
||||
setTimeout(() => {
|
||||
loader.resolve();
|
||||
});
|
||||
|
||||
return loader.promise;
|
||||
});
|
||||
mockComposition.on('add', mockListener);
|
||||
|
@ -29,5 +29,5 @@ export default function ConditionSetCompositionPolicy(openmct) {
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -20,7 +20,7 @@
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
|
||||
import ConditionSetCompositionPolicy from './ConditionSetCompositionPolicy';
|
||||
import ConditionSetCompositionPolicy from './ConditionSetCompositionPolicy';
|
||||
|
||||
describe('ConditionSetCompositionPolicy', () => {
|
||||
|
||||
@ -31,7 +31,10 @@ describe('ConditionSetCompositionPolicy', () => {
|
||||
|
||||
beforeAll(function () {
|
||||
testTelemetryObject = {
|
||||
identifier:{ namespace: "", key: "test-object"},
|
||||
identifier: {
|
||||
namespace: "",
|
||||
key: "test-object"
|
||||
},
|
||||
type: "test-object",
|
||||
name: "Test Object",
|
||||
telemetry: {
|
||||
|
@ -20,7 +20,7 @@
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
|
||||
import ConditionManager from './ConditionManager'
|
||||
import ConditionManager from './ConditionManager';
|
||||
|
||||
export default class ConditionSetTelemetryProvider {
|
||||
constructor(openmct) {
|
||||
|
@ -27,7 +27,8 @@ ConditionSetViewPolicy.prototype.allow = function (view, domainObject) {
|
||||
if (domainObject.getModel().type === 'conditionSet') {
|
||||
return view.key === 'conditionSet.view';
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
export default ConditionSetViewPolicy;
|
||||
|
@ -44,6 +44,7 @@ export default class ConditionSetViewProvider {
|
||||
view(domainObject, objectPath) {
|
||||
let component;
|
||||
const openmct = this.openmct;
|
||||
|
||||
return {
|
||||
show: (container, isEditing) => {
|
||||
component = new Vue({
|
||||
@ -59,7 +60,7 @@ export default class ConditionSetViewProvider {
|
||||
data() {
|
||||
return {
|
||||
isEditing
|
||||
}
|
||||
};
|
||||
},
|
||||
template: '<condition-set :isEditing="isEditing"></condition-set>'
|
||||
});
|
||||
|
@ -43,7 +43,10 @@ describe("The condition", function () {
|
||||
conditionManager.updateConditionDescription.and.returnValue(function () {});
|
||||
|
||||
testTelemetryObject = {
|
||||
identifier:{ namespace: "", key: "test-object"},
|
||||
identifier: {
|
||||
namespace: "",
|
||||
key: "test-object"
|
||||
},
|
||||
type: "test-object",
|
||||
name: "Test Object",
|
||||
telemetry: {
|
||||
@ -75,7 +78,7 @@ describe("The condition", function () {
|
||||
openmct.objects = jasmine.createSpyObj('objects', ['get', 'makeKeyString']);
|
||||
openmct.objects.get.and.returnValue(new Promise(function (resolve, reject) {
|
||||
resolve(testTelemetryObject);
|
||||
})); openmct.objects.makeKeyString.and.returnValue(testTelemetryObject.identifier.key);
|
||||
})); openmct.objects.makeKeyString.and.returnValue(testTelemetryObject.identifier.key);
|
||||
openmct.telemetry = jasmine.createSpyObj('telemetry', ['isTelemetryObject', 'subscribe', 'getMetadata']);
|
||||
openmct.telemetry.isTelemetryObject.and.returnValue(true);
|
||||
openmct.telemetry.subscribe.and.returnValue(function () {});
|
||||
|
@ -31,6 +31,7 @@ export default class StyleRuleManager extends EventEmitter {
|
||||
this.openmct.editor.on('isEditing', this.toggleSubscription.bind(this));
|
||||
this.isEditing = this.openmct.editor.editing;
|
||||
}
|
||||
|
||||
if (styleConfiguration) {
|
||||
this.initialize(styleConfiguration);
|
||||
if (styleConfiguration.conditionSetIdentifier) {
|
||||
@ -48,6 +49,7 @@ export default class StyleRuleManager extends EventEmitter {
|
||||
this.stopProvidingTelemetry();
|
||||
delete this.stopProvidingTelemetry;
|
||||
}
|
||||
|
||||
if (this.conditionSetIdentifier) {
|
||||
this.applySelectedConditionStyle();
|
||||
}
|
||||
@ -69,6 +71,7 @@ export default class StyleRuleManager extends EventEmitter {
|
||||
this.stopProvidingTelemetry();
|
||||
delete this.stopProvidingTelemetry;
|
||||
}
|
||||
|
||||
this.openmct.objects.get(this.conditionSetIdentifier).then((conditionSetDomainObject) => {
|
||||
this.openmct.telemetry.request(conditionSetDomainObject)
|
||||
.then(output => {
|
||||
@ -85,8 +88,8 @@ export default class StyleRuleManager extends EventEmitter {
|
||||
this.initialize(styleConfiguration || {});
|
||||
this.destroy();
|
||||
} else {
|
||||
let isNewConditionSet = !this.conditionSetIdentifier ||
|
||||
!this.openmct.objects.areIdsEqual(this.conditionSetIdentifier, styleConfiguration.conditionSetIdentifier);
|
||||
let isNewConditionSet = !this.conditionSetIdentifier
|
||||
|| !this.openmct.objects.areIdsEqual(this.conditionSetIdentifier, styleConfiguration.conditionSetIdentifier);
|
||||
this.initialize(styleConfiguration);
|
||||
if (this.isEditing) {
|
||||
this.applySelectedConditionStyle();
|
||||
@ -117,6 +120,7 @@ export default class StyleRuleManager extends EventEmitter {
|
||||
if (foundStyle !== this.currentStyle) {
|
||||
this.currentStyle = foundStyle;
|
||||
}
|
||||
|
||||
this.updateDomainObjectStyle();
|
||||
} else {
|
||||
this.applyStaticStyle();
|
||||
@ -149,6 +153,7 @@ export default class StyleRuleManager extends EventEmitter {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
this.updateDomainObjectStyle();
|
||||
}
|
||||
|
||||
@ -158,6 +163,7 @@ export default class StyleRuleManager extends EventEmitter {
|
||||
this.stopProvidingTelemetry();
|
||||
delete this.stopProvidingTelemetry;
|
||||
}
|
||||
|
||||
this.conditionSetIdentifier = undefined;
|
||||
}
|
||||
|
||||
|
@ -253,20 +253,22 @@ export default {
|
||||
label: `when ${TRIGGER_LABEL[TRIGGER[trigger]]}`
|
||||
});
|
||||
});
|
||||
|
||||
return triggerOptions;
|
||||
},
|
||||
canEvaluateCriteria: function () {
|
||||
let criteria = this.condition.configuration.criteria;
|
||||
if (criteria.length) {
|
||||
let lastCriterion = criteria[criteria.length - 1];
|
||||
if (lastCriterion.telemetry &&
|
||||
lastCriterion.operation &&
|
||||
(lastCriterion.input.length ||
|
||||
lastCriterion.operation === 'isDefined' ||
|
||||
lastCriterion.operation === 'isUndefined')) {
|
||||
if (lastCriterion.telemetry
|
||||
&& lastCriterion.operation
|
||||
&& (lastCriterion.input.length
|
||||
|| lastCriterion.operation === 'isDefined'
|
||||
|| lastCriterion.operation === 'isUndefined')) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
},
|
||||
@ -293,6 +295,7 @@ export default {
|
||||
} else {
|
||||
this.condition.configuration.output = this.selectedOutputSelection;
|
||||
}
|
||||
|
||||
this.persist();
|
||||
},
|
||||
addCriteria() {
|
||||
@ -317,8 +320,14 @@ export default {
|
||||
this.$emit('dragComplete');
|
||||
},
|
||||
dropCondition(event, targetIndex) {
|
||||
if (!this.isDragging) { return }
|
||||
if (targetIndex > this.moveIndex) { targetIndex-- } // for 'downward' move
|
||||
if (!this.isDragging) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (targetIndex > this.moveIndex) {
|
||||
targetIndex--;
|
||||
} // for 'downward' move
|
||||
|
||||
if (this.isValidTarget(targetIndex)) {
|
||||
this.dragElement = undefined;
|
||||
this.draggingOver = false;
|
||||
@ -326,8 +335,14 @@ export default {
|
||||
}
|
||||
},
|
||||
dragEnter(event, targetIndex) {
|
||||
if (!this.isDragging) { return }
|
||||
if (targetIndex > this.moveIndex) { targetIndex-- } // for 'downward' move
|
||||
if (!this.isDragging) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (targetIndex > this.moveIndex) {
|
||||
targetIndex--;
|
||||
} // for 'downward' move
|
||||
|
||||
if (this.isValidTarget(targetIndex)) {
|
||||
this.dragElement = event.target.parentElement;
|
||||
this.draggingOver = true;
|
||||
@ -370,8 +385,8 @@ export default {
|
||||
});
|
||||
},
|
||||
initCap(str) {
|
||||
return str.charAt(0).toUpperCase() + str.slice(1)
|
||||
return str.charAt(0).toUpperCase() + str.slice(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
@ -94,7 +94,7 @@ export default {
|
||||
return {
|
||||
applied: false,
|
||||
conditionTestInputs: []
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -126,10 +126,11 @@ export default {
|
||||
destroyed() {
|
||||
this.composition.off('add', this.addTelemetryObject);
|
||||
this.composition.off('remove', this.removeTelemetryObject);
|
||||
if(this.conditionManager) {
|
||||
if (this.conditionManager) {
|
||||
this.conditionManager.off('conditionSetResultUpdated', this.handleConditionSetResultUpdated);
|
||||
this.conditionManager.destroy();
|
||||
}
|
||||
|
||||
if (this.stopObservingForChanges) {
|
||||
this.stopObservingForChanges();
|
||||
}
|
||||
@ -148,7 +149,7 @@ export default {
|
||||
methods: {
|
||||
handleConditionSetResultUpdated(data) {
|
||||
this.currentConditionId = data.conditionId;
|
||||
this.$emit('conditionSetResultUpdated', data)
|
||||
this.$emit('conditionSetResultUpdated', data);
|
||||
},
|
||||
observeForChanges() {
|
||||
this.stopObservingForChanges = this.openmct.objects.observe(this.domainObject, 'configuration.conditionCollection', (newConditionCollection) => {
|
||||
@ -172,23 +173,31 @@ export default {
|
||||
while (old_index < 0) {
|
||||
old_index += arr.length;
|
||||
}
|
||||
|
||||
while (new_index < 0) {
|
||||
new_index += arr.length;
|
||||
}
|
||||
|
||||
if (new_index >= arr.length) {
|
||||
var k = new_index - arr.length;
|
||||
while ((k--) + 1) {
|
||||
arr.push(undefined);
|
||||
}
|
||||
}
|
||||
|
||||
arr.splice(new_index, 0, arr.splice(old_index, 1)[0]);
|
||||
|
||||
return arr;
|
||||
}
|
||||
};
|
||||
|
||||
const newIndexArr = move(oldIndexArr, this.moveIndex, targetIndex);
|
||||
const reorderPlan = [];
|
||||
|
||||
for (let i = 0; i < oldIndexArr.length; i++) {
|
||||
reorderPlan.push({oldIndex: Number(newIndexArr[i]), newIndex: i});
|
||||
reorderPlan.push({
|
||||
oldIndex: Number(newIndexArr[i]),
|
||||
newIndex: i
|
||||
});
|
||||
}
|
||||
|
||||
this.reorder(reorderPlan);
|
||||
@ -204,6 +213,7 @@ export default {
|
||||
let index = this.telemetryObjs.findIndex(obj => {
|
||||
let objId = this.openmct.objects.makeKeyString(obj.identifier);
|
||||
let id = this.openmct.objects.makeKeyString(identifier);
|
||||
|
||||
return objId === id;
|
||||
});
|
||||
if (index > -1) {
|
||||
@ -229,5 +239,5 @@ export default {
|
||||
this.conditionManager.updateTestData(this.testData);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
@ -64,5 +64,5 @@ export default {
|
||||
return this.condition ? this.condition.summary : '';
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
@ -52,7 +52,7 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
conditionErrors: []
|
||||
}
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
this.getConditionErrors();
|
||||
@ -76,5 +76,5 @@ export default {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
@ -72,7 +72,7 @@ export default {
|
||||
defaultConditionOutput: '',
|
||||
telemetryObjs: [],
|
||||
testData: {}
|
||||
}
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
this.conditionSetIdentifier = this.openmct.objects.makeKeyString(this.domainObject.identifier);
|
||||
|
@ -142,11 +142,12 @@ export default {
|
||||
operationFormat: '',
|
||||
enumerations: [],
|
||||
inputTypes: INPUT_TYPES
|
||||
}
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
setRowLabel: function () {
|
||||
let operator = TRIGGER_CONJUNCTION[this.trigger];
|
||||
|
||||
return (this.index !== 0 ? operator : '') + ' when';
|
||||
},
|
||||
filteredOps: function () {
|
||||
@ -163,11 +164,13 @@ export default {
|
||||
if (this.filteredOps[i].appliesTo.length) {
|
||||
type = this.inputTypes[this.filteredOps[i].appliesTo[0]];
|
||||
} else {
|
||||
type = 'text'
|
||||
type = 'text';
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
},
|
||||
@ -184,11 +187,11 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
checkTelemetry() {
|
||||
if(this.criterion.telemetry) {
|
||||
if (this.criterion.telemetry) {
|
||||
const isAnyAllTelemetry = this.criterion.telemetry === 'any' || this.criterion.telemetry === 'all';
|
||||
const telemetryForCriterionExists = this.telemetry.find((telemetryObj) => this.openmct.objects.areIdsEqual(this.criterion.telemetry, telemetryObj.identifier));
|
||||
if (!isAnyAllTelemetry &&
|
||||
!telemetryForCriterionExists) {
|
||||
if (!isAnyAllTelemetry
|
||||
&& !telemetryForCriterionExists) {
|
||||
//telemetry being used was removed. So reset this criterion.
|
||||
this.criterion.telemetry = '';
|
||||
this.criterion.metadata = '';
|
||||
@ -223,6 +226,7 @@ export default {
|
||||
} else if (this.criterion.metadata === 'dataReceived') {
|
||||
this.operationFormat = 'number';
|
||||
}
|
||||
|
||||
this.updateInputVisibilityAndValues();
|
||||
},
|
||||
updateMetadataOptions(ev) {
|
||||
@ -230,12 +234,14 @@ export default {
|
||||
this.clearDependentFields(ev.target);
|
||||
this.persist();
|
||||
}
|
||||
|
||||
if (this.criterion.telemetry) {
|
||||
let telemetryObjects = this.telemetry;
|
||||
if (this.criterion.telemetry !== 'all' && this.criterion.telemetry !== 'any') {
|
||||
const found = this.telemetry.find(telemetryObj => (this.openmct.objects.areIdsEqual(telemetryObj.identifier, this.criterion.telemetry)));
|
||||
telemetryObjects = found ? [found] : [];
|
||||
}
|
||||
|
||||
this.telemetryMetadataOptions = [];
|
||||
telemetryObjects.forEach(telemetryObject => {
|
||||
let telemetryMetadata = this.openmct.telemetry.getMetadata(telemetryObject);
|
||||
@ -248,9 +254,10 @@ export default {
|
||||
if (!this.telemetryMetadataOptions) {
|
||||
this.telemetryMetadataOptions = options;
|
||||
}
|
||||
|
||||
options.forEach((option) => {
|
||||
const found = this.telemetryMetadataOptions.find((metadataOption) => {
|
||||
return (metadataOption.key && (metadataOption.key === option.key)) && (metadataOption.name && (metadataOption.name === option.name))
|
||||
return (metadataOption.key && (metadataOption.key === option.key)) && (metadataOption.name && (metadataOption.name === option.name));
|
||||
});
|
||||
if (!found) {
|
||||
this.telemetryMetadataOptions.push(option);
|
||||
@ -275,6 +282,7 @@ export default {
|
||||
this.inputCount = this.filteredOps[i].inputCount;
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.inputCount) {
|
||||
this.criterion.input = [];
|
||||
}
|
||||
@ -292,6 +300,7 @@ export default {
|
||||
if (this.enumerations.length && !this.criterion.input.length) {
|
||||
this.criterion.input = [this.enumerations[0].value.toString()];
|
||||
}
|
||||
|
||||
this.inputCount = 0;
|
||||
}
|
||||
},
|
||||
|
@ -136,7 +136,7 @@ export default {
|
||||
return {
|
||||
applied: false,
|
||||
conditionTestInputs: []
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -183,6 +183,7 @@ export default {
|
||||
if (this.testData && this.testData.conditionTestInputs) {
|
||||
this.testInputs = this.testData.conditionTestInputs;
|
||||
}
|
||||
|
||||
if (!this.testInputs.length) {
|
||||
this.addTestInput();
|
||||
}
|
||||
@ -209,14 +210,16 @@ export default {
|
||||
if (identifier) {
|
||||
return this.openmct.objects.makeKeyString(identifier);
|
||||
}
|
||||
|
||||
return [];
|
||||
},
|
||||
updateMetadata(testInput) {
|
||||
if (testInput.telemetry) {
|
||||
const id = this.openmct.objects.makeKeyString(testInput.telemetry);
|
||||
if(this.telemetryMetadataOptions[id]) {
|
||||
if (this.telemetryMetadataOptions[id]) {
|
||||
return;
|
||||
}
|
||||
|
||||
let telemetryMetadata = this.openmct.telemetry.getMetadata(testInput);
|
||||
this.telemetryMetadataOptions[id] = telemetryMetadata.values().slice();
|
||||
}
|
||||
@ -232,5 +235,5 @@ export default {
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
@ -98,7 +98,7 @@ export default {
|
||||
loaded: false,
|
||||
children: [],
|
||||
expanded: false
|
||||
}
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
navigated() {
|
||||
@ -106,8 +106,10 @@ export default {
|
||||
const isSelectedObject = itemId && this.openmct.objects.areIdsEqual(this.node.object.identifier, itemId);
|
||||
if (isSelectedObject && this.node.objectPath && this.node.objectPath.length > 1) {
|
||||
const isParent = this.openmct.objects.areIdsEqual(this.node.objectPath[1].identifier, this.selectedItem.parentId);
|
||||
|
||||
return isSelectedObject && isParent;
|
||||
}
|
||||
|
||||
return isSelectedObject;
|
||||
},
|
||||
isAlias() {
|
||||
@ -115,7 +117,9 @@ export default {
|
||||
if (!parent) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let parentKeyString = this.openmct.objects.makeKeyString(parent.identifier);
|
||||
|
||||
return parentKeyString !== this.node.object.location;
|
||||
},
|
||||
typeClass() {
|
||||
@ -123,6 +127,7 @@ export default {
|
||||
if (!type) {
|
||||
return 'icon-object-unknown';
|
||||
}
|
||||
|
||||
return type.definition.cssClass;
|
||||
}
|
||||
},
|
||||
@ -131,6 +136,7 @@ export default {
|
||||
if (!this.hasChildren) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.loaded && !this.isLoading) {
|
||||
this.composition = this.openmct.composition.get(this.domainObject);
|
||||
this.composition.on('add', this.addChild);
|
||||
@ -181,5 +187,5 @@ export default {
|
||||
this.loaded = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
@ -98,7 +98,7 @@ export default {
|
||||
filteredTreeItems: [],
|
||||
isLoading: false,
|
||||
selectedItem: undefined
|
||||
}
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
this.searchService = this.openmct.$injector.get('searchService');
|
||||
@ -109,7 +109,7 @@ export default {
|
||||
this.isLoading = true;
|
||||
this.openmct.objects.get('ROOT')
|
||||
.then(root => {
|
||||
return this.openmct.composition.get(root).load()
|
||||
return this.openmct.composition.get(root).load();
|
||||
})
|
||||
.then(children => {
|
||||
this.isLoading = false;
|
||||
@ -146,7 +146,7 @@ export default {
|
||||
object,
|
||||
objectPath,
|
||||
navigateToParent
|
||||
}
|
||||
};
|
||||
});
|
||||
});
|
||||
},
|
||||
@ -168,5 +168,5 @@ export default {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
@ -131,7 +131,7 @@ export default {
|
||||
conditionsLoaded: false,
|
||||
navigateToPath: '',
|
||||
selectedConditionId: ''
|
||||
}
|
||||
};
|
||||
},
|
||||
destroyed() {
|
||||
this.removeListeners();
|
||||
@ -150,6 +150,7 @@ export default {
|
||||
} else {
|
||||
this.initializeStaticStyle();
|
||||
}
|
||||
|
||||
this.openmct.editor.on('isEditing', this.setEditState);
|
||||
},
|
||||
methods: {
|
||||
@ -166,8 +167,8 @@ export default {
|
||||
layoutItem = this.selection[0][0].context.layoutItem;
|
||||
const item = this.selection[0][0].context.item;
|
||||
this.canHide = true;
|
||||
if (item &&
|
||||
(!layoutItem || (this.isItemType('subobject-view', layoutItem)))) {
|
||||
if (item
|
||||
&& (!layoutItem || (this.isItemType('subobject-view', layoutItem)))) {
|
||||
domainObject = item;
|
||||
} else {
|
||||
domainObject = this.selection[0][1].context.item;
|
||||
@ -178,6 +179,7 @@ export default {
|
||||
} else {
|
||||
domainObject = this.selection[0][0].context.item;
|
||||
}
|
||||
|
||||
this.domainObject = domainObject;
|
||||
this.initialStyles = getApplicableStylesForItem(domainObject, layoutItem);
|
||||
this.$nextTick(() => {
|
||||
@ -192,9 +194,11 @@ export default {
|
||||
if (this.stopObserving) {
|
||||
this.stopObserving();
|
||||
}
|
||||
|
||||
if (this.stopObservingItems) {
|
||||
this.stopObservingItems();
|
||||
}
|
||||
|
||||
if (this.stopProvidingTelemetry) {
|
||||
this.stopProvidingTelemetry();
|
||||
delete this.stopProvidingTelemetry;
|
||||
@ -224,6 +228,7 @@ export default {
|
||||
conditionSetDomainObject = item;
|
||||
}
|
||||
};
|
||||
|
||||
const dismissDialog = (overlay, initialize) => {
|
||||
overlay.dismiss();
|
||||
if (initialize && conditionSetDomainObject) {
|
||||
@ -232,6 +237,7 @@ export default {
|
||||
this.initializeConditionalStyles();
|
||||
}
|
||||
};
|
||||
|
||||
let vm = new Vue({
|
||||
provide: {
|
||||
openmct: this.openmct
|
||||
@ -240,7 +246,7 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
handleItemSelection
|
||||
}
|
||||
};
|
||||
},
|
||||
template: '<condition-set-selector-dialog @conditionSetSelected="handleItemSelection"></condition-set-selector-dialog>'
|
||||
}).$mount();
|
||||
@ -283,7 +289,7 @@ export default {
|
||||
removeConditionSet() {
|
||||
this.conditionSetDomainObject = undefined;
|
||||
this.conditionalStyles = [];
|
||||
let domainObjectStyles = (this.domainObject.configuration && this.domainObject.configuration.objectStyles) || {};
|
||||
let domainObjectStyles = (this.domainObject.configuration && this.domainObject.configuration.objectStyles) || {};
|
||||
if (this.itemId) {
|
||||
domainObjectStyles[this.itemId].conditionSetIdentifier = undefined;
|
||||
domainObjectStyles[this.itemId].selectedConditionId = undefined;
|
||||
@ -302,6 +308,7 @@ export default {
|
||||
domainObjectStyles.styles = undefined;
|
||||
delete domainObjectStyles.styles;
|
||||
}
|
||||
|
||||
if (isEmpty(domainObjectStyles)) {
|
||||
domainObjectStyles = undefined;
|
||||
}
|
||||
@ -314,16 +321,16 @@ export default {
|
||||
},
|
||||
updateDomainObjectItemStyles(newItems) {
|
||||
//check that all items that have been styles still exist. Otherwise delete those styles
|
||||
let domainObjectStyles = (this.domainObject.configuration && this.domainObject.configuration.objectStyles) || {};
|
||||
let domainObjectStyles = (this.domainObject.configuration && this.domainObject.configuration.objectStyles) || {};
|
||||
let itemsToRemove = [];
|
||||
let keys = Object.keys(domainObjectStyles);
|
||||
//TODO: Need an easier way to find which properties are itemIds
|
||||
keys.forEach((key) => {
|
||||
const keyIsItemId = (key !== 'styles') &&
|
||||
(key !== 'staticStyle') &&
|
||||
(key !== 'defaultConditionId') &&
|
||||
(key !== 'selectedConditionId') &&
|
||||
(key !== 'conditionSetIdentifier');
|
||||
const keyIsItemId = (key !== 'styles')
|
||||
&& (key !== 'staticStyle')
|
||||
&& (key !== 'defaultConditionId')
|
||||
&& (key !== 'selectedConditionId')
|
||||
&& (key !== 'conditionSetIdentifier');
|
||||
if (keyIsItemId) {
|
||||
if (!(newItems.find(item => item.id === key))) {
|
||||
itemsToRemove.push(key);
|
||||
@ -344,17 +351,20 @@ export default {
|
||||
if (isEmpty(domainObjectStyles)) {
|
||||
domainObjectStyles = undefined;
|
||||
}
|
||||
|
||||
this.persist(domainObjectStyles);
|
||||
},
|
||||
initializeConditionalStyles() {
|
||||
if (!this.conditions) {
|
||||
this.conditions = {};
|
||||
}
|
||||
|
||||
let conditionalStyles = [];
|
||||
this.conditionSetDomainObject.configuration.conditionCollection.forEach((conditionConfiguration, index) => {
|
||||
if (conditionConfiguration.isDefault) {
|
||||
this.selectedConditionId = conditionConfiguration.id;
|
||||
}
|
||||
|
||||
this.conditions[conditionConfiguration.id] = conditionConfiguration;
|
||||
let foundStyle = this.findStyleByConditionId(conditionConfiguration.id);
|
||||
if (foundStyle) {
|
||||
@ -380,6 +390,7 @@ export default {
|
||||
this.stopProvidingTelemetry();
|
||||
delete this.stopProvidingTelemetry;
|
||||
}
|
||||
|
||||
if (this.conditionSetDomainObject) {
|
||||
this.openmct.telemetry.request(this.conditionSetDomainObject)
|
||||
.then(output => {
|
||||
@ -429,11 +440,12 @@ export default {
|
||||
if (defaultConditionId) {
|
||||
objectStyle.defaultConditionId = defaultConditionId;
|
||||
}
|
||||
|
||||
if (this.conditionSetDomainObject) {
|
||||
objectStyle.conditionSetIdentifier = this.conditionSetDomainObject.identifier;
|
||||
}
|
||||
|
||||
let domainObjectStyles = (this.domainObject.configuration && this.domainObject.configuration.objectStyles) || {};
|
||||
let domainObjectStyles = (this.domainObject.configuration && this.domainObject.configuration.objectStyles) || {};
|
||||
|
||||
if (this.itemId) {
|
||||
domainObjectStyles[this.itemId] = objectStyle;
|
||||
@ -442,7 +454,7 @@ export default {
|
||||
domainObjectStyles = {
|
||||
...domainObjectStyles,
|
||||
...objectStyle
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return domainObjectStyles;
|
||||
@ -458,5 +470,5 @@ export default {
|
||||
this.openmct.objects.mutate(this.domainObject, 'configuration.objectStyles', style);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
@ -67,7 +67,7 @@ export default {
|
||||
isEditing: this.openmct.editor.isEditing(),
|
||||
mixedStyles: [],
|
||||
isStaticAndConditionalStyles: false
|
||||
}
|
||||
};
|
||||
},
|
||||
destroyed() {
|
||||
this.removeListeners();
|
||||
@ -113,6 +113,7 @@ export default {
|
||||
this.isStaticAndConditionalStyles = this.hasConditionalStyles(domainObject, layoutItem.id);
|
||||
}
|
||||
}
|
||||
|
||||
itemInitialStyles.push(itemStyle);
|
||||
});
|
||||
const {styles, mixedStyles} = getConsolidatedStyleValues(itemInitialStyles);
|
||||
@ -132,9 +133,9 @@ export default {
|
||||
//check that all items that have been styles still exist. Otherwise delete those styles
|
||||
let keys = Object.keys(this.domainObject.configuration.objectStyles || {});
|
||||
keys.forEach((key) => {
|
||||
if ((key !== 'styles') &&
|
||||
(key !== 'staticStyle') &&
|
||||
(key !== 'conditionSetIdentifier')) {
|
||||
if ((key !== 'styles')
|
||||
&& (key !== 'staticStyle')
|
||||
&& (key !== 'conditionSetIdentifier')) {
|
||||
if (!(newItems.find(item => item.id === key))) {
|
||||
this.removeItemStyles(key);
|
||||
}
|
||||
@ -163,18 +164,21 @@ export default {
|
||||
if (this.stopObserving) {
|
||||
this.stopObserving();
|
||||
}
|
||||
|
||||
if (this.stopObservingItems) {
|
||||
this.stopObservingItems();
|
||||
}
|
||||
|
||||
if (this.unObserveObjects) {
|
||||
this.unObserveObjects.forEach((unObserveObject) => {
|
||||
unObserveObject();
|
||||
});
|
||||
}
|
||||
|
||||
this.unObserveObjects = [];
|
||||
},
|
||||
removeItemStyles(itemId) {
|
||||
let domainObjectStyles = (this.domainObject.configuration && this.domainObject.configuration.objectStyles) || {};
|
||||
let domainObjectStyles = (this.domainObject.configuration && this.domainObject.configuration.objectStyles) || {};
|
||||
if (itemId && domainObjectStyles[itemId]) {
|
||||
domainObjectStyles[itemId] = undefined;
|
||||
delete domainObjectStyles[this.itemId];
|
||||
@ -182,6 +186,7 @@ export default {
|
||||
if (isEmpty(domainObjectStyles)) {
|
||||
domainObjectStyles = undefined;
|
||||
}
|
||||
|
||||
this.persist(this.domainObject, domainObjectStyles);
|
||||
}
|
||||
},
|
||||
@ -217,6 +222,7 @@ export default {
|
||||
this.persist(domainObject, this.getDomainObjectStyle(domainObject, property));
|
||||
});
|
||||
}
|
||||
|
||||
this.isStaticAndConditionalStyles = false;
|
||||
let foundIndex = this.mixedStyles.indexOf(property);
|
||||
if (foundIndex > -1) {
|
||||
@ -224,7 +230,7 @@ export default {
|
||||
}
|
||||
},
|
||||
getDomainObjectStyle(domainObject, property, items) {
|
||||
let domainObjectStyles = (domainObject.configuration && domainObject.configuration.objectStyles) || {};
|
||||
let domainObjectStyles = (domainObject.configuration && domainObject.configuration.objectStyles) || {};
|
||||
|
||||
if (items) {
|
||||
items.forEach(item => {
|
||||
@ -232,6 +238,7 @@ export default {
|
||||
if (domainObjectStyles[item.id] && domainObjectStyles[item.id].staticStyle) {
|
||||
itemStaticStyle = domainObjectStyles[item.id].staticStyle.style;
|
||||
}
|
||||
|
||||
Object.keys(item.applicableStyles).forEach(key => {
|
||||
if (property === key) {
|
||||
itemStaticStyle[key] = this.staticStyle.style[key];
|
||||
@ -240,6 +247,7 @@ export default {
|
||||
if (this.isStaticAndConditionalStyles) {
|
||||
this.removeConditionalStyles(domainObjectStyles, item.id);
|
||||
}
|
||||
|
||||
if (isEmpty(itemStaticStyle)) {
|
||||
itemStaticStyle = undefined;
|
||||
domainObjectStyles[item.id] = undefined;
|
||||
@ -251,11 +259,13 @@ export default {
|
||||
if (!domainObjectStyles.staticStyle) {
|
||||
domainObjectStyles.staticStyle = {
|
||||
style: {}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
if (this.isStaticAndConditionalStyles) {
|
||||
this.removeConditionalStyles(domainObjectStyles);
|
||||
}
|
||||
|
||||
domainObjectStyles.staticStyle.style[property] = this.staticStyle.style[property];
|
||||
}
|
||||
|
||||
@ -266,5 +276,5 @@ export default {
|
||||
this.openmct.objects.mutate(domainObject, 'configuration.objectStyles', style);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
@ -104,6 +104,7 @@ export default {
|
||||
},
|
||||
borderColorOption() {
|
||||
let value = this.styleItem.style.border.replace('1px solid ', '');
|
||||
|
||||
return {
|
||||
icon: 'icon-line-horz',
|
||||
title: STYLE_CONSTANTS.borderColorTitle,
|
||||
@ -111,10 +112,11 @@ export default {
|
||||
property: 'border',
|
||||
isEditing: this.isEditing,
|
||||
nonSpecific: this.mixedStyles.indexOf('border') > -1
|
||||
}
|
||||
};
|
||||
},
|
||||
backgroundColorOption() {
|
||||
let value = this.styleItem.style.backgroundColor;
|
||||
|
||||
return {
|
||||
icon: 'icon-paint-bucket',
|
||||
title: STYLE_CONSTANTS.backgroundColorTitle,
|
||||
@ -122,10 +124,11 @@ export default {
|
||||
property: 'backgroundColor',
|
||||
isEditing: this.isEditing,
|
||||
nonSpecific: this.mixedStyles.indexOf('backgroundColor') > -1
|
||||
}
|
||||
};
|
||||
},
|
||||
colorOption() {
|
||||
let value = this.styleItem.style.color;
|
||||
|
||||
return {
|
||||
icon: 'icon-font',
|
||||
title: STYLE_CONSTANTS.textColorTitle,
|
||||
@ -133,7 +136,7 @@ export default {
|
||||
property: 'color',
|
||||
isEditing: this.isEditing,
|
||||
nonSpecific: this.mixedStyles.indexOf('color') > -1
|
||||
}
|
||||
};
|
||||
},
|
||||
imageUrlOption() {
|
||||
return {
|
||||
@ -159,7 +162,7 @@ export default {
|
||||
value: {url: this.styleItem.style.imageUrl},
|
||||
isEditing: this.isEditing,
|
||||
nonSpecific: this.mixedStyles.indexOf('imageUrl') > -1
|
||||
}
|
||||
};
|
||||
},
|
||||
isStyleInvisibleOption() {
|
||||
return {
|
||||
@ -178,7 +181,7 @@ export default {
|
||||
title: STYLE_CONSTANTS.visibilityVisible
|
||||
}
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
},
|
||||
@ -190,12 +193,14 @@ export default {
|
||||
if (value && value.indexOf('__no_value') > -1) {
|
||||
return value.replace('__no_value', 'transparent');
|
||||
}
|
||||
|
||||
return value;
|
||||
},
|
||||
normalizeValueForStyle(value) {
|
||||
if (value && value === 'transparent') {
|
||||
return '__no_value';
|
||||
}
|
||||
|
||||
return value;
|
||||
},
|
||||
updateStyleValue(value, item) {
|
||||
@ -203,13 +208,15 @@ export default {
|
||||
if (item.property === 'border') {
|
||||
value = '1px solid ' + value;
|
||||
}
|
||||
|
||||
if (value && (value.url !== undefined)) {
|
||||
this.styleItem.style[item.property] = value.url;
|
||||
} else {
|
||||
this.styleItem.style[item.property] = value;
|
||||
}
|
||||
|
||||
this.$emit('persist', this.styleItem, item.property);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
@ -140,7 +140,7 @@ export default {
|
||||
navigateToPath: '',
|
||||
selectedConditionId: '',
|
||||
locked: false
|
||||
}
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
allowEditing() {
|
||||
@ -165,6 +165,7 @@ export default {
|
||||
} else {
|
||||
this.initializeStaticStyle();
|
||||
}
|
||||
|
||||
this.openmct.editor.on('isEditing', this.setEditState);
|
||||
},
|
||||
methods: {
|
||||
@ -183,6 +184,7 @@ export default {
|
||||
} else if (this.domainObject.configuration && this.domainObject.configuration.objectStyles) {
|
||||
objectStyles = this.domainObject.configuration.objectStyles;
|
||||
}
|
||||
|
||||
return objectStyles;
|
||||
},
|
||||
setEditState(isEditing) {
|
||||
@ -219,6 +221,7 @@ export default {
|
||||
},
|
||||
hasConditionalStyle(domainObject, layoutItem) {
|
||||
const id = layoutItem ? layoutItem.id : undefined;
|
||||
|
||||
return getConditionSetIdentifierForItem(domainObject, id) !== undefined;
|
||||
},
|
||||
getObjectsAndItemsFromSelection() {
|
||||
@ -265,6 +268,7 @@ export default {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
itemInitialStyles.push(itemStyle);
|
||||
});
|
||||
this.isStaticAndConditionalStyles = this.isMultipleSelection && itemsWithConditionalStyles;
|
||||
@ -292,11 +296,11 @@ export default {
|
||||
});
|
||||
},
|
||||
isKeyItemId(key) {
|
||||
return (key !== 'styles') &&
|
||||
(key !== 'staticStyle') &&
|
||||
(key !== 'defaultConditionId') &&
|
||||
(key !== 'selectedConditionId') &&
|
||||
(key !== 'conditionSetIdentifier');
|
||||
return (key !== 'styles')
|
||||
&& (key !== 'staticStyle')
|
||||
&& (key !== 'defaultConditionId')
|
||||
&& (key !== 'selectedConditionId')
|
||||
&& (key !== 'conditionSetIdentifier');
|
||||
},
|
||||
registerListener(domainObject) {
|
||||
let id = this.openmct.objects.makeKeyString(domainObject.identifier);
|
||||
@ -320,6 +324,7 @@ export default {
|
||||
if (this.stopObserving) {
|
||||
this.stopObserving();
|
||||
}
|
||||
|
||||
if (this.stopObservingItems) {
|
||||
this.stopObservingItems();
|
||||
}
|
||||
@ -334,6 +339,7 @@ export default {
|
||||
unObserveObject();
|
||||
});
|
||||
}
|
||||
|
||||
this.unObserveObjects = [];
|
||||
},
|
||||
subscribeToConditionSet() {
|
||||
@ -341,6 +347,7 @@ export default {
|
||||
this.stopProvidingTelemetry();
|
||||
delete this.stopProvidingTelemetry;
|
||||
}
|
||||
|
||||
if (this.conditionSetDomainObject) {
|
||||
this.openmct.telemetry.request(this.conditionSetDomainObject)
|
||||
.then(output => {
|
||||
@ -364,11 +371,13 @@ export default {
|
||||
if (!this.conditions) {
|
||||
this.conditions = {};
|
||||
}
|
||||
|
||||
let conditionalStyles = [];
|
||||
this.conditionSetDomainObject.configuration.conditionCollection.forEach((conditionConfiguration, index) => {
|
||||
if (conditionConfiguration.isDefault) {
|
||||
this.selectedConditionId = conditionConfiguration.id;
|
||||
}
|
||||
|
||||
this.conditions[conditionConfiguration.id] = conditionConfiguration;
|
||||
let foundStyle = this.findStyleByConditionId(conditionConfiguration.id);
|
||||
if (foundStyle) {
|
||||
@ -403,13 +412,14 @@ export default {
|
||||
}
|
||||
},
|
||||
removeItemStyles(itemId) {
|
||||
let domainObjectStyles = (this.domainObject.configuration && this.domainObject.configuration.objectStyles) || {};
|
||||
let domainObjectStyles = (this.domainObject.configuration && this.domainObject.configuration.objectStyles) || {};
|
||||
if (itemId && domainObjectStyles[itemId]) {
|
||||
delete domainObjectStyles[itemId];
|
||||
|
||||
if (Object.keys(domainObjectStyles).length <= 0) {
|
||||
domainObjectStyles = undefined;
|
||||
}
|
||||
|
||||
this.persist(this.domainObject, domainObjectStyles);
|
||||
}
|
||||
},
|
||||
@ -426,6 +436,7 @@ export default {
|
||||
conditionSetDomainObject = item;
|
||||
}
|
||||
};
|
||||
|
||||
const dismissDialog = (overlay, initialize) => {
|
||||
overlay.dismiss();
|
||||
if (initialize && conditionSetDomainObject) {
|
||||
@ -434,6 +445,7 @@ export default {
|
||||
this.initializeConditionalStyles();
|
||||
}
|
||||
};
|
||||
|
||||
let vm = new Vue({
|
||||
provide: {
|
||||
openmct: this.openmct
|
||||
@ -442,7 +454,7 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
handleItemSelection
|
||||
}
|
||||
};
|
||||
},
|
||||
template: '<condition-set-selector-dialog @conditionSetSelected="handleItemSelection"></condition-set-selector-dialog>'
|
||||
}).$mount();
|
||||
@ -467,18 +479,20 @@ export default {
|
||||
removeConditionSet() {
|
||||
this.conditionSetDomainObject = undefined;
|
||||
this.conditionalStyles = [];
|
||||
let domainObjectStyles = (this.domainObject.configuration && this.domainObject.configuration.objectStyles) || {};
|
||||
let domainObjectStyles = (this.domainObject.configuration && this.domainObject.configuration.objectStyles) || {};
|
||||
if (this.domainObjectsById) {
|
||||
const domainObjects = Object.values(this.domainObjectsById);
|
||||
domainObjects.forEach(domainObject => {
|
||||
let objectStyles = (domainObject.configuration && domainObject.configuration.objectStyles) || {};
|
||||
let objectStyles = (domainObject.configuration && domainObject.configuration.objectStyles) || {};
|
||||
this.removeConditionalStyles(objectStyles);
|
||||
if (objectStyles && Object.keys(objectStyles).length <= 0) {
|
||||
objectStyles = undefined;
|
||||
}
|
||||
|
||||
this.persist(domainObject, objectStyles);
|
||||
});
|
||||
}
|
||||
|
||||
if (this.items.length) {
|
||||
this.items.forEach((item) => {
|
||||
const itemId = item.id;
|
||||
@ -487,12 +501,14 @@ export default {
|
||||
delete domainObjectStyles[itemId];
|
||||
}
|
||||
});
|
||||
} else {
|
||||
} else {
|
||||
this.removeConditionalStyles(domainObjectStyles);
|
||||
}
|
||||
|
||||
if (domainObjectStyles && Object.keys(domainObjectStyles).length <= 0) {
|
||||
domainObjectStyles = undefined;
|
||||
}
|
||||
|
||||
this.persist(this.domainObject, domainObjectStyles);
|
||||
|
||||
if (this.stopProvidingTelemetry) {
|
||||
@ -539,9 +555,11 @@ export default {
|
||||
this.persist(domainObject, this.getDomainObjectStyle(domainObject, property, null, defaultConditionId));
|
||||
});
|
||||
}
|
||||
|
||||
if (!this.items.length && !this.domainObjectsById) {
|
||||
this.persist(this.domainObject, this.getDomainObjectStyle(this.domainObject, property, null, defaultConditionId));
|
||||
}
|
||||
|
||||
this.isStaticAndConditionalStyles = false;
|
||||
if (property) {
|
||||
let foundIndex = this.mixedStyles.indexOf(property);
|
||||
@ -559,10 +577,12 @@ export default {
|
||||
if (defaultConditionId) {
|
||||
objectStyle.defaultConditionId = defaultConditionId;
|
||||
}
|
||||
|
||||
if (this.conditionSetDomainObject) {
|
||||
objectStyle.conditionSetIdentifier = this.conditionSetDomainObject.identifier;
|
||||
}
|
||||
let domainObjectStyles = (domainObject.configuration && domainObject.configuration.objectStyles) || {};
|
||||
|
||||
let domainObjectStyles = (domainObject.configuration && domainObject.configuration.objectStyles) || {};
|
||||
|
||||
if (items) {
|
||||
items.forEach(item => {
|
||||
@ -572,12 +592,15 @@ export default {
|
||||
if (domainObjectStyles[item.id] && domainObjectStyles[item.id].staticStyle) {
|
||||
itemStaticStyle = Object.assign({}, domainObjectStyles[item.id].staticStyle.style);
|
||||
}
|
||||
|
||||
if (item.applicableStyles[property] !== undefined) {
|
||||
itemStaticStyle[property] = this.staticStyle.style[property];
|
||||
}
|
||||
|
||||
if (Object.keys(itemStaticStyle).length <= 0) {
|
||||
itemStaticStyle = undefined;
|
||||
}
|
||||
|
||||
domainObjectStyles[item.id] = { staticStyle: { style: itemStaticStyle } };
|
||||
} else {
|
||||
objectStyle.styles.forEach((conditionalStyle, index) => {
|
||||
@ -614,5 +637,5 @@ export default {
|
||||
this.openmct.objects.mutate(domainObject, 'configuration.objectStyles', style);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
@ -51,14 +51,15 @@ export default class AllTelemetryCriterion extends TelemetryCriterion {
|
||||
if (!this.stalenessSubscription) {
|
||||
this.stalenessSubscription = {};
|
||||
}
|
||||
|
||||
Object.values(telemetryObjects).forEach((telemetryObject) => {
|
||||
const id = this.openmct.objects.makeKeyString(telemetryObject.identifier);
|
||||
if (!this.stalenessSubscription[id]) {
|
||||
this.stalenessSubscription[id] = subscribeForStaleness((data) => {
|
||||
this.handleStaleTelemetry(id, data);
|
||||
}, this.input[0]*1000);
|
||||
}, this.input[0] * 1000);
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
handleStaleTelemetry(id, data) {
|
||||
@ -66,6 +67,7 @@ export default class AllTelemetryCriterion extends TelemetryCriterion {
|
||||
this.telemetryDataCache[id] = true;
|
||||
this.result = evaluateResults(Object.values(this.telemetryDataCache), this.telemetry);
|
||||
}
|
||||
|
||||
this.emitEvent('telemetryIsStale', data);
|
||||
}
|
||||
|
||||
@ -116,9 +118,10 @@ export default class AllTelemetryCriterion extends TelemetryCriterion {
|
||||
|
||||
if (data) {
|
||||
this.openmct.time.getAllTimeSystems().forEach(timeSystem => {
|
||||
datum[timeSystem.key] = data[timeSystem.key]
|
||||
datum[timeSystem.key] = data[timeSystem.key];
|
||||
});
|
||||
}
|
||||
|
||||
return datum;
|
||||
}
|
||||
|
||||
@ -130,6 +133,7 @@ export default class AllTelemetryCriterion extends TelemetryCriterion {
|
||||
if (this.stalenessSubscription && this.stalenessSubscription[validatedData.id]) {
|
||||
this.stalenessSubscription[validatedData.id].update(validatedData);
|
||||
}
|
||||
|
||||
this.telemetryDataCache[validatedData.id] = false;
|
||||
} else {
|
||||
this.telemetryDataCache[validatedData.id] = this.computeResult(validatedData);
|
||||
@ -164,6 +168,7 @@ export default class AllTelemetryCriterion extends TelemetryCriterion {
|
||||
));
|
||||
|
||||
let telemetryDataCache = {};
|
||||
|
||||
return Promise.all(telemetryRequests)
|
||||
.then(telemetryRequestsResults => {
|
||||
let latestTimestamp;
|
||||
@ -203,7 +208,7 @@ export default class AllTelemetryCriterion extends TelemetryCriterion {
|
||||
let inputValue = this.input;
|
||||
if (this.metadata) {
|
||||
const telemetryObjects = Object.values(this.telemetryObjects);
|
||||
for (let i=0; i < telemetryObjects.length; i++) {
|
||||
for (let i = 0; i < telemetryObjects.length; i++) {
|
||||
const telemetryObject = telemetryObjects[i];
|
||||
const metadataObject = this.getMetaDataObject(telemetryObject, this.metadata);
|
||||
if (metadataObject) {
|
||||
@ -213,6 +218,7 @@ export default class AllTelemetryCriterion extends TelemetryCriterion {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return `${telemetryDescription} ${metadataValue} ${getOperatorText(this.operation, inputValue)}`;
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ export default class TelemetryCriterion extends EventEmitter {
|
||||
this.telemetryObjectIdAsString = this.openmct.objects.makeKeyString(this.telemetryDomainObjectDefinition.telemetry);
|
||||
this.updateTelemetryObjects(this.telemetryDomainObjectDefinition.telemetryObjects);
|
||||
if (this.isValid() && this.isStalenessCheck() && this.isValidInput()) {
|
||||
this.subscribeForStaleData()
|
||||
this.subscribeForStaleData();
|
||||
}
|
||||
}
|
||||
|
||||
@ -62,7 +62,8 @@ export default class TelemetryCriterion extends EventEmitter {
|
||||
if (this.stalenessSubscription) {
|
||||
this.stalenessSubscription.clear();
|
||||
}
|
||||
this.stalenessSubscription = subscribeForStaleness(this.handleStaleTelemetry.bind(this), this.input[0]*1000);
|
||||
|
||||
this.stalenessSubscription = subscribeForStaleness(this.handleStaleTelemetry.bind(this), this.input[0] * 1000);
|
||||
}
|
||||
|
||||
handleStaleTelemetry(data) {
|
||||
@ -85,7 +86,7 @@ export default class TelemetryCriterion extends EventEmitter {
|
||||
updateTelemetryObjects(telemetryObjects) {
|
||||
this.telemetryObject = telemetryObjects[this.telemetryObjectIdAsString];
|
||||
if (this.isValid() && this.isStalenessCheck() && this.isValidInput()) {
|
||||
this.subscribeForStaleData()
|
||||
this.subscribeForStaleData();
|
||||
}
|
||||
}
|
||||
|
||||
@ -96,6 +97,7 @@ export default class TelemetryCriterion extends EventEmitter {
|
||||
const normalizedDatum = Object.values(metadata).reduce((datum, metadatum) => {
|
||||
const formatter = this.openmct.telemetry.getValueFormatter(metadatum);
|
||||
datum[metadatum.key] = formatter.parse(telemetryDatum[metadatum.source]);
|
||||
|
||||
return datum;
|
||||
}, {});
|
||||
|
||||
@ -111,9 +113,10 @@ export default class TelemetryCriterion extends EventEmitter {
|
||||
|
||||
if (data) {
|
||||
this.openmct.time.getAllTimeSystems().forEach(timeSystem => {
|
||||
datum[timeSystem.key] = data[timeSystem.key]
|
||||
datum[timeSystem.key] = data[timeSystem.key];
|
||||
});
|
||||
}
|
||||
|
||||
return datum;
|
||||
}
|
||||
|
||||
@ -123,6 +126,7 @@ export default class TelemetryCriterion extends EventEmitter {
|
||||
if (this.stalenessSubscription) {
|
||||
this.stalenessSubscription.update(validatedData);
|
||||
}
|
||||
|
||||
this.result = false;
|
||||
} else {
|
||||
this.result = this.computeResult(validatedData);
|
||||
@ -159,11 +163,12 @@ export default class TelemetryCriterion extends EventEmitter {
|
||||
}
|
||||
|
||||
findOperation(operation) {
|
||||
for (let i=0, ii=OPERATIONS.length; i < ii; i++) {
|
||||
for (let i = 0, ii = OPERATIONS.length; i < ii; i++) {
|
||||
if (operation === OPERATIONS[i].name) {
|
||||
return OPERATIONS[i].operation;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -176,10 +181,12 @@ export default class TelemetryCriterion extends EventEmitter {
|
||||
if (this.isValidInput()) {
|
||||
this.input.forEach(input => params.push(input));
|
||||
}
|
||||
|
||||
if (typeof comparator === 'function') {
|
||||
result = !!comparator(params);
|
||||
result = Boolean(comparator(params));
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -196,19 +203,21 @@ export default class TelemetryCriterion extends EventEmitter {
|
||||
const telemetryMetadata = this.openmct.telemetry.getMetadata(telemetryObject);
|
||||
metadataObject = telemetryMetadata.valueMetadatas.find((valueMetadata) => valueMetadata.key === metadata);
|
||||
}
|
||||
|
||||
return metadataObject;
|
||||
}
|
||||
|
||||
getInputValueFromMetaData(metadataObject, input) {
|
||||
let inputValue;
|
||||
if (metadataObject) {
|
||||
if(metadataObject.enumerations && input.length) {
|
||||
if (metadataObject.enumerations && input.length) {
|
||||
const enumeration = metadataObject.enumerations[input[0]];
|
||||
if (enumeration !== undefined && enumeration.string) {
|
||||
inputValue = [enumeration.string];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return inputValue;
|
||||
}
|
||||
|
||||
@ -219,6 +228,7 @@ export default class TelemetryCriterion extends EventEmitter {
|
||||
metadataValue = metadataObject.name;
|
||||
}
|
||||
}
|
||||
|
||||
return metadataValue;
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,10 @@ describe("The telemetry criterion", function () {
|
||||
|
||||
beforeEach (() => {
|
||||
testTelemetryObject = {
|
||||
identifier:{ namespace: "", key: "test-object"},
|
||||
identifier: {
|
||||
namespace: "",
|
||||
key: "test-object"
|
||||
},
|
||||
type: "test-object",
|
||||
name: "Test Object",
|
||||
telemetry: {
|
||||
@ -76,7 +79,10 @@ describe("The telemetry criterion", function () {
|
||||
['timeSystem', 'bounds', 'getAllTimeSystems']
|
||||
);
|
||||
openmct.time.timeSystem.and.returnValue({key: 'system'});
|
||||
openmct.time.bounds.and.returnValue({start: 0, end: 1});
|
||||
openmct.time.bounds.and.returnValue({
|
||||
start: 0,
|
||||
end: 1
|
||||
});
|
||||
openmct.time.getAllTimeSystems.and.returnValue([{key: 'system'}]);
|
||||
|
||||
testCriterionDefinition = {
|
||||
@ -122,6 +128,7 @@ describe("The telemetry criterion", function () {
|
||||
setTimeout(() => {
|
||||
telemetryRequestResolve(mockTelemetry);
|
||||
}, 100);
|
||||
|
||||
return telemetryRequestPromise;
|
||||
});
|
||||
});
|
||||
|
@ -64,5 +64,5 @@ export default function ConditionPlugin() {
|
||||
openmct.telemetry.addProvider(new ConditionSetTelemetryProvider(openmct));
|
||||
openmct.objectViews.addProvider(new ConditionSetViewProvider(openmct));
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -42,7 +42,10 @@ describe('the plugin', function () {
|
||||
|
||||
beforeEach((done) => {
|
||||
testTelemetryObject = {
|
||||
identifier:{ namespace: "", key: "test-object"},
|
||||
identifier: {
|
||||
namespace: "",
|
||||
key: "test-object"
|
||||
},
|
||||
type: "test-object",
|
||||
name: "Test Object",
|
||||
telemetry: {
|
||||
@ -121,7 +124,7 @@ describe('the plugin', function () {
|
||||
|
||||
it('provides a view', () => {
|
||||
const testViewObject = {
|
||||
id:"test-object",
|
||||
id: "test-object",
|
||||
type: "conditionSet",
|
||||
configuration: {
|
||||
conditionCollection: []
|
||||
@ -143,142 +146,142 @@ describe('the plugin', function () {
|
||||
let component;
|
||||
let styleViewComponentObject;
|
||||
const conditionSetDomainObject = {
|
||||
"configuration":{
|
||||
"conditionTestData":[
|
||||
"configuration": {
|
||||
"conditionTestData": [
|
||||
{
|
||||
"telemetry":"",
|
||||
"metadata":"",
|
||||
"input":""
|
||||
"telemetry": "",
|
||||
"metadata": "",
|
||||
"input": ""
|
||||
}
|
||||
],
|
||||
"conditionCollection":[
|
||||
"conditionCollection": [
|
||||
{
|
||||
"id":"39584410-cbf9-499e-96dc-76f27e69885d",
|
||||
"configuration":{
|
||||
"name":"Unnamed Condition",
|
||||
"output":"Sine > 0",
|
||||
"trigger":"all",
|
||||
"criteria":[
|
||||
"id": "39584410-cbf9-499e-96dc-76f27e69885d",
|
||||
"configuration": {
|
||||
"name": "Unnamed Condition",
|
||||
"output": "Sine > 0",
|
||||
"trigger": "all",
|
||||
"criteria": [
|
||||
{
|
||||
"id":"85fbb2f7-7595-42bd-9767-a932266c5225",
|
||||
"telemetry":{
|
||||
"namespace":"",
|
||||
"key":"be0ba97f-b510-4f40-a18d-4ff121d5ea1a"
|
||||
"id": "85fbb2f7-7595-42bd-9767-a932266c5225",
|
||||
"telemetry": {
|
||||
"namespace": "",
|
||||
"key": "be0ba97f-b510-4f40-a18d-4ff121d5ea1a"
|
||||
},
|
||||
"operation":"greaterThan",
|
||||
"input":[
|
||||
"operation": "greaterThan",
|
||||
"input": [
|
||||
"0"
|
||||
],
|
||||
"metadata":"sin"
|
||||
"metadata": "sin"
|
||||
},
|
||||
{
|
||||
"id":"35400132-63b0-425c-ac30-8197df7d5862",
|
||||
"telemetry":"any",
|
||||
"operation":"enumValueIs",
|
||||
"input":[
|
||||
"id": "35400132-63b0-425c-ac30-8197df7d5862",
|
||||
"telemetry": "any",
|
||||
"operation": "enumValueIs",
|
||||
"input": [
|
||||
"0"
|
||||
],
|
||||
"metadata":"state"
|
||||
"metadata": "state"
|
||||
}
|
||||
]
|
||||
},
|
||||
"summary":"Match if all criteria are met: Sine Wave Generator Sine > 0 and any telemetry State is OFF "
|
||||
"summary": "Match if all criteria are met: Sine Wave Generator Sine > 0 and any telemetry State is OFF "
|
||||
},
|
||||
{
|
||||
"isDefault":true,
|
||||
"id":"2532d90a-e0d6-4935-b546-3123522da2de",
|
||||
"configuration":{
|
||||
"name":"Default",
|
||||
"output":"Default",
|
||||
"trigger":"all",
|
||||
"criteria":[
|
||||
"isDefault": true,
|
||||
"id": "2532d90a-e0d6-4935-b546-3123522da2de",
|
||||
"configuration": {
|
||||
"name": "Default",
|
||||
"output": "Default",
|
||||
"trigger": "all",
|
||||
"criteria": [
|
||||
]
|
||||
},
|
||||
"summary":""
|
||||
"summary": ""
|
||||
}
|
||||
]
|
||||
},
|
||||
"composition":[
|
||||
"composition": [
|
||||
{
|
||||
"namespace":"",
|
||||
"key":"be0ba97f-b510-4f40-a18d-4ff121d5ea1a"
|
||||
"namespace": "",
|
||||
"key": "be0ba97f-b510-4f40-a18d-4ff121d5ea1a"
|
||||
},
|
||||
{
|
||||
"namespace":"",
|
||||
"key":"077ffa67-e78f-4e99-80e0-522ac33a3888"
|
||||
"namespace": "",
|
||||
"key": "077ffa67-e78f-4e99-80e0-522ac33a3888"
|
||||
}
|
||||
],
|
||||
"telemetry":{
|
||||
"telemetry": {
|
||||
},
|
||||
"name":"Condition Set",
|
||||
"type":"conditionSet",
|
||||
"identifier":{
|
||||
"namespace":"",
|
||||
"key":"863012c1-f6ca-4ab0-aed7-fd43d5e4cd12"
|
||||
"name": "Condition Set",
|
||||
"type": "conditionSet",
|
||||
"identifier": {
|
||||
"namespace": "",
|
||||
"key": "863012c1-f6ca-4ab0-aed7-fd43d5e4cd12"
|
||||
}
|
||||
|
||||
};
|
||||
const staticStyle = {
|
||||
"style":{
|
||||
"backgroundColor":"#717171",
|
||||
"border":"1px solid #00ffff"
|
||||
"style": {
|
||||
"backgroundColor": "#717171",
|
||||
"border": "1px solid #00ffff"
|
||||
}
|
||||
};
|
||||
const conditionalStyle = {
|
||||
"conditionId":"39584410-cbf9-499e-96dc-76f27e69885d",
|
||||
"style":{
|
||||
"isStyleInvisible":"",
|
||||
"backgroundColor":"#717171",
|
||||
"border":"1px solid #ffff00"
|
||||
"conditionId": "39584410-cbf9-499e-96dc-76f27e69885d",
|
||||
"style": {
|
||||
"isStyleInvisible": "",
|
||||
"backgroundColor": "#717171",
|
||||
"border": "1px solid #ffff00"
|
||||
}
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
displayLayoutItem = {
|
||||
"composition":[
|
||||
"composition": [
|
||||
],
|
||||
"configuration":{
|
||||
"items":[
|
||||
"configuration": {
|
||||
"items": [
|
||||
{
|
||||
"fill":"#717171",
|
||||
"stroke":"",
|
||||
"x":1,
|
||||
"y":1,
|
||||
"width":10,
|
||||
"height":5,
|
||||
"type":"box-view",
|
||||
"id":"89b88746-d325-487b-aec4-11b79afff9e8"
|
||||
"fill": "#717171",
|
||||
"stroke": "",
|
||||
"x": 1,
|
||||
"y": 1,
|
||||
"width": 10,
|
||||
"height": 5,
|
||||
"type": "box-view",
|
||||
"id": "89b88746-d325-487b-aec4-11b79afff9e8"
|
||||
},
|
||||
{
|
||||
"x":18,
|
||||
"y":9,
|
||||
"x2":23,
|
||||
"y2":4,
|
||||
"stroke":"#717171",
|
||||
"type":"line-view",
|
||||
"id":"57d49a28-7863-43bd-9593-6570758916f0"
|
||||
"x": 18,
|
||||
"y": 9,
|
||||
"x2": 23,
|
||||
"y2": 4,
|
||||
"stroke": "#717171",
|
||||
"type": "line-view",
|
||||
"id": "57d49a28-7863-43bd-9593-6570758916f0"
|
||||
}
|
||||
],
|
||||
"layoutGrid":[
|
||||
"layoutGrid": [
|
||||
10,
|
||||
10
|
||||
]
|
||||
},
|
||||
"name":"Display Layout",
|
||||
"type":"layout",
|
||||
"identifier":{
|
||||
"namespace":"",
|
||||
"key":"c5e636c1-6771-4c9c-b933-8665cab189b3"
|
||||
"name": "Display Layout",
|
||||
"type": "layout",
|
||||
"identifier": {
|
||||
"namespace": "",
|
||||
"key": "c5e636c1-6771-4c9c-b933-8665cab189b3"
|
||||
}
|
||||
};
|
||||
lineLayoutItem = {
|
||||
"x":18,
|
||||
"y":9,
|
||||
"x2":23,
|
||||
"y2":4,
|
||||
"stroke":"#717171",
|
||||
"type":"line-view",
|
||||
"id":"57d49a28-7863-43bd-9593-6570758916f0"
|
||||
"x": 18,
|
||||
"y": 9,
|
||||
"x2": 23,
|
||||
"y2": 4,
|
||||
"stroke": "#717171",
|
||||
"type": "line-view",
|
||||
"id": "57d49a28-7863-43bd-9593-6570758916f0"
|
||||
};
|
||||
boxLayoutItem = {
|
||||
"fill": "#717171",
|
||||
@ -294,13 +297,13 @@ describe('the plugin', function () {
|
||||
[{
|
||||
context: {
|
||||
"layoutItem": lineLayoutItem,
|
||||
"index":1
|
||||
"index": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
context: {
|
||||
"item": displayLayoutItem,
|
||||
"supportsMultiSelect":true
|
||||
"supportsMultiSelect": true
|
||||
}
|
||||
}],
|
||||
[{
|
||||
@ -312,7 +315,7 @@ describe('the plugin', function () {
|
||||
{
|
||||
context: {
|
||||
item: displayLayoutItem,
|
||||
"supportsMultiSelect":true
|
||||
"supportsMultiSelect": true
|
||||
}
|
||||
}]
|
||||
];
|
||||
@ -329,6 +332,7 @@ describe('the plugin', function () {
|
||||
},
|
||||
template: '<styles-view/>'
|
||||
});
|
||||
|
||||
return Vue.nextTick().then(() => {
|
||||
styleViewComponentObject = component.$root.$children[0];
|
||||
styleViewComponentObject.setEditState(true);
|
||||
@ -352,6 +356,7 @@ describe('the plugin', function () {
|
||||
styleViewComponentObject.initializeConditionalStyles();
|
||||
expect(styleViewComponentObject.conditionalStyles.length).toBe(2);
|
||||
styleViewComponentObject.updateConditionalStyle(conditionalStyle, 'border');
|
||||
|
||||
return Vue.nextTick().then(() => {
|
||||
expect(styleViewComponentObject.domainObject.configuration.objectStyles).toBeDefined();
|
||||
[boxLayoutItem, lineLayoutItem].forEach((item) => {
|
||||
@ -373,6 +378,7 @@ describe('the plugin', function () {
|
||||
|
||||
it('updates applicable static styles', () => {
|
||||
styleViewComponentObject.updateStaticStyle(staticStyle, 'border');
|
||||
|
||||
return Vue.nextTick().then(() => {
|
||||
expect(styleViewComponentObject.domainObject.configuration.objectStyles).toBeDefined();
|
||||
[boxLayoutItem, lineLayoutItem].forEach((item) => {
|
||||
@ -393,64 +399,64 @@ describe('the plugin', function () {
|
||||
describe('the condition check for staleness', () => {
|
||||
let conditionSetDomainObject;
|
||||
|
||||
beforeEach(()=>{
|
||||
beforeEach(() => {
|
||||
conditionSetDomainObject = {
|
||||
"configuration":{
|
||||
"conditionTestData":[
|
||||
"configuration": {
|
||||
"conditionTestData": [
|
||||
{
|
||||
"telemetry":"",
|
||||
"metadata":"",
|
||||
"input":""
|
||||
"telemetry": "",
|
||||
"metadata": "",
|
||||
"input": ""
|
||||
}
|
||||
],
|
||||
"conditionCollection":[
|
||||
"conditionCollection": [
|
||||
{
|
||||
"id":"39584410-cbf9-499e-96dc-76f27e69885d",
|
||||
"configuration":{
|
||||
"name":"Unnamed Condition",
|
||||
"output":"Any stale telemetry",
|
||||
"trigger":"all",
|
||||
"criteria":[
|
||||
"id": "39584410-cbf9-499e-96dc-76f27e69885d",
|
||||
"configuration": {
|
||||
"name": "Unnamed Condition",
|
||||
"output": "Any stale telemetry",
|
||||
"trigger": "all",
|
||||
"criteria": [
|
||||
{
|
||||
"id":"35400132-63b0-425c-ac30-8197df7d5862",
|
||||
"telemetry":"any",
|
||||
"operation":"isStale",
|
||||
"input":[
|
||||
"id": "35400132-63b0-425c-ac30-8197df7d5862",
|
||||
"telemetry": "any",
|
||||
"operation": "isStale",
|
||||
"input": [
|
||||
"1"
|
||||
],
|
||||
"metadata":"dataReceived"
|
||||
"metadata": "dataReceived"
|
||||
}
|
||||
]
|
||||
},
|
||||
"summary":"Match if all criteria are met: Any telemetry is stale after 5 seconds"
|
||||
"summary": "Match if all criteria are met: Any telemetry is stale after 5 seconds"
|
||||
},
|
||||
{
|
||||
"isDefault":true,
|
||||
"id":"2532d90a-e0d6-4935-b546-3123522da2de",
|
||||
"configuration":{
|
||||
"name":"Default",
|
||||
"output":"Default",
|
||||
"trigger":"all",
|
||||
"criteria":[
|
||||
"isDefault": true,
|
||||
"id": "2532d90a-e0d6-4935-b546-3123522da2de",
|
||||
"configuration": {
|
||||
"name": "Default",
|
||||
"output": "Default",
|
||||
"trigger": "all",
|
||||
"criteria": [
|
||||
]
|
||||
},
|
||||
"summary":""
|
||||
"summary": ""
|
||||
}
|
||||
]
|
||||
},
|
||||
"composition":[
|
||||
"composition": [
|
||||
{
|
||||
"namespace":"",
|
||||
"key":"test-object"
|
||||
"namespace": "",
|
||||
"key": "test-object"
|
||||
}
|
||||
],
|
||||
"telemetry":{
|
||||
"telemetry": {
|
||||
},
|
||||
"name":"Condition Set",
|
||||
"type":"conditionSet",
|
||||
"identifier":{
|
||||
"namespace":"",
|
||||
"key":"cf4456a9-296a-4e6b-b182-62ed29cd15b9"
|
||||
"name": "Condition Set",
|
||||
"type": "conditionSet",
|
||||
"identifier": {
|
||||
"namespace": "",
|
||||
"key": "cf4456a9-296a-4e6b-b182-62ed29cd15b9"
|
||||
}
|
||||
|
||||
};
|
||||
@ -467,7 +473,10 @@ describe('the plugin', function () {
|
||||
setTimeout(() => {
|
||||
expect(mockListener).toHaveBeenCalledWith({
|
||||
output: 'Any stale telemetry',
|
||||
id: { namespace: '', key: 'cf4456a9-296a-4e6b-b182-62ed29cd15b9' },
|
||||
id: {
|
||||
namespace: '',
|
||||
key: 'cf4456a9-296a-4e6b-b182-62ed29cd15b9'
|
||||
},
|
||||
conditionId: '39584410-cbf9-499e-96dc-76f27e69885d',
|
||||
utc: undefined
|
||||
});
|
||||
@ -490,7 +499,10 @@ describe('the plugin', function () {
|
||||
setTimeout(() => {
|
||||
expect(mockListener).toHaveBeenCalledWith({
|
||||
output: 'Default',
|
||||
id: { namespace: '', key: 'cf4456a9-296a-4e6b-b182-62ed29cd15b9' },
|
||||
id: {
|
||||
namespace: '',
|
||||
key: 'cf4456a9-296a-4e6b-b182-62ed29cd15b9'
|
||||
},
|
||||
conditionId: '2532d90a-e0d6-4935-b546-3123522da2de',
|
||||
utc: undefined
|
||||
});
|
||||
|
@ -31,7 +31,7 @@ export const evaluateResults = (results, trigger) => {
|
||||
} else {
|
||||
return matchAny(results);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function matchAll(results) {
|
||||
for (const result of results) {
|
||||
@ -59,6 +59,7 @@ function matchExact(results, target) {
|
||||
if (result === true) {
|
||||
matches++;
|
||||
}
|
||||
|
||||
if (matches > target) {
|
||||
return false;
|
||||
}
|
||||
|
@ -130,7 +130,7 @@ describe('evaluate results', () => {
|
||||
it('should evaluate to expected result', () => {
|
||||
tests.forEach(test => {
|
||||
const result = evaluateResults(test.values, TRIGGER.ANY);
|
||||
expect(result).toEqual(test[TRIGGER.ANY])
|
||||
expect(result).toEqual(test[TRIGGER.ANY]);
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -139,7 +139,7 @@ describe('evaluate results', () => {
|
||||
it('should evaluate to expected result', () => {
|
||||
tests.forEach(test => {
|
||||
const result = evaluateResults(test.values, TRIGGER.ALL);
|
||||
expect(result).toEqual(test[TRIGGER.ALL])
|
||||
expect(result).toEqual(test[TRIGGER.ALL]);
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -148,7 +148,7 @@ describe('evaluate results', () => {
|
||||
it('should evaluate to expected result', () => {
|
||||
tests.forEach(test => {
|
||||
const result = evaluateResults(test.values, TRIGGER.NOT);
|
||||
expect(result).toEqual(test[TRIGGER.NOT])
|
||||
expect(result).toEqual(test[TRIGGER.NOT]);
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -157,7 +157,7 @@ describe('evaluate results', () => {
|
||||
it('should evaluate to expected result', () => {
|
||||
tests.forEach(test => {
|
||||
const result = evaluateResults(test.values, TRIGGER.XOR);
|
||||
expect(result).toEqual(test[TRIGGER.XOR])
|
||||
expect(result).toEqual(test[TRIGGER.XOR]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -23,12 +23,14 @@
|
||||
const convertToNumbers = (input) => {
|
||||
let numberInputs = [];
|
||||
input.forEach(inputValue => numberInputs.push(Number(inputValue)));
|
||||
|
||||
return numberInputs;
|
||||
};
|
||||
|
||||
const convertToStrings = (input) => {
|
||||
let stringInputs = [];
|
||||
input.forEach(inputValue => stringInputs.push(inputValue !== undefined ? inputValue.toString() : ''));
|
||||
|
||||
return stringInputs;
|
||||
};
|
||||
|
||||
@ -113,8 +115,9 @@ export const OPERATIONS = [
|
||||
name: 'between',
|
||||
operation: function (input) {
|
||||
let numberInputs = convertToNumbers(input);
|
||||
let larger = Math.max(...numberInputs.slice(1,3));
|
||||
let smaller = Math.min(...numberInputs.slice(1,3));
|
||||
let larger = Math.max(...numberInputs.slice(1, 3));
|
||||
let smaller = Math.min(...numberInputs.slice(1, 3));
|
||||
|
||||
return (numberInputs[0] > smaller) && (numberInputs[0] < larger);
|
||||
},
|
||||
text: 'is between',
|
||||
@ -128,8 +131,9 @@ export const OPERATIONS = [
|
||||
name: 'notBetween',
|
||||
operation: function (input) {
|
||||
let numberInputs = convertToNumbers(input);
|
||||
let larger = Math.max(...numberInputs.slice(1,3));
|
||||
let smaller = Math.min(...numberInputs.slice(1,3));
|
||||
let larger = Math.max(...numberInputs.slice(1, 3));
|
||||
let smaller = Math.min(...numberInputs.slice(1, 3));
|
||||
|
||||
return (numberInputs[0] < smaller) || (numberInputs[0] > larger);
|
||||
},
|
||||
text: 'is not between',
|
||||
@ -227,6 +231,7 @@ export const OPERATIONS = [
|
||||
name: 'enumValueIs',
|
||||
operation: function (input) {
|
||||
let stringInputs = convertToStrings(input);
|
||||
|
||||
return stringInputs[0] === stringInputs[1];
|
||||
},
|
||||
text: 'is',
|
||||
@ -240,6 +245,7 @@ export const OPERATIONS = [
|
||||
name: 'enumValueIsNot',
|
||||
operation: function (input) {
|
||||
let stringInputs = convertToStrings(input);
|
||||
|
||||
return stringInputs[0] !== stringInputs[1];
|
||||
},
|
||||
text: 'is not',
|
||||
@ -255,8 +261,10 @@ export const OPERATIONS = [
|
||||
const lhsValue = input[0] !== undefined ? input[0].toString() : '';
|
||||
if (input[1]) {
|
||||
const values = input[1].split(',');
|
||||
|
||||
return values.some((value) => lhsValue === value.toString().trim());
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
text: 'is one of',
|
||||
@ -273,8 +281,10 @@ export const OPERATIONS = [
|
||||
if (input[1]) {
|
||||
const values = input[1].split(',');
|
||||
const found = values.some((value) => lhsValue === value.toString().trim());
|
||||
|
||||
return !found;
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
text: 'is not one of',
|
||||
@ -305,5 +315,6 @@ export const INPUT_TYPES = {
|
||||
|
||||
export const getOperatorText = (operationName, values) => {
|
||||
const found = OPERATIONS.find((operation) => operation.name === operationName);
|
||||
|
||||
return found ? found.getDescription(values) : '';
|
||||
};
|
||||
|
@ -32,111 +32,111 @@ describe('operations', function () {
|
||||
|
||||
it('should evaluate isOneOf to true for number inputs', () => {
|
||||
const inputs = [45, "5,6,45,8"];
|
||||
expect(!!isOneOfOperation.operation(inputs)).toBeTrue();
|
||||
expect(Boolean(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();
|
||||
expect(Boolean(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();
|
||||
expect(Boolean(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();
|
||||
expect(Boolean(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();
|
||||
expect(Boolean(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();
|
||||
expect(Boolean(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();
|
||||
expect(Boolean(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();
|
||||
expect(Boolean(isNotOneOfOperation.operation(inputs))).toBeFalse();
|
||||
});
|
||||
|
||||
it('should evaluate isBetween to true', () => {
|
||||
const inputs = ["4", "3", "89"];
|
||||
expect(!!isBetween.operation(inputs)).toBeTrue();
|
||||
expect(Boolean(isBetween.operation(inputs))).toBeTrue();
|
||||
});
|
||||
|
||||
it('should evaluate isNotBetween to true', () => {
|
||||
const inputs = ["45", "100", "89"];
|
||||
expect(!!isNotBetween.operation(inputs)).toBeTrue();
|
||||
expect(Boolean(isNotBetween.operation(inputs))).toBeTrue();
|
||||
});
|
||||
|
||||
it('should evaluate isBetween to false', () => {
|
||||
const inputs = ["4", "100", "89"];
|
||||
expect(!!isBetween.operation(inputs)).toBeFalse();
|
||||
expect(Boolean(isBetween.operation(inputs))).toBeFalse();
|
||||
});
|
||||
|
||||
it('should evaluate isNotBetween to false', () => {
|
||||
const inputs = ["45", "30", "50"];
|
||||
expect(!!isNotBetween.operation(inputs)).toBeFalse();
|
||||
expect(Boolean(isNotBetween.operation(inputs))).toBeFalse();
|
||||
});
|
||||
|
||||
it('should evaluate enumValueIs to true for number inputs', () => {
|
||||
const inputs = [1, "1"];
|
||||
expect(!!enumIsOperation.operation(inputs)).toBeTrue();
|
||||
expect(Boolean(enumIsOperation.operation(inputs))).toBeTrue();
|
||||
});
|
||||
|
||||
it('should evaluate enumValueIs to true for string inputs', () => {
|
||||
const inputs = ["45", "45"];
|
||||
expect(!!enumIsOperation.operation(inputs)).toBeTrue();
|
||||
expect(Boolean(enumIsOperation.operation(inputs))).toBeTrue();
|
||||
});
|
||||
|
||||
it('should evaluate enumValueIsNot to true for number inputs', () => {
|
||||
const inputs = [45, "46"];
|
||||
expect(!!enumIsNotOperation.operation(inputs)).toBeTrue();
|
||||
expect(Boolean(enumIsNotOperation.operation(inputs))).toBeTrue();
|
||||
});
|
||||
|
||||
it('should evaluate enumValueIsNot to true for string inputs', () => {
|
||||
const inputs = ["45", "46"];
|
||||
expect(!!enumIsNotOperation.operation(inputs)).toBeTrue();
|
||||
expect(Boolean(enumIsNotOperation.operation(inputs))).toBeTrue();
|
||||
});
|
||||
|
||||
it('should evaluate enumValueIs to false for number inputs', () => {
|
||||
const inputs = [1, "2"];
|
||||
expect(!!enumIsOperation.operation(inputs)).toBeFalse();
|
||||
expect(Boolean(enumIsOperation.operation(inputs))).toBeFalse();
|
||||
});
|
||||
|
||||
it('should evaluate enumValueIs to false for string inputs', () => {
|
||||
const inputs = ["45", "46"];
|
||||
expect(!!enumIsOperation.operation(inputs)).toBeFalse();
|
||||
expect(Boolean(enumIsOperation.operation(inputs))).toBeFalse();
|
||||
});
|
||||
|
||||
it('should evaluate enumValueIsNot to false for number inputs', () => {
|
||||
const inputs = [45, "45"];
|
||||
expect(!!enumIsNotOperation.operation(inputs)).toBeFalse();
|
||||
expect(Boolean(enumIsNotOperation.operation(inputs))).toBeFalse();
|
||||
});
|
||||
|
||||
it('should evaluate enumValueIsNot to false for string inputs', () => {
|
||||
const inputs = ["45", "45"];
|
||||
expect(!!enumIsNotOperation.operation(inputs)).toBeFalse();
|
||||
expect(Boolean(enumIsNotOperation.operation(inputs))).toBeFalse();
|
||||
});
|
||||
|
||||
it('should evaluate enumValueIs to false for undefined input', () => {
|
||||
const inputs = [undefined, "45"];
|
||||
expect(!!enumIsOperation.operation(inputs)).toBeFalse();
|
||||
expect(Boolean(enumIsOperation.operation(inputs))).toBeFalse();
|
||||
});
|
||||
|
||||
it('should evaluate enumValueIsNot to true for undefined input', () => {
|
||||
const inputs = [undefined, "45"];
|
||||
expect(!!enumIsNotOperation.operation(inputs)).toBeTrue();
|
||||
expect(Boolean(enumIsNotOperation.operation(inputs))).toBeTrue();
|
||||
});
|
||||
});
|
||||
|
@ -28,31 +28,31 @@ const styleProps = {
|
||||
svgProperty: 'fill',
|
||||
noneValue: NONE_VALUE,
|
||||
applicableForType: type => {
|
||||
return !type ? true : (type === 'text-view' ||
|
||||
type === 'telemetry-view' ||
|
||||
type === 'box-view' ||
|
||||
type === 'subobject-view');
|
||||
return !type ? true : (type === 'text-view'
|
||||
|| type === 'telemetry-view'
|
||||
|| type === 'box-view'
|
||||
|| type === 'subobject-view');
|
||||
}
|
||||
},
|
||||
border: {
|
||||
svgProperty: 'stroke',
|
||||
noneValue: NONE_VALUE,
|
||||
applicableForType: type => {
|
||||
return !type ? true : (type === 'text-view' ||
|
||||
type === 'telemetry-view' ||
|
||||
type === 'box-view' ||
|
||||
type === 'image-view' ||
|
||||
type === 'line-view'||
|
||||
type === 'subobject-view');
|
||||
return !type ? true : (type === 'text-view'
|
||||
|| type === 'telemetry-view'
|
||||
|| type === 'box-view'
|
||||
|| type === 'image-view'
|
||||
|| type === 'line-view'
|
||||
|| type === 'subobject-view');
|
||||
}
|
||||
},
|
||||
color: {
|
||||
svgProperty: 'color',
|
||||
noneValue: NONE_VALUE,
|
||||
applicableForType: type => {
|
||||
return !type ? true : (type === 'text-view' ||
|
||||
type === 'telemetry-view'||
|
||||
type === 'subobject-view');
|
||||
return !type ? true : (type === 'text-view'
|
||||
|| type === 'telemetry-view'
|
||||
|| type === 'subobject-view');
|
||||
}
|
||||
},
|
||||
imageUrl: {
|
||||
@ -71,11 +71,13 @@ const aggregateStyleValues = (accumulator, currentStyle) => {
|
||||
if (!accumulator[property]) {
|
||||
accumulator[property] = [];
|
||||
}
|
||||
|
||||
const found = styleKeys.find(key => key === property);
|
||||
if (found) {
|
||||
accumulator[property].push(currentStyle[found]);
|
||||
}
|
||||
});
|
||||
|
||||
return accumulator;
|
||||
};
|
||||
|
||||
@ -98,6 +100,7 @@ export const getConsolidatedStyleValues = (multipleItemStyles) => {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
styles: styleValues,
|
||||
mixedStyles
|
||||
@ -108,7 +111,7 @@ const getStaticStyleForItem = (domainObject, id) => {
|
||||
let domainObjectStyles = domainObject && domainObject.configuration && domainObject.configuration.objectStyles;
|
||||
if (domainObjectStyles) {
|
||||
if (id) {
|
||||
if(domainObjectStyles[id] && domainObjectStyles[id].staticStyle) {
|
||||
if (domainObjectStyles[id] && domainObjectStyles[id].staticStyle) {
|
||||
return domainObjectStyles[id].staticStyle.style;
|
||||
}
|
||||
} else if (domainObjectStyles.staticStyle) {
|
||||
@ -161,6 +164,7 @@ export const getApplicableStylesForItem = (domainObject, item) => {
|
||||
} else if (item) {
|
||||
defaultValue = item[styleProp.svgProperty];
|
||||
}
|
||||
|
||||
style[property] = defaultValue === undefined ? styleProp.noneValue : defaultValue;
|
||||
}
|
||||
});
|
||||
@ -172,6 +176,7 @@ export const getStylesWithoutNoneValue = (style) => {
|
||||
if (isEmpty(style) || !style) {
|
||||
return;
|
||||
}
|
||||
|
||||
let styleObj = {};
|
||||
const keys = Object.keys(style);
|
||||
keys.forEach(key => {
|
||||
@ -183,5 +188,6 @@ export const getStylesWithoutNoneValue = (style) => {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return styleObj;
|
||||
};
|
||||
|
@ -31,15 +31,15 @@ export const getLatestTimestamp = (
|
||||
const key = currentTimeSystem.key;
|
||||
|
||||
if (!latest || !latest[key]) {
|
||||
latest = updateLatestTimeStamp(compare, timeSystems)
|
||||
latest = updateLatestTimeStamp(compare, timeSystems);
|
||||
}
|
||||
|
||||
if (compare[key] > latest[key]) {
|
||||
latest = updateLatestTimeStamp(compare, timeSystems)
|
||||
latest = updateLatestTimeStamp(compare, timeSystems);
|
||||
}
|
||||
|
||||
return latest;
|
||||
}
|
||||
};
|
||||
|
||||
function updateLatestTimeStamp(timestamp, timeSystems) {
|
||||
let latest = {};
|
||||
@ -56,11 +56,13 @@ export const subscribeForStaleness = (callback, timeout) => {
|
||||
clearTimeout(stalenessTimer);
|
||||
callback();
|
||||
}, timeout);
|
||||
|
||||
return {
|
||||
update: (data) => {
|
||||
if (stalenessTimer) {
|
||||
clearTimeout(stalenessTimer);
|
||||
}
|
||||
|
||||
stalenessTimer = setTimeout(() => {
|
||||
clearTimeout(stalenessTimer);
|
||||
callback(data);
|
||||
@ -71,5 +73,5 @@ export const subscribeForStaleness = (callback, timeout) => {
|
||||
clearTimeout(stalenessTimer);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
@ -45,6 +45,7 @@ describe('time related utils', () => {
|
||||
done();
|
||||
}, 50);
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
subscription.update();
|
||||
updated();
|
||||
|
Reference in New Issue
Block a user