mirror of
https://github.com/nasa/openmct.git
synced 2025-06-15 21:58:13 +00:00
Create a base view configuration class. (#2225)
This commit is contained in:
committed by
Pete Richards
parent
3e7527d55c
commit
74faf1bd48
@ -20,51 +20,34 @@
|
|||||||
* at runtime from the About dialog for additional information.
|
* at runtime from the About dialog for additional information.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
define([],
|
define(
|
||||||
function () {
|
['./ViewConfiguration'],
|
||||||
class SubobjectViewConfiguration {
|
function (ViewConfiguration) {
|
||||||
|
class SubobjectViewConfiguration extends ViewConfiguration {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param domainObject the domain object to mutate.
|
* @param {Object} configuration the subobject view configuration
|
||||||
* @param id
|
* @param {String} configuration.id the domain object keystring identifier
|
||||||
* @param rawPosition
|
* @param {Boolean} configuration.hasFrame flag to show/hide the frame
|
||||||
* @param openmct
|
* @param {Object} configuration.domainObject the domain object
|
||||||
|
* @param {Object} configuration.rawPosition an object that holds raw position and dimensions
|
||||||
|
* @param {Object} configuration.openmct the openmct object
|
||||||
*/
|
*/
|
||||||
constructor(domainObject, id, hasFrame, rawPosition, openmct) {
|
constructor({id, hasFrame, ...rest}) {
|
||||||
this.domainObject = domainObject;
|
super(rest);
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.hasFrame = hasFrame;
|
this.hasFrame = hasFrame;
|
||||||
this.rawPosition = rawPosition;
|
|
||||||
this.mutatePosition = this.mutatePosition.bind(this);
|
|
||||||
this.observe = openmct.objects.observe.bind(openmct.objects);
|
|
||||||
this.mutate = function (path, value) {
|
|
||||||
openmct.objects.mutate(this.domainObject, path, value);
|
|
||||||
}.bind(this);
|
|
||||||
this.listeners = [];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mutatePosition() {
|
path() {
|
||||||
let path = "configuration.panels[" + this.id + "]";
|
return "configuration.panels[" + this.id + "]";
|
||||||
this.mutate(path + ".dimensions", this.rawPosition.dimensions);
|
|
||||||
this.mutate(path + ".position", this.rawPosition.position);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
attachListeners() {
|
observeProperties() {
|
||||||
let path = "configuration.panels[" + this.id + "].hasFrame";
|
this.attachListener("hasFrame", newValue => {
|
||||||
this.listeners.push(this.observe(this.domainObject, path, function (newValue) {
|
|
||||||
this.hasFrame = newValue;
|
this.hasFrame = newValue;
|
||||||
}.bind(this)));
|
|
||||||
|
|
||||||
this.listeners.push(this.observe(this.domainObject, '*', function (obj) {
|
|
||||||
this.domainObject = JSON.parse(JSON.stringify(obj));
|
|
||||||
}.bind(this)));
|
|
||||||
}
|
|
||||||
|
|
||||||
removeListeners() {
|
|
||||||
this.listeners.forEach(listener => {
|
|
||||||
listener();
|
|
||||||
});
|
});
|
||||||
this.listeners = [];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,36 +20,28 @@
|
|||||||
* at runtime from the About dialog for additional information.
|
* at runtime from the About dialog for additional information.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
define([],
|
define(
|
||||||
function () {
|
['./ViewConfiguration'],
|
||||||
class TelemetryViewConfiguration {
|
function (ViewConfiguration) {
|
||||||
|
class TelemetryViewConfiguration extends ViewConfiguration {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @param {Object} configuration the telemetry object view configuration
|
||||||
* @param domainObject the domain object to mutate.
|
* @param {Object} configuration.alphanumeric
|
||||||
* @param alphanumeric
|
* @param {Object} configuration.domainObject the telemetry domain object
|
||||||
* @param rawPosition
|
* @param {Object} configuration.rawPosition an object that holds raw position and dimensions
|
||||||
* @param openmct
|
* @param {Object} configuration.openmct the openmct object
|
||||||
*/
|
*/
|
||||||
constructor(domainObject, alphanumeric, rawPosition, openmct) {
|
constructor({alphanumeric, ...rest}) {
|
||||||
this.domainObject = domainObject;
|
super(rest);
|
||||||
this.alphanumeric = alphanumeric;
|
this.alphanumeric = alphanumeric;
|
||||||
this.rawPosition = rawPosition;
|
|
||||||
this.observe = openmct.objects.observe.bind(openmct.objects);
|
|
||||||
this.mutate = function (path, value) {
|
|
||||||
openmct.objects.mutate(this.domainObject, path, value);
|
|
||||||
}.bind(this);
|
|
||||||
this.mutatePosition = this.mutatePosition.bind(this);
|
|
||||||
this.listeners = [];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mutatePosition() {
|
path() {
|
||||||
let path = "configuration.alphanumerics[" + this.alphanumeric.index + "]";
|
return "configuration.alphanumerics[" + this.alphanumeric.index + "]";
|
||||||
this.mutate(path + ".dimensions", this.rawPosition.dimensions);
|
|
||||||
this.mutate(path + ".position", this.rawPosition.position);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
attachListeners() {
|
observeProperties() {
|
||||||
let path = "configuration.alphanumerics[" + this.alphanumeric.index + "]";
|
|
||||||
[
|
[
|
||||||
'displayMode',
|
'displayMode',
|
||||||
'value',
|
'value',
|
||||||
@ -58,24 +50,11 @@ define([],
|
|||||||
'color',
|
'color',
|
||||||
'size'
|
'size'
|
||||||
].forEach(property => {
|
].forEach(property => {
|
||||||
this.listeners.push(
|
this.attachListener(property, newValue => {
|
||||||
this.observe(this.domainObject, path + "." + property, function (newValue) {
|
this.alphanumeric[property] = newValue;
|
||||||
this.alphanumeric[property] = newValue;
|
});
|
||||||
}.bind(this))
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
this.listeners.push(this.observe(this.domainObject, '*', function (obj) {
|
|
||||||
this.domainObject = JSON.parse(JSON.stringify(obj));
|
|
||||||
}.bind(this)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
removeListeners() {
|
|
||||||
this.listeners.forEach(listener => {
|
|
||||||
listener();
|
|
||||||
});
|
|
||||||
this.listeners = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return TelemetryViewConfiguration;
|
return TelemetryViewConfiguration;
|
||||||
|
72
src/plugins/displayLayout/ViewConfiguration.js
Normal file
72
src/plugins/displayLayout/ViewConfiguration.js
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* Open MCT, Copyright (c) 2014-2018, 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.
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
define([],
|
||||||
|
function () {
|
||||||
|
class ViewConfiguration {
|
||||||
|
|
||||||
|
constructor({domainObject, openmct, rawPosition}) {
|
||||||
|
this.domainObject = domainObject;
|
||||||
|
this.rawPosition = rawPosition;
|
||||||
|
this.mutatePosition = this.mutatePosition.bind(this);
|
||||||
|
this.listeners = [];
|
||||||
|
this.observe = openmct.objects.observe.bind(openmct.objects);
|
||||||
|
this.mutate = function (path, value) {
|
||||||
|
openmct.objects.mutate(this.domainObject, path, value);
|
||||||
|
}.bind(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
mutatePosition() {
|
||||||
|
this.mutate(this.path() + ".dimensions", this.rawPosition.dimensions);
|
||||||
|
this.mutate(this.path() + ".position", this.rawPosition.position);
|
||||||
|
}
|
||||||
|
|
||||||
|
attachListener(property, callback) {
|
||||||
|
this.listeners.push(this.observe(this.domainObject, this.path() + "." + property, callback));
|
||||||
|
}
|
||||||
|
|
||||||
|
attachListeners() {
|
||||||
|
this.observeProperties();
|
||||||
|
this.listeners.push(this.observe(this.domainObject, '*', function (obj) {
|
||||||
|
this.domainObject = JSON.parse(JSON.stringify(obj));
|
||||||
|
}.bind(this)));
|
||||||
|
}
|
||||||
|
|
||||||
|
removeListeners() {
|
||||||
|
this.listeners.forEach(listener => {
|
||||||
|
listener();
|
||||||
|
});
|
||||||
|
this.listeners = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
path() {
|
||||||
|
throw "NOT IMPLEMENTED;"
|
||||||
|
}
|
||||||
|
|
||||||
|
observeProperties() {
|
||||||
|
// Not implemented
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ViewConfiguration;
|
||||||
|
}
|
||||||
|
);
|
@ -126,8 +126,13 @@
|
|||||||
};
|
};
|
||||||
let style = this.convertPosition(rawPosition);
|
let style = this.convertPosition(rawPosition);
|
||||||
let id = this.openmct.objects.makeKeyString(panel.domainObject.identifier);
|
let id = this.openmct.objects.makeKeyString(panel.domainObject.identifier);
|
||||||
let config = new SubobjectViewConfiguration(
|
let config = new SubobjectViewConfiguration({
|
||||||
this.newDomainObject, id, panel.hasFrame, rawPosition, openmct);
|
domainObject: this.newDomainObject,
|
||||||
|
id: id,
|
||||||
|
hasFrame: panel.hasFrame,
|
||||||
|
rawPosition: rawPosition,
|
||||||
|
openmct: openmct
|
||||||
|
});
|
||||||
|
|
||||||
this.layoutItems.push({
|
this.layoutItems.push({
|
||||||
id: id,
|
id: id,
|
||||||
@ -148,8 +153,12 @@
|
|||||||
let id = this.openmct.objects.makeKeyString(alphanumeric.identifier);
|
let id = this.openmct.objects.makeKeyString(alphanumeric.identifier);
|
||||||
|
|
||||||
this.openmct.objects.get(id).then(domainObject => {
|
this.openmct.objects.get(id).then(domainObject => {
|
||||||
let config = new TelemetryViewConfiguration(
|
let config = new TelemetryViewConfiguration({
|
||||||
this.newDomainObject, alphanumeric, rawPosition, openmct);
|
domainObject: this.newDomainObject,
|
||||||
|
alphanumeric: alphanumeric,
|
||||||
|
rawPosition: rawPosition,
|
||||||
|
openmct: openmct
|
||||||
|
});
|
||||||
|
|
||||||
this.layoutItems.push({
|
this.layoutItems.push({
|
||||||
id: id,
|
id: id,
|
||||||
|
Reference in New Issue
Block a user