mirror of
https://github.com/nasa/openmct.git
synced 2024-12-21 14:07:50 +00:00
WIP: debugging
This commit is contained in:
parent
9bcab02e35
commit
8baee7a0c9
@ -1,3 +1,25 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* 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.
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<section id="conditionCollection"
|
<section id="conditionCollection"
|
||||||
class="c-cs__ui_section"
|
class="c-cs__ui_section"
|
||||||
@ -46,7 +68,6 @@
|
|||||||
:telemetry="telemetryObjs"
|
:telemetry="telemetryObjs"
|
||||||
@update-current-condition="updateCurrentCondition"
|
@update-current-condition="updateCurrentCondition"
|
||||||
@remove-condition="removeCondition"
|
@remove-condition="removeCondition"
|
||||||
@clone-condition="cloneCondition"
|
|
||||||
@condition-result-updated="handleConditionResult"
|
@condition-result-updated="handleConditionResult"
|
||||||
@set-move-index="setMoveIndex"
|
@set-move-index="setMoveIndex"
|
||||||
/>
|
/>
|
||||||
@ -54,7 +75,6 @@
|
|||||||
<div v-else>
|
<div v-else>
|
||||||
<Condition :condition-identifier="conditionIdentifier"
|
<Condition :condition-identifier="conditionIdentifier"
|
||||||
:current-condition-identifier="currentConditionIdentifier"
|
:current-condition-identifier="currentConditionIdentifier"
|
||||||
@condition-result-updated="handleConditionResult"
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
@ -86,8 +106,8 @@ export default {
|
|||||||
conditionCollection: [],
|
conditionCollection: [],
|
||||||
conditions: [],
|
conditions: [],
|
||||||
currentConditionIdentifier: this.currentConditionIdentifier || {},
|
currentConditionIdentifier: this.currentConditionIdentifier || {},
|
||||||
moveIndex: null,
|
moveIndex: Number,
|
||||||
telemetryObjs: this.telemetryObjs
|
isDragging: false
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
destroyed() {
|
destroyed() {
|
||||||
@ -99,7 +119,6 @@ export default {
|
|||||||
this.instantiate = this.openmct.$injector.get('instantiate');
|
this.instantiate = this.openmct.$injector.get('instantiate');
|
||||||
this.composition = this.openmct.composition.get(this.domainObject);
|
this.composition = this.openmct.composition.get(this.domainObject);
|
||||||
this.composition.on('add', this.addTelemetry);
|
this.composition.on('add', this.addTelemetry);
|
||||||
this.composition.on('remove', this.removeTelemetry);
|
|
||||||
this.composition.load();
|
this.composition.load();
|
||||||
this.conditionCollection = this.domainObject.configuration ? this.domainObject.configuration.conditionCollection : [];
|
this.conditionCollection = this.domainObject.configuration ? this.domainObject.configuration.conditionCollection : [];
|
||||||
if (!this.conditionCollection.length) {
|
if (!this.conditionCollection.length) {
|
||||||
@ -111,10 +130,11 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
setMoveIndex(index) {
|
setMoveIndex(index) {
|
||||||
this.moveIndex = index;
|
this.moveIndex = index;
|
||||||
|
this.isDragging = true;
|
||||||
},
|
},
|
||||||
dropCondition(e) {
|
dropCondition(e) {
|
||||||
let targetIndex = Array.from(document.querySelectorAll('.c-c__drag-ghost')).indexOf(e.target);
|
let targetIndex = Array.from(document.querySelectorAll('.c-c__drag-ghost')).indexOf(e.target);
|
||||||
if (targetIndex > this.moveIndex) { targetIndex-- }
|
if (targetIndex > this.moveIndex) { targetIndex-- } // for 'downward' move
|
||||||
const oldIndexArr = Object.keys(this.conditionCollection);
|
const oldIndexArr = Object.keys(this.conditionCollection);
|
||||||
const move = function (arr, old_index, new_index) {
|
const move = function (arr, old_index, new_index) {
|
||||||
while (old_index < 0) {
|
while (old_index < 0) {
|
||||||
@ -142,11 +162,12 @@ export default {
|
|||||||
this.reorder(reorderPlan);
|
this.reorder(reorderPlan);
|
||||||
|
|
||||||
e.target.classList.remove("dragging");
|
e.target.classList.remove("dragging");
|
||||||
|
this.isDragging = false;
|
||||||
},
|
},
|
||||||
dragEnter(e) {
|
dragEnter(e) {
|
||||||
|
if (!this.isDragging) { return }
|
||||||
let targetIndex = Array.from(document.querySelectorAll('.c-c__drag-ghost')).indexOf(e.target);
|
let targetIndex = Array.from(document.querySelectorAll('.c-c__drag-ghost')).indexOf(e.target);
|
||||||
|
if (targetIndex > this.moveIndex) { targetIndex-- } // for 'downward' move
|
||||||
if (targetIndex > this.moveIndex) { targetIndex-- }
|
|
||||||
if (this.moveIndex === targetIndex) { return }
|
if (this.moveIndex === targetIndex) { return }
|
||||||
e.target.classList.add("dragging");
|
e.target.classList.add("dragging");
|
||||||
},
|
},
|
||||||
@ -173,59 +194,34 @@ export default {
|
|||||||
addTelemetry(telemetryDomainObject) {
|
addTelemetry(telemetryDomainObject) {
|
||||||
this.telemetryObjs.push(telemetryDomainObject);
|
this.telemetryObjs.push(telemetryDomainObject);
|
||||||
},
|
},
|
||||||
removeTelemetry(telemetryDomainObjectIdentifier) {
|
addCondition(event, isDefault) {
|
||||||
let index = _.findIndex(this.telemetryObjs, (obj) => {
|
let conditionDO = this.getConditionDomainObject(!!isDefault);
|
||||||
let objId = this.openmct.objects.makeKeyString(obj.identifier);
|
|
||||||
let id = this.openmct.objects.makeKeyString(telemetryDomainObjectIdentifier);
|
|
||||||
return objId === id;
|
|
||||||
});
|
|
||||||
if (index > -1) {
|
|
||||||
this.telemetryObjs.splice(index, 1);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
/*
|
|
||||||
Adds a condition to list via programatic creation of default for initial list, manual
|
|
||||||
creation via Add Condition button, or duplication via button in title bar of condition.
|
|
||||||
Params:
|
|
||||||
event: always null,
|
|
||||||
isDefault (boolean): true if conditionList is empty
|
|
||||||
isClone (boolean): true if duplicating a condition
|
|
||||||
definition (string): definition property of condition being duplicated with new name
|
|
||||||
index (number): index of condition being duplicated
|
|
||||||
*/
|
|
||||||
addCondition(event, isDefault, isClone, definition, index) {
|
|
||||||
let conditionDO = this.getConditionDomainObject(!!isDefault, isClone, definition);
|
|
||||||
//persist the condition DO so that we can do an openmct.objects.get on it and only persist the identifier in the conditionCollection of conditionSet
|
//persist the condition DO so that we can do an openmct.objects.get on it and only persist the identifier in the conditionCollection of conditionSet
|
||||||
this.openmct.objects.mutate(conditionDO, 'created', new Date());
|
this.openmct.objects.mutate(conditionDO, 'created', new Date());
|
||||||
if (!isClone) {
|
this.conditionCollection.unshift(conditionDO.identifier);
|
||||||
this.conditionCollection.unshift(conditionDO.identifier);
|
|
||||||
} else {
|
|
||||||
this.conditionCollection.splice(index + 1, 0, conditionDO.identifier);
|
|
||||||
}
|
|
||||||
this.persist();
|
this.persist();
|
||||||
},
|
},
|
||||||
updateCurrentCondition(identifier) {
|
updateCurrentCondition(identifier) {
|
||||||
this.currentConditionIdentifier = identifier;
|
this.currentConditionIdentifier = identifier;
|
||||||
},
|
},
|
||||||
getConditionDomainObject(isDefault, isClone, definition) {
|
getConditionDomainObject(isDefault) {
|
||||||
const definitionTemplate = {
|
|
||||||
name: isDefault ? 'Default' : 'Unnamed Condition',
|
|
||||||
output: 'false',
|
|
||||||
trigger: 'any',
|
|
||||||
criteria: isDefault ? [] : [{
|
|
||||||
operation: '',
|
|
||||||
input: '',
|
|
||||||
metaDataKey: '',
|
|
||||||
key: ''
|
|
||||||
}]
|
|
||||||
};
|
|
||||||
let conditionObj = {
|
let conditionObj = {
|
||||||
isDefault: isDefault,
|
isDefault: isDefault,
|
||||||
identifier: {
|
identifier: {
|
||||||
namespace: this.domainObject.identifier.namespace,
|
namespace: this.domainObject.identifier.namespace,
|
||||||
key: uuid()
|
key: uuid()
|
||||||
},
|
},
|
||||||
definition: isClone ? definition: definitionTemplate,
|
definition: {
|
||||||
|
name: isDefault ? 'Default' : 'Unnamed Condition',
|
||||||
|
output: 'false',
|
||||||
|
trigger: 'any',
|
||||||
|
criteria: isDefault ? [] : [{
|
||||||
|
operation: '',
|
||||||
|
input: '',
|
||||||
|
metaDataKey: this.openmct.telemetry.getMetadata(this.telemetryObjs[0]).values()[0].key,
|
||||||
|
key: this.telemetryObjs.length ? this.openmct.objects.makeKeyString(this.telemetryObjs[0].identifier) : null
|
||||||
|
}]
|
||||||
|
},
|
||||||
summary: 'summary description'
|
summary: 'summary description'
|
||||||
};
|
};
|
||||||
let conditionDOKeyString = this.openmct.objects.makeKeyString(conditionObj.identifier);
|
let conditionDOKeyString = this.openmct.objects.makeKeyString(conditionObj.identifier);
|
||||||
@ -249,22 +245,15 @@ export default {
|
|||||||
this.updateCurrentConditionId();
|
this.updateCurrentConditionId();
|
||||||
},
|
},
|
||||||
reorder(reorderPlan) {
|
reorder(reorderPlan) {
|
||||||
let oldConditions = Array.from(this.conditionCollection);
|
let oldConditions = this.conditionCollection.slice();
|
||||||
reorderPlan.forEach((reorderEvent) => {
|
reorderPlan.forEach((reorderEvent) => {
|
||||||
this.$set(this.conditionCollection, reorderEvent.newIndex, oldConditions[reorderEvent.oldIndex]);
|
this.$set(this.conditionCollection, reorderEvent.newIndex, oldConditions[reorderEvent.oldIndex]);
|
||||||
});
|
});
|
||||||
this.persist();
|
this.persist();
|
||||||
},
|
},
|
||||||
cloneCondition(condition) {
|
|
||||||
this.openmct.objects.get(condition.identifier).then((obj) => {
|
|
||||||
obj.definition.name = 'Copy of ' + obj.definition.name;
|
|
||||||
this.addCondition(null, false, true, obj.definition, condition.index);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
persist() {
|
persist() {
|
||||||
this.openmct.objects.mutate(this.domainObject, 'configuration.conditionCollection', this.conditionCollection);
|
this.openmct.objects.mutate(this.domainObject, 'configuration.conditionCollection', this.conditionCollection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -185,6 +185,7 @@ export default {
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
condition: this.condition,
|
condition: this.condition,
|
||||||
|
currentCriteria: this.currentCriteria,
|
||||||
expanded: true,
|
expanded: true,
|
||||||
telemetryObject: this.telemetryObject,
|
telemetryObject: this.telemetryObject,
|
||||||
telemetryMetadata: this.telemetryMetadata,
|
telemetryMetadata: this.telemetryMetadata,
|
||||||
@ -245,10 +246,9 @@ export default {
|
|||||||
this.$emit('set-move-index', Number(e.target.getAttribute('data-condition-index')));
|
this.$emit('set-move-index', Number(e.target.getAttribute('data-condition-index')));
|
||||||
},
|
},
|
||||||
initialize() {
|
initialize() {
|
||||||
if (!this.condition.definition.criteria.length) {
|
//if (!this.condition.definition.criteria.length) {
|
||||||
this.setCurrentCriterion(0);
|
this.setCurrentCriterion();
|
||||||
}
|
//}
|
||||||
console.log('this.currentCriteria', this.currentCriteria);
|
|
||||||
this.setOutput();
|
this.setOutput();
|
||||||
this.setOperation();
|
this.setOperation();
|
||||||
this.updateTelemetry();
|
this.updateTelemetry();
|
||||||
@ -256,7 +256,8 @@ export default {
|
|||||||
this.conditionClass.on('conditionResultUpdated', this.handleConditionResult.bind(this));
|
this.conditionClass.on('conditionResultUpdated', this.handleConditionResult.bind(this));
|
||||||
},
|
},
|
||||||
setCurrentCriterion(index) {
|
setCurrentCriterion(index) {
|
||||||
this.currentCriteria = this.condition.definition.criteria[index];
|
this.currentCriteria = this.condition.definition.criteria;
|
||||||
|
console.log('setCurrentCriterion() this.currentCriteria', this.currentCriteria[0].key);
|
||||||
},
|
},
|
||||||
destroy() {
|
destroy() {
|
||||||
this.conditionClass.off('conditionResultUpdated', this.handleConditionResult.bind(this));
|
this.conditionClass.off('conditionResultUpdated', this.handleConditionResult.bind(this));
|
||||||
@ -320,12 +321,14 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
updateTelemetry() {
|
updateTelemetry() {
|
||||||
|
// console.log('this.hasTelemetry()', this.hasTelemetry())
|
||||||
if (this.hasTelemetry()) {
|
if (this.hasTelemetry()) {
|
||||||
this.openmct.objects.get(this.currentCriteria.key).then((obj) => {
|
this.openmct.objects.get(this.currentCriteria.key).then((obj) => {
|
||||||
this.telemetryObject = obj;
|
this.telemetryObject = obj;
|
||||||
this.telemetryMetadata[this.currentCriteria.key.key] = this.openmct.telemetry.getMetadata(this.telemetryObject).values();
|
this.telemetryMetadata[this.currentCriteria.key.key] = this.openmct.telemetry.getMetadata(this.telemetryObject).values();
|
||||||
this.selectedMetaDataKey[this.currentCriteria.key.key] = this.getTelemetryMetadataKey();
|
this.selectedMetaDataKey[this.currentCriteria.key.key] = this.getTelemetryMetadataKey();
|
||||||
this.selectedTelemetryKey[this.currentCriteria.key.key] = this.getTelemetryKey();
|
this.selectedTelemetryKey[this.currentCriteria.key.key] = this.getTelemetryKey();
|
||||||
|
// console.log('selectedTelemetryKey', this.selectedTelemetryKey);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.telemetryObject = null;
|
this.telemetryObject = null;
|
||||||
@ -355,14 +358,16 @@ export default {
|
|||||||
return this.telemetry.length && index > -1 ? this.telemetry[index].identifier : '';
|
return this.telemetry.length && index > -1 ? this.telemetry[index].identifier : '';
|
||||||
},
|
},
|
||||||
hasTelemetry() {
|
hasTelemetry() {
|
||||||
|
// console.log('hasTelemetry() this.currentCriteria', this.currentCriteria)
|
||||||
|
// return this.currentCriteria && this.currentCriteria.key;
|
||||||
return this.currentCriteria && this.currentCriteria.key;
|
return this.currentCriteria && this.currentCriteria.key;
|
||||||
},
|
},
|
||||||
updateConditionCriteria() {
|
updateConditionCriteria() {
|
||||||
if (this.currentCriteria) {
|
if (this.currentCriteria) {
|
||||||
this.currentCriteria.key = this.selectedTelemetryKey[this.currentCriteria.key];
|
this.currentCriteria.selectedTelemetryKey = this.selectedTelemetryKey[this.currentCriteria[0].key];
|
||||||
this.currentCriteria.metaDataKey = this.selectedMetaDataKey[this.currentCriteria.key];
|
this.currentCriteria.metaDataKey = this.selectedMetaDataKey[this.currentCriteria[0].key];
|
||||||
this.currentCriteria.operation = this.selectedOperationKey[this.currentCriteria.key];
|
this.currentCriteria.operation = this.selectedOperationKey[this.currentCriteria[0].key];
|
||||||
this.currentCriteria.input = this.operationValue[this.currentCriteria.key];
|
this.currentCriteria.input = this.operationValue[this.currentCriteria[0].key];
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
persist() {
|
persist() {
|
||||||
|
Loading…
Reference in New Issue
Block a user