mirror of
https://github.com/nasa/openmct.git
synced 2025-05-03 01:02:52 +00:00
* Support displaying and adding telemerty points in display layouts. * Create TelemetryView component. Also disable the toolbar frame button for telemetry objects. * Add 'components' directory and move the toolbar provider definition to a separate file. * Saving work * Saving work * Saving work * Fix telemetryClass * Fixes for .no-frame in new markup structure - CSS cleaned up and reorganized; - Added .c-telemetry-view classes; * Add computed properties for hiding label and value. * Filter value meta data based on the item config display mode. * Add drop down menus for display mode and value * Add toolbar controls for telemerty points * Set border and fill related styles on telemetry view instead of layout item * Refinements to telemetry view - Stoke and fill styling now work; - Internal element layout now much better when sizing in a Layout frame; - Tweaked color of frame border while editing; * Prevents adding a new (panel) object if it's already in the composition. * Fix for jumping edit area - Removed v-if from Toolbar.vue; - Refined c-toolbar styling; - TODO: don't include toolbar component when not editing, and for components that don't use a toolbar; * Add a separator toolbar control * Check for domainObject being on the toolbar item as not all controls have that property * Hide 'no fill' option from the text palette. Modify the color-picker component to say 'No border' for stroke palette. * Move the listener for hasFrame to the subobject view configuration * Fixes for toolbar-separator - New mixin; - Corrected markup for separator; - New class for .c-toolbar__separator; - Updated DisplayLayoutToolbar.js to include separators in the right spots; * Get type from item. * Include copyright notice. * Use arrow function for consistency and define a TEXT_SIZE constant. * Use composition API to add non-telemetry objects instead of relying on the drop handler. Display a blocking dialog if an existing non-telemetry object is dropped. * Fix text color picker icon * Address reviewer's feedback * Load the composition and update addObject() to render existing panels as well. Also, cache the telemetry value formatter. * Add listener for changes to time bounds. * Code cleanup * Use getFormatMap() to store formats. Reset telemetry value and class before fetching new data. * Fix a typo * Define telemetry class and value as computed properties. * Change context object definition * Look at the telemetry metadata to find a good default for the value key instead of defaulting to 'sin'. Also, make formats reactive. * Use let instead of var.
167 lines
6.3 KiB
Vue
167 lines
6.3 KiB
Vue
<template>
|
|
<div class="c-toolbar">
|
|
<component v-for="item in structure"
|
|
:is="item.control"
|
|
:options="item"
|
|
@click="triggerMethod(item, $event)"
|
|
@change="updateObjectValue"></component>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import toolbarButton from './components/toolbar-button.vue';
|
|
import toolbarColorPicker from './components/toolbar-color-picker.vue';
|
|
import toolbarCheckbox from './components/toolbar-checkbox.vue';
|
|
import toolbarInput from './components/toolbar-input.vue';
|
|
import toolbarMenu from './components/toolbar-menu.vue';
|
|
import toolbarSelectMenu from './components/toolbar-select-menu.vue';
|
|
import toolbarSeparator from './components/toolbar-separator.vue';
|
|
import toolbarToggleButton from './components/toolbar-toggle-button.vue';
|
|
|
|
export default {
|
|
inject: ['openmct', 'lodash'],
|
|
components: {
|
|
toolbarButton,
|
|
toolbarColorPicker,
|
|
toolbarCheckbox,
|
|
toolbarInput,
|
|
toolbarMenu,
|
|
toolbarSelectMenu,
|
|
toolbarSeparator,
|
|
toolbarToggleButton
|
|
},
|
|
data: function () {
|
|
return {
|
|
structure: []
|
|
};
|
|
},
|
|
methods: {
|
|
handleSelection(selection) {
|
|
this.removeListeners();
|
|
this.domainObjectsById = {};
|
|
|
|
if (!selection[0]) {
|
|
this.structure = [];
|
|
return;
|
|
}
|
|
|
|
let structure = this.openmct.toolbars.get(selection) || [];
|
|
this.structure = structure.map(function (item) {
|
|
let toolbarItem = {...item};
|
|
let domainObject = toolbarItem.domainObject;
|
|
toolbarItem.control = "toolbar-" + toolbarItem.control;
|
|
|
|
if (domainObject) {
|
|
toolbarItem.value = _.get(domainObject, item.property);
|
|
this.registerListener(domainObject);
|
|
}
|
|
|
|
return toolbarItem;
|
|
}.bind(this));
|
|
},
|
|
registerListener(domainObject) {
|
|
let id = this.openmct.objects.makeKeyString(domainObject.identifier);
|
|
|
|
if (!this.domainObjectsById[id]) {
|
|
this.domainObjectsById[id] = {
|
|
domainObject: domainObject
|
|
}
|
|
this.observeObject(domainObject, id);
|
|
}
|
|
},
|
|
observeObject(domainObject, id) {
|
|
let unobserveObject = this.openmct.objects.observe(domainObject, '*', function(newObject) {
|
|
this.domainObjectsById[id].newObject = JSON.parse(JSON.stringify(newObject));
|
|
this.scheduleToolbarUpdate();
|
|
}.bind(this));
|
|
this.unObserveObjects.push(unobserveObject);
|
|
},
|
|
scheduleToolbarUpdate() {
|
|
if (this.toolbarUpdateScheduled) {
|
|
return;
|
|
}
|
|
|
|
this.toolbarUpdateScheduled = true;
|
|
setTimeout(this.updateToolbarAfterMutation.bind(this));
|
|
},
|
|
updateToolbarAfterMutation() {
|
|
this.structure = this.structure.map((item) => {
|
|
let toolbarItem = {...item};
|
|
let domainObject = toolbarItem.domainObject;
|
|
|
|
if (domainObject) {
|
|
let id = this.openmct.objects.makeKeyString(domainObject.identifier);
|
|
let newObject = this.domainObjectsById[id].newObject;
|
|
|
|
if (newObject) {
|
|
toolbarItem.domainObject = newObject;
|
|
let newValue = _.get(newObject, item.property);
|
|
|
|
if (toolbarItem.value !== newValue) {
|
|
toolbarItem.value = newValue;
|
|
}
|
|
}
|
|
}
|
|
|
|
return toolbarItem;
|
|
});
|
|
|
|
Object.values(this.domainObjectsById).forEach(function (tracker) {
|
|
if (tracker.newObject) {
|
|
tracker.domainObject = tracker.newObject;
|
|
delete tracker.newObject;
|
|
}
|
|
});
|
|
this.toolbarUpdateScheduled = false;
|
|
},
|
|
removeListeners() {
|
|
if (this.unObserveObjects) {
|
|
this.unObserveObjects.forEach((unObserveObject) => {
|
|
unObserveObject();
|
|
});
|
|
}
|
|
this.unObserveObjects = [];
|
|
},
|
|
updateObjectValue(value, item) {
|
|
let changedItemId = this.openmct.objects.makeKeyString(item.domainObject.identifier);
|
|
this.structure = this.structure.map((s) => {
|
|
let toolbarItem = {...s};
|
|
let domainObject = toolbarItem.domainObject;
|
|
|
|
if (domainObject) {
|
|
let id = this.openmct.objects.makeKeyString(domainObject.identifier);
|
|
|
|
if (changedItemId === id && item.property === s.property) {
|
|
toolbarItem.value = value;
|
|
}
|
|
}
|
|
|
|
return toolbarItem;
|
|
});
|
|
this.openmct.objects.mutate(item.domainObject, item.property, value);
|
|
},
|
|
triggerMethod(item, event) {
|
|
if (item.method) {
|
|
item.method({...event});
|
|
}
|
|
},
|
|
handleEditing(isEditing) {
|
|
this.handleSelection(this.openmct.selection.get());
|
|
}
|
|
},
|
|
mounted() {
|
|
this.openmct.selection.on('change', this.handleSelection);
|
|
this.handleSelection(this.openmct.selection.get());
|
|
|
|
// Toolbars may change when edit mode is enabled/disabled, so listen
|
|
// for edit mode changes and update toolbars if necessary.
|
|
this.openmct.editor.on('isEditing', this.handleEditing);
|
|
},
|
|
detroyed() {
|
|
this.openmct.selection.off('change', this.handleSelection);
|
|
this.openmct.editor.off('isEditing', this.handleEditing);
|
|
this.removeListeners();
|
|
}
|
|
}
|
|
</script>
|