mirror of
https://github.com/nasa/openmct.git
synced 2025-05-10 20:43:00 +00:00
Merge branch 'condition-from-identifier' of https://github.com/nasa/openmct into conditionSet-ui-merge
This commit is contained in:
commit
e88ead30dc
@ -1,8 +1,8 @@
|
|||||||
<template>
|
<template>
|
||||||
<div id="conditionArea"
|
<div v-if="condition"
|
||||||
v-if="condition && condition.definition"
|
id="conditionArea"
|
||||||
class="c-cs-ui__conditions"
|
class="c-cs-ui__conditions"
|
||||||
:class="['widget-condition', { 'widget-condition--current': condition.isCurrent }]"
|
:class="['widget-condition', { 'widget-condition--current': isCurrent && (isCurrent.key === conditionIdentifier.key) }]"
|
||||||
>
|
>
|
||||||
<div class="title-bar">
|
<div class="title-bar">
|
||||||
<span class="condition-name">
|
<span class="condition-name">
|
||||||
@ -27,11 +27,14 @@ export default {
|
|||||||
conditionIdentifier: {
|
conditionIdentifier: {
|
||||||
type: Object,
|
type: Object,
|
||||||
required: true
|
required: true
|
||||||
|
},
|
||||||
|
isCurrent: {
|
||||||
|
type: Object,
|
||||||
|
required: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
conditionData: {},
|
|
||||||
condition: this.condition
|
condition: this.condition
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@ -39,8 +42,6 @@ export default {
|
|||||||
this.openmct.objects.get(this.conditionIdentifier).then((obj => {
|
this.openmct.objects.get(this.conditionIdentifier).then((obj => {
|
||||||
this.condition = obj;
|
this.condition = obj;
|
||||||
}));
|
}));
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -35,11 +35,16 @@
|
|||||||
>
|
>
|
||||||
<div v-if="isEditing">
|
<div v-if="isEditing">
|
||||||
<ConditionEdit :condition-identifier="conditionIdentifier"
|
<ConditionEdit :condition-identifier="conditionIdentifier"
|
||||||
|
:is-current="currentConditionIdentifier"
|
||||||
|
@update-current-condition="updateCurrentCondition"
|
||||||
|
@remove-condition="removeCondition"
|
||||||
@condition-result-updated="handleConditionResult"
|
@condition-result-updated="handleConditionResult"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div v-else>
|
<div v-else>
|
||||||
<Condition :condition-identifier="conditionIdentifier" />
|
<Condition :condition-identifier="conditionIdentifier"
|
||||||
|
:is-current="currentConditionIdentifier"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -66,7 +71,8 @@ export default {
|
|||||||
expanded: true,
|
expanded: true,
|
||||||
parentKeyString: this.openmct.objects.makeKeyString(this.domainObject.identifier),
|
parentKeyString: this.openmct.objects.makeKeyString(this.domainObject.identifier),
|
||||||
conditionCollection: [],
|
conditionCollection: [],
|
||||||
conditions: []
|
conditions: [],
|
||||||
|
currentConditionIdentifier: this.currentConditionIdentifier || {}
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
destroyed() {
|
destroyed() {
|
||||||
@ -79,11 +85,7 @@ export default {
|
|||||||
this.composition.on('add', this.addTelemetry);
|
this.composition.on('add', this.addTelemetry);
|
||||||
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) {this.addCondition(null, true)}
|
||||||
this.addCondition(null, true)
|
|
||||||
} else {
|
|
||||||
console.log(this.conditionCollection.length, this.conditionCollection);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
handleConditionResult(args) {
|
handleConditionResult(args) {
|
||||||
@ -96,10 +98,12 @@ export default {
|
|||||||
let conditionDO = this.getConditionDomainObject(!!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
|
//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());
|
||||||
|
|
||||||
this.conditionCollection.unshift(conditionDO.identifier);
|
this.conditionCollection.unshift(conditionDO.identifier);
|
||||||
this.persist();
|
this.persist();
|
||||||
},
|
},
|
||||||
|
updateCurrentCondition(identifier) {
|
||||||
|
this.currentConditionIdentifier = identifier;
|
||||||
|
},
|
||||||
getConditionDomainObject(isDefault) {
|
getConditionDomainObject(isDefault) {
|
||||||
let conditionObj = {
|
let conditionObj = {
|
||||||
isDefault: isDefault,
|
isDefault: isDefault,
|
||||||
@ -131,8 +135,12 @@ export default {
|
|||||||
this.conditions[index] = updatedCondition;
|
this.conditions[index] = updatedCondition;
|
||||||
},
|
},
|
||||||
removeCondition(identifier) {
|
removeCondition(identifier) {
|
||||||
let index = _.findIndex(this.conditionCollection, (condition) => this.openmct.objects.makeKeyString(identifier) === condition.identifier.key);
|
console.log('this.conditions', this.conditions);
|
||||||
this.conditionCollection.splice(index, 1);
|
let index = _.findIndex(this.conditionCollection, (condition) => {
|
||||||
|
identifier.key === condition.key
|
||||||
|
});
|
||||||
|
this.conditionCollection.splice(index + 1, 1);
|
||||||
|
this.persist();
|
||||||
},
|
},
|
||||||
reorder(reorderPlan) {
|
reorder(reorderPlan) {
|
||||||
let oldConditions = this.conditionCollection.slice();
|
let oldConditions = this.conditionCollection.slice();
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div v-if="condition"
|
<div v-if="condition"
|
||||||
class="c-cs-editui__conditions"
|
class="c-cs-editui__conditions"
|
||||||
:class="['widget-condition', { 'widget-condition--current': condition.isCurrent }]"
|
:class="['widget-condition', { 'widget-condition--current': isCurrent && (isCurrent.key === conditionIdentifier.key) }]"
|
||||||
>
|
>
|
||||||
<div class="title-bar">
|
<div class="title-bar">
|
||||||
<span
|
<span
|
||||||
@ -16,7 +16,7 @@
|
|||||||
></span>
|
></span>
|
||||||
<div class="condition-summary">
|
<div class="condition-summary">
|
||||||
<span class="condition-name">{{ condition.definition.name }}</span>
|
<span class="condition-name">{{ condition.definition.name }}</span>
|
||||||
<span class="condition-description">{{ condition.definition.description }}</span>
|
<span class="condition-description">{{ condition.definition.name }}</span>
|
||||||
</div>
|
</div>
|
||||||
<span v-if="!condition.isDefault"
|
<span v-if="!condition.isDefault"
|
||||||
class="is-enabled c-c__duplicate"
|
class="is-enabled c-c__duplicate"
|
||||||
@ -139,19 +139,23 @@
|
|||||||
<script>
|
<script>
|
||||||
import { OPERATIONS } from '../utils/operations';
|
import { OPERATIONS } from '../utils/operations';
|
||||||
import ConditionClass from "@/plugins/condition/Condition";
|
import ConditionClass from "@/plugins/condition/Condition";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
inject: ['openmct', 'domainObject'],
|
inject: ['openmct', 'domainObject'],
|
||||||
props: {
|
props: {
|
||||||
conditionIdentifier: {
|
conditionIdentifier: {
|
||||||
type: Object,
|
type: Object,
|
||||||
required: true
|
required: true
|
||||||
|
},
|
||||||
|
isCurrent: {
|
||||||
|
type: Object,
|
||||||
|
required: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
condition: this.condition,
|
condition: this.condition,
|
||||||
expanded: true,
|
expanded: true,
|
||||||
conditionCollection: this.conditionCollection,
|
|
||||||
telemetryObject: this.telemetryObject,
|
telemetryObject: this.telemetryObject,
|
||||||
telemetryMetadata: this.telemetryMetadata,
|
telemetryMetadata: this.telemetryMetadata,
|
||||||
operations: OPERATIONS,
|
operations: OPERATIONS,
|
||||||
@ -175,6 +179,7 @@ export default {
|
|||||||
text: 'String'
|
text: 'String'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
destroyed() {
|
destroyed() {
|
||||||
@ -194,6 +199,9 @@ export default {
|
|||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
updated() {
|
updated() {
|
||||||
|
if (this.isCurrent && this.isCurrent.key === this.condition.key) {
|
||||||
|
this.updateCurrentCondition();
|
||||||
|
}
|
||||||
this.persist();
|
this.persist();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@ -205,11 +213,7 @@ export default {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
removeCondition(ev) { //move this to conditionCollection
|
removeCondition(ev) { //move this to conditionCollection
|
||||||
// const conditionDiv = ev.target.closest('.conditionArea');
|
this.$emit('remove-condition', this.conditionIdentifier);
|
||||||
// const conditionCollectionDiv = conditionDiv.closest('.condition-collection');
|
|
||||||
// const index = Array.from(conditionCollectionDiv.children).indexOf(conditionDiv);
|
|
||||||
//
|
|
||||||
// this.domainObject.configuration.conditionCollection.splice(index, 1);
|
|
||||||
},
|
},
|
||||||
setOutput() {
|
setOutput() {
|
||||||
if (this.condition.definition.output !== 'false' && this.condition.definition.output !== 'true') {
|
if (this.condition.definition.output !== 'false' && this.condition.definition.output !== 'true') {
|
||||||
|
@ -4,7 +4,9 @@
|
|||||||
<div class="c-sw-edit__ui holder">
|
<div class="c-sw-edit__ui holder">
|
||||||
<CurrentOutput :condition="currentCondition" />
|
<CurrentOutput :condition="currentCondition" />
|
||||||
<TestData :is-editing="isEditing" />
|
<TestData :is-editing="isEditing" />
|
||||||
<ConditionCollection :is-editing="isEditing"/>
|
<ConditionCollection :is-editing="isEditing"
|
||||||
|
@update-current-condition="updateCurrentcondition"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -15,6 +17,7 @@ import CurrentOutput from './CurrentOutput.vue';
|
|||||||
import TestData from './TestData.vue';
|
import TestData from './TestData.vue';
|
||||||
import ConditionCollection from './ConditionCollection.vue';
|
import ConditionCollection from './ConditionCollection.vue';
|
||||||
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
inject: ["openmct", "domainObject"],
|
inject: ["openmct", "domainObject"],
|
||||||
components: {
|
components: {
|
||||||
@ -27,18 +30,26 @@ export default {
|
|||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
// conditionCollection: this.conditionCollection,
|
|
||||||
currentCondition: this.currentCondition
|
currentCondition: this.currentCondition
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
let conditionCollection = this.domainObject.configuration.conditionCollection;
|
let conditionCollection = this.domainObject.configuration.conditionCollection;
|
||||||
this.currentConditionIdentifier = conditionCollection.length ? conditionCollection[0] : null;
|
this.currentConditionIdentifier = conditionCollection.length ? this.domainObject.configuration.conditionCollection[0] : null;
|
||||||
if (this.currentConditionIdentifier) {
|
if (this.currentConditionIdentifier) {
|
||||||
this.openmct.objects.get(this.currentConditionIdentifier).then((obj) => {
|
this.openmct.objects.get(this.currentConditionIdentifier).then((obj) => {
|
||||||
this.currentCondition = obj;
|
this.currentCondition = obj;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
updateCurrentcondition(identifier) {
|
||||||
|
this.currentConditionIdentifier = identifier;
|
||||||
|
this.openmct.objects.get(this.currentConditionIdentifier).then((obj) => {
|
||||||
|
this.currentCondition = obj;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
@ -36,7 +36,6 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
||||||
|
0
src/plugins/condition/event
Normal file
0
src/plugins/condition/event
Normal file
2
src/plugins/condition/utils/eventbus.js
Normal file
2
src/plugins/condition/utils/eventbus.js
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
import Vue from 'vue';
|
||||||
|
export const EventBus = new Vue();
|
Loading…
x
Reference in New Issue
Block a user