mirror of
https://github.com/nasa/openmct.git
synced 2025-06-06 01:11:41 +00:00
styles
This commit is contained in:
parent
aa8750eb97
commit
4d546fb63f
@ -26,14 +26,25 @@ export default class CompsManager extends EventEmitter {
|
|||||||
return metaDatum.key === specificTimeKey || metaDatum.source === specificTimeKey;
|
return metaDatum.key === specificTimeKey || metaDatum.source === specificTimeKey;
|
||||||
});
|
});
|
||||||
const random4Digit = Math.floor(1000 + Math.random() * 9000);
|
const random4Digit = Math.floor(1000 + Math.random() * 9000);
|
||||||
|
// in the valuesMetadata, find the first numeric data type
|
||||||
|
const rangeItems = metaData.valueMetadatas.filter(
|
||||||
|
(metaDatum) => metaDatum.hints && metaDatum.hints.range
|
||||||
|
);
|
||||||
|
rangeItems.sort((a, b) => a.hints.range - b.hints.range);
|
||||||
|
let valueToUse = rangeItems[0]?.key;
|
||||||
|
if (!valueToUse) {
|
||||||
|
// if no numeric data type, just use the first one
|
||||||
|
valueToUse = metaData.valueMetadatas[0]?.key;
|
||||||
|
}
|
||||||
this.#domainObject.configuration.comps.parameters.push({
|
this.#domainObject.configuration.comps.parameters.push({
|
||||||
keyString,
|
keyString,
|
||||||
name: `${telemetryObject.name}_${random4Digit}`,
|
name: `${telemetryObject.name}_${random4Digit}`,
|
||||||
valueToUse: metaData.valueMetadatas[0].key,
|
valueToUse,
|
||||||
testValue: 0,
|
testValue: 0,
|
||||||
timeMetaData
|
timeMetaData
|
||||||
});
|
});
|
||||||
this.persist(this.#domainObject);
|
this.persist(this.#domainObject);
|
||||||
|
this.emit('parametersUpdated', keyString);
|
||||||
}
|
}
|
||||||
|
|
||||||
getParameters() {
|
getParameters() {
|
||||||
@ -69,7 +80,7 @@ export default class CompsManager extends EventEmitter {
|
|||||||
if (!parameterExists) {
|
if (!parameterExists) {
|
||||||
this.#composition.remove(this.#telemetryObjects[keyString]);
|
this.#composition.remove(this.#telemetryObjects[keyString]);
|
||||||
}
|
}
|
||||||
this.persist();
|
this.persist(this.#domainObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
persist(passedDomainObject) {
|
persist(passedDomainObject) {
|
||||||
@ -171,6 +182,13 @@ export default class CompsManager extends EventEmitter {
|
|||||||
delete this.#telemetryObjects[keyString];
|
delete this.#telemetryObjects[keyString];
|
||||||
this.#telemetryCollections[keyString]?.destroy();
|
this.#telemetryCollections[keyString]?.destroy();
|
||||||
delete this.#telemetryCollections[keyString];
|
delete this.#telemetryCollections[keyString];
|
||||||
|
// remove all parameters that reference this telemetry object
|
||||||
|
this.#domainObject.configuration.comps.parameters =
|
||||||
|
this.#domainObject.configuration.comps.parameters.filter(
|
||||||
|
(parameter) => parameter.keyString !== keyString
|
||||||
|
);
|
||||||
|
this.persist(this.#domainObject);
|
||||||
|
this.emit('parametersUpdated', keyString);
|
||||||
};
|
};
|
||||||
|
|
||||||
requestUnderlyingTelemetry() {
|
requestUnderlyingTelemetry() {
|
||||||
|
@ -44,7 +44,7 @@
|
|||||||
]"
|
]"
|
||||||
>
|
>
|
||||||
<label class="c-toggle-switch">
|
<label class="c-toggle-switch">
|
||||||
<input type="checkbox" :checked="testDataApplied" @change="applyTestData" />
|
<input type="checkbox" :checked="testDataApplied" @change="toggleTestData" />
|
||||||
<span class="c-toggle-switch__slider" aria-label="Apply Test Data"></span>
|
<span class="c-toggle-switch__slider" aria-label="Apply Test Data"></span>
|
||||||
<span class="c-toggle-switch__label">Apply Test Values</span>
|
<span class="c-toggle-switch__label">Apply Test Values</span>
|
||||||
</label>
|
</label>
|
||||||
@ -56,7 +56,11 @@
|
|||||||
>
|
>
|
||||||
<div v-for="parameter in parameters" :key="parameter.name" class="telemery-reference">
|
<div v-for="parameter in parameters" :key="parameter.name" class="telemery-reference">
|
||||||
Reference
|
Reference
|
||||||
<input v-model="parameter.name" @change="persistParameters" />
|
<input
|
||||||
|
v-model="parameter.name"
|
||||||
|
class="telemery-reference-variable-input"
|
||||||
|
@change="persistParameters"
|
||||||
|
/>
|
||||||
<ObjectPath
|
<ObjectPath
|
||||||
:domain-object="compsManager.getTelemetryObjectForParameter(parameter.keyString)"
|
:domain-object="compsManager.getTelemetryObjectForParameter(parameter.keyString)"
|
||||||
/>
|
/>
|
||||||
@ -73,7 +77,11 @@
|
|||||||
{{ parameterValueOption.name }}
|
{{ parameterValueOption.name }}
|
||||||
</option>
|
</option>
|
||||||
</select>
|
</select>
|
||||||
<input v-model="parameter.testValue" @change="persistParameters" />
|
<input
|
||||||
|
v-model="parameter.testValue"
|
||||||
|
class="telemery-reference-variable-input"
|
||||||
|
@change="persistAndApplyTestData"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<template v-if="!domainObject.configuration.comps.parameters"
|
<template v-if="!domainObject.configuration.comps.parameters"
|
||||||
>Drag telemetry into Telemetry References to add variables for an expression</template
|
>Drag telemetry into Telemetry References to add variables for an expression</template
|
||||||
@ -89,7 +97,7 @@
|
|||||||
<div>
|
<div>
|
||||||
<textarea
|
<textarea
|
||||||
v-model="expression"
|
v-model="expression"
|
||||||
class="c-cs__expression__input"
|
class="expression-input"
|
||||||
placeholder="Enter an expression"
|
placeholder="Enter an expression"
|
||||||
@change="persistExpression"
|
@change="persistExpression"
|
||||||
></textarea>
|
></textarea>
|
||||||
@ -100,7 +108,8 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { inject, onBeforeMount, onBeforeUnmount, ref } from 'vue';
|
import { evaluate } from 'mathjs';
|
||||||
|
import { inject, onBeforeMount, onBeforeUnmount, ref, watch } from 'vue';
|
||||||
|
|
||||||
import ObjectPath from '../../../ui/components/ObjectPath.vue';
|
import ObjectPath from '../../../ui/components/ObjectPath.vue';
|
||||||
import CompsManager from '../CompsManager';
|
import CompsManager from '../CompsManager';
|
||||||
@ -120,6 +129,13 @@ defineProps({
|
|||||||
isEditing: { type: Boolean, required: true }
|
isEditing: { type: Boolean, required: true }
|
||||||
});
|
});
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => domainObject.configuration.comps.parameters,
|
||||||
|
(newParameters) => {
|
||||||
|
parameters.value = newParameters;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
onBeforeMount(async () => {
|
onBeforeMount(async () => {
|
||||||
console.debug('🚀 CompsView: onMounted with compsManager', compsManager);
|
console.debug('🚀 CompsView: onMounted with compsManager', compsManager);
|
||||||
outputTelemetryCollection = openmct.telemetry.requestCollection(domainObject);
|
outputTelemetryCollection = openmct.telemetry.requestCollection(domainObject);
|
||||||
@ -128,6 +144,7 @@ onBeforeMount(async () => {
|
|||||||
await compsManager.load();
|
await compsManager.load();
|
||||||
parameters.value = compsManager.getParameters();
|
parameters.value = compsManager.getParameters();
|
||||||
expression.value = compsManager.getExpression();
|
expression.value = compsManager.getExpression();
|
||||||
|
compsManager.on('parametersUpdated', reloadParameters);
|
||||||
outputTelemetryCollection.load();
|
outputTelemetryCollection.load();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -137,19 +154,47 @@ onBeforeUnmount(() => {
|
|||||||
outputTelemetryCollection.destroy();
|
outputTelemetryCollection.destroy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function reloadParameters() {
|
||||||
|
parameters.value = compsManager.getParameters();
|
||||||
|
}
|
||||||
|
|
||||||
function persistParameters() {
|
function persistParameters() {
|
||||||
domainObject.configuration.comps.parameters = parameters.value;
|
domainObject.configuration.comps.parameters = parameters.value;
|
||||||
compsManager.persist(domainObject);
|
compsManager.persist(domainObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function toggleTestData() {
|
||||||
|
testDataApplied.value = !testDataApplied.value;
|
||||||
|
if (testDataApplied.value) {
|
||||||
|
applyTestData();
|
||||||
|
} else {
|
||||||
|
clearData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function persistExpression() {
|
function persistExpression() {
|
||||||
domainObject.configuration.comps.expression = expression.value;
|
domainObject.configuration.comps.expression = expression.value;
|
||||||
compsManager.persist(domainObject);
|
compsManager.persist(domainObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
function applyTestData() {}
|
function persistAndApplyTestData() {
|
||||||
|
persistParameters();
|
||||||
|
applyTestData();
|
||||||
|
}
|
||||||
|
|
||||||
|
function applyTestData() {
|
||||||
|
const scope = parameters.value.reduce((acc, parameter) => {
|
||||||
|
acc[parameter.name] = parameter.testValue;
|
||||||
|
return acc;
|
||||||
|
}, {});
|
||||||
|
const testOutput = evaluate(expression.value, scope);
|
||||||
|
currentCompOutput.value = testOutput;
|
||||||
|
}
|
||||||
|
|
||||||
function telemetryProcessor(data) {
|
function telemetryProcessor(data) {
|
||||||
|
if (testDataApplied.value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
// new data will come in as array, so just take the last element
|
// new data will come in as array, so just take the last element
|
||||||
currentCompOutput.value = data[data.length - 1]?.output;
|
currentCompOutput.value = data[data.length - 1]?.output;
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,19 @@
|
|||||||
.telemery-reference {
|
.telemery-reference {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
|
flex-wrap: wrap;
|
||||||
justify-content: start;
|
justify-content: start;
|
||||||
align-items: left;
|
align-items: left;
|
||||||
padding: 0 10px;
|
padding-bottom: 10px;
|
||||||
|
padding-top: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.expression-input {
|
||||||
|
width: 100%;
|
||||||
|
margin-right: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.telemery-reference-variable-input {
|
||||||
|
background-color: $colorBodyBg;
|
||||||
|
color: white;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user