mirror of
https://github.com/nasa/openmct.git
synced 2024-12-30 09:58:52 +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>
|
||||
<section id="conditionCollection"
|
||||
class="c-cs__ui_section"
|
||||
@ -46,7 +68,6 @@
|
||||
:telemetry="telemetryObjs"
|
||||
@update-current-condition="updateCurrentCondition"
|
||||
@remove-condition="removeCondition"
|
||||
@clone-condition="cloneCondition"
|
||||
@condition-result-updated="handleConditionResult"
|
||||
@set-move-index="setMoveIndex"
|
||||
/>
|
||||
@ -54,7 +75,6 @@
|
||||
<div v-else>
|
||||
<Condition :condition-identifier="conditionIdentifier"
|
||||
:current-condition-identifier="currentConditionIdentifier"
|
||||
@condition-result-updated="handleConditionResult"
|
||||
/>
|
||||
</div>
|
||||
</li>
|
||||
@ -86,8 +106,8 @@ export default {
|
||||
conditionCollection: [],
|
||||
conditions: [],
|
||||
currentConditionIdentifier: this.currentConditionIdentifier || {},
|
||||
moveIndex: null,
|
||||
telemetryObjs: this.telemetryObjs
|
||||
moveIndex: Number,
|
||||
isDragging: false
|
||||
};
|
||||
},
|
||||
destroyed() {
|
||||
@ -99,7 +119,6 @@ export default {
|
||||
this.instantiate = this.openmct.$injector.get('instantiate');
|
||||
this.composition = this.openmct.composition.get(this.domainObject);
|
||||
this.composition.on('add', this.addTelemetry);
|
||||
this.composition.on('remove', this.removeTelemetry);
|
||||
this.composition.load();
|
||||
this.conditionCollection = this.domainObject.configuration ? this.domainObject.configuration.conditionCollection : [];
|
||||
if (!this.conditionCollection.length) {
|
||||
@ -111,10 +130,11 @@ export default {
|
||||
methods: {
|
||||
setMoveIndex(index) {
|
||||
this.moveIndex = index;
|
||||
this.isDragging = true;
|
||||
},
|
||||
dropCondition(e) {
|
||||
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 move = function (arr, old_index, new_index) {
|
||||
while (old_index < 0) {
|
||||
@ -142,11 +162,12 @@ export default {
|
||||
this.reorder(reorderPlan);
|
||||
|
||||
e.target.classList.remove("dragging");
|
||||
this.isDragging = false;
|
||||
},
|
||||
dragEnter(e) {
|
||||
if (!this.isDragging) { return }
|
||||
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
|
||||
if (this.moveIndex === targetIndex) { return }
|
||||
e.target.classList.add("dragging");
|
||||
},
|
||||
@ -173,59 +194,34 @@ export default {
|
||||
addTelemetry(telemetryDomainObject) {
|
||||
this.telemetryObjs.push(telemetryDomainObject);
|
||||
},
|
||||
removeTelemetry(telemetryDomainObjectIdentifier) {
|
||||
let index = _.findIndex(this.telemetryObjs, (obj) => {
|
||||
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);
|
||||
addCondition(event, isDefault) {
|
||||
let conditionDO = this.getConditionDomainObject(!!isDefault);
|
||||
//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());
|
||||
if (!isClone) {
|
||||
this.conditionCollection.unshift(conditionDO.identifier);
|
||||
} else {
|
||||
this.conditionCollection.splice(index + 1, 0, conditionDO.identifier);
|
||||
}
|
||||
this.conditionCollection.unshift(conditionDO.identifier);
|
||||
this.persist();
|
||||
},
|
||||
updateCurrentCondition(identifier) {
|
||||
this.currentConditionIdentifier = identifier;
|
||||
},
|
||||
getConditionDomainObject(isDefault, isClone, definition) {
|
||||
const definitionTemplate = {
|
||||
name: isDefault ? 'Default' : 'Unnamed Condition',
|
||||
output: 'false',
|
||||
trigger: 'any',
|
||||
criteria: isDefault ? [] : [{
|
||||
operation: '',
|
||||
input: '',
|
||||
metaDataKey: '',
|
||||
key: ''
|
||||
}]
|
||||
};
|
||||
getConditionDomainObject(isDefault) {
|
||||
let conditionObj = {
|
||||
isDefault: isDefault,
|
||||
identifier: {
|
||||
namespace: this.domainObject.identifier.namespace,
|
||||
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'
|
||||
};
|
||||
let conditionDOKeyString = this.openmct.objects.makeKeyString(conditionObj.identifier);
|
||||
@ -249,22 +245,15 @@ export default {
|
||||
this.updateCurrentConditionId();
|
||||
},
|
||||
reorder(reorderPlan) {
|
||||
let oldConditions = Array.from(this.conditionCollection);
|
||||
let oldConditions = this.conditionCollection.slice();
|
||||
reorderPlan.forEach((reorderEvent) => {
|
||||
this.$set(this.conditionCollection, reorderEvent.newIndex, oldConditions[reorderEvent.oldIndex]);
|
||||
});
|
||||
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() {
|
||||
this.openmct.objects.mutate(this.domainObject, 'configuration.conditionCollection', this.conditionCollection);
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
@ -185,6 +185,7 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
condition: this.condition,
|
||||
currentCriteria: this.currentCriteria,
|
||||
expanded: true,
|
||||
telemetryObject: this.telemetryObject,
|
||||
telemetryMetadata: this.telemetryMetadata,
|
||||
@ -245,10 +246,9 @@ export default {
|
||||
this.$emit('set-move-index', Number(e.target.getAttribute('data-condition-index')));
|
||||
},
|
||||
initialize() {
|
||||
if (!this.condition.definition.criteria.length) {
|
||||
this.setCurrentCriterion(0);
|
||||
}
|
||||
console.log('this.currentCriteria', this.currentCriteria);
|
||||
//if (!this.condition.definition.criteria.length) {
|
||||
this.setCurrentCriterion();
|
||||
//}
|
||||
this.setOutput();
|
||||
this.setOperation();
|
||||
this.updateTelemetry();
|
||||
@ -256,7 +256,8 @@ export default {
|
||||
this.conditionClass.on('conditionResultUpdated', this.handleConditionResult.bind(this));
|
||||
},
|
||||
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() {
|
||||
this.conditionClass.off('conditionResultUpdated', this.handleConditionResult.bind(this));
|
||||
@ -320,12 +321,14 @@ export default {
|
||||
}
|
||||
},
|
||||
updateTelemetry() {
|
||||
// console.log('this.hasTelemetry()', this.hasTelemetry())
|
||||
if (this.hasTelemetry()) {
|
||||
this.openmct.objects.get(this.currentCriteria.key).then((obj) => {
|
||||
this.telemetryObject = obj;
|
||||
this.telemetryMetadata[this.currentCriteria.key.key] = this.openmct.telemetry.getMetadata(this.telemetryObject).values();
|
||||
this.selectedMetaDataKey[this.currentCriteria.key.key] = this.getTelemetryMetadataKey();
|
||||
this.selectedTelemetryKey[this.currentCriteria.key.key] = this.getTelemetryKey();
|
||||
// console.log('selectedTelemetryKey', this.selectedTelemetryKey);
|
||||
});
|
||||
} else {
|
||||
this.telemetryObject = null;
|
||||
@ -355,14 +358,16 @@ export default {
|
||||
return this.telemetry.length && index > -1 ? this.telemetry[index].identifier : '';
|
||||
},
|
||||
hasTelemetry() {
|
||||
// console.log('hasTelemetry() this.currentCriteria', this.currentCriteria)
|
||||
// return this.currentCriteria && this.currentCriteria.key;
|
||||
return this.currentCriteria && this.currentCriteria.key;
|
||||
},
|
||||
updateConditionCriteria() {
|
||||
if (this.currentCriteria) {
|
||||
this.currentCriteria.key = this.selectedTelemetryKey[this.currentCriteria.key];
|
||||
this.currentCriteria.metaDataKey = this.selectedMetaDataKey[this.currentCriteria.key];
|
||||
this.currentCriteria.operation = this.selectedOperationKey[this.currentCriteria.key];
|
||||
this.currentCriteria.input = this.operationValue[this.currentCriteria.key];
|
||||
this.currentCriteria.selectedTelemetryKey = this.selectedTelemetryKey[this.currentCriteria[0].key];
|
||||
this.currentCriteria.metaDataKey = this.selectedMetaDataKey[this.currentCriteria[0].key];
|
||||
this.currentCriteria.operation = this.selectedOperationKey[this.currentCriteria[0].key];
|
||||
this.currentCriteria.input = this.operationValue[this.currentCriteria[0].key];
|
||||
}
|
||||
},
|
||||
persist() {
|
||||
|
Loading…
Reference in New Issue
Block a user