feat: AMD -> ES6 (#7029)

* feat: full amd -> es6 conversion

* fix: move MCT to ES6 class

* fix: default drop, correct imports

* fix: correct all imports

* fix: property typo

* fix: avoid anonymous functions

* fix: correct typo

scarily small - can see why this e2e coverage issue is high priority

* fix: use proper uuid format

* style: fmt

* fix: import vue correctly, get correct layout

* fix: createApp without JSON

fixes template issues

* fix: don't use default on InspectorDataVisualization

* fix: remove more .default calls

* Update src/api/api.js

Co-authored-by: Jesse Mazzella <ozyx@users.noreply.github.com>

* Update src/plugins/plugins.js

Co-authored-by: Jesse Mazzella <ozyx@users.noreply.github.com>

* Update src/plugins/plugins.js

Co-authored-by: Jesse Mazzella <ozyx@users.noreply.github.com>

* fix: suggestions

* fix: drop unnecessary this.annotation initialization

* fix: move all initialization calls to constructor

* refactor: move vue dist import to webpack alias

---------

Co-authored-by: Jesse Mazzella <ozyx@users.noreply.github.com>
This commit is contained in:
Tristan F 2023-12-27 15:15:51 -05:00 committed by GitHub
parent 715a44864e
commit 2e03bc394c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
102 changed files with 11730 additions and 12016 deletions

View File

@ -76,7 +76,8 @@ const config = {
MCT: path.join(projectRootDir, 'src/MCT'),
testUtils: path.join(projectRootDir, 'src/utils/testUtils.js'),
objectUtils: path.join(projectRootDir, 'src/api/objects/object-utils.js'),
utils: path.join(projectRootDir, 'src/utils')
utils: path.join(projectRootDir, 'src/utils'),
vue: 'vue/dist/vue.esm-bundler'
}
},
plugins: [

View File

@ -1,5 +1,4 @@
define(['lodash'], function (_) {
var METADATA_BY_TYPE = {
const METADATA_BY_TYPE = {
generator: {
values: [
{
@ -122,17 +121,14 @@ define(['lodash'], function (_) {
}
]
}
};
};
function GeneratorMetadataProvider() {}
export default function GeneratorMetadataProvider() {}
GeneratorMetadataProvider.prototype.supportsMetadata = function (domainObject) {
GeneratorMetadataProvider.prototype.supportsMetadata = function (domainObject) {
return Object.prototype.hasOwnProperty.call(METADATA_BY_TYPE, domainObject.type);
};
};
GeneratorMetadataProvider.prototype.getMetadata = function (domainObject) {
GeneratorMetadataProvider.prototype.getMetadata = function (domainObject) {
return Object.assign({}, domainObject.telemetry, METADATA_BY_TYPE[domainObject.type]);
};
return GeneratorMetadataProvider;
});
};

View File

@ -20,8 +20,9 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
define(['./WorkerInterface'], function (WorkerInterface) {
var REQUEST_DEFAULTS = {
import WorkerInterface from './WorkerInterface';
const REQUEST_DEFAULTS = {
amplitude: 1,
period: 10,
offset: 0,
@ -31,21 +32,21 @@ define(['./WorkerInterface'], function (WorkerInterface) {
loadDelay: 0,
infinityValues: false,
exceedFloat32: false
};
};
function GeneratorProvider(openmct, StalenessProvider) {
export default function GeneratorProvider(openmct, StalenessProvider) {
this.openmct = openmct;
this.workerInterface = new WorkerInterface(openmct, StalenessProvider);
}
}
GeneratorProvider.prototype.canProvideTelemetry = function (domainObject) {
GeneratorProvider.prototype.canProvideTelemetry = function (domainObject) {
return domainObject.type === 'generator';
};
};
GeneratorProvider.prototype.supportsRequest = GeneratorProvider.prototype.supportsSubscribe =
GeneratorProvider.prototype.supportsRequest = GeneratorProvider.prototype.supportsSubscribe =
GeneratorProvider.prototype.canProvideTelemetry;
GeneratorProvider.prototype.makeWorkerRequest = function (domainObject, request) {
GeneratorProvider.prototype.makeWorkerRequest = function (domainObject, request) {
var props = [
'amplitude',
'period',
@ -85,21 +86,18 @@ define(['./WorkerInterface'], function (WorkerInterface) {
workerRequest.name = domainObject.name;
return workerRequest;
};
};
GeneratorProvider.prototype.request = function (domainObject, request) {
GeneratorProvider.prototype.request = function (domainObject, request) {
var workerRequest = this.makeWorkerRequest(domainObject, request);
workerRequest.start = request.start;
workerRequest.end = request.end;
return this.workerInterface.request(workerRequest);
};
};
GeneratorProvider.prototype.subscribe = function (domainObject, callback) {
GeneratorProvider.prototype.subscribe = function (domainObject, callback) {
var workerRequest = this.makeWorkerRequest(domainObject, {});
return this.workerInterface.subscribe(workerRequest, callback);
};
return GeneratorProvider;
});
};

View File

@ -20,8 +20,7 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
define([], function () {
var PURPLE = {
var PURPLE = {
sin: 2.2,
cos: 2.2
},
@ -68,13 +67,13 @@ define([], function () {
}
};
function SinewaveLimitProvider() {}
export default function SinewaveLimitProvider() {}
SinewaveLimitProvider.prototype.supportsLimits = function (domainObject) {
SinewaveLimitProvider.prototype.supportsLimits = function (domainObject) {
return domainObject.type === 'generator';
};
};
SinewaveLimitProvider.prototype.getLimitEvaluator = function (domainObject) {
SinewaveLimitProvider.prototype.getLimitEvaluator = function (domainObject) {
return {
evaluate: function (datum, valueMetadata) {
var range = valueMetadata && valueMetadata.key;
@ -96,9 +95,9 @@ define([], function () {
}
}
};
};
};
SinewaveLimitProvider.prototype.getLimits = function (domainObject) {
SinewaveLimitProvider.prototype.getLimits = function (domainObject) {
return {
limits: function () {
return Promise.resolve({
@ -160,7 +159,4 @@ define([], function () {
});
}
};
};
return SinewaveLimitProvider;
});
};

View File

@ -20,22 +20,21 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
define([], function () {
function StateGeneratorProvider() {}
export default function StateGeneratorProvider() {}
function pointForTimestamp(timestamp, duration, name) {
function pointForTimestamp(timestamp, duration, name) {
return {
name: name,
utc: Math.floor(timestamp / duration) * duration,
value: Math.floor(timestamp / duration) % 2
};
}
}
StateGeneratorProvider.prototype.supportsSubscribe = function (domainObject) {
StateGeneratorProvider.prototype.supportsSubscribe = function (domainObject) {
return domainObject.type === 'example.state-generator';
};
};
StateGeneratorProvider.prototype.subscribe = function (domainObject, callback) {
StateGeneratorProvider.prototype.subscribe = function (domainObject, callback) {
var duration = domainObject.telemetry.duration * 1000;
var interval = setInterval(function () {
@ -48,13 +47,13 @@ define([], function () {
return function () {
clearInterval(interval);
};
};
};
StateGeneratorProvider.prototype.supportsRequest = function (domainObject, options) {
StateGeneratorProvider.prototype.supportsRequest = function (domainObject, options) {
return domainObject.type === 'example.state-generator';
};
};
StateGeneratorProvider.prototype.request = function (domainObject, options) {
StateGeneratorProvider.prototype.request = function (domainObject, options) {
var start = options.start;
var end = Math.min(Date.now(), options.end); // no future values
var duration = domainObject.telemetry.duration * 1000;
@ -69,7 +68,4 @@ define([], function () {
}
return Promise.resolve(data);
};
return StateGeneratorProvider;
});
};

View File

@ -20,8 +20,9 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
define(['uuid'], function ({ v4: uuid }) {
function WorkerInterface(openmct, StalenessProvider) {
import { v4 as uuid } from 'uuid';
export default function WorkerInterface(openmct, StalenessProvider) {
// eslint-disable-next-line no-undef
const workerUrl = `${openmct.getAssetPath()}${__OPENMCT_ROOT_RELATIVE__}generatorWorker.js`;
this.StalenessProvider = StalenessProvider;
@ -31,23 +32,23 @@ define(['uuid'], function ({ v4: uuid }) {
this.staleTelemetryIds = {};
this.watchStaleness();
}
}
WorkerInterface.prototype.watchStaleness = function () {
WorkerInterface.prototype.watchStaleness = function () {
this.StalenessProvider.on('stalenessEvent', ({ id, isStale }) => {
this.staleTelemetryIds[id] = isStale;
});
};
};
WorkerInterface.prototype.onMessage = function (message) {
WorkerInterface.prototype.onMessage = function (message) {
message = message.data;
var callback = this.callbacks[message.id];
if (callback) {
callback(message);
}
};
};
WorkerInterface.prototype.dispatch = function (request, data, callback) {
WorkerInterface.prototype.dispatch = function (request, data, callback) {
var message = {
request: request,
data: data,
@ -61,9 +62,9 @@ define(['uuid'], function ({ v4: uuid }) {
this.worker.postMessage(message);
return message.id;
};
};
WorkerInterface.prototype.request = function (request) {
WorkerInterface.prototype.request = function (request) {
var deferred = {};
var promise = new Promise(function (resolve, reject) {
deferred.resolve = resolve;
@ -85,9 +86,9 @@ define(['uuid'], function ({ v4: uuid }) {
messageId = this.dispatch('request', request, callback.bind(this));
return promise;
};
};
WorkerInterface.prototype.subscribe = function (request, cb) {
WorkerInterface.prototype.subscribe = function (request, cb) {
const { id, loadDelay } = request;
const messageId = this.dispatch('subscribe', request, (message) => {
if (!this.staleTelemetryIds[id]) {
@ -101,7 +102,4 @@ define(['uuid'], function ({ v4: uuid }) {
});
delete this.callbacks[messageId];
}.bind(this);
};
return WorkerInterface;
});
};

View File

@ -75,7 +75,7 @@ if (document.currentScript) {
* @property {OpenMCTComponent[]} components
*/
const MCT = require('./src/MCT');
const { MCT } = require('./src/MCT');
/** @type {OpenMCT} */
const openmct = new MCT();

View File

@ -20,56 +20,47 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
/* eslint-disable no-undef */
define([
'EventEmitter',
'./api/api',
'./api/overlays/OverlayAPI',
'./api/tooltips/ToolTipAPI',
'./selection/Selection',
'./plugins/plugins',
'./ui/registries/ViewRegistry',
'./plugins/imagery/plugin',
'./ui/registries/InspectorViewRegistry',
'./ui/registries/ToolbarRegistry',
'./ui/router/ApplicationRouter',
'./ui/router/Browse',
'./ui/layout/AppLayout.vue',
'./ui/preview/plugin',
'./api/Branding',
'./plugins/licenses/plugin',
'./plugins/remove/plugin',
'./plugins/move/plugin',
'./plugins/linkAction/plugin',
'./plugins/duplicate/plugin',
'./plugins/importFromJSONAction/plugin',
'./plugins/exportAsJSONAction/plugin',
'vue'
], function (
EventEmitter,
api,
OverlayAPI,
ToolTipAPI,
Selection,
plugins,
ViewRegistry,
ImageryPlugin,
InspectorViewRegistry,
ToolbarRegistry,
ApplicationRouter,
Browse,
Layout,
PreviewPlugin,
BrandingAPI,
LicensesPlugin,
RemoveActionPlugin,
MoveActionPlugin,
LinkActionPlugin,
DuplicateActionPlugin,
ImportFromJSONAction,
ExportAsJSONAction,
Vue
) {
/**
import EventEmitter from 'EventEmitter';
import { createApp, markRaw } from 'vue';
import ActionsAPI from './api/actions/ActionsAPI';
import AnnotationAPI from './api/annotation/AnnotationAPI';
import BrandingAPI from './api/Branding';
import CompositionAPI from './api/composition/CompositionAPI';
import EditorAPI from './api/Editor';
import FaultManagementAPI from './api/faultmanagement/FaultManagementAPI';
import FormsAPI from './api/forms/FormsAPI';
import IndicatorAPI from './api/indicators/IndicatorAPI';
import MenuAPI from './api/menu/MenuAPI';
import NotificationAPI from './api/notifications/NotificationAPI';
import ObjectAPI from './api/objects/ObjectAPI';
import OverlayAPI from './api/overlays/OverlayAPI';
import PriorityAPI from './api/priority/PriorityAPI';
import StatusAPI from './api/status/StatusAPI';
import TelemetryAPI from './api/telemetry/TelemetryAPI';
import TimeAPI from './api/time/TimeAPI';
import ToolTipAPI from './api/tooltips/ToolTipAPI';
import TypeRegistry from './api/types/TypeRegistry';
import UserAPI from './api/user/UserAPI';
import DuplicateActionPlugin from './plugins/duplicate/plugin';
import ExportAsJSONAction from './plugins/exportAsJSONAction/plugin';
import ImageryPlugin from './plugins/imagery/plugin';
import ImportFromJSONAction from './plugins/importFromJSONAction/plugin';
import LicensesPlugin from './plugins/licenses/plugin';
import LinkActionPlugin from './plugins/linkAction/plugin';
import MoveActionPlugin from './plugins/move/plugin';
import plugins from './plugins/plugins';
import RemoveActionPlugin from './plugins/remove/plugin';
import Selection from './selection/Selection';
import Layout from './ui/layout/AppLayout.vue';
import PreviewPlugin from './ui/preview/plugin';
import InspectorViewRegistry from './ui/registries/InspectorViewRegistry';
import ToolbarRegistry from './ui/registries/ToolbarRegistry';
import ViewRegistry from './ui/registries/ViewRegistry';
import ApplicationRouter from './ui/router/ApplicationRouter';
import Browse from './ui/router/Browse';
/**
* Open MCT is an extensible web application for building mission
* control user interfaces. This module is itself an instance of
* [MCT]{@link module:openmct.MCT}, which provides an interface for
@ -78,14 +69,17 @@ define([
* @exports openmct
*/
/**
/**
* The Open MCT application. This may be configured by installing plugins
* or registering extensions before the application is started.
* @constructor
* @memberof module:openmct
*/
function MCT() {
export class MCT extends EventEmitter {
constructor() {
super();
EventEmitter.call(this);
this.buildInfo = {
version: __OPENMCT_VERSION__,
buildDate: __OPENMCT_BUILD_DATE__,
@ -95,12 +89,14 @@ define([
this.destroy = this.destroy.bind(this);
this.defaultClock = 'local';
[
this.plugins = plugins;
/**
* Tracks current selection state of the application.
* @private
*/
['selection', () => new Selection.default(this)],
this.selection = new Selection(this);
/**
* MCT's time conductor, which may be used to synchronize view contents
@ -109,7 +105,7 @@ define([
* @memberof module:openmct.MCT#
* @name conductor
*/
['time', () => new api.TimeAPI(this)],
this.time = new TimeAPI(this);
/**
* An interface for interacting with the composition of domain objects.
@ -124,7 +120,7 @@ define([
* @memberof module:openmct.MCT#
* @name composition
*/
['composition', () => new api.CompositionAPI.default(this)],
this.composition = new CompositionAPI(this);
/**
* Registry for views of domain objects which should appear in the
@ -134,7 +130,7 @@ define([
* @memberof module:openmct.MCT#
* @name objectViews
*/
['objectViews', () => new ViewRegistry()],
this.objectViews = new ViewRegistry();
/**
* Registry for views which should appear in the Inspector area.
@ -144,7 +140,7 @@ define([
* @memberof module:openmct.MCT#
* @name inspectorViews
*/
['inspectorViews', () => new InspectorViewRegistry.default()],
this.inspectorViews = new InspectorViewRegistry();
/**
* Registry for views which should appear in Edit Properties
@ -155,7 +151,7 @@ define([
* @memberof module:openmct.MCT#
* @name propertyEditors
*/
['propertyEditors', () => new ViewRegistry()],
this.propertyEditors = new ViewRegistry();
/**
* Registry for views which should appear in the toolbar area while
@ -165,7 +161,7 @@ define([
* @memberof module:openmct.MCT#
* @name toolbars
*/
['toolbars', () => new ToolbarRegistry()],
this.toolbars = new ToolbarRegistry();
/**
* Registry for domain object types which may exist within this
@ -175,7 +171,7 @@ define([
* @memberof module:openmct.MCT#
* @name types
*/
['types', () => new api.TypeRegistry()],
this.types = new TypeRegistry();
/**
* An interface for interacting with domain objects and the domain
@ -185,7 +181,7 @@ define([
* @memberof module:openmct.MCT#
* @name objects
*/
['objects', () => new api.ObjectAPI.default(this.types, this)],
this.objects = new ObjectAPI(this.types, this);
/**
* An interface for retrieving and interpreting telemetry data associated
@ -195,7 +191,7 @@ define([
* @memberof module:openmct.MCT#
* @name telemetry
*/
['telemetry', () => new api.TelemetryAPI.default(this)],
this.telemetry = new TelemetryAPI(this);
/**
* An interface for creating new indicators and changing them dynamically.
@ -204,7 +200,7 @@ define([
* @memberof module:openmct.MCT#
* @name indicators
*/
['indicators', () => new api.IndicatorAPI(this)],
this.indicators = new IndicatorAPI(this);
/**
* MCT's user awareness management, to enable user and
@ -213,31 +209,20 @@ define([
* @memberof module:openmct.MCT#
* @name user
*/
['user', () => new api.UserAPI(this)],
this.user = new UserAPI(this);
['notifications', () => new api.NotificationAPI()],
['editor', () => new api.EditorAPI.default(this)],
['overlays', () => new OverlayAPI.default()],
['tooltips', () => new ToolTipAPI.default()],
['menus', () => new api.MenuAPI(this)],
['actions', () => new api.ActionsAPI(this)],
['status', () => new api.StatusAPI(this)],
['priority', () => api.PriorityAPI],
['router', () => new ApplicationRouter(this)],
['faults', () => new api.FaultManagementAPI.default(this)],
['forms', () => new api.FormsAPI.default(this)],
['branding', () => BrandingAPI.default],
this.notifications = new NotificationAPI();
this.editor = new EditorAPI(this);
this.overlays = new OverlayAPI();
this.tooltips = new ToolTipAPI();
this.menus = new MenuAPI(this);
this.actions = new ActionsAPI(this);
this.status = new StatusAPI(this);
this.priority = PriorityAPI;
this.router = new ApplicationRouter(this);
this.faults = new FaultManagementAPI(this);
this.forms = new FormsAPI(this);
this.branding = BrandingAPI;
/**
* MCT's annotation API that enables
@ -246,43 +231,23 @@ define([
* @memberof module:openmct.MCT#
* @name annotation
*/
['annotation', () => new api.AnnotationAPI(this)]
].forEach((apiEntry) => {
const apiName = apiEntry[0];
const apiObject = apiEntry[1]();
Object.defineProperty(this, apiName, {
value: apiObject,
enumerable: false,
configurable: false,
writable: true
});
});
/**
* MCT's annotation API that enables
* human-created comments and categorization linked to data products
* @type {module:openmct.AnnotationAPI}
* @memberof module:openmct.MCT#
* @name annotation
*/
this.annotation = new api.AnnotationAPI(this);
this.annotation = new AnnotationAPI(this);
// Plugins that are installed by default
this.install(this.plugins.Plot());
this.install(this.plugins.TelemetryTable.default());
this.install(PreviewPlugin.default());
this.install(LicensesPlugin.default());
this.install(RemoveActionPlugin.default());
this.install(MoveActionPlugin.default());
this.install(LinkActionPlugin.default());
this.install(DuplicateActionPlugin.default());
this.install(ExportAsJSONAction.default());
this.install(ImportFromJSONAction.default());
this.install(this.plugins.FormActions.default());
this.install(this.plugins.TelemetryTable());
this.install(PreviewPlugin());
this.install(LicensesPlugin());
this.install(RemoveActionPlugin());
this.install(MoveActionPlugin());
this.install(LinkActionPlugin());
this.install(DuplicateActionPlugin());
this.install(ExportAsJSONAction());
this.install(ImportFromJSONAction());
this.install(this.plugins.FormActions());
this.install(this.plugins.FolderView());
this.install(this.plugins.Tabs());
this.install(ImageryPlugin.default());
this.install(ImageryPlugin());
this.install(this.plugins.FlexibleLayout());
this.install(this.plugins.GoToOriginalAction());
this.install(this.plugins.OpenInNewTabAction());
@ -300,26 +265,20 @@ define([
this.install(this.plugins.Gauge());
this.install(this.plugins.InspectorViews());
}
MCT.prototype = Object.create(EventEmitter.prototype);
MCT.prototype.MCT = MCT;
/**
* Set path to where assets are hosted. This should be the path to main.js.
* @memberof module:openmct.MCT#
* @method setAssetPath
*/
MCT.prototype.setAssetPath = function (assetPath) {
setAssetPath(assetPath) {
this._assetPath = assetPath;
};
}
/**
* Get path to where assets are hosted.
* @memberof module:openmct.MCT#
* @method getAssetPath
*/
MCT.prototype.getAssetPath = function () {
getAssetPath() {
const assetPathLength = this._assetPath && this._assetPath.length;
if (!assetPathLength) {
return '/';
@ -330,8 +289,7 @@ define([
}
return this._assetPath;
};
}
/**
* Start running Open MCT. This should be called only after any plugins
* have been installed.
@ -341,10 +299,7 @@ define([
* @param {HTMLElement} [domElement] the DOM element in which to run
* MCT; if undefined, MCT will be run in the body of the document
*/
MCT.prototype.start = function (
domElement = document.body.firstElementChild,
isHeadlessMode = false
) {
start(domElement = document.body.firstElementChild, isHeadlessMode = false) {
// Create element to mount Layout if it doesn't exist
if (domElement === null) {
domElement = document.createElement('div');
@ -376,20 +331,12 @@ define([
* @event start
* @memberof module:openmct.MCT~
*/
if (!isHeadlessMode) {
const appLayout = Vue.createApp({
components: {
Layout: Layout.default
},
provide: {
openmct: Vue.markRaw(this)
},
template: '<Layout ref="layout"></Layout>'
});
const appLayout = createApp(Layout);
appLayout.provide('openmct', markRaw(this));
const component = appLayout.mount(domElement);
component.$nextTick(() => {
this.layout = component.$refs.layout;
this.layout = component;
this.app = appLayout;
Browse(this);
window.addEventListener('beforeunload', this.destroy);
@ -402,14 +349,12 @@ define([
this.router.start();
this.emit('start');
}
};
MCT.prototype.startHeadless = function () {
}
startHeadless() {
let unreachableNode = document.createElement('div');
return this.start(unreachableNode, true);
};
}
/**
* Install a plugin in MCT.
*
@ -417,17 +362,13 @@ define([
* invoked with the mct instance.
* @memberof module:openmct.MCT#
*/
MCT.prototype.install = function (plugin) {
install(plugin) {
plugin(this);
};
}
MCT.prototype.destroy = function () {
destroy() {
window.removeEventListener('beforeunload', this.destroy);
this.emit('destroy');
this.router.destroy();
};
MCT.prototype.plugins = plugins;
return MCT;
});
}
}

View File

@ -20,8 +20,11 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
define(['./plugins/plugins', 'utils/testing'], function (plugins, testUtils) {
describe('MCT', function () {
import * as testUtils from 'utils/testing';
import plugins from './plugins/plugins';
describe('MCT', function () {
let openmct;
let mockPlugin;
let mockPlugin2;
@ -111,5 +114,4 @@ define(['./plugins/plugins', 'utils/testing'], function (plugins, testUtils) {
expect(openmct.getAssetPath()).toBe(testAssetPath + '/');
});
});
});
});

View File

@ -20,24 +20,24 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
define([
'./actions/ActionsAPI',
'./composition/CompositionAPI',
'./Editor',
'./faultmanagement/FaultManagementAPI',
'./forms/FormsAPI',
'./indicators/IndicatorAPI',
'./menu/MenuAPI',
'./notifications/NotificationAPI',
'./objects/ObjectAPI',
'./priority/PriorityAPI',
'./status/StatusAPI',
'./telemetry/TelemetryAPI',
'./time/TimeAPI',
'./types/TypeRegistry',
'./user/UserAPI',
'./annotation/AnnotationAPI'
], function (
import ActionsAPI from './actions/ActionsAPI';
import AnnotationAPI from './annotation/AnnotationAPI';
import CompositionAPI from './composition/CompositionAPI';
import EditorAPI from './Editor';
import FaultManagementAPI from './faultmanagement/FaultManagementAPI';
import FormsAPI from './forms/FormsAPI';
import IndicatorAPI from './indicators/IndicatorAPI';
import MenuAPI from './menu/MenuAPI';
import NotificationAPI from './notifications/NotificationAPI';
import ObjectAPI from './objects/ObjectAPI';
import PriorityAPI from './priority/PriorityAPI';
import StatusAPI from './status/StatusAPI';
import TelemetryAPI from './telemetry/TelemetryAPI';
import TimeAPI from './time/TimeAPI';
import TypeRegistry from './types/TypeRegistry';
import UserAPI from './user/UserAPI';
export default {
ActionsAPI,
CompositionAPI,
EditorAPI,
@ -54,23 +54,4 @@ define([
TypeRegistry,
UserAPI,
AnnotationAPI
) {
return {
ActionsAPI: ActionsAPI.default,
CompositionAPI: CompositionAPI,
EditorAPI: EditorAPI,
FaultManagementAPI: FaultManagementAPI,
FormsAPI: FormsAPI,
IndicatorAPI: IndicatorAPI.default,
MenuAPI: MenuAPI.default,
NotificationAPI: NotificationAPI.default,
ObjectAPI: ObjectAPI,
PriorityAPI: PriorityAPI.default,
StatusAPI: StatusAPI.default,
TelemetryAPI: TelemetryAPI,
TimeAPI: TimeAPI.default,
TypeRegistry: TypeRegistry.default,
UserAPI: UserAPI.default,
AnnotationAPI: AnnotationAPI.default
};
});
};

View File

@ -20,28 +20,27 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
define([], function () {
/**
/**
* Utility for checking if a thing is an Open MCT Identifier.
* @private
*/
function isIdentifier(thing) {
function isIdentifier(thing) {
return (
typeof thing === 'object' &&
Object.prototype.hasOwnProperty.call(thing, 'key') &&
Object.prototype.hasOwnProperty.call(thing, 'namespace')
);
}
}
/**
/**
* Utility for checking if a thing is a key string. Not perfect.
* @private
*/
function isKeyString(thing) {
function isKeyString(thing) {
return typeof thing === 'string';
}
}
/**
/**
* Convert a keyString into an Open MCT Identifier, ex:
* 'scratch:root' ==> {namespace: 'scratch', key: 'root'}
*
@ -50,7 +49,7 @@ define([], function () {
* @param keyString
* @returns identifier
*/
function parseKeyString(keyString) {
function parseKeyString(keyString) {
if (isIdentifier(keyString)) {
return keyString;
}
@ -76,9 +75,9 @@ define([], function () {
namespace: namespace,
key: key
};
}
}
/**
/**
* Convert an Open MCT Identifier into a keyString, ex:
* {namespace: 'scratch', key: 'root'} ==> 'scratch:root'
*
@ -87,7 +86,7 @@ define([], function () {
* @param identifier
* @returns keyString
*/
function makeKeyString(identifier) {
function makeKeyString(identifier) {
if (!identifier) {
throw new Error('Cannot make key string from null identifier');
}
@ -101,9 +100,9 @@ define([], function () {
}
return [identifier.namespace.replace(/:/g, '\\:'), identifier.key].join(':');
}
}
/**
/**
* Convert a new domain object into an old format model, removing the
* identifier and converting the composition array from Open MCT Identifiers
* to old format keyStrings.
@ -111,7 +110,7 @@ define([], function () {
* @param domainObject
* @returns oldFormatModel
*/
function toOldFormat(model) {
function toOldFormat(model) {
model = JSON.parse(JSON.stringify(model));
delete model.identifier;
if (model.composition) {
@ -119,9 +118,9 @@ define([], function () {
}
return model;
}
}
/**
/**
* Convert an old format domain object model into a new format domain
* object. Adds an identifier using the provided keyString, and converts
* the composition array to utilize Open MCT Identifiers.
@ -130,7 +129,7 @@ define([], function () {
* @param keyString
* @returns domainObject
*/
function toNewFormat(model, keyString) {
function toNewFormat(model, keyString) {
model = JSON.parse(JSON.stringify(model));
model.identifier = parseKeyString(keyString);
if (model.composition) {
@ -138,20 +137,20 @@ define([], function () {
}
return model;
}
}
/**
/**
* Compare two Open MCT Identifiers, returning true if they are equal.
*
* @param identifier
* @param otherIdentifier
* @returns Boolean true if identifiers are equal.
*/
function identifierEquals(a, b) {
function identifierEquals(a, b) {
return a.key === b.key && a.namespace === b.namespace;
}
}
/**
/**
* Compare two domain objects, return true if they're the same object.
* Equality is determined by identifier.
*
@ -159,17 +158,17 @@ define([], function () {
* @param otherDomainOBject
* @returns Boolean true if objects are equal.
*/
function objectEquals(a, b) {
function objectEquals(a, b) {
return identifierEquals(a.identifier, b.identifier);
}
}
function refresh(oldObject, newObject) {
function refresh(oldObject, newObject) {
let deleted = _.difference(Object.keys(oldObject), Object.keys(newObject));
deleted.forEach((propertyName) => delete oldObject[propertyName]);
Object.assign(oldObject, newObject);
}
}
return {
export default {
isIdentifier: isIdentifier,
toOldFormat: toOldFormat,
toNewFormat: toNewFormat,
@ -178,5 +177,4 @@ define([], function () {
equals: objectEquals,
identifierEquals: identifierEquals,
refresh: refresh
};
});
};

View File

@ -1,5 +1,6 @@
define(['objectUtils'], function (objectUtils) {
describe('objectUtils', function () {
import objectUtils from 'objectUtils';
describe('objectUtils', function () {
describe('keyString util', function () {
const EXPECTATIONS = {
ROOT: {
@ -143,5 +144,4 @@ define(['objectUtils'], function (objectUtils) {
});
});
});
});
});

View File

@ -20,8 +20,9 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
define(['lodash'], function (_) {
/**
import _ from 'lodash';
/**
* This is the default metadata provider; for any object with a "telemetry"
* property, this provider will return the value of that property as the
* telemetry metadata.
@ -30,7 +31,8 @@ define(['lodash'], function (_) {
* defined on the type. Telemetry metadata definitions on type will be
* depreciated in the future.
*/
function DefaultMetadataProvider(openmct) {
export default class DefaultMetadataProvider {
constructor(openmct) {
this.openmct = openmct;
}
@ -38,15 +40,43 @@ define(['lodash'], function (_) {
* Applies to any domain object with a telemetry property, or whose type
* definition has a telemetry property.
*/
DefaultMetadataProvider.prototype.supportsMetadata = function (domainObject) {
supportsMetadata(domainObject) {
return Boolean(domainObject.telemetry) || Boolean(this.typeHasTelemetry(domainObject));
};
}
/**
* Returns telemetry metadata for a given domain object.
*/
getMetadata(domainObject) {
const metadata = domainObject.telemetry || {};
if (this.typeHasTelemetry(domainObject)) {
const typeMetadata = this.openmct.types.get(domainObject.type).definition.telemetry;
Object.assign(metadata, typeMetadata);
if (!metadata.values) {
metadata.values = valueMetadatasFromOldFormat(metadata);
}
}
return metadata;
}
/**
* @private
*/
typeHasTelemetry(domainObject) {
const type = this.openmct.types.get(domainObject.type);
return Boolean(type.definition.telemetry);
}
}
/**
* Retrieves valueMetadata from legacy metadata.
* @private
*/
function valueMetadatasFromOldFormat(metadata) {
function valueMetadatasFromOldFormat(metadata) {
const valueMetadatas = [];
valueMetadatas.push({
@ -91,34 +121,4 @@ define(['lodash'], function (_) {
});
return valueMetadatas;
}
/**
* Returns telemetry metadata for a given domain object.
*/
DefaultMetadataProvider.prototype.getMetadata = function (domainObject) {
const metadata = domainObject.telemetry || {};
if (this.typeHasTelemetry(domainObject)) {
const typeMetadata = this.openmct.types.get(domainObject.type).definition.telemetry;
Object.assign(metadata, typeMetadata);
if (!metadata.values) {
metadata.values = valueMetadatasFromOldFormat(metadata);
}
}
return metadata;
};
/**
* @private
*/
DefaultMetadataProvider.prototype.typeHasTelemetry = function (domainObject) {
const type = this.openmct.types.get(domainObject.type);
return Boolean(type.definition.telemetry);
};
return DefaultMetadataProvider;
});
}

View File

@ -20,8 +20,9 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
define(['lodash'], function (_) {
function applyReasonableDefaults(valueMetadata, index) {
import _ from 'lodash';
function applyReasonableDefaults(valueMetadata, index) {
valueMetadata.source = valueMetadata.source || valueMetadata.key;
valueMetadata.hints = valueMetadata.hints || {};
@ -60,43 +61,43 @@ define(['lodash'], function (_) {
}
return valueMetadata;
}
}
/**
/**
* Utility class for handling and inspecting telemetry metadata. Applies
* reasonable defaults to simplify the task of providing metadata, while
* also providing methods for interrogating telemetry metadata.
*/
function TelemetryMetadataManager(metadata) {
export default function TelemetryMetadataManager(metadata) {
this.metadata = metadata;
this.valueMetadatas = this.metadata.values
? this.metadata.values.map(applyReasonableDefaults)
: [];
}
}
/**
/**
* Get value metadata for a single key.
*/
TelemetryMetadataManager.prototype.value = function (key) {
TelemetryMetadataManager.prototype.value = function (key) {
return this.valueMetadatas.filter(function (metadata) {
return metadata.key === key;
})[0];
};
};
/**
/**
* Returns all value metadatas, sorted by priority.
*/
TelemetryMetadataManager.prototype.values = function () {
TelemetryMetadataManager.prototype.values = function () {
return this.valuesForHints(['priority']);
};
};
/**
/**
* Get an array of valueMetadatas that possess all hints requested.
* Array is sorted based on hint priority.
*
*/
TelemetryMetadataManager.prototype.valuesForHints = function (hints) {
TelemetryMetadataManager.prototype.valuesForHints = function (hints) {
function hasHint(hint) {
// eslint-disable-next-line no-invalid-this
return Object.prototype.hasOwnProperty.call(this.hints, hint);
@ -114,35 +115,35 @@ define(['lodash'], function (_) {
});
return _.sortBy(matchingMetadata, ...iteratees);
};
};
/**
/**
* check out of a given metadata has array values
*/
TelemetryMetadataManager.prototype.isArrayValue = function (metadata) {
TelemetryMetadataManager.prototype.isArrayValue = function (metadata) {
const regex = /\[\]$/g;
if (!metadata.format && !metadata.formatString) {
return false;
}
return (metadata.format || metadata.formatString).match(regex) !== null;
};
};
TelemetryMetadataManager.prototype.getFilterableValues = function () {
TelemetryMetadataManager.prototype.getFilterableValues = function () {
return this.valueMetadatas.filter(
(metadatum) => metadatum.filters && metadatum.filters.length > 0
);
};
};
TelemetryMetadataManager.prototype.getUseToUpdateInPlaceValue = function () {
TelemetryMetadataManager.prototype.getUseToUpdateInPlaceValue = function () {
return this.valueMetadatas.find(this.isInPlaceUpdateValue);
};
};
TelemetryMetadataManager.prototype.isInPlaceUpdateValue = function (metadatum) {
TelemetryMetadataManager.prototype.isInPlaceUpdateValue = function (metadatum) {
return metadatum.useToUpdateInPlace === true;
};
};
TelemetryMetadataManager.prototype.getDefaultDisplayValue = function () {
TelemetryMetadataManager.prototype.getDefaultDisplayValue = function () {
let valueMetadata = this.valuesForHints(['range'])[0];
if (valueMetadata === undefined) {
@ -156,7 +157,4 @@ define(['lodash'], function (_) {
}
return valueMetadata;
};
return TelemetryMetadataManager;
});
};

View File

@ -20,22 +20,21 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
define([], function () {
// Set of connection states; changing among these states will be
// reflected in the indicator's appearance.
// CONNECTED: Everything nominal, expect to be able to read/write.
// DISCONNECTED: HTTP failed; maybe misconfigured, disconnected.
// PENDING: Still trying to connect, and haven't failed yet.
const CONNECTED = {
// Set of connection states; changing among these states will be
// reflected in the indicator's appearance.
// CONNECTED: Everything nominal, expect to be able to read/write.
// DISCONNECTED: HTTP failed; maybe misconfigured, disconnected.
// PENDING: Still trying to connect, and haven't failed yet.
const CONNECTED = {
statusClass: 's-status-on'
};
const PENDING = {
};
const PENDING = {
statusClass: 's-status-warning-lo'
};
const DISCONNECTED = {
};
const DISCONNECTED = {
statusClass: 's-status-warning-hi'
};
function URLIndicator(options, simpleIndicator) {
};
export default function URLIndicator(options, simpleIndicator) {
this.bindMethods();
this.count = 0;
@ -45,9 +44,9 @@ define([], function () {
this.fetchUrl();
setInterval(this.fetchUrl, this.interval);
}
}
URLIndicator.prototype.setIndicatorToState = function (state) {
URLIndicator.prototype.setIndicatorToState = function (state) {
switch (state) {
case CONNECTED: {
this.indicator.text(this.label + ' is connected');
@ -73,9 +72,9 @@ define([], function () {
}
this.indicator.statusClass(state.statusClass);
};
};
URLIndicator.prototype.fetchUrl = function () {
URLIndicator.prototype.fetchUrl = function () {
fetch(this.URLpath)
.then((response) => {
if (response.ok) {
@ -87,29 +86,26 @@ define([], function () {
.catch((error) => {
this.handleError();
});
};
};
URLIndicator.prototype.handleError = function (e) {
URLIndicator.prototype.handleError = function (e) {
this.setIndicatorToState(DISCONNECTED);
};
};
URLIndicator.prototype.handleSuccess = function () {
URLIndicator.prototype.handleSuccess = function () {
this.setIndicatorToState(CONNECTED);
};
};
URLIndicator.prototype.setDefaultsFromOptions = function (options) {
URLIndicator.prototype.setDefaultsFromOptions = function (options) {
this.URLpath = options.url;
this.label = options.label || options.url;
this.interval = options.interval || 10000;
this.indicator.iconClass(options.iconClass || 'icon-chain-links');
};
};
URLIndicator.prototype.bindMethods = function () {
URLIndicator.prototype.bindMethods = function () {
this.fetchUrl = this.fetchUrl.bind(this);
this.handleSuccess = this.handleSuccess.bind(this);
this.handleError = this.handleError.bind(this);
this.setIndicatorToState = this.setIndicatorToState.bind(this);
};
return URLIndicator;
});
};

View File

@ -19,8 +19,9 @@
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
define(['./URLIndicator'], function URLIndicatorPlugin(URLIndicator) {
return function (opts) {
import URLIndicator from './URLIndicator';
export default function URLIndicatorPlugin(opts) {
return function install(openmct) {
const simpleIndicator = openmct.indicators.simpleIndicator();
const urlIndicator = new URLIndicator(opts, simpleIndicator);
@ -29,5 +30,4 @@ define(['./URLIndicator'], function URLIndicatorPlugin(URLIndicator) {
return urlIndicator;
};
};
});
}

View File

@ -20,13 +20,11 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
define(['utils/testing', './URLIndicator', './URLIndicatorPlugin', '../../MCT'], function (
testingUtils,
URLIndicator,
URLIndicatorPlugin,
MCT
) {
describe('The URLIndicator', function () {
import * as testingUtils from 'utils/testing';
import URLIndicatorPlugin from './URLIndicatorPlugin';
describe('The URLIndicator', function () {
let openmct;
let indicatorElement;
let pluginOptions;
@ -133,5 +131,4 @@ define(['utils/testing', './URLIndicator', './URLIndicatorPlugin', '../../MCT'],
expect(indicatorElement.classList.contains('s-status-warning-hi')).toBe(true);
});
});
});
});

View File

@ -20,15 +20,13 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
define([], function () {
/**
/**
* Constant values used by the Autoflow Tabular View.
*/
return {
export default {
ROW_HEIGHT: 16,
SLIDER_HEIGHT: 10,
INITIAL_COLUMN_WIDTH: 225,
MAX_COLUMN_WIDTH: 525,
COLUMN_WIDTH_STEP: 25
};
});
};

View File

@ -20,8 +20,9 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
define(['./AutoflowTabularRowController'], function (AutoflowTabularRowController) {
/**
import AutoflowTabularRowController from './AutoflowTabularRowController';
/**
* Controller for an Autoflow Tabular View. Subscribes to telemetry
* associated with children of the domain object and passes that
* information on to the view.
@ -30,7 +31,7 @@ define(['./AutoflowTabularRowController'], function (AutoflowTabularRowControlle
* @param {*} data the view data
* @param openmct a reference to the openmct application
*/
function AutoflowTabularController(domainObject, data, openmct) {
export default function AutoflowTabularController(domainObject, data, openmct) {
this.composition = openmct.composition.get(domainObject);
this.data = data;
this.openmct = openmct;
@ -40,22 +41,22 @@ define(['./AutoflowTabularRowController'], function (AutoflowTabularRowControlle
this.addRow = this.addRow.bind(this);
this.removeRow = this.removeRow.bind(this);
}
}
/**
/**
* Set the "Last Updated" value to be displayed.
* @param {String} value the value to display
* @private
*/
AutoflowTabularController.prototype.trackLastUpdated = function (value) {
AutoflowTabularController.prototype.trackLastUpdated = function (value) {
this.data.updated = value;
};
};
/**
/**
* Respond to an `add` event from composition by adding a new row.
* @private
*/
AutoflowTabularController.prototype.addRow = function (childObject) {
AutoflowTabularController.prototype.addRow = function (childObject) {
const identifier = childObject.identifier;
const id = [identifier.namespace, identifier.key].join(':');
@ -74,14 +75,14 @@ define(['./AutoflowTabularRowController'], function (AutoflowTabularRowControlle
this.controllers[id].activate();
this.data.items.push(this.rows[id]);
}
};
};
/**
/**
* Respond to an `remove` event from composition by removing any
* related row.
* @private
*/
AutoflowTabularController.prototype.removeRow = function (identifier) {
AutoflowTabularController.prototype.removeRow = function (identifier) {
const id = [identifier.namespace, identifier.key].join(':');
if (this.rows[id]) {
@ -94,21 +95,21 @@ define(['./AutoflowTabularRowController'], function (AutoflowTabularRowControlle
delete this.controllers[id];
delete this.rows[id];
}
};
};
/**
/**
* Activate this controller; begin listening for changes.
*/
AutoflowTabularController.prototype.activate = function () {
AutoflowTabularController.prototype.activate = function () {
this.composition.on('add', this.addRow);
this.composition.on('remove', this.removeRow);
this.composition.load();
};
};
/**
/**
* Destroy this controller; detach any associated resources.
*/
AutoflowTabularController.prototype.destroy = function () {
AutoflowTabularController.prototype.destroy = function () {
Object.keys(this.controllers).forEach(
function (id) {
this.controllers[id].destroy();
@ -117,7 +118,4 @@ define(['./AutoflowTabularRowController'], function (AutoflowTabularRowControlle
this.controllers = {};
this.composition.off('add', this.addRow);
this.composition.off('remove', this.removeRow);
};
return AutoflowTabularController;
});
};

View File

@ -20,8 +20,9 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
define(['./AutoflowTabularView'], function (AutoflowTabularView) {
return function (options) {
import AutoflowTabularView from './AutoflowTabularView';
export default function (options) {
return function (openmct) {
const views = openmct.mainViews || openmct.objectViews;
@ -38,5 +39,4 @@ define(['./AutoflowTabularView'], function (AutoflowTabularView) {
}
});
};
};
});
}

View File

@ -20,8 +20,7 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
define([], function () {
/**
/**
* Controller for individual rows of an Autoflow Tabular View.
* Subscribes to telemetry and updates row data.
*
@ -30,7 +29,7 @@ define([], function () {
* @param openmct a reference to the openmct application
* @param {Function} callback a callback to invoke with "last updated" timestamps
*/
function AutoflowTabularRowController(domainObject, data, openmct, callback) {
export default function AutoflowTabularRowController(domainObject, data, openmct, callback) {
this.domainObject = domainObject;
this.data = data;
this.openmct = openmct;
@ -44,25 +43,25 @@ define([], function () {
this.evaluator = this.openmct.telemetry.limitEvaluator(this.domainObject);
this.initialized = false;
}
}
/**
/**
* Update row to reflect incoming telemetry data.
* @private
*/
AutoflowTabularRowController.prototype.updateRowData = function (datum) {
AutoflowTabularRowController.prototype.updateRowData = function (datum) {
const violations = this.evaluator.evaluate(datum, this.ranges[0]);
this.initialized = true;
this.data.classes = violations ? violations.cssClass : '';
this.data.value = this.rangeFormatter.format(datum);
this.callback(this.domainFormatter.format(datum));
};
};
/**
/**
* Activate this controller; begin listening for changes.
*/
AutoflowTabularRowController.prototype.activate = function () {
AutoflowTabularRowController.prototype.activate = function () {
this.unsubscribe = this.openmct.telemetry.subscribe(
this.domainObject,
this.updateRowData.bind(this)
@ -80,16 +79,13 @@ define([], function () {
}
}.bind(this)
);
};
};
/**
/**
* Destroy this controller; detach any associated resources.
*/
AutoflowTabularRowController.prototype.destroy = function () {
AutoflowTabularRowController.prototype.destroy = function () {
if (this.unsubscribe) {
this.unsubscribe();
}
};
return AutoflowTabularRowController;
});
};

View File

@ -20,22 +20,21 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
define([
'./AutoflowTabularController',
'./AutoflowTabularConstants',
'./VueView',
'./autoflow-tabular.html'
], function (AutoflowTabularController, AutoflowTabularConstants, VueView, autoflowTemplate) {
const ROW_HEIGHT = AutoflowTabularConstants.ROW_HEIGHT;
const SLIDER_HEIGHT = AutoflowTabularConstants.SLIDER_HEIGHT;
const INITIAL_COLUMN_WIDTH = AutoflowTabularConstants.INITIAL_COLUMN_WIDTH;
const MAX_COLUMN_WIDTH = AutoflowTabularConstants.MAX_COLUMN_WIDTH;
const COLUMN_WIDTH_STEP = AutoflowTabularConstants.COLUMN_WIDTH_STEP;
import autoflowTemplate from './autoflow-tabular.html';
import AutoflowTabularConstants from './AutoflowTabularConstants';
import AutoflowTabularController from './AutoflowTabularController';
import VueView from './VueView';
/**
const ROW_HEIGHT = AutoflowTabularConstants.ROW_HEIGHT;
const SLIDER_HEIGHT = AutoflowTabularConstants.SLIDER_HEIGHT;
const INITIAL_COLUMN_WIDTH = AutoflowTabularConstants.INITIAL_COLUMN_WIDTH;
const MAX_COLUMN_WIDTH = AutoflowTabularConstants.MAX_COLUMN_WIDTH;
const COLUMN_WIDTH_STEP = AutoflowTabularConstants.COLUMN_WIDTH_STEP;
/**
* Implements the Autoflow Tabular view of a domain object.
*/
function AutoflowTabularView(domainObject, openmct) {
export default function AutoflowTabularView(domainObject, openmct) {
const data = {
items: [],
columns: [],
@ -107,9 +106,6 @@ define([
this.$nextTick(updateRowHeight);
}
});
}
}
AutoflowTabularView.prototype = Object.create(VueView.default.prototype);
return AutoflowTabularView;
});
AutoflowTabularView.prototype = Object.create(VueView.prototype);

View File

@ -22,13 +22,15 @@
import mount from 'utils/mount';
export default function () {
return function VueView(options) {
class VueView {
constructor(options) {
const { vNode, destroy } = mount(options);
this.show = function (container) {
container.appendChild(vNode.el);
};
this.destroy = destroy;
};
}
}
return VueView;
}

View File

@ -20,13 +20,12 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
define([], function () {
function DOMObserver(element) {
export default function DOMObserver(element) {
this.element = element;
this.observers = [];
}
}
DOMObserver.prototype.when = function (latchFunction) {
DOMObserver.prototype.when = function (latchFunction) {
return new Promise(
function (resolve, reject) {
//Test latch function at least once
@ -49,15 +48,12 @@ define([], function () {
}
}.bind(this)
);
};
};
DOMObserver.prototype.destroy = function () {
DOMObserver.prototype.destroy = function () {
this.observers.forEach(
function (observer) {
observer.disconnect();
}.bind(this)
);
};
return DOMObserver;
});
};

View File

@ -20,8 +20,7 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
define(function () {
function DisplayLayoutType() {
export default function DisplayLayoutType() {
return {
name: 'Display Layout',
creatable: true,
@ -66,7 +65,4 @@ define(function () {
}
]
};
}
return DisplayLayoutType;
});
}

View File

@ -20,8 +20,7 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
define([], function () {
/**
/**
* Handles drag interactions on frames in layouts. This will
* provides new positions/dimensions for frames based on
* relative pixel positions provided; these will take into account
@ -48,65 +47,62 @@ define([], function () {
* @constructor
* @memberof platform/features/layout
*/
function LayoutDrag(rawPosition, posFactor, dimFactor, gridSize) {
export default function LayoutDrag(rawPosition, posFactor, dimFactor, gridSize) {
this.rawPosition = rawPosition;
this.posFactor = posFactor;
this.dimFactor = dimFactor;
this.gridSize = gridSize;
}
}
// Convert a delta from pixel coordinates to grid coordinates,
// rounding to whole-number grid coordinates.
function toGridDelta(gridSize, pixelDelta) {
// Convert a delta from pixel coordinates to grid coordinates,
// rounding to whole-number grid coordinates.
function toGridDelta(gridSize, pixelDelta) {
return pixelDelta.map(function (v, i) {
return Math.round(v / gridSize[i]);
});
}
}
// Utility function to perform element-by-element multiplication
function multiply(array, factors) {
// Utility function to perform element-by-element multiplication
function multiply(array, factors) {
return array.map(function (v, i) {
return v * factors[i];
});
}
}
// Utility function to perform element-by-element addition
function add(array, other) {
// Utility function to perform element-by-element addition
function add(array, other) {
return array.map(function (v, i) {
return v + other[i];
});
}
}
// Utility function to perform element-by-element max-choosing
function max(array, other) {
// Utility function to perform element-by-element max-choosing
function max(array, other) {
return array.map(function (v, i) {
return Math.max(v, other[i]);
});
}
}
/**
/**
* Get a new position object in grid coordinates, with
* position and dimensions both offset appropriately
* according to the factors supplied in the constructor.
* @param {number[]} pixelDelta the offset from the
* original position, in pixels
*/
LayoutDrag.prototype.getAdjustedPositionAndDimensions = function (pixelDelta) {
LayoutDrag.prototype.getAdjustedPositionAndDimensions = function (pixelDelta) {
const gridDelta = toGridDelta(this.gridSize, pixelDelta);
return {
position: max(add(this.rawPosition.position, multiply(gridDelta, this.posFactor)), [0, 0]),
dimensions: max(add(this.rawPosition.dimensions, multiply(gridDelta, this.dimFactor)), [1, 1])
};
};
};
LayoutDrag.prototype.getAdjustedPosition = function (pixelDelta) {
LayoutDrag.prototype.getAdjustedPosition = function (pixelDelta) {
const gridDelta = toGridDelta(this.gridSize, pixelDelta);
return {
position: max(add(this.rawPosition.position, multiply(gridDelta, this.posFactor)), [0, 0])
};
};
return LayoutDrag;
});
};

View File

@ -20,12 +20,12 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
define(['./FiltersInspectorViewProvider'], function (FiltersInspectorViewProvider) {
return function plugin(supportedObjectTypesArray) {
import FiltersInspectorViewProvider from './FiltersInspectorViewProvider';
export default function plugin(supportedObjectTypesArray) {
return function install(openmct) {
openmct.inspectorViews.addProvider(
new FiltersInspectorViewProvider.default(openmct, supportedObjectTypesArray)
new FiltersInspectorViewProvider(openmct, supportedObjectTypesArray)
);
};
};
});
}

View File

@ -20,14 +20,13 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
define(['./flexibleLayoutViewProvider', './utils/container', './toolbarProvider'], function (
FlexibleLayoutViewProvider,
Container,
ToolBarProvider
) {
return function plugin() {
import FlexibleLayoutViewProvider from './flexibleLayoutViewProvider';
import ToolBarProvider from './toolbarProvider';
import Container from './utils/container';
export default function plugin() {
return function install(openmct) {
openmct.objectViews.addProvider(new FlexibleLayoutViewProvider.default(openmct));
openmct.objectViews.addProvider(new FlexibleLayoutViewProvider(openmct));
openmct.types.addType('flexible-layout', {
name: 'Flexible Layout',
@ -37,16 +36,15 @@ define(['./flexibleLayoutViewProvider', './utils/container', './toolbarProvider'
cssClass: 'icon-flexible-layout',
initialize: function (domainObject) {
domainObject.configuration = {
containers: [new Container.default(50), new Container.default(50)],
containers: [new Container(50), new Container(50)],
rowsLayout: false
};
domainObject.composition = [];
}
});
let toolbar = ToolBarProvider.default(openmct);
let toolbar = ToolBarProvider(openmct);
openmct.toolbars.addProvider(toolbar);
};
};
});
}

View File

@ -20,8 +20,7 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
define([], function () {
const helperFunctions = {
const helperFunctions = {
listenTo: function (object, event, callback, context) {
if (!this._listeningTo) {
this._listeningTo = [];
@ -93,7 +92,6 @@ define([], function () {
object.listenTo = helperFunctions.listenTo;
object.stopListening = helperFunctions.stopListening;
}
};
};
return helperFunctions;
});
export default helperFunctions;

View File

@ -20,24 +20,24 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
define(['../../../src/plugins/utcTimeSystem/LocalClock'], function (LocalClock) {
import LocalClock from '../../../src/plugins/utcTimeSystem/LocalClock';
class LADClock extends LocalClock {
/**
* A {@link Clock} that mocks a "latest available data" type tick source.
* This is for testing purposes only, and behaves identically to a local clock.
* It DOES NOT tick on receipt of data.
* @constructor
*/
function LADClock(period) {
LocalClock.call(this, period);
constructor(period) {
super(period);
this.key = 'test-lad';
this.mode = 'lad';
this.cssClass = 'icon-suitcase';
this.name = 'Latest available data';
this.description = 'Updates when when new data is available';
this.description = 'Updates when new data is available';
}
}
LADClock.prototype = Object.create(LocalClock.prototype);
return LADClock;
});
export default LADClock;

View File

@ -20,10 +20,10 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
define(['./LADClock'], function (LADClock) {
return function () {
import LADClock from './LADClock';
export default function () {
return function (openmct) {
openmct.time.addClock(new LADClock());
};
};
});
}

View File

@ -20,18 +20,19 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
define(['moment'], function (moment) {
const DATE_FORMAT = 'YYYY-MM-DD h:mm:ss.SSS a';
import moment from 'moment';
const DATE_FORMATS = [DATE_FORMAT, 'YYYY-MM-DD h:mm:ss a', 'YYYY-MM-DD h:mm a', 'YYYY-MM-DD'];
const DATE_FORMAT = 'YYYY-MM-DD h:mm:ss.SSS a';
/**
const DATE_FORMATS = [DATE_FORMAT, 'YYYY-MM-DD h:mm:ss a', 'YYYY-MM-DD h:mm a', 'YYYY-MM-DD'];
/**
* @typedef Scale
* @property {number} min the minimum scale value, in ms
* @property {number} max the maximum scale value, in ms
*/
/**
/**
* Formatter for UTC timestamps. Interprets numeric values as
* milliseconds since the start of 1970.
*
@ -39,30 +40,27 @@ define(['moment'], function (moment) {
* @constructor
* @memberof platform/commonUI/formats
*/
function LocalTimeFormat() {
export default function LocalTimeFormat() {
this.key = 'local-format';
}
}
/**
/**
*
* @param value
* @returns {string} the formatted date
*/
LocalTimeFormat.prototype.format = function (value, scale) {
LocalTimeFormat.prototype.format = function (value, scale) {
return moment(value).format(DATE_FORMAT);
};
};
LocalTimeFormat.prototype.parse = function (text) {
LocalTimeFormat.prototype.parse = function (text) {
if (typeof text === 'number') {
return text;
}
return moment(text, DATE_FORMATS).valueOf();
};
};
LocalTimeFormat.prototype.validate = function (text) {
LocalTimeFormat.prototype.validate = function (text) {
return moment(text, DATE_FORMATS).isValid();
};
return LocalTimeFormat;
});
};

View File

@ -20,13 +20,13 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
define([], function () {
/**
/**
* This time system supports UTC dates and provides a ticking clock source.
* @implements TimeSystem
* @constructor
*/
function LocalTimeSystem() {
export default class LocalTimeSystem {
constructor() {
/**
* Some metadata, which will be used to identify the time system in
* the UI
@ -41,6 +41,4 @@ define([], function () {
this.isUTCBased = true;
}
return LocalTimeSystem;
});
}

View File

@ -20,11 +20,12 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
define(['./LocalTimeSystem', './LocalTimeFormat'], function (LocalTimeSystem, LocalTimeFormat) {
return function () {
import LocalTimeFormat from './LocalTimeFormat';
import LocalTimeSystem from './LocalTimeSystem';
export default function () {
return function (openmct) {
openmct.time.addTimeSystem(new LocalTimeSystem());
openmct.telemetry.addFormat(new LocalTimeFormat());
};
};
});
}

View File

@ -20,8 +20,9 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
define(['uuid'], function ({ v4: uuid }) {
return function Migrations(openmct) {
import { v4 as uuid } from 'uuid';
export default function Migrations(openmct) {
function getColumnNameKeyMap(domainObject) {
let composition = openmct.composition.get(domainObject);
if (composition) {
@ -275,5 +276,4 @@ define(['uuid'], function ({ v4: uuid }) {
}
}
];
};
});
}

View File

@ -20,160 +20,91 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
define([
'lodash',
'./utcTimeSystem/plugin',
'./remoteClock/plugin',
'./localTimeSystem/plugin',
'./ISOTimeFormat/plugin',
'./myItems/plugin',
'../../example/generator/plugin',
'../../example/eventGenerator/plugin',
'../../example/dataVisualization/plugin',
'./autoflow/AutoflowTabularPlugin',
'./timeConductor/plugin',
'../../example/imagery/plugin',
'../../example/faultManagement/exampleFaultSource',
'./imagery/plugin',
'./summaryWidget/plugin',
'./URLIndicatorPlugin/URLIndicatorPlugin',
'./telemetryMean/plugin',
'./plot/plugin',
'./charts/bar/plugin',
'./charts/scatter/plugin',
'./telemetryTable/plugin',
'./staticRootPlugin/plugin',
'./notebook/plugin',
'./displayLayout/plugin',
'./formActions/plugin',
'./folderView/plugin',
'./flexibleLayout/plugin',
'./tabs/plugin',
'./LADTable/plugin',
'./filters/plugin',
'./objectMigration/plugin',
'./goToOriginalAction/plugin',
'./openInNewTabAction/plugin',
'./clearData/plugin',
'./webPage/plugin',
'./condition/plugin',
'./conditionWidget/plugin',
'./themes/espresso',
'./themes/snow',
'./URLTimeSettingsSynchronizer/plugin',
'./notificationIndicator/plugin',
'./newFolderAction/plugin',
'./persistence/couch/plugin',
'./defaultRootName/plugin',
'./plan/plugin',
'./viewDatumAction/plugin',
'./viewLargeAction/plugin',
'./interceptors/plugin',
'./performanceIndicator/plugin',
'./CouchDBSearchFolder/plugin',
'./timeline/plugin',
'./hyperlink/plugin',
'./clock/plugin',
'./DeviceClassifier/plugin',
'./timer/plugin',
'./userIndicator/plugin',
'../../example/exampleUser/plugin',
'./localStorage/plugin',
'./operatorStatus/plugin',
'./gauge/GaugePlugin',
'./timelist/plugin',
'./faultManagement/FaultManagementPlugin',
'../../example/exampleTags/plugin',
'./inspectorViews/plugin',
'./inspectorDataVisualization/plugin'
], function (
_,
UTCTimeSystem,
RemoteClock,
LocalTimeSystem,
ISOTimeFormat,
MyItems,
GeneratorPlugin,
EventGeneratorPlugin,
ExampleDataVisualizationSourcePlugin,
AutoflowPlugin,
TimeConductorPlugin,
ExampleImagery,
ExampleFaultSource,
ImageryPlugin,
SummaryWidget,
URLIndicatorPlugin,
TelemetryMean,
PlotPlugin,
BarChartPlugin,
ScatterPlotPlugin,
TelemetryTablePlugin,
StaticRootPlugin,
Notebook,
DisplayLayoutPlugin,
FormActions,
FolderView,
FlexibleLayout,
Tabs,
LADTable,
Filters,
ObjectMigration,
GoToOriginalAction,
OpenInNewTabAction,
ClearData,
WebPagePlugin,
ConditionPlugin,
ConditionWidgetPlugin,
Espresso,
Snow,
URLTimeSettingsSynchronizer,
NotificationIndicator,
NewFolderAction,
CouchDBPlugin,
DefaultRootName,
PlanLayout,
ViewDatumAction,
ViewLargeAction,
ObjectInterceptors,
PerformanceIndicator,
CouchDBSearchFolder,
Timeline,
Hyperlink,
Clock,
DeviceClassifier,
Timer,
UserIndicator,
ExampleUser,
LocalStorage,
OperatorStatus,
GaugePlugin,
TimeList,
FaultManagementPlugin,
ExampleTags,
InspectorViews,
InspectorDataVisualization
) {
const plugins = {};
import ExampleDataVisualizationSourcePlugin from '../../example/dataVisualization/plugin';
import EventGeneratorPlugin from '../../example/eventGenerator/plugin';
import ExampleTags from '../../example/exampleTags/plugin';
import ExampleUser from '../../example/exampleUser/plugin';
import ExampleFaultSource from '../../example/faultManagement/exampleFaultSource';
import GeneratorPlugin from '../../example/generator/plugin';
import ExampleImagery from '../../example/imagery/plugin';
import AutoflowPlugin from './autoflow/AutoflowTabularPlugin';
import BarChartPlugin from './charts/bar/plugin';
import ScatterPlotPlugin from './charts/scatter/plugin';
import ClearData from './clearData/plugin';
import Clock from './clock/plugin';
import ConditionPlugin from './condition/plugin';
import ConditionWidgetPlugin from './conditionWidget/plugin';
import CouchDBSearchFolder from './CouchDBSearchFolder/plugin';
import DefaultRootName from './defaultRootName/plugin';
import DeviceClassifier from './DeviceClassifier/plugin';
import DisplayLayoutPlugin from './displayLayout/plugin';
import FaultManagementPlugin from './faultManagement/FaultManagementPlugin';
import Filters from './filters/plugin';
import FlexibleLayout from './flexibleLayout/plugin';
import FolderView from './folderView/plugin';
import FormActions from './formActions/plugin';
import GaugePlugin from './gauge/GaugePlugin';
import GoToOriginalAction from './goToOriginalAction/plugin';
import Hyperlink from './hyperlink/plugin';
import ImageryPlugin from './imagery/plugin';
import InspectorDataVisualization from './inspectorDataVisualization/plugin';
import InspectorViews from './inspectorViews/plugin';
import ObjectInterceptors from './interceptors/plugin';
import ISOTimeFormat from './ISOTimeFormat/plugin';
import LADTable from './LADTable/plugin';
import LocalStorage from './localStorage/plugin';
import LocalTimeSystem from './localTimeSystem/plugin';
import MyItems from './myItems/plugin';
import NewFolderAction from './newFolderAction/plugin';
import { NotebookPlugin, RestrictedNotebookPlugin } from './notebook/plugin';
import NotificationIndicator from './notificationIndicator/plugin';
import ObjectMigration from './objectMigration/plugin';
import OpenInNewTabAction from './openInNewTabAction/plugin';
import OperatorStatus from './operatorStatus/plugin';
import PerformanceIndicator from './performanceIndicator/plugin';
import CouchDBPlugin from './persistence/couch/plugin';
import PlanLayout from './plan/plugin';
import PlotPlugin from './plot/plugin';
import RemoteClock from './remoteClock/plugin';
import StaticRootPlugin from './staticRootPlugin/plugin';
import SummaryWidget from './summaryWidget/plugin';
import Tabs from './tabs/plugin';
import TelemetryMean from './telemetryMean/plugin';
import TelemetryTablePlugin from './telemetryTable/plugin';
import Espresso from './themes/espresso';
import Snow from './themes/snow';
import TimeConductorPlugin from './timeConductor/plugin';
import Timeline from './timeline/plugin';
import TimeList from './timelist/plugin';
import Timer from './timer/plugin';
import URLIndicatorPlugin from './URLIndicatorPlugin/URLIndicatorPlugin';
import URLTimeSettingsSynchronizer from './URLTimeSettingsSynchronizer/plugin';
import UserIndicator from './userIndicator/plugin';
import UTCTimeSystem from './utcTimeSystem/plugin';
import ViewDatumAction from './viewDatumAction/plugin';
import ViewLargeAction from './viewLargeAction/plugin';
import WebPagePlugin from './webPage/plugin';
plugins.example = {};
plugins.example.ExampleUser = ExampleUser.default;
plugins.example.ExampleImagery = ExampleImagery.default;
plugins.example.ExampleFaultSource = ExampleFaultSource.default;
plugins.example.EventGeneratorPlugin = EventGeneratorPlugin.default;
plugins.example.ExampleDataVisualizationSourcePlugin =
ExampleDataVisualizationSourcePlugin.default;
plugins.example.ExampleTags = ExampleTags.default;
plugins.example.Generator = () => GeneratorPlugin.default;
const plugins = {};
plugins.UTCTimeSystem = UTCTimeSystem.default;
plugins.LocalTimeSystem = LocalTimeSystem;
plugins.RemoteClock = RemoteClock.default;
plugins.example = {};
plugins.example.ExampleUser = ExampleUser;
plugins.example.ExampleImagery = ExampleImagery;
plugins.example.ExampleFaultSource = ExampleFaultSource;
plugins.example.EventGeneratorPlugin = EventGeneratorPlugin;
plugins.example.ExampleDataVisualizationSourcePlugin = ExampleDataVisualizationSourcePlugin;
plugins.example.ExampleTags = ExampleTags;
plugins.example.Generator = () => GeneratorPlugin;
plugins.MyItems = MyItems.default;
plugins.UTCTimeSystem = UTCTimeSystem;
plugins.LocalTimeSystem = LocalTimeSystem;
plugins.RemoteClock = RemoteClock;
plugins.StaticRootPlugin = StaticRootPlugin.default;
plugins.MyItems = MyItems;
/**
plugins.StaticRootPlugin = StaticRootPlugin;
/**
* A tabular view showing the latest values of multiple telemetry points at
* once. Formatted so that labels and values are aligned.
*
@ -182,63 +113,62 @@ define([
* @param {string} [options.type] The key of an object type to apply this view
* to exclusively.
*/
plugins.AutoflowView = AutoflowPlugin;
plugins.AutoflowView = AutoflowPlugin;
plugins.Conductor = TimeConductorPlugin.default;
plugins.Conductor = TimeConductorPlugin;
plugins.CouchDB = CouchDBPlugin.default;
plugins.CouchDB = CouchDBPlugin;
plugins.ImageryPlugin = ImageryPlugin;
plugins.Plot = PlotPlugin.default;
plugins.BarChart = BarChartPlugin.default;
plugins.ScatterPlot = ScatterPlotPlugin.default;
plugins.TelemetryTable = TelemetryTablePlugin;
plugins.ImageryPlugin = ImageryPlugin;
plugins.Plot = PlotPlugin;
plugins.BarChart = BarChartPlugin;
plugins.ScatterPlot = ScatterPlotPlugin;
plugins.TelemetryTable = TelemetryTablePlugin;
plugins.SummaryWidget = SummaryWidget;
plugins.TelemetryMean = TelemetryMean;
plugins.URLIndicator = URLIndicatorPlugin;
plugins.Notebook = Notebook.NotebookPlugin;
plugins.RestrictedNotebook = Notebook.RestrictedNotebookPlugin;
plugins.DisplayLayout = DisplayLayoutPlugin.default;
plugins.FaultManagement = FaultManagementPlugin.default;
plugins.FormActions = FormActions;
plugins.FolderView = FolderView.default;
plugins.Tabs = Tabs;
plugins.FlexibleLayout = FlexibleLayout;
plugins.LADTable = LADTable.default;
plugins.Filters = Filters;
plugins.ObjectMigration = ObjectMigration.default;
plugins.GoToOriginalAction = GoToOriginalAction.default;
plugins.OpenInNewTabAction = OpenInNewTabAction.default;
plugins.ClearData = ClearData.default;
plugins.WebPage = WebPagePlugin.default;
plugins.Espresso = Espresso.default;
plugins.Snow = Snow.default;
plugins.Condition = ConditionPlugin.default;
plugins.ConditionWidget = ConditionWidgetPlugin.default;
plugins.URLTimeSettingsSynchronizer = URLTimeSettingsSynchronizer.default;
plugins.NotificationIndicator = NotificationIndicator.default;
plugins.NewFolderAction = NewFolderAction.default;
plugins.ISOTimeFormat = ISOTimeFormat.default;
plugins.DefaultRootName = DefaultRootName.default;
plugins.PlanLayout = PlanLayout.default;
plugins.ViewDatumAction = ViewDatumAction.default;
plugins.ViewLargeAction = ViewLargeAction.default;
plugins.ObjectInterceptors = ObjectInterceptors.default;
plugins.PerformanceIndicator = PerformanceIndicator.default;
plugins.CouchDBSearchFolder = CouchDBSearchFolder.default;
plugins.Timeline = Timeline.default;
plugins.Hyperlink = Hyperlink.default;
plugins.Clock = Clock.default;
plugins.Timer = Timer.default;
plugins.DeviceClassifier = DeviceClassifier.default;
plugins.UserIndicator = UserIndicator.default;
plugins.LocalStorage = LocalStorage.default;
plugins.OperatorStatus = OperatorStatus.default;
plugins.Gauge = GaugePlugin.default;
plugins.Timelist = TimeList.default;
plugins.InspectorViews = InspectorViews.default;
plugins.InspectorDataVisualization = InspectorDataVisualization.default;
plugins.SummaryWidget = SummaryWidget;
plugins.TelemetryMean = TelemetryMean;
plugins.URLIndicator = URLIndicatorPlugin;
plugins.Notebook = NotebookPlugin;
plugins.RestrictedNotebook = RestrictedNotebookPlugin;
plugins.DisplayLayout = DisplayLayoutPlugin;
plugins.FaultManagement = FaultManagementPlugin;
plugins.FormActions = FormActions;
plugins.FolderView = FolderView;
plugins.Tabs = Tabs;
plugins.FlexibleLayout = FlexibleLayout;
plugins.LADTable = LADTable;
plugins.Filters = Filters;
plugins.ObjectMigration = ObjectMigration;
plugins.GoToOriginalAction = GoToOriginalAction;
plugins.OpenInNewTabAction = OpenInNewTabAction;
plugins.ClearData = ClearData;
plugins.WebPage = WebPagePlugin;
plugins.Espresso = Espresso;
plugins.Snow = Snow;
plugins.Condition = ConditionPlugin;
plugins.ConditionWidget = ConditionWidgetPlugin;
plugins.URLTimeSettingsSynchronizer = URLTimeSettingsSynchronizer;
plugins.NotificationIndicator = NotificationIndicator;
plugins.NewFolderAction = NewFolderAction;
plugins.ISOTimeFormat = ISOTimeFormat;
plugins.DefaultRootName = DefaultRootName;
plugins.PlanLayout = PlanLayout;
plugins.ViewDatumAction = ViewDatumAction;
plugins.ViewLargeAction = ViewLargeAction;
plugins.ObjectInterceptors = ObjectInterceptors;
plugins.PerformanceIndicator = PerformanceIndicator;
plugins.CouchDBSearchFolder = CouchDBSearchFolder;
plugins.Timeline = Timeline;
plugins.Hyperlink = Hyperlink;
plugins.Clock = Clock;
plugins.Timer = Timer;
plugins.DeviceClassifier = DeviceClassifier;
plugins.UserIndicator = UserIndicator;
plugins.LocalStorage = LocalStorage;
plugins.OperatorStatus = OperatorStatus;
plugins.Gauge = GaugePlugin;
plugins.Timelist = TimeList;
plugins.InspectorViews = InspectorViews;
plugins.InspectorDataVisualization = InspectorDataVisualization;
return plugins;
});
export default plugins;

View File

@ -20,20 +20,16 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
define([], function () {
/**
/**
* Policy determining which views can apply to summary widget. Disables
* any view other than normal summary widget view.
*/
function SummaryWidgetViewPolicy() {}
export default function SummaryWidgetViewPolicy() {}
SummaryWidgetViewPolicy.prototype.allow = function (view, domainObject) {
SummaryWidgetViewPolicy.prototype.allow = function (view, domainObject) {
if (domainObject.getModel().type === 'summary-widget') {
return view.key === 'summary-widget-viewer';
}
return true;
};
return SummaryWidgetViewPolicy;
});
};

View File

@ -20,12 +20,11 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
define([], function () {
function SummaryWidgetsCompositionPolicy(openmct) {
export default function SummaryWidgetsCompositionPolicy(openmct) {
this.openmct = openmct;
}
}
SummaryWidgetsCompositionPolicy.prototype.allow = function (parent, child) {
SummaryWidgetsCompositionPolicy.prototype.allow = function (parent, child) {
const parentType = parent.type;
if (parentType === 'summary-widget' && !this.openmct.telemetry.isTelemetryObject(child)) {
@ -33,7 +32,4 @@ define([], function () {
}
return true;
};
return SummaryWidgetsCompositionPolicy;
});
};

View File

@ -1,17 +1,9 @@
define([
'./SummaryWidgetsCompositionPolicy',
'./src/telemetry/SummaryWidgetMetadataProvider',
'./src/telemetry/SummaryWidgetTelemetryProvider',
'./src/views/SummaryWidgetViewProvider',
'./SummaryWidgetViewPolicy'
], function (
SummaryWidgetsCompositionPolicy,
SummaryWidgetMetadataProvider,
SummaryWidgetTelemetryProvider,
SummaryWidgetViewProvider,
SummaryWidgetViewPolicy
) {
function plugin() {
import SummaryWidgetMetadataProvider from './src/telemetry/SummaryWidgetMetadataProvider';
import SummaryWidgetTelemetryProvider from './src/telemetry/SummaryWidgetTelemetryProvider';
import SummaryWidgetViewProvider from './src/views/SummaryWidgetViewProvider';
import SummaryWidgetsCompositionPolicy from './SummaryWidgetsCompositionPolicy';
export default function plugin() {
const widgetType = {
name: 'Summary Widget',
description: 'A compact status update for collections of telemetry-producing items',
@ -92,7 +84,4 @@ define([
openmct.telemetry.addProvider(new SummaryWidgetTelemetryProvider(openmct));
openmct.objectViews.addProvider(new SummaryWidgetViewProvider(openmct));
};
}
return plugin;
});
}

View File

@ -19,24 +19,17 @@
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
define([
'../res/conditionTemplate.html',
'./input/ObjectSelect',
'./input/KeySelect',
'./input/OperationSelect',
'./eventHelpers',
'../../../utils/template/templateHelpers',
'EventEmitter'
], function (
conditionTemplate,
ObjectSelect,
KeySelect,
OperationSelect,
eventHelpers,
templateHelpers,
EventEmitter
) {
/**
import EventEmitter from 'EventEmitter';
import * as templateHelpers from '../../../utils/template/templateHelpers';
import conditionTemplate from '../res/conditionTemplate.html';
import eventHelpers from './eventHelpers';
import KeySelect from './input/KeySelect';
import ObjectSelect from './input/ObjectSelect';
import OperationSelect from './input/OperationSelect';
/**
* Represents an individual condition for a summary widget rule. Manages the
* associated inputs and view.
* @param {Object} conditionConfig The configuration for this condition, consisting
@ -46,7 +39,7 @@ define([
* @param {ConditionManager} conditionManager A ConditionManager instance for populating
* selects with configuration data
*/
function Condition(conditionConfig, index, conditionManager) {
export default function Condition(conditionConfig, index, conditionManager) {
eventHelpers.extend(this);
this.config = conditionConfig;
this.index = index;
@ -128,13 +121,13 @@ define([
});
this.listenTo(this.domElement.querySelector('.t-value-inputs'), 'input', onValueInput);
}
}
Condition.prototype.getDOM = function (container) {
Condition.prototype.getDOM = function (container) {
return this.domElement;
};
};
/**
/**
* Register a callback with this condition: supported callbacks are remove, change,
* duplicate
* @param {string} event The key for the event to listen to
@ -142,57 +135,57 @@ define([
* @param {Object} context A reference to a scope to use as the context for
* context for the callback function
*/
Condition.prototype.on = function (event, callback, context) {
Condition.prototype.on = function (event, callback, context) {
if (this.supportedCallbacks.includes(event)) {
this.eventEmitter.on(event, callback, context || this);
}
};
};
/**
/**
* Hide the appropriate inputs when this is the only condition
*/
Condition.prototype.hideButtons = function () {
Condition.prototype.hideButtons = function () {
this.deleteButton.style.display = 'none';
};
};
/**
/**
* Remove this condition from the configuration. Invokes any registered
* remove callbacks
*/
Condition.prototype.remove = function () {
Condition.prototype.remove = function () {
this.selects.object.off('change', this.handleObjectChange);
this.selects.key.off('change', this.handleKeyChange);
this.eventEmitter.emit('remove', this.index);
this.destroy();
};
};
Condition.prototype.destroy = function () {
Condition.prototype.destroy = function () {
this.stopListening();
Object.values(this.selects).forEach(function (select) {
select.destroy();
});
};
};
/**
/**
* Make a deep clone of this condition's configuration and invoke any duplicate
* callbacks with the cloned configuration and this rule's index
*/
Condition.prototype.duplicate = function () {
Condition.prototype.duplicate = function () {
const sourceCondition = JSON.parse(JSON.stringify(this.config));
this.eventEmitter.emit('duplicate', {
sourceCondition: sourceCondition,
index: this.index
});
};
};
/**
/**
* When an operation is selected, create the appropriate value inputs
* and add them to the view. If an operation is of type enum, create
* a drop-down menu instead.
*
* @param {string} operation The key of currently selected operation
*/
Condition.prototype.generateValueInputs = function (operation) {
Condition.prototype.generateValueInputs = function (operation) {
const evaluator = this.conditionManager.getEvaluator();
const inputArea = this.domElement.querySelector('.t-value-inputs');
let inputCount;
@ -240,9 +233,9 @@ define([
});
}
}
};
};
Condition.prototype.generateSelectOptions = function () {
Condition.prototype.generateSelectOptions = function () {
let telemetryMetadata = this.conditionManager.getTelemetryMetadata(this.config.object);
let fragment = document.createDocumentFragment();
@ -254,7 +247,4 @@ define([
});
return fragment;
};
return Condition;
});
};

View File

@ -1,5 +1,4 @@
define([], function () {
/**
/**
* Responsible for maintaining the possible operations for conditions
* in this widget, and evaluating the boolean value of conditions passed as
* input.
@ -10,7 +9,7 @@ define([], function () {
* @param {Object} compositionObjs The current set of composition objects to
* evaluate for 'any' and 'all' conditions
*/
function ConditionEvaluator(subscriptionCache, compositionObjs) {
export default function ConditionEvaluator(subscriptionCache, compositionObjs) {
this.subscriptionCache = subscriptionCache;
this.compositionObjs = compositionObjs;
@ -242,9 +241,9 @@ define([], function () {
}
}
};
}
}
/**
/**
* Evaluate the conditions passed in as an argument, and return the boolean
* value of these conditions. Available evaluation modes are 'any', which will
* return true if any of the conditions evaluates to true (i.e. logical OR); 'all',
@ -256,7 +255,7 @@ define([], function () {
* @param {string} mode The key of the mode to use when evaluating the conditions.
* @return {boolean} The boolean value of the conditions
*/
ConditionEvaluator.prototype.execute = function (conditions, mode) {
ConditionEvaluator.prototype.execute = function (conditions, mode) {
let active = false;
let conditionValue;
let conditionDefined = false;
@ -320,9 +319,9 @@ define([], function () {
}
return active;
};
};
/**
/**
* Execute a condition defined as an object.
* @param {string} object The identifier of the telemetry object to retrieve data from
* @param {string} key The property of the telemetry object
@ -330,7 +329,7 @@ define([], function () {
* @param {string} values An array of comparison values to invoke the operation with
* @return {boolean} The value of this condition
*/
ConditionEvaluator.prototype.executeCondition = function (object, key, operation, values) {
ConditionEvaluator.prototype.executeCondition = function (object, key, operation, values) {
const cache = this.useTestCache ? this.testCache : this.subscriptionCache;
let telemetryValue;
let op;
@ -355,95 +354,95 @@ define([], function () {
} else {
throw new Error('Malformed condition');
}
};
};
/**
/**
* A function that returns true only if each value in its input argument is
* of a numerical type
* @param {[]} input An array of values
* @returns {boolean}
*/
ConditionEvaluator.prototype.validateNumberInput = function (input) {
ConditionEvaluator.prototype.validateNumberInput = function (input) {
let valid = true;
input.forEach(function (value) {
valid = valid && typeof value === 'number';
});
return valid;
};
};
/**
/**
* A function that returns true only if each value in its input argument is
* a string
* @param {[]} input An array of values
* @returns {boolean}
*/
ConditionEvaluator.prototype.validateStringInput = function (input) {
ConditionEvaluator.prototype.validateStringInput = function (input) {
let valid = true;
input.forEach(function (value) {
valid = valid && typeof value === 'string';
});
return valid;
};
};
/**
/**
* Get the keys of operations supported by this evaluator
* @return {string[]} An array of the keys of supported operations
*/
ConditionEvaluator.prototype.getOperationKeys = function () {
ConditionEvaluator.prototype.getOperationKeys = function () {
return Object.keys(this.operations);
};
};
/**
/**
* Get the human-readable text corresponding to a given operation
* @param {string} key The key of the operation
* @return {string} The text description of the operation
*/
ConditionEvaluator.prototype.getOperationText = function (key) {
ConditionEvaluator.prototype.getOperationText = function (key) {
return this.operations[key].text;
};
};
/**
/**
* Returns true only if the given operation applies to a given type
* @param {string} key The key of the operation
* @param {string} type The value type to query
* @returns {boolean} True if the condition applies, false otherwise
*/
ConditionEvaluator.prototype.operationAppliesTo = function (key, type) {
ConditionEvaluator.prototype.operationAppliesTo = function (key, type) {
return this.operations[key].appliesTo.includes(type);
};
};
/**
/**
* Return the number of value inputs required by an operation
* @param {string} key The key of the operation to query
* @return {number}
*/
ConditionEvaluator.prototype.getInputCount = function (key) {
ConditionEvaluator.prototype.getInputCount = function (key) {
if (this.operations[key]) {
return this.operations[key].inputCount;
}
};
};
/**
/**
* Return the human-readable shorthand description of the operation for a rule header
* @param {string} key The key of the operation to query
* @param {} values An array of values with which to invoke the getDescription function
* of the operation
* @return {string} A text description of this operation
*/
ConditionEvaluator.prototype.getOperationDescription = function (key, values) {
ConditionEvaluator.prototype.getOperationDescription = function (key, values) {
if (this.operations[key]) {
return this.operations[key].getDescription(values);
}
};
};
/**
/**
* Return the HTML input type associated with a given operation
* @param {string} key The key of the operation to query
* @return {string} The key for an HTML5 input type
*/
ConditionEvaluator.prototype.getInputType = function (key) {
ConditionEvaluator.prototype.getInputType = function (key) {
let type;
if (this.operations[key]) {
type = this.operations[key].appliesTo[0];
@ -452,35 +451,32 @@ define([], function () {
if (this.inputTypes[type]) {
return this.inputTypes[type];
}
};
};
/**
/**
* Returns the HTML input type associated with a value type
* @param {string} dataType The JavaScript value type
* @return {string} The key for an HTML5 input type
*/
ConditionEvaluator.prototype.getInputTypeById = function (dataType) {
ConditionEvaluator.prototype.getInputTypeById = function (dataType) {
return this.inputTypes[dataType];
};
};
/**
/**
* Set the test data cache used by this rule evaluator
* @param {object} testCache A mock cache following the format of the real
* subscription cache
*/
ConditionEvaluator.prototype.setTestDataCache = function (testCache) {
ConditionEvaluator.prototype.setTestDataCache = function (testCache) {
this.testCache = testCache;
};
};
/**
/**
* Have this RuleEvaluator pull data values from the provided test cache
* instead of its actual subscription cache when evaluating. If invoked with true,
* will use the test cache; otherwise, will use the subscription cache
* @param {boolean} useTestData Boolean flag
*/
ConditionEvaluator.prototype.useTestData = function (useTestCache) {
ConditionEvaluator.prototype.useTestData = function (useTestCache) {
this.useTestCache = useTestCache;
};
return ConditionEvaluator;
});
};

View File

@ -1,10 +1,10 @@
define(['./ConditionEvaluator', 'objectUtils', 'EventEmitter', 'lodash'], function (
ConditionEvaluator,
objectUtils,
EventEmitter,
_
) {
/**
import EventEmitter from 'EventEmitter';
import _ from 'lodash';
import objectUtils from 'objectUtils';
import ConditionEvaluator from './ConditionEvaluator';
/**
* Provides a centralized content manager for conditions in the summary widget.
* Loads and caches composition and telemetry subscriptions, and maintains a
* {ConditionEvaluator} instance to handle evaluation
@ -12,7 +12,7 @@ define(['./ConditionEvaluator', 'objectUtils', 'EventEmitter', 'lodash'], functi
* @param {Object} domainObject the Summary Widget domain object
* @param {MCT} openmct an MCT instance
*/
function ConditionManager(domainObject, openmct) {
export default function ConditionManager(domainObject, openmct) {
this.domainObject = domainObject;
this.openmct = openmct;
@ -47,9 +47,9 @@ define(['./ConditionEvaluator', 'objectUtils', 'EventEmitter', 'lodash'], functi
this.composition.on('load', this.onCompositionLoad, this);
this.composition.load();
}
}
/**
/**
* Register a callback with this ConditionManager: supported callbacks are add
* remove, load, metadata, and receiveTelemetry
* @param {string} event The key for the event to listen to
@ -57,7 +57,7 @@ define(['./ConditionEvaluator', 'objectUtils', 'EventEmitter', 'lodash'], functi
* @param {Object} context A reference to a scope to use as the context for
* context for the callback function
*/
ConditionManager.prototype.on = function (event, callback, context) {
ConditionManager.prototype.on = function (event, callback, context) {
if (this.supportedCallbacks.includes(event)) {
this.eventEmitter.on(event, callback, context || this);
} else {
@ -65,9 +65,9 @@ define(['./ConditionEvaluator', 'objectUtils', 'EventEmitter', 'lodash'], functi
event + ' is not a supported callback. Supported callbacks are ' + this.supportedCallbacks
);
}
};
};
/**
/**
* Given a set of rules, execute the conditions associated with each rule
* and return the id of the last rule whose conditions evaluate to true
* @param {string[]} ruleOrder An array of rule IDs indicating what order They
@ -75,7 +75,7 @@ define(['./ConditionEvaluator', 'objectUtils', 'EventEmitter', 'lodash'], functi
* @param {Object} rules An object mapping rule IDs to rule configurations
* @return {string} The ID of the rule to display on the widget
*/
ConditionManager.prototype.executeRules = function (ruleOrder, rules) {
ConditionManager.prototype.executeRules = function (ruleOrder, rules) {
const self = this;
let activeId = ruleOrder[0];
let rule;
@ -90,35 +90,35 @@ define(['./ConditionEvaluator', 'objectUtils', 'EventEmitter', 'lodash'], functi
});
return activeId;
};
};
/**
/**
* Adds a field to the list of all available metadata fields in the widget
* @param {Object} metadatum An object representing a set of telemetry metadata
*/
ConditionManager.prototype.addGlobalMetadata = function (metadatum) {
ConditionManager.prototype.addGlobalMetadata = function (metadatum) {
this.telemetryMetadataById.any[metadatum.key] = metadatum;
this.telemetryMetadataById.all[metadatum.key] = metadatum;
};
};
/**
/**
* Adds a field to the list of properties for globally available metadata
* @param {string} key The key for the property this type applies to
* @param {string} type The type that should be associated with this property
*/
ConditionManager.prototype.addGlobalPropertyType = function (key, type) {
ConditionManager.prototype.addGlobalPropertyType = function (key, type) {
this.telemetryTypesById.any[key] = type;
this.telemetryTypesById.all[key] = type;
};
};
/**
/**
* Given a telemetry-producing domain object, associate each of it's telemetry
* fields with a type, parsing from historical data.
* @param {Object} object a domain object that can produce telemetry
* @return {Promise} A promise that resolves when a telemetry request
* has completed and types have been parsed
*/
ConditionManager.prototype.parsePropertyTypes = function (object) {
ConditionManager.prototype.parsePropertyTypes = function (object) {
const objectId = objectUtils.makeKeyString(object.identifier);
this.telemetryTypesById[objectId] = {};
@ -139,47 +139,47 @@ define(['./ConditionEvaluator', 'objectUtils', 'EventEmitter', 'lodash'], functi
this.telemetryTypesById[objectId][valueMetadata.key] = type;
this.addGlobalPropertyType(valueMetadata.key, type);
}, this);
};
};
/**
/**
* Parse types of telemetry fields from all composition objects; used internally
* to perform a block types load once initial composition load has completed
* @return {Promise} A promise that resolves when all metadata has been loaded
* and property types parsed
*/
ConditionManager.prototype.parseAllPropertyTypes = function () {
ConditionManager.prototype.parseAllPropertyTypes = function () {
Object.values(this.compositionObjs).forEach(this.parsePropertyTypes, this);
this.metadataLoadComplete = true;
this.eventEmitter.emit('metadata');
};
};
/**
/**
* Invoked when a telemetry subscription yields new data. Updates the LAD
* cache and invokes any registered receiveTelemetry callbacks
* @param {string} objId The key associated with the telemetry source
* @param {datum} datum The new data from the telemetry source
* @private
*/
ConditionManager.prototype.handleSubscriptionCallback = function (objId, telemetryDatum) {
ConditionManager.prototype.handleSubscriptionCallback = function (objId, telemetryDatum) {
this.subscriptionCache[objId] = this.createNormalizedDatum(objId, telemetryDatum);
this.eventEmitter.emit('receiveTelemetry');
};
};
ConditionManager.prototype.createNormalizedDatum = function (objId, telemetryDatum) {
ConditionManager.prototype.createNormalizedDatum = function (objId, telemetryDatum) {
return Object.values(this.telemetryMetadataById[objId]).reduce((normalizedDatum, metadatum) => {
normalizedDatum[metadatum.key] = telemetryDatum[metadatum.source];
return normalizedDatum;
}, {});
};
};
/**
/**
* Event handler for an add event in this Summary Widget's composition.
* Sets up subscription handlers and parses its property types.
* @param {Object} obj The newly added domain object
* @private
*/
ConditionManager.prototype.onCompositionAdd = function (obj) {
ConditionManager.prototype.onCompositionAdd = function (obj) {
let compositionKeys;
const telemetryAPI = this.openmct.telemetry;
const objId = objectUtils.makeKeyString(obj.identifier);
@ -236,15 +236,15 @@ define(['./ConditionEvaluator', 'objectUtils', 'EventEmitter', 'lodash'], functi
summaryWidget.classList.remove('s-status-no-data');
}
}
};
};
/**
/**
* Invoked on a remove event in this Summary Widget's composition. Removes
* the object from the local composition, and untracks it
* @param {object} identifier The identifier of the object to be removed
* @private
*/
ConditionManager.prototype.onCompositionRemove = function (identifier) {
ConditionManager.prototype.onCompositionRemove = function (identifier) {
const objectId = objectUtils.makeKeyString(identifier);
// FIXME: this should just update by listener.
_.remove(this.domainObject.composition, function (id) {
@ -262,34 +262,34 @@ define(['./ConditionEvaluator', 'objectUtils', 'EventEmitter', 'lodash'], functi
summaryWidget.classList.add('s-status-no-data');
}
}
};
};
/**
/**
* Invoked when the Summary Widget's composition finishes its initial load.
* Invokes any registered load callbacks, does a block load of all metadata,
* and then invokes any registered metadata load callbacks.
* @private
*/
ConditionManager.prototype.onCompositionLoad = function () {
ConditionManager.prototype.onCompositionLoad = function () {
this.loadComplete = true;
this.eventEmitter.emit('load');
this.parseAllPropertyTypes();
};
};
/**
/**
* Returns the currently tracked telemetry sources
* @return {Object} An object mapping object keys to domain objects
*/
ConditionManager.prototype.getComposition = function () {
ConditionManager.prototype.getComposition = function () {
return this.compositionObjs;
};
};
/**
/**
* Get the human-readable name of a domain object from its key
* @param {string} id The key of the domain object
* @return {string} The human-readable name of the domain object
*/
ConditionManager.prototype.getObjectName = function (id) {
ConditionManager.prototype.getObjectName = function (id) {
let name;
if (this.keywordLabels[id]) {
@ -299,88 +299,85 @@ define(['./ConditionEvaluator', 'objectUtils', 'EventEmitter', 'lodash'], functi
}
return name;
};
};
/**
/**
* Returns the property metadata associated with a given telemetry source
* @param {string} id The key associated with the domain object
* @return {Object} Returns an object with fields representing each telemetry field
*/
ConditionManager.prototype.getTelemetryMetadata = function (id) {
ConditionManager.prototype.getTelemetryMetadata = function (id) {
return this.telemetryMetadataById[id];
};
};
/**
/**
* Returns the type associated with a telemetry data field of a particular domain
* object
* @param {string} id The key associated with the domain object
* @param {string} property The telemetry field key to retrieve the type of
* @return {string} The type name
*/
ConditionManager.prototype.getTelemetryPropertyType = function (id, property) {
ConditionManager.prototype.getTelemetryPropertyType = function (id, property) {
if (this.telemetryTypesById[id]) {
return this.telemetryTypesById[id][property];
}
};
};
/**
/**
* Returns the human-readable name of a telemetry data field of a particular domain
* object
* @param {string} id The key associated with the domain object
* @param {string} property The telemetry field key to retrieve the type of
* @return {string} The telemetry field name
*/
ConditionManager.prototype.getTelemetryPropertyName = function (id, property) {
ConditionManager.prototype.getTelemetryPropertyName = function (id, property) {
if (this.telemetryMetadataById[id] && this.telemetryMetadataById[id][property]) {
return this.telemetryMetadataById[id][property].name;
}
};
};
/**
/**
* Returns the {ConditionEvaluator} instance associated with this condition
* manager
* @return {ConditionEvaluator}
*/
ConditionManager.prototype.getEvaluator = function () {
ConditionManager.prototype.getEvaluator = function () {
return this.evaluator;
};
};
/**
/**
* Returns true if the initial composition load has completed
* @return {boolean}
*/
ConditionManager.prototype.loadCompleted = function () {
ConditionManager.prototype.loadCompleted = function () {
return this.loadComplete;
};
};
/**
/**
* Returns true if the initial block metadata load has completed
*/
ConditionManager.prototype.metadataLoadCompleted = function () {
ConditionManager.prototype.metadataLoadCompleted = function () {
return this.metadataLoadComplete;
};
};
/**
/**
* Triggers the telemetryReceive callbacks registered to this ConditionManager,
* used by the {TestDataManager} to force a rule evaluation when test data is
* enabled
*/
ConditionManager.prototype.triggerTelemetryCallback = function () {
ConditionManager.prototype.triggerTelemetryCallback = function () {
this.eventEmitter.emit('receiveTelemetry');
};
};
/**
/**
* Unsubscribe from all registered telemetry sources and unregister all event
* listeners registered with the Open MCT APIs
*/
ConditionManager.prototype.destroy = function () {
ConditionManager.prototype.destroy = function () {
Object.values(this.subscriptions).forEach(function (unsubscribeFunction) {
unsubscribeFunction();
});
this.composition.off('add', this.onCompositionAdd, this);
this.composition.off('remove', this.onCompositionRemove, this);
this.composition.off('load', this.onCompositionLoad, this);
};
return ConditionManager;
});
};

View File

@ -1,23 +1,14 @@
define([
'../res/ruleTemplate.html',
'./Condition',
'./input/ColorPalette',
'./input/IconPalette',
'./eventHelpers',
'../../../utils/template/templateHelpers',
'EventEmitter',
'lodash'
], function (
ruleTemplate,
Condition,
ColorPalette,
IconPalette,
eventHelpers,
templateHelpers,
EventEmitter,
_
) {
/**
import EventEmitter from 'EventEmitter';
import _ from 'lodash';
import * as templateHelpers from '../../../utils/template/templateHelpers';
import ruleTemplate from '../res/ruleTemplate.html';
import Condition from './Condition';
import eventHelpers from './eventHelpers';
import ColorPalette from './input/ColorPalette';
import IconPalette from './input/IconPalette';
/**
* An object representing a summary widget rule. Maintains a set of text
* and css properties for output, and a set of conditions for configuring
* when the rule will be applied to the summary widget.
@ -29,7 +20,14 @@ define([
* @param {WidgetDnD} widgetDnD A WidgetDnD instance to handle dragging and dropping rules
* @param {element} container The DOM element which contains this summary widget
*/
function Rule(ruleConfig, domainObject, openmct, conditionManager, widgetDnD, container) {
export default function Rule(
ruleConfig,
domainObject,
openmct,
conditionManager,
widgetDnD,
container
) {
eventHelpers.extend(this);
const self = this;
const THUMB_ICON_CLASS = 'c-sw__icon js-sw__icon';
@ -164,9 +162,7 @@ define([
function onDragStart(event) {
document.querySelectorAll('.t-drag-indicator').forEach((indicator) => {
// eslint-disable-next-line no-invalid-this
const ruleHeader = self.domElement
.querySelectorAll('.widget-rule-header')[0]
.cloneNode(true);
const ruleHeader = self.domElement.querySelectorAll('.widget-rule-header')[0].cloneNode(true);
indicator.textContent = '';
indicator.appendChild(ruleHeader);
});
@ -276,20 +272,20 @@ define([
this.domElement.querySelector('.t-widget-rule-config').style.display = 'none';
this.domElement.querySelector('.t-grippy').style.display = 'none';
}
}
}
/**
/**
* Return the DOM element representing this rule
* @return {Element} A DOM element
*/
Rule.prototype.getDOM = function () {
Rule.prototype.getDOM = function () {
return this.domElement;
};
};
/**
/**
* Unregister any event handlers registered with external sources
*/
Rule.prototype.destroy = function () {
Rule.prototype.destroy = function () {
Object.values(this.colorInputs).forEach(function (palette) {
palette.destroy();
});
@ -298,9 +294,9 @@ define([
this.conditions.forEach(function (condition) {
condition.destroy();
});
};
};
/**
/**
* Register a callback with this rule: supported callbacks are remove, change,
* conditionChange, and duplicate
* @param {string} event The key for the event to listen to
@ -308,58 +304,58 @@ define([
* @param {Object} context A reference to a scope to use as the context for
* context for the callback function
*/
Rule.prototype.on = function (event, callback, context) {
Rule.prototype.on = function (event, callback, context) {
if (this.supportedCallbacks.includes(event)) {
this.eventEmitter.on(event, callback, context || this);
}
};
};
/**
/**
* An event handler for when a condition's configuration is modified
* @param {} value
* @param {string} property The path in the configuration to updateDomainObject
* @param {number} index The index of the condition that initiated this change
*/
Rule.prototype.onConditionChange = function (event) {
Rule.prototype.onConditionChange = function (event) {
_.set(this.config.conditions[event.index], event.property, event.value);
this.generateDescription();
this.updateDomainObject();
this.eventEmitter.emit('conditionChange');
};
};
/**
/**
* During a rule drag event, show the placeholder element after this rule
*/
Rule.prototype.showDragIndicator = function () {
Rule.prototype.showDragIndicator = function () {
document.querySelector('.t-drag-indicator').style.display = 'none';
this.domElement.querySelector('.t-drag-indicator').style.display = '';
};
};
/**
/**
* Mutate the domain object with this rule's local configuration
*/
Rule.prototype.updateDomainObject = function () {
Rule.prototype.updateDomainObject = function () {
this.openmct.objects.mutate(
this.domainObject,
'configuration.ruleConfigById.' + this.config.id,
this.config
);
};
};
/**
/**
* Get a property of this rule by key
* @param {string} prop They property key of this rule to get
* @return {} The queried property
*/
Rule.prototype.getProperty = function (prop) {
Rule.prototype.getProperty = function (prop) {
return this.config[prop];
};
};
/**
/**
* Remove this rule from the domain object's configuration and invoke any
* registered remove callbacks
*/
Rule.prototype.remove = function () {
Rule.prototype.remove = function () {
const ruleOrder = this.domainObject.configuration.ruleOrder;
const ruleConfigById = this.domainObject.configuration.ruleConfigById;
const self = this;
@ -373,19 +369,19 @@ define([
this.openmct.objects.mutate(this.domainObject, 'configuration.ruleOrder', ruleOrder);
this.destroy();
this.eventEmitter.emit('remove');
};
};
/**
/**
* Makes a deep clone of this rule's configuration, and calls the duplicate event
* callback with the cloned configuration as an argument if one has been registered
*/
Rule.prototype.duplicate = function () {
Rule.prototype.duplicate = function () {
const sourceRule = JSON.parse(JSON.stringify(this.config));
sourceRule.expanded = true;
this.eventEmitter.emit('duplicate', sourceRule);
};
};
/**
/**
* Initialize a new condition. If called with the sourceConfig and sourceIndex arguments,
* will insert a new condition with the provided configuration after the sourceIndex
* index. Otherwise, initializes a new blank rule and inserts it at the end
@ -393,7 +389,7 @@ define([
* @param {Object} [config] The configuration to initialize this rule from,
* consisting of sourceCondition and index fields
*/
Rule.prototype.initCondition = function (config) {
Rule.prototype.initCondition = function (config) {
const ruleConfigById = this.domainObject.configuration.ruleConfigById;
let newConfig;
const sourceIndex = config && config.index;
@ -415,12 +411,12 @@ define([
this.updateDomainObject();
this.refreshConditions();
this.generateDescription();
};
};
/**
/**
* Build {Condition} objects from configuration and rebuild associated view
*/
Rule.prototype.refreshConditions = function () {
Rule.prototype.refreshConditions = function () {
const self = this;
let $condition = null;
let loopCnt = 0;
@ -467,13 +463,13 @@ define([
if (self.conditions.length === 1) {
self.conditions[0].hideButtons();
}
};
};
/**
/**
* Remove a condition from this rule's configuration at the given index
* @param {number} removeIndex The index of the condition to remove
*/
Rule.prototype.removeCondition = function (removeIndex) {
Rule.prototype.removeCondition = function (removeIndex) {
const ruleConfigById = this.domainObject.configuration.ruleConfigById;
const conditions = ruleConfigById[this.config.id].conditions;
@ -486,12 +482,12 @@ define([
this.refreshConditions();
this.generateDescription();
this.eventEmitter.emit('conditionChange');
};
};
/**
/**
* Build a human-readable description from this rule's conditions
*/
Rule.prototype.generateDescription = function () {
Rule.prototype.generateDescription = function () {
let description = '';
const manager = this.conditionManager;
const evaluator = manager.getEvaluator();
@ -531,7 +527,4 @@ define([
description = description === '' ? this.config.description : description;
this.description.innerText = self.config.description;
this.config.description = description;
};
return Rule;
});
};

View File

@ -1,34 +1,21 @@
define([
'../res/widgetTemplate.html',
'./Rule',
'./ConditionManager',
'./TestDataManager',
'./WidgetDnD',
'./eventHelpers',
'../../../utils/template/templateHelpers',
'objectUtils',
'lodash',
'@braintree/sanitize-url'
], function (
widgetTemplate,
Rule,
ConditionManager,
TestDataManager,
WidgetDnD,
eventHelpers,
templateHelpers,
objectUtils,
_,
urlSanitizeLib
) {
//default css configuration for new rules
const DEFAULT_PROPS = {
import * as urlSanitizeLib from '@braintree/sanitize-url';
import * as templateHelpers from '../../../utils/template/templateHelpers';
import widgetTemplate from '../res/widgetTemplate.html';
import ConditionManager from './ConditionManager';
import eventHelpers from './eventHelpers';
import Rule from './Rule';
import TestDataManager from './TestDataManager';
import WidgetDnD from './WidgetDnD';
//default css configuration for new rules
const DEFAULT_PROPS = {
color: '#cccccc',
'background-color': '#666666',
'border-color': 'rgba(0,0,0,0)'
};
};
/**
/**
* A Summary Widget object, which allows a user to configure rules based
* on telemetry producing domain objects, and update a compact display
* accordingly.
@ -36,7 +23,7 @@ define([
* @param {Object} domainObject The domain Object represented by this Widget
* @param {MCT} openmct An MCT instance
*/
function SummaryWidget(domainObject, openmct) {
export default function SummaryWidget(domainObject, openmct) {
eventHelpers.extend(this);
this.domainObject = domainObject;
@ -123,14 +110,14 @@ define([
}
this.listenTo(this.toggleRulesControl, 'click', toggleRules);
}
}
/**
/**
* adds or removes href to widget button and adds or removes openInNewTab
* @param {string} url String that denotes the url to be opened
* @param {string} openNewTab String that denotes wether to open link in new tab or not
*/
SummaryWidget.prototype.addHyperlink = function (url, openNewTab) {
SummaryWidget.prototype.addHyperlink = function (url, openNewTab) {
if (url) {
this.widgetButton.href = urlSanitizeLib.sanitizeUrl(url);
} else {
@ -142,15 +129,15 @@ define([
} else {
this.widgetButton.removeAttribute('target');
}
};
};
/**
/**
* adds a listener to the object to watch for any changes made by user
* only executes if changes are observed
* @param {openmct} Object Instance of OpenMCT
* @param {domainObject} Object instance of this object
*/
SummaryWidget.prototype.watchForChanges = function (openmct, domainObject) {
SummaryWidget.prototype.watchForChanges = function (openmct, domainObject) {
this.watchForChangesUnsubscribe = openmct.objects.observe(
domainObject,
'*',
@ -163,15 +150,15 @@ define([
}
}.bind(this)
);
};
};
/**
/**
* Builds the Summary Widget's DOM, performs other necessary setup, and attaches
* this Summary Widget's view to the supplied container.
* @param {element} container The DOM element that will contain this Summary
* Widget's view.
*/
SummaryWidget.prototype.show = function (container) {
SummaryWidget.prototype.show = function (container) {
const self = this;
this.container = container;
this.container.append(this.domElement);
@ -193,13 +180,13 @@ define([
this.listenTo(this.addRuleButton, 'click', this.addRule);
this.conditionManager.on('receiveTelemetry', this.executeRules, this);
this.widgetDnD.on('drop', this.reorder, this);
};
};
/**
/**
* Unregister event listeners with the Open MCT APIs, unsubscribe from telemetry,
* and clean up event handlers
*/
SummaryWidget.prototype.destroy = function (container) {
SummaryWidget.prototype.destroy = function (container) {
this.editListenerUnsubscribe();
this.conditionManager.destroy();
this.testDataManager.destroy();
@ -210,12 +197,12 @@ define([
});
this.stopListening();
};
};
/**
/**
* Update the view from the current rule configuration and order
*/
SummaryWidget.prototype.refreshRules = function () {
SummaryWidget.prototype.refreshRules = function () {
const self = this;
const ruleOrder = self.domainObject.configuration.ruleOrder;
const rules = self.rulesById;
@ -226,9 +213,9 @@ define([
this.executeRules();
this.addOrRemoveDragIndicator();
};
};
SummaryWidget.prototype.addOrRemoveDragIndicator = function () {
SummaryWidget.prototype.addOrRemoveDragIndicator = function () {
const rules = this.domainObject.configuration.ruleOrder;
const rulesById = this.rulesById;
@ -239,12 +226,12 @@ define([
rulesById[ruleKey].domElement.querySelector('.t-grippy').style.display = 'none';
}
});
};
};
/**
/**
* Update the widget's appearance from the configuration of the active rule
*/
SummaryWidget.prototype.updateWidget = function () {
SummaryWidget.prototype.updateWidget = function () {
const WIDGET_ICON_CLASS = 'c-sw__icon js-sw__icon';
const activeRule = this.rulesById[this.activeId];
@ -253,23 +240,23 @@ define([
this.domElement.querySelector('#widgetLabel').textContent = activeRule.getProperty('label');
this.domElement.querySelector('#widgetIcon').classList =
WIDGET_ICON_CLASS + ' ' + activeRule.getProperty('icon');
};
};
/**
/**
* Get the active rule and update the Widget's appearance.
*/
SummaryWidget.prototype.executeRules = function () {
SummaryWidget.prototype.executeRules = function () {
this.activeId = this.conditionManager.executeRules(
this.domainObject.configuration.ruleOrder,
this.rulesById
);
this.updateWidget();
};
};
/**
/**
* Add a new rule to this widget
*/
SummaryWidget.prototype.addRule = function () {
SummaryWidget.prototype.addRule = function () {
let ruleCount = 0;
let ruleId;
const ruleOrder = this.domainObject.configuration.ruleOrder;
@ -285,15 +272,15 @@ define([
this.initRule(ruleId, 'Rule');
this.updateDomainObject();
this.refreshRules();
};
};
/**
/**
* Duplicate an existing widget rule from its configuration and splice it in
* after the rule it duplicates
* @param {Object} sourceConfig The configuration properties of the rule to be
* instantiated
*/
SummaryWidget.prototype.duplicateRule = function (sourceConfig) {
SummaryWidget.prototype.duplicateRule = function (sourceConfig) {
let ruleCount = 0;
let ruleId;
const sourceRuleId = sourceConfig.id;
@ -313,16 +300,16 @@ define([
this.initRule(ruleId, sourceConfig.name);
this.updateDomainObject();
this.refreshRules();
};
};
/**
/**
* Initialize a new rule from a default configuration, or build a {Rule} object
* from it if already exists
* @param {string} ruleId An key to be used to identify this ruleId, or the key
of the rule to be instantiated
* @param {string} ruleName The initial human-readable name of this rule
*/
SummaryWidget.prototype.initRule = function (ruleId, ruleName) {
SummaryWidget.prototype.initRule = function (ruleId, ruleName) {
let ruleConfig;
const styleObj = {};
@ -363,15 +350,15 @@ define([
this.rulesById[ruleId].on('duplicate', this.duplicateRule, this);
this.rulesById[ruleId].on('change', this.updateWidget, this);
this.rulesById[ruleId].on('conditionChange', this.executeRules, this);
};
};
/**
/**
* Given two ruleIds, move the source rule after the target rule and update
* the view.
* @param {Object} event An event object representing this drop with draggingId
* and dropTarget fields
*/
SummaryWidget.prototype.reorder = function (event) {
SummaryWidget.prototype.reorder = function (event) {
const ruleOrder = this.domainObject.configuration.ruleOrder;
const sourceIndex = ruleOrder.indexOf(event.draggingId);
let targetIndex;
@ -385,29 +372,22 @@ define([
}
this.refreshRules();
};
};
/**
/**
* Apply a list of css properties to an element
* @param {element} elem The DOM element to which the rules will be applied
* @param {object} style an object representing the style
*/
SummaryWidget.prototype.applyStyle = function (elem, style) {
SummaryWidget.prototype.applyStyle = function (elem, style) {
Object.keys(style).forEach(function (propId) {
elem.style[propId] = style[propId];
});
};
};
/**
/**
* Mutate this domain object's configuration with the current local configuration
*/
SummaryWidget.prototype.updateDomainObject = function () {
this.openmct.objects.mutate(
this.domainObject,
'configuration',
this.domainObject.configuration
);
};
return SummaryWidget;
});
SummaryWidget.prototype.updateDomainObject = function () {
this.openmct.objects.mutate(this.domainObject, 'configuration', this.domainObject.configuration);
};

View File

@ -1,12 +1,12 @@
define([
'../res/testDataItemTemplate.html',
'./input/ObjectSelect',
'./input/KeySelect',
'./eventHelpers',
'../../../utils/template/templateHelpers',
'EventEmitter'
], function (itemTemplate, ObjectSelect, KeySelect, eventHelpers, templateHelpers, EventEmitter) {
/**
import EventEmitter from 'EventEmitter';
import * as templateHelpers from '../../../utils/template/templateHelpers';
import itemTemplate from '../res/testDataItemTemplate.html';
import eventHelpers from './eventHelpers';
import KeySelect from './input/KeySelect';
import ObjectSelect from './input/ObjectSelect';
/**
* An object representing a single mock telemetry value
* @param {object} itemConfig the configuration for this item, consisting of
* object, key, and value fields
@ -17,7 +17,7 @@ define([
* for populating selects with configuration data
* @constructor
*/
function TestDataItem(itemConfig, index, conditionManager) {
export default function TestDataItem(itemConfig, index, conditionManager) {
eventHelpers.extend(this);
this.config = itemConfig;
this.index = index;
@ -97,17 +97,17 @@ define([
self.domElement.querySelector('.t-configuration').append(select.getDOM());
});
this.listenTo(this.domElement, 'input', onValueInput);
}
}
/**
/**
* Gets the DOM associated with this element's view
* @return {Element}
*/
TestDataItem.prototype.getDOM = function (container) {
TestDataItem.prototype.getDOM = function (container) {
return this.domElement;
};
};
/**
/**
* Register a callback with this item: supported callbacks are remove, change,
* and duplicate
* @param {string} event The key for the event to listen to
@ -115,31 +115,31 @@ define([
* @param {Object} context A reference to a scope to use as the context for
* context for the callback function
*/
TestDataItem.prototype.on = function (event, callback, context) {
TestDataItem.prototype.on = function (event, callback, context) {
if (this.supportedCallbacks.includes(event)) {
this.eventEmitter.on(event, callback, context || this);
}
};
};
/**
/**
* Implement "off" to complete event emitter interface.
*/
TestDataItem.prototype.off = function (event, callback, context) {
TestDataItem.prototype.off = function (event, callback, context) {
this.eventEmitter.off(event, callback, context);
};
};
/**
/**
* Hide the appropriate inputs when this is the only item
*/
TestDataItem.prototype.hideButtons = function () {
TestDataItem.prototype.hideButtons = function () {
this.deleteButton.style.display = 'none';
};
};
/**
/**
* Remove this item from the configuration. Invokes any registered
* remove callbacks
*/
TestDataItem.prototype.remove = function () {
TestDataItem.prototype.remove = function () {
const self = this;
this.eventEmitter.emit('remove', self.index);
this.stopListening();
@ -147,13 +147,13 @@ define([
Object.values(this.selects).forEach(function (select) {
select.destroy();
});
};
};
/**
/**
* Makes a deep clone of this item's configuration, and invokes any registered
* duplicate callbacks with the cloned configuration as an argument
*/
TestDataItem.prototype.duplicate = function () {
TestDataItem.prototype.duplicate = function () {
const sourceItem = JSON.parse(JSON.stringify(this.config));
const self = this;
@ -161,14 +161,14 @@ define([
sourceItem: sourceItem,
index: self.index
});
};
};
/**
/**
* When a telemetry property key is selected, create the appropriate value input
* and add it to the view
* @param {string} key The key of currently selected telemetry property
*/
TestDataItem.prototype.generateValueInput = function (key) {
TestDataItem.prototype.generateValueInput = function (key) {
const evaluator = this.conditionManager.getEvaluator();
const inputArea = this.domElement.querySelector('.t-value-inputs');
const dataType = this.conditionManager.getTelemetryPropertyType(this.config.object, key);
@ -187,7 +187,4 @@ define([
this.valueInput = newInput;
inputArea.append(this.valueInput);
}
};
return TestDataItem;
});
};

View File

@ -1,18 +1,18 @@
define([
'./eventHelpers',
'../res/testDataTemplate.html',
'./TestDataItem',
'../../../utils/template/templateHelpers',
'lodash'
], function (eventHelpers, testDataTemplate, TestDataItem, templateHelpers, _) {
/**
import _ from 'lodash';
import * as templateHelpers from '../../../utils/template/templateHelpers';
import testDataTemplate from '../res/testDataTemplate.html';
import eventHelpers from './eventHelpers';
import TestDataItem from './TestDataItem';
/**
* Controls the input and usage of test data in the summary widget.
* @constructor
* @param {Object} domainObject The summary widget domain object
* @param {ConditionManager} conditionManager A conditionManager instance
* @param {MCT} openmct and MCT instance
*/
function TestDataManager(domainObject, conditionManager, openmct) {
export default function TestDataManager(domainObject, conditionManager, openmct) {
eventHelpers.extend(this);
const self = this;
@ -50,22 +50,22 @@ define([
this.evaluator.useTestData(false);
this.refreshItems();
}
}
/**
/**
* Get the DOM element representing this test data manager in the view
*/
TestDataManager.prototype.getDOM = function () {
TestDataManager.prototype.getDOM = function () {
return this.domElement;
};
};
/**
/**
* Initialize a new test data item, either from a source configuration, or with
* the default empty configuration
* @param {Object} [config] An object with sourceItem and index fields to instantiate
* this rule from, optional
*/
TestDataManager.prototype.initItem = function (config) {
TestDataManager.prototype.initItem = function (config) {
const sourceIndex = config && config.index;
const defaultItem = {
object: '',
@ -83,47 +83,47 @@ define([
this.updateDomainObject();
this.refreshItems();
};
};
/**
/**
* Remove an item from this TestDataManager at the given index
* @param {number} removeIndex The index of the item to remove
*/
TestDataManager.prototype.removeItem = function (removeIndex) {
TestDataManager.prototype.removeItem = function (removeIndex) {
_.remove(this.config, function (item, index) {
return index === removeIndex;
});
this.updateDomainObject();
this.refreshItems();
};
};
/**
/**
* Change event handler for the test data items which compose this
* test data generator
* @param {Object} event An object representing this event, with value, property,
* and index fields
*/
TestDataManager.prototype.onItemChange = function (event) {
TestDataManager.prototype.onItemChange = function (event) {
this.config[event.index][event.property] = event.value;
this.updateDomainObject();
this.updateTestCache();
};
};
/**
/**
* Builds the test cache from the current item configuration, and passes
* the new test cache to the associated {ConditionEvaluator} instance
*/
TestDataManager.prototype.updateTestCache = function () {
TestDataManager.prototype.updateTestCache = function () {
this.generateTestCache();
this.evaluator.setTestDataCache(this.testCache);
this.manager.triggerTelemetryCallback();
};
};
/**
/**
* Instantiate {TestDataItem} objects from the current configuration, and
* update the view accordingly
*/
TestDataManager.prototype.refreshItems = function () {
TestDataManager.prototype.refreshItems = function () {
const self = this;
if (this.items) {
this.items.forEach(function (item) {
@ -154,13 +154,13 @@ define([
}
this.updateTestCache();
};
};
/**
/**
* Builds a test data cache in the format of a telemetry subscription cache
* as expected by a {ConditionEvaluator}
*/
TestDataManager.prototype.generateTestCache = function () {
TestDataManager.prototype.generateTestCache = function () {
let testCache = this.testCache;
const manager = this.manager;
const compositionObjs = manager.getComposition();
@ -181,21 +181,18 @@ define([
});
this.testCache = testCache;
};
};
/**
/**
* Update the domain object configuration associated with this test data manager
*/
TestDataManager.prototype.updateDomainObject = function () {
TestDataManager.prototype.updateDomainObject = function () {
this.openmct.objects.mutate(this.domainObject, 'configuration.testDataConfig', this.config);
};
};
TestDataManager.prototype.destroy = function () {
TestDataManager.prototype.destroy = function () {
this.stopListening();
this.items.forEach(function (item) {
item.remove();
});
};
return TestDataManager;
});
};

View File

@ -1,15 +1,15 @@
define([
'../res/ruleImageTemplate.html',
'EventEmitter',
'../../../utils/template/templateHelpers'
], function (ruleImageTemplate, EventEmitter, templateHelpers) {
/**
import EventEmitter from 'EventEmitter';
import * as templateHelpers from '../../../utils/template/templateHelpers';
import ruleImageTemplate from '../res/ruleImageTemplate.html';
/**
* Manages the Sortable List interface for reordering rules by drag and drop
* @param {Element} container The DOM element that contains this Summary Widget's view
* @param {string[]} ruleOrder An array of rule IDs representing the current rule order
* @param {Object} rulesById An object mapping rule IDs to rule configurations
*/
function WidgetDnD(container, ruleOrder, rulesById) {
export default function WidgetDnD(container, ruleOrder, rulesById) {
this.container = container;
this.ruleOrder = ruleOrder;
this.rulesById = rulesById;
@ -28,44 +28,44 @@ define([
document.addEventListener('mouseup', this.drop);
this.container.parentNode.insertBefore(this.imageContainer, this.container);
this.imageContainer.style.display = 'none';
}
}
/**
/**
* Remove event listeners registered to elements external to the widget
*/
WidgetDnD.prototype.destroy = function () {
WidgetDnD.prototype.destroy = function () {
this.container.removeEventListener('mousemove', this.drag);
document.removeEventListener('mouseup', this.drop);
};
};
/**
/**
* Register a callback with this WidgetDnD: supported callback is drop
* @param {string} event The key for the event to listen to
* @param {function} callback The function that this rule will invoke on this event
* @param {Object} context A reference to a scope to use as the context for
* context for the callback function
*/
WidgetDnD.prototype.on = function (event, callback, context) {
WidgetDnD.prototype.on = function (event, callback, context) {
if (this.supportedCallbacks.includes(event)) {
this.eventEmitter.on(event, callback, context || this);
}
};
};
/**
/**
* Sets the image for the dragged element to the given DOM element
* @param {Element} image The HTML element to set as the drap image
*/
WidgetDnD.prototype.setDragImage = function (image) {
WidgetDnD.prototype.setDragImage = function (image) {
this.image.html(image);
};
};
/**
/**
* Calculate where this rule has been dragged relative to the other rules
* @param {Event} event The mousemove or mouseup event that triggered this
event handler
* @return {string} The ID of the rule whose drag indicator should be displayed
*/
WidgetDnD.prototype.getDropLocation = function (event) {
WidgetDnD.prototype.getDropLocation = function (event) {
const ruleOrder = this.ruleOrder;
const rulesById = this.rulesById;
const draggingId = this.draggingId;
@ -96,13 +96,13 @@ define([
});
return target;
};
};
/**
/**
* Called by a {Rule} instance that initiates a drag gesture
* @param {string} ruleId The identifier of the rule which is being dragged
*/
WidgetDnD.prototype.dragStart = function (ruleId) {
WidgetDnD.prototype.dragStart = function (ruleId) {
const ruleOrder = this.ruleOrder;
this.draggingId = ruleId;
this.draggingRulePrevious = ruleOrder[ruleOrder.indexOf(ruleId) - 1];
@ -112,13 +112,13 @@ define([
top: event.pageY - this.image.height() / 2,
left: event.pageX - this.image.querySelector('.t-grippy').style.width
});
};
};
/**
/**
* An event handler for a mousemove event, once a rule has begun a drag gesture
* @param {Event} event The mousemove event that triggered this callback
*/
WidgetDnD.prototype.drag = function (event) {
WidgetDnD.prototype.drag = function (event) {
let dragTarget;
if (this.draggingId && this.draggingId !== '') {
event.preventDefault();
@ -133,16 +133,16 @@ define([
this.rulesById[this.draggingRulePrevious].showDragIndicator();
}
}
};
};
/**
/**
* Handles the mouseup event that corresponds to the user dropping the rule
* in its final location. Invokes any registered drop callbacks with the dragged
* rule's ID and the ID of the target rule that the dragged rule should be
* inserted after
* @param {Event} event The mouseup event that triggered this callback
*/
WidgetDnD.prototype.drop = function (event) {
WidgetDnD.prototype.drop = function (event) {
let dropTarget = this.getDropLocation(event);
const draggingId = this.draggingId;
@ -159,7 +159,4 @@ define([
this.draggingRulePrevious = '';
this.imageContainer.hide();
}
};
return WidgetDnD;
});
};

View File

@ -20,9 +20,8 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
define([], function () {
const helperFunctions = {
listenTo: function (object, event, callback, context) {
const helperFunctions = {
listenTo(object, event, callback, context) {
if (!this._listeningTo) {
this._listeningTo = [];
}
@ -48,7 +47,7 @@ define([], function () {
this._listeningTo.push(listener);
},
stopListening: function (object, event, callback, context) {
stopListening(object, event, callback, context) {
if (!this._listeningTo) {
this._listeningTo = [];
}
@ -93,7 +92,6 @@ define([], function () {
object.listenTo = helperFunctions.listenTo;
object.stopListening = helperFunctions.stopListening;
}
};
};
return helperFunctions;
});
export default helperFunctions;

View File

@ -1,6 +1,7 @@
define(['./Palette'], function (Palette) {
//The colors that will be used to instantiate this palette if none are provided
const DEFAULT_COLORS = [
import Palette from './Palette';
// The colors that will be used to instantiate this palette if none are provided
const DEFAULT_COLORS = [
'#000000',
'#434343',
'#666666',
@ -81,9 +82,9 @@ define(['./Palette'], function (Palette) {
'#073763',
'#20124d',
'#4c1130'
];
];
/**
/**
* Instantiates a new Open MCT Color Palette input
* @constructor
* @param {string} cssClass The class name of the icon which should be applied
@ -91,7 +92,7 @@ define(['./Palette'], function (Palette) {
* @param {Element} container The view that contains this palette
* @param {string[]} colors (optional) A list of colors that should be used to instantiate this palette
*/
function ColorPalette(cssClass, container, colors) {
export default function ColorPalette(cssClass, container, colors) {
this.colors = colors || DEFAULT_COLORS;
this.palette = new Palette(cssClass, container, this.colors);
@ -122,7 +123,4 @@ define(['./Palette'], function (Palette) {
this.palette.on('change', updateSwatch);
return this.palette;
}
return ColorPalette;
});
}

View File

@ -1,6 +1,7 @@
define(['./Palette'], function (Palette) {
//The icons that will be used to instantiate this palette if none are provided
const DEFAULT_ICONS = [
import Palette from './Palette';
//The icons that will be used to instantiate this palette if none are provided
const DEFAULT_ICONS = [
'icon-alert-rect',
'icon-alert-triangle',
'icon-arrow-down',
@ -25,9 +26,9 @@ define(['./Palette'], function (Palette) {
'icon-plus',
'icon-trash',
'icon-x'
];
];
/**
/**
* Instantiates a new Open MCT Icon Palette input
* @constructor
* @param {string} cssClass The class name of the icon which should be applied
@ -35,7 +36,7 @@ define(['./Palette'], function (Palette) {
* @param {Element} container The view that contains this palette
* @param {string[]} icons (optional) A list of icons that should be used to instantiate this palette
*/
function IconPalette(cssClass, container, icons) {
export default function IconPalette(cssClass, container, icons) {
this.icons = icons || DEFAULT_ICONS;
this.palette = new Palette(cssClass, container, this.icons);
@ -71,7 +72,4 @@ define(['./Palette'], function (Palette) {
this.palette.on('change', updateSwatch);
return this.palette;
}
return IconPalette;
});
}

View File

@ -1,5 +1,6 @@
define(['./Select'], function (Select) {
/**
import Select from './Select';
/**
* Create a {Select} element whose composition is dynamically updated with
* the telemetry fields of a particular domain object
* @constructor
@ -13,9 +14,9 @@ define(['./Select'], function (Select) {
* @param {function} changeCallback A change event callback to register with this
* select on initialization
*/
const NULLVALUE = '- Select Field -';
const NULLVALUE = '- Select Field -';
function KeySelect(config, objectSelect, manager, changeCallback) {
export default function KeySelect(config, objectSelect, manager, changeCallback) {
const self = this;
this.config = config;
@ -68,12 +69,12 @@ define(['./Select'], function (Select) {
this.manager.on('metadata', onMetadataLoad);
return this.select;
}
}
/**
/**
* Populate this select with options based on its current composition
*/
KeySelect.prototype.generateOptions = function () {
KeySelect.prototype.generateOptions = function () {
const items = Object.entries(this.telemetryMetadata).map(function (metaDatum) {
return [metaDatum[0], metaDatum[1].name];
});
@ -85,11 +86,8 @@ define(['./Select'], function (Select) {
} else if (this.select.options.length > 1) {
this.select.show();
}
};
};
KeySelect.prototype.destroy = function () {
KeySelect.prototype.destroy = function () {
this.objectSelect.destroy();
};
return KeySelect;
});
};

View File

@ -1,5 +1,8 @@
define(['./Select', 'objectUtils'], function (Select, objectUtils) {
/**
import objectUtils from 'objectUtils';
import Select from './Select';
/**
* Create a {Select} element whose composition is dynamically updated with
* the current composition of the Summary Widget
* @constructor
@ -10,7 +13,7 @@ define(['./Select', 'objectUtils'], function (Select, objectUtils) {
* @param {string[][]} baseOptions A set of [value, label] keyword pairs to
* display regardless of the composition state
*/
function ObjectSelect(config, manager, baseOptions) {
export default function ObjectSelect(config, manager, baseOptions) {
const self = this;
this.config = config;
@ -67,12 +70,12 @@ define(['./Select', 'objectUtils'], function (Select, objectUtils) {
}
return this.select;
}
}
/**
/**
* Populate this select with options based on its current composition
*/
ObjectSelect.prototype.generateOptions = function () {
ObjectSelect.prototype.generateOptions = function () {
const items = Object.values(this.compositionObjs).map(function (obj) {
return [objectUtils.makeKeyString(obj.identifier), obj.name];
});
@ -80,7 +83,4 @@ define(['./Select', 'objectUtils'], function (Select, objectUtils) {
items.splice(index, 0, option);
});
this.select.setOptions(items);
};
return ObjectSelect;
});
};

View File

@ -1,5 +1,7 @@
define(['./Select', '../eventHelpers'], function (Select, eventHelpers) {
/**
import eventHelpers from '../eventHelpers';
import Select from './Select';
/**
* Create a {Select} element whose composition is dynamically updated with
* the operations applying to a particular telemetry property
* @constructor
@ -13,9 +15,9 @@ define(['./Select', '../eventHelpers'], function (Select, eventHelpers) {
* @param {function} changeCallback A change event callback to register with this
* select on initialization
*/
const NULLVALUE = '- Select Comparison -';
const NULLVALUE = '- Select Comparison -';
function OperationSelect(config, keySelect, manager, changeCallback) {
export default function OperationSelect(config, keySelect, manager, changeCallback) {
eventHelpers.extend(this);
const self = this;
@ -73,12 +75,12 @@ define(['./Select', '../eventHelpers'], function (Select, eventHelpers) {
}
return this.select;
}
}
/**
/**
* Populate this select with options based on its current composition
*/
OperationSelect.prototype.generateOptions = function () {
OperationSelect.prototype.generateOptions = function () {
const self = this;
const items = this.operationKeys.map(function (operation) {
return [operation, self.evaluator.getOperationText(operation)];
@ -91,14 +93,14 @@ define(['./Select', '../eventHelpers'], function (Select, eventHelpers) {
} else {
this.select.show();
}
};
};
/**
/**
* Retrieve the data type associated with a given telemetry property and
* the applicable operations from the {ConditionEvaluator}
* @param {string} key The telemetry property to load operations for
*/
OperationSelect.prototype.loadOptions = function (key) {
OperationSelect.prototype.loadOptions = function (key) {
const self = this;
const operations = self.evaluator.getOperationKeys();
let type;
@ -110,11 +112,8 @@ define(['./Select', '../eventHelpers'], function (Select, eventHelpers) {
return self.evaluator.operationAppliesTo(operation, type);
});
}
};
};
OperationSelect.prototype.destroy = function () {
OperationSelect.prototype.destroy = function () {
this.stopListening();
};
return OperationSelect;
});
};

View File

@ -1,10 +1,10 @@
define([
'../eventHelpers',
'../../res/input/paletteTemplate.html',
'../../../../utils/template/templateHelpers',
'EventEmitter'
], function (eventHelpers, paletteTemplate, templateHelpers, EventEmitter) {
/**
import EventEmitter from 'EventEmitter';
import * as templateHelpers from '../../../../utils/template/templateHelpers';
import paletteTemplate from '../../res/input/paletteTemplate.html';
import eventHelpers from '../eventHelpers';
/**
* Instantiates a new Open MCT Color Palette input
* @constructor
* @param {string} cssClass The class name of the icon which should be applied
@ -14,7 +14,7 @@ define([
* palette item in the view; how this data is represented is
* up to the descendent class
*/
function Palette(cssClass, container, items) {
export default function Palette(cssClass, container, items) {
eventHelpers.extend(this);
const self = this;
@ -77,56 +77,56 @@ define([
self.domElement.querySelectorAll('.c-palette__item').forEach((item) => {
this.listenTo(item, 'click', handleItemClick);
});
}
}
/**
/**
* Get the DOM element representing this palette in the view
*/
Palette.prototype.getDOM = function () {
Palette.prototype.getDOM = function () {
return this.domElement;
};
};
/**
/**
* Clean up any event listeners registered to DOM elements external to the widget
*/
Palette.prototype.destroy = function () {
Palette.prototype.destroy = function () {
this.stopListening();
};
};
Palette.prototype.hideMenu = function () {
Palette.prototype.hideMenu = function () {
this.domElement.querySelector('.c-menu').style.display = 'none';
};
};
/**
/**
* Register a callback with this palette: supported callback is change
* @param {string} event The key for the event to listen to
* @param {function} callback The function that this rule will invoke on this event
* @param {Object} context A reference to a scope to use as the context for
* context for the callback function
*/
Palette.prototype.on = function (event, callback, context) {
Palette.prototype.on = function (event, callback, context) {
if (this.supportedCallbacks.includes(event)) {
this.eventEmitter.on(event, callback, context || this);
} else {
throw new Error('Unsupported event type: ' + event);
}
};
};
/**
/**
* Get the currently selected value of this palette
* @return {string} The selected value
*/
Palette.prototype.getCurrent = function () {
Palette.prototype.getCurrent = function () {
return this.value;
};
};
/**
/**
* Set the selected value of this palette; if the item doesn't exist in the
* palette's data model, the selected value will not change. Invokes any
* change callbacks associated with this palette.
* @param {string} item The key of the item to set as selected
*/
Palette.prototype.set = function (item) {
Palette.prototype.set = function (item) {
const self = this;
if (this.items.includes(item) || item === this.nullOption) {
this.value = item;
@ -138,12 +138,12 @@ define([
}
this.eventEmitter.emit('change', self.value);
};
};
/**
/**
* Update the view associated with the currently selected item
*/
Palette.prototype.updateSelected = function (item) {
Palette.prototype.updateSelected = function (item) {
this.domElement.querySelectorAll('.c-palette__item').forEach((paletteItem) => {
if (paletteItem.classList.contains('is-selected')) {
paletteItem.classList.remove('is-selected');
@ -155,22 +155,22 @@ define([
} else {
this.domElement.querySelector('.t-swatch').classList.remove('no-selection');
}
};
};
/**
/**
* set the property to be used for the 'no selection' item. If not set, this
* defaults to a single space
* @param {string} item The key to use as the 'no selection' item
*/
Palette.prototype.setNullOption = function (item) {
Palette.prototype.setNullOption = function (item) {
this.nullOption = item;
this.itemElements.nullOption.data = { item: item };
};
};
/**
/**
* Hides the 'no selection' option to be hidden in the view if it doesn't apply
*/
Palette.prototype.toggleNullOption = function () {
Palette.prototype.toggleNullOption = function () {
const elem = this.domElement.querySelector('.c-palette__item-none');
if (elem.style.display === 'none') {
@ -178,7 +178,4 @@ define([
} else {
this.domElement.querySelector('.c-palette__item-none').style.display = 'none';
}
};
return Palette;
});
};

View File

@ -1,15 +1,15 @@
define([
'../eventHelpers',
'../../res/input/selectTemplate.html',
'../../../../utils/template/templateHelpers',
'EventEmitter'
], function (eventHelpers, selectTemplate, templateHelpers, EventEmitter) {
/**
import EventEmitter from 'EventEmitter';
import * as templateHelpers from '../../../../utils/template/templateHelpers';
import selectTemplate from '../../res/input/selectTemplate.html';
import eventHelpers from '../eventHelpers';
/**
* Wraps an HTML select element, and provides methods for dynamically altering
* its composition from the data model
* @constructor
*/
function Select() {
export default function Select() {
eventHelpers.extend(this);
const self = this;
@ -36,50 +36,50 @@ define([
}
this.listenTo(this.domElement.querySelector('select'), 'change', onChange, this);
}
}
/**
/**
* Get the DOM element representing this Select in the view
* @return {Element}
*/
Select.prototype.getDOM = function () {
Select.prototype.getDOM = function () {
return this.domElement;
};
};
/**
/**
* Register a callback with this select: supported callback is change
* @param {string} event The key for the event to listen to
* @param {function} callback The function that this rule will invoke on this event
* @param {Object} context A reference to a scope to use as the context for
* context for the callback function
*/
Select.prototype.on = function (event, callback, context) {
Select.prototype.on = function (event, callback, context) {
if (this.supportedCallbacks.includes(event)) {
this.eventEmitter.on(event, callback, context || this);
} else {
throw new Error('Unsupported event type' + event);
}
};
};
/**
/**
* Unregister a callback from this select.
* @param {string} event The key for the event to stop listening to
* @param {function} callback The function to unregister
* @param {Object} context A reference to a scope to use as the context for the callback function
*/
Select.prototype.off = function (event, callback, context) {
Select.prototype.off = function (event, callback, context) {
if (this.supportedCallbacks.includes(event)) {
this.eventEmitter.off(event, callback, context || this);
} else {
throw new Error('Unsupported event type: ' + event);
}
};
};
/**
/**
* Update the select element in the view from the current state of the data
* model
*/
Select.prototype.populate = function () {
Select.prototype.populate = function () {
const self = this;
let selectedIndex = 0;
@ -96,34 +96,34 @@ define([
});
this.domElement.querySelector('select').selectedIndex = selectedIndex;
};
};
/**
/**
* Add a single option to this select
* @param {string} value The value for the new option
* @param {string} label The human-readable text for the new option
*/
Select.prototype.addOption = function (value, label) {
Select.prototype.addOption = function (value, label) {
this.options.push([value, label]);
this.populate();
};
};
/**
/**
* Set the available options for this select. Replaces any existing options
* @param {string[][]} options An array of [value, label] pairs to display
*/
Select.prototype.setOptions = function (options) {
Select.prototype.setOptions = function (options) {
this.options = options;
this.populate();
};
};
/**
/**
* Sets the currently selected element an invokes any registered change
* callbacks with the new value. If the value doesn't exist in this select's
* model, its state will not change.
* @param {string} value The value to set as the selected option
*/
Select.prototype.setSelected = function (value) {
Select.prototype.setSelected = function (value) {
let selectedIndex = 0;
let selectedOption;
@ -136,33 +136,30 @@ define([
selectedOption = this.options[selectedIndex];
this.eventEmitter.emit('change', selectedOption[0]);
};
};
/**
/**
* Get the value of the currently selected item
* @return {string}
*/
Select.prototype.getSelected = function () {
Select.prototype.getSelected = function () {
return this.domElement.querySelector('select').value;
};
};
Select.prototype.hide = function () {
Select.prototype.hide = function () {
this.domElement.classList.add('hidden');
if (this.domElement.querySelector('.equal-to')) {
this.domElement.querySelector('.equal-to').classList.add('hidden');
}
};
};
Select.prototype.show = function () {
Select.prototype.show = function () {
this.domElement.classList.remove('hidden');
if (this.domElement.querySelector('.equal-to')) {
this.domElement.querySelector('.equal-to').classList.remove('hidden');
}
};
};
Select.prototype.destroy = function () {
Select.prototype.destroy = function () {
this.stopListening();
};
return Select;
});
};

View File

@ -20,14 +20,17 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
define(['./SummaryWidgetEvaluator', 'objectUtils'], function (SummaryWidgetEvaluator, objectUtils) {
function EvaluatorPool(openmct) {
import objectUtils from 'objectUtils';
import SummaryWidgetEvaluator from './SummaryWidgetEvaluator';
export default function EvaluatorPool(openmct) {
this.openmct = openmct;
this.byObjectId = {};
this.byEvaluator = new WeakMap();
}
}
EvaluatorPool.prototype.get = function (domainObject) {
EvaluatorPool.prototype.get = function (domainObject) {
const objectId = objectUtils.makeKeyString(domainObject.identifier);
let poolEntry = this.byObjectId[objectId];
if (!poolEntry) {
@ -43,9 +46,9 @@ define(['./SummaryWidgetEvaluator', 'objectUtils'], function (SummaryWidgetEvalu
poolEntry.leases += 1;
return poolEntry.evaluator;
};
};
EvaluatorPool.prototype.release = function (evaluator) {
EvaluatorPool.prototype.release = function (evaluator) {
const poolEntry = this.byEvaluator.get(evaluator);
poolEntry.leases -= 1;
if (poolEntry.leases === 0) {
@ -53,7 +56,4 @@ define(['./SummaryWidgetEvaluator', 'objectUtils'], function (SummaryWidgetEvalu
this.byEvaluator.delete(evaluator);
delete this.byObjectId[poolEntry.objectId];
}
};
return EvaluatorPool;
});
};

View File

@ -20,11 +20,9 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
define(['./EvaluatorPool', './SummaryWidgetEvaluator'], function (
EvaluatorPool,
SummaryWidgetEvaluator
) {
describe('EvaluatorPool', function () {
import EvaluatorPool from './EvaluatorPool';
describe('EvaluatorPool', function () {
let pool;
let openmct;
let objectA;
@ -93,5 +91,4 @@ define(['./EvaluatorPool', './SummaryWidgetEvaluator'], function (
const evaluatorC = pool.get(objectA);
expect(evaluatorA).not.toBe(evaluatorC);
});
});
});

View File

@ -20,8 +20,9 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
define(['./operations'], function (OPERATIONS) {
function SummaryWidgetCondition(definition) {
import OPERATIONS from './operations';
export default function SummaryWidgetCondition(definition) {
this.object = definition.object;
this.key = definition.key;
this.values = definition.values;
@ -33,9 +34,9 @@ define(['./operations'], function (OPERATIONS) {
} else {
this.comparator = OPERATIONS[definition.operation].operation;
}
}
}
SummaryWidgetCondition.prototype.evaluate = function (telemetryState) {
SummaryWidgetCondition.prototype.evaluate = function (telemetryState) {
const stateKeys = Object.keys(telemetryState);
let state;
let result;
@ -64,13 +65,10 @@ define(['./operations'], function (OPERATIONS) {
} else {
return this.evaluateState(telemetryState[this.object]);
}
};
};
SummaryWidgetCondition.prototype.evaluateState = function (state) {
SummaryWidgetCondition.prototype.evaluateState = function (state) {
const testValues = [state.formats[this.key].parse(state.lastDatum)].concat(this.values);
return this.comparator(testValues);
};
return SummaryWidgetCondition;
});
};

View File

@ -20,8 +20,9 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
define(['./SummaryWidgetCondition'], function (SummaryWidgetCondition) {
describe('SummaryWidgetCondition', function () {
import SummaryWidgetCondition from './SummaryWidgetCondition';
describe('SummaryWidgetCondition', function () {
let condition;
let telemetryState;
@ -121,5 +122,4 @@ define(['./SummaryWidgetCondition'], function (SummaryWidgetCondition) {
telemetryState.otherObjectId.lastDatum.value = 15;
expect(condition.evaluate(telemetryState)).toBe(true);
});
});
});

View File

@ -20,18 +20,18 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
define(['./SummaryWidgetRule', '../eventHelpers', 'objectUtils', 'lodash'], function (
SummaryWidgetRule,
eventHelpers,
objectUtils,
_
) {
/**
import _ from 'lodash';
import objectUtils from 'objectUtils';
import eventHelpers from '../eventHelpers';
import SummaryWidgetRule from './SummaryWidgetRule';
/**
* evaluates rules defined in a summary widget against either lad or
* realtime state.
*
*/
function SummaryWidgetEvaluator(domainObject, openmct) {
export default function SummaryWidgetEvaluator(domainObject, openmct) {
this.openmct = openmct;
this.baseState = {};
@ -44,14 +44,14 @@ define(['./SummaryWidgetRule', '../eventHelpers', 'objectUtils', 'lodash'], func
this.listenTo(composition, 'remove', this.removeChild, this);
this.loadPromise = composition.load();
}
}
eventHelpers.extend(SummaryWidgetEvaluator.prototype);
eventHelpers.extend(SummaryWidgetEvaluator.prototype);
/**
/**
* Subscribes to realtime telemetry for the given summary widget.
*/
SummaryWidgetEvaluator.prototype.subscribe = function (callback) {
SummaryWidgetEvaluator.prototype.subscribe = function (callback) {
let active = true;
let unsubscribes = [];
@ -69,10 +69,7 @@ define(['./SummaryWidgetRule', '../eventHelpers', 'objectUtils', 'lodash'], func
}.bind(this);
/* eslint-disable you-dont-need-lodash-underscore/map */
unsubscribes = _.map(
realtimeStates,
this.subscribeToObjectState.bind(this, updateCallback)
);
unsubscribes = _.map(realtimeStates, this.subscribeToObjectState.bind(this, updateCallback));
/* eslint-enable you-dont-need-lodash-underscore/map */
}.bind(this)
);
@ -83,13 +80,13 @@ define(['./SummaryWidgetRule', '../eventHelpers', 'objectUtils', 'lodash'], func
unsubscribe();
});
};
};
};
/**
/**
* Returns a promise for a telemetry datum obtained by evaluating the
* current lad data.
*/
SummaryWidgetEvaluator.prototype.requestLatest = function (options) {
SummaryWidgetEvaluator.prototype.requestLatest = function (options) {
return this.getBaseStateClone()
.then(
function (ladState) {
@ -107,15 +104,15 @@ define(['./SummaryWidgetRule', '../eventHelpers', 'objectUtils', 'lodash'], func
return this.evaluateState(ladStates, options.domain);
}.bind(this)
);
};
};
SummaryWidgetEvaluator.prototype.updateRules = function (domainObject) {
SummaryWidgetEvaluator.prototype.updateRules = function (domainObject) {
this.rules = domainObject.configuration.ruleOrder.map(function (ruleId) {
return new SummaryWidgetRule(domainObject.configuration.ruleConfigById[ruleId]);
});
};
};
SummaryWidgetEvaluator.prototype.addChild = function (childObject) {
SummaryWidgetEvaluator.prototype.addChild = function (childObject) {
const childId = objectUtils.makeKeyString(childObject.identifier);
const metadata = this.openmct.telemetry.getMetadata(childObject);
const formats = this.openmct.telemetry.getFormatMap(metadata);
@ -126,24 +123,24 @@ define(['./SummaryWidgetRule', '../eventHelpers', 'objectUtils', 'lodash'], func
metadata: metadata,
formats: formats
};
};
};
SummaryWidgetEvaluator.prototype.removeChild = function (childObject) {
SummaryWidgetEvaluator.prototype.removeChild = function (childObject) {
const childId = objectUtils.makeKeyString(childObject.identifier);
delete this.baseState[childId];
};
};
SummaryWidgetEvaluator.prototype.load = function () {
SummaryWidgetEvaluator.prototype.load = function () {
return this.loadPromise;
};
};
/**
/**
* Return a promise for a 2-deep clone of the base state object: object
* states are shallow cloned, and then assembled and returned as a new base
* state. Allows object states to be mutated while sharing telemetry
* metadata and formats.
*/
SummaryWidgetEvaluator.prototype.getBaseStateClone = function () {
SummaryWidgetEvaluator.prototype.getBaseStateClone = function () {
return this.load().then(
function () {
/* eslint-disable you-dont-need-lodash-underscore/values */
@ -151,15 +148,15 @@ define(['./SummaryWidgetRule', '../eventHelpers', 'objectUtils', 'lodash'], func
/* eslint-enable you-dont-need-lodash-underscore/values */
}.bind(this)
);
};
};
/**
/**
* Subscribes to realtime updates for a given objectState, and invokes
* the supplied callback when objectState has been updated. Returns
* a function to unsubscribe.
* @private.
*/
SummaryWidgetEvaluator.prototype.subscribeToObjectState = function (callback, objectState) {
SummaryWidgetEvaluator.prototype.subscribeToObjectState = function (callback, objectState) {
return this.openmct.telemetry.subscribe(
objectState.domainObject,
function (datum) {
@ -168,14 +165,14 @@ define(['./SummaryWidgetRule', '../eventHelpers', 'objectUtils', 'lodash'], func
callback();
}.bind(this)
);
};
};
/**
/**
* Given an object state, will return a promise that is resolved when the
* object state has been updated from the LAD.
* @private.
*/
SummaryWidgetEvaluator.prototype.updateObjectStateFromLAD = function (options, objectState) {
SummaryWidgetEvaluator.prototype.updateObjectStateFromLAD = function (options, objectState) {
options = Object.assign({}, options, {
strategy: 'latest',
size: 1
@ -187,28 +184,27 @@ define(['./SummaryWidgetRule', '../eventHelpers', 'objectUtils', 'lodash'], func
objectState.timestamps = this.getTimestamps(objectState.id, objectState.lastDatum);
}.bind(this)
);
};
};
/**
/**
* Returns an object containing all domain values in a datum.
* @private.
*/
SummaryWidgetEvaluator.prototype.getTimestamps = function (childId, datum) {
SummaryWidgetEvaluator.prototype.getTimestamps = function (childId, datum) {
const timestampedDatum = {};
this.openmct.time.getAllTimeSystems().forEach(function (timeSystem) {
timestampedDatum[timeSystem.key] =
this.baseState[childId].formats[timeSystem.key].parse(datum);
timestampedDatum[timeSystem.key] = this.baseState[childId].formats[timeSystem.key].parse(datum);
}, this);
return timestampedDatum;
};
};
/**
/**
* Given a base datum(containing timestamps) and rule index, adds values
* from the matching rule.
* @private
*/
SummaryWidgetEvaluator.prototype.makeDatumFromRule = function (ruleIndex, baseDatum) {
SummaryWidgetEvaluator.prototype.makeDatumFromRule = function (ruleIndex, baseDatum) {
const rule = this.rules[ruleIndex];
baseDatum.ruleLabel = rule.label;
@ -221,16 +217,16 @@ define(['./SummaryWidgetRule', '../eventHelpers', 'objectUtils', 'lodash'], func
baseDatum.icon = rule.icon;
return baseDatum;
};
};
/**
/**
* Evaluate a `state` object and return a summary widget telemetry datum.
* Datum timestamps will be taken from the "latest" datum in the `state`
* where "latest" is the datum with the largest value for the given
* `timestampKey`.
* @private.
*/
SummaryWidgetEvaluator.prototype.evaluateState = function (state, timestampKey) {
SummaryWidgetEvaluator.prototype.evaluateState = function (state, timestampKey) {
const hasRequiredData = Object.keys(state).reduce(function (itDoes, k) {
return itDoes && state[k].lastDatum;
}, true);
@ -256,15 +252,12 @@ define(['./SummaryWidgetRule', '../eventHelpers', 'objectUtils', 'lodash'], func
const baseDatum = _.clone(latestTimestamp);
return this.makeDatumFromRule(i, baseDatum);
};
};
/**
/**
* remove all listeners and clean up any resources.
*/
SummaryWidgetEvaluator.prototype.destroy = function () {
SummaryWidgetEvaluator.prototype.destroy = function () {
this.stopListening();
this.removeObserver();
};
return SummaryWidgetEvaluator;
});
};

View File

@ -20,16 +20,15 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
define([], function () {
function SummaryWidgetMetadataProvider(openmct) {
export default function SummaryWidgetMetadataProvider(openmct) {
this.openmct = openmct;
}
}
SummaryWidgetMetadataProvider.prototype.supportsMetadata = function (domainObject) {
SummaryWidgetMetadataProvider.prototype.supportsMetadata = function (domainObject) {
return domainObject.type === 'summary-widget';
};
};
SummaryWidgetMetadataProvider.prototype.getDomains = function (domainObject) {
SummaryWidgetMetadataProvider.prototype.getDomains = function (domainObject) {
return this.openmct.time.getAllTimeSystems().map(function (ts, i) {
return {
key: ts.key,
@ -40,9 +39,9 @@ define([], function () {
}
};
});
};
};
SummaryWidgetMetadataProvider.prototype.getMetadata = function (domainObject) {
SummaryWidgetMetadataProvider.prototype.getMetadata = function (domainObject) {
const ruleOrder = domainObject.configuration.ruleOrder || [];
const enumerations = ruleOrder
.filter(function (ruleId) {
@ -107,7 +106,4 @@ define([], function () {
};
return metadata;
};
return SummaryWidgetMetadataProvider;
});
};

View File

@ -20,8 +20,9 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
define(['./SummaryWidgetCondition'], function (SummaryWidgetCondition) {
function SummaryWidgetRule(definition) {
import SummaryWidgetCondition from './SummaryWidgetCondition';
export default function SummaryWidgetRule(definition) {
this.name = definition.name;
this.label = definition.label;
this.id = definition.id;
@ -33,13 +34,13 @@ define(['./SummaryWidgetCondition'], function (SummaryWidgetCondition) {
return new SummaryWidgetCondition(cDefinition);
});
this.trigger = definition.trigger;
}
}
/**
/**
* Evaluate the given rule against a telemetryState and return true if it
* matches.
*/
SummaryWidgetRule.prototype.evaluate = function (telemetryState) {
SummaryWidgetRule.prototype.evaluate = function (telemetryState) {
let i;
let result;
@ -64,7 +65,4 @@ define(['./SummaryWidgetCondition'], function (SummaryWidgetCondition) {
} else {
throw new Error('Invalid rule trigger: ' + this.trigger);
}
};
return SummaryWidgetRule;
});
};

View File

@ -20,8 +20,9 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
define(['./SummaryWidgetRule'], function (SummaryWidgetRule) {
describe('SummaryWidgetRule', function () {
import SummaryWidgetRule from './SummaryWidgetRule';
describe('SummaryWidgetRule', function () {
let rule;
let telemetryState;
@ -149,5 +150,4 @@ define(['./SummaryWidgetRule'], function (SummaryWidgetRule) {
telemetryState.otherObjectId.lastDatum.value = 25;
expect(rule.evaluate(telemetryState)).toBe(true);
});
});
});

View File

@ -20,16 +20,17 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
define(['./EvaluatorPool'], function (EvaluatorPool) {
function SummaryWidgetTelemetryProvider(openmct) {
import EvaluatorPool from './EvaluatorPool';
export default function SummaryWidgetTelemetryProvider(openmct) {
this.pool = new EvaluatorPool(openmct);
}
}
SummaryWidgetTelemetryProvider.prototype.supportsRequest = function (domainObject, options) {
SummaryWidgetTelemetryProvider.prototype.supportsRequest = function (domainObject, options) {
return domainObject.type === 'summary-widget';
};
};
SummaryWidgetTelemetryProvider.prototype.request = function (domainObject, options) {
SummaryWidgetTelemetryProvider.prototype.request = function (domainObject, options) {
if (options.strategy !== 'latest' && options.size !== 1) {
return Promise.resolve([]);
}
@ -43,13 +44,13 @@ define(['./EvaluatorPool'], function (EvaluatorPool) {
return latestDatum ? [latestDatum] : [];
}.bind(this)
);
};
};
SummaryWidgetTelemetryProvider.prototype.supportsSubscribe = function (domainObject) {
SummaryWidgetTelemetryProvider.prototype.supportsSubscribe = function (domainObject) {
return domainObject.type === 'summary-widget';
};
};
SummaryWidgetTelemetryProvider.prototype.subscribe = function (domainObject, callback) {
SummaryWidgetTelemetryProvider.prototype.subscribe = function (domainObject, callback) {
const evaluator = this.pool.get(domainObject);
const unsubscribe = evaluator.subscribe(callback);
@ -57,7 +58,4 @@ define(['./EvaluatorPool'], function (EvaluatorPool) {
this.pool.release(evaluator);
unsubscribe();
}.bind(this);
};
return SummaryWidgetTelemetryProvider;
});
};

View File

@ -20,8 +20,9 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
define(['./SummaryWidgetTelemetryProvider'], function (SummaryWidgetTelemetryProvider) {
xdescribe('SummaryWidgetTelemetryProvider', function () {
import SummaryWidgetTelemetryProvider from './SummaryWidgetTelemetryProvider';
xdescribe('SummaryWidgetTelemetryProvider', function () {
let telemObjectA;
let telemObjectB;
let summaryWidgetObject;
@ -459,5 +460,4 @@ define(['./SummaryWidgetTelemetryProvider'], function (SummaryWidgetTelemetryPro
]);
});
});
});
});

View File

@ -20,8 +20,7 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
define([], function () {
const OPERATIONS = {
const OPERATIONS = {
equalTo: {
operation: function (input) {
return input[0] === input[1];
@ -209,7 +208,6 @@ define([], function () {
return ' != ' + values[0];
}
}
};
};
return OPERATIONS;
});
export default OPERATIONS;

View File

@ -1,13 +1,30 @@
define(['../SummaryWidget', './SummaryWidgetView', 'objectUtils'], function (
SummaryWidgetEditView,
SummaryWidgetView,
objectUtils
) {
const DEFAULT_VIEW_PRIORITY = 100;
/**
/*****************************************************************************
* Open MCT, Copyright (c) 2014-2023, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
*/
function SummaryWidgetViewProvider(openmct) {
* 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.
*****************************************************************************/
import SummaryWidgetEditView from '../SummaryWidget';
import SummaryWidgetView from './SummaryWidgetView';
const DEFAULT_VIEW_PRIORITY = 100;
export default function SummaryWidgetViewProvider(openmct) {
return {
key: 'summary-widget-viewer',
name: 'Summary View',
@ -32,7 +49,4 @@ define(['../SummaryWidget', './SummaryWidgetView', 'objectUtils'], function (
}
}
};
}
return SummaryWidgetViewProvider;
});
}

View File

@ -1,5 +1,6 @@
define(['../src/ConditionEvaluator'], function (ConditionEvaluator) {
describe('A Summary Widget Rule Evaluator', function () {
import ConditionEvaluator from '../src/ConditionEvaluator';
describe('A Summary Widget Rule Evaluator', function () {
let evaluator;
let testEvaluator;
let testOperation;
@ -359,5 +360,4 @@ define(['../src/ConditionEvaluator'], function (ConditionEvaluator) {
expect(testEvaluator.getOperationDescription(key, [])).toBeDefined();
});
});
});
});

View File

@ -20,8 +20,9 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
define(['../src/ConditionManager'], function (ConditionManager) {
describe('A Summary Widget Condition Manager', function () {
import ConditionManager from '../src/ConditionManager';
describe('A Summary Widget Condition Manager', function () {
let conditionManager;
let mockDomainObject;
let mockCompObject1;
@ -180,12 +181,7 @@ define(['../src/ConditionManager'], function (ConditionManager) {
}
};
mockComposition = jasmine.createSpyObj('composition', [
'on',
'off',
'load',
'triggerCallback'
]);
mockComposition = jasmine.createSpyObj('composition', ['on', 'off', 'load', 'triggerCallback']);
mockComposition.on.and.callFake(function (event, callback, context) {
mockEventCallbacks[event] = callback.bind(context);
});
@ -439,5 +435,4 @@ define(['../src/ConditionManager'], function (ConditionManager) {
conditionManager.triggerTelemetryCallback();
expect(telemetryCallbackSpy).toHaveBeenCalled();
});
});
});

View File

@ -20,8 +20,9 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
define(['../src/Condition'], function (Condition) {
describe('A summary widget condition', function () {
import Condition from '../src/Condition';
describe('A summary widget condition', function () {
let testCondition;
let mockConfig;
let mockConditionManager;
@ -201,5 +202,4 @@ define(['../src/Condition'], function (Condition) {
index: 54
});
});
});
});

View File

@ -1,5 +1,28 @@
define(['../src/Rule'], function (Rule) {
describe('A Summary Widget Rule', function () {
/*****************************************************************************
* Open MCT, Copyright (c) 2014-2023, 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.
*****************************************************************************/
import Rule from '../src/Rule';
describe('A Summary Widget Rule', function () {
let mockRuleConfig;
let mockDomainObject;
let mockOpenMCT;
@ -289,5 +312,4 @@ define(['../src/Rule'], function (Rule) {
}
]);
});
});
});

View File

@ -20,8 +20,9 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
define(['../src/SummaryWidget'], function (SummaryWidget) {
describe('The Summary Widget', function () {
import SummaryWidget from '../src/SummaryWidget';
describe('The Summary Widget', function () {
let summaryWidget;
let mockDomainObject;
let mockOldDomainObject;
@ -188,5 +189,4 @@ define(['../src/SummaryWidget'], function (SummaryWidget) {
expect(widgetButton.href).toEqual('https://www.nasa.gov/');
expect(widgetButton.target).toEqual('_blank');
});
});
});

View File

@ -20,8 +20,9 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
define(['../SummaryWidgetViewPolicy'], function (SummaryWidgetViewPolicy) {
describe('SummaryWidgetViewPolicy', function () {
import SummaryWidgetViewPolicy from '../SummaryWidgetViewPolicy';
describe('SummaryWidgetViewPolicy', function () {
let policy;
let domainObject;
let view;
@ -54,5 +55,4 @@ define(['../SummaryWidgetViewPolicy'], function (SummaryWidgetViewPolicy) {
view.key = 'other view';
expect(policy.allow(view, domainObject)).toBe(false);
});
});
});

View File

@ -1,5 +1,6 @@
define(['../src/TestDataItem'], function (TestDataItem) {
describe('A summary widget test data item', function () {
import TestDataItem from '../src/TestDataItem';
describe('A summary widget test data item', function () {
let testDataItem;
let mockConfig;
let mockConditionManager;
@ -163,5 +164,4 @@ define(['../src/TestDataItem'], function (TestDataItem) {
index: 54
});
});
});
});

View File

@ -1,5 +1,6 @@
define(['../src/TestDataManager'], function (TestDataManager) {
describe('A Summary Widget Rule', function () {
import TestDataManager from '../src/TestDataManager';
describe('A Summary Widget Rule', function () {
let mockDomainObject;
let mockOpenMCT;
let mockConditionManager;
@ -118,9 +119,7 @@ define(['../src/TestDataManager'], function (TestDataManager) {
it('exposes a DOM element to represent itself in the view', function () {
mockContainer.append(testDataManager.getDOM());
expect(mockContainer.querySelectorAll('.t-widget-test-data-content').length).toBeGreaterThan(
0
);
expect(mockContainer.querySelectorAll('.t-widget-test-data-content').length).toBeGreaterThan(0);
});
it('generates a test cache in the format expected by a condition evaluator', function () {
@ -137,10 +136,7 @@ define(['../src/TestDataManager'], function (TestDataManager) {
});
});
it(
'updates its configuration on a item change and provides an updated' +
'cache to the evaluator',
function () {
it('updates its configuration on a item change and provides an updated cache to the evaluator', function () {
testDataManager.onItemChange({
value: 26,
property: 'value',
@ -157,8 +153,7 @@ define(['../src/TestDataManager'], function (TestDataManager) {
property4: 'Text It Is'
}
});
}
);
});
it('allows initializing a new item with a default configuration', function () {
testDataManager.initItem();
@ -246,5 +241,4 @@ define(['../src/TestDataManager'], function (TestDataManager) {
});
it('exposes a UI element to toggle test data on and off', function () {});
});
});

View File

@ -1,5 +1,6 @@
define(['../../src/input/ColorPalette'], function (ColorPalette) {
describe('An Open MCT color palette', function () {
import ColorPalette from '../../src/input/ColorPalette';
describe('An Open MCT color palette', function () {
let colorPalette;
let changeCallback;
@ -20,5 +21,4 @@ define(['../../src/input/ColorPalette'], function (ColorPalette) {
colorPalette = new ColorPalette('someClass', 'someContainer');
expect(colorPalette.getCurrent()).toBeDefined();
});
});
});

View File

@ -1,5 +1,6 @@
define(['../../src/input/IconPalette'], function (IconPalette) {
describe('An Open MCT icon palette', function () {
import IconPalette from '../../src/input/IconPalette';
describe('An Open MCT icon palette', function () {
let iconPalette;
let changeCallback;
@ -20,5 +21,4 @@ define(['../../src/input/IconPalette'], function (IconPalette) {
iconPalette = new IconPalette('someClass', 'someContainer');
expect(iconPalette.getCurrent()).toBeDefined();
});
});
});

View File

@ -1,5 +1,6 @@
define(['../../src/input/KeySelect'], function (KeySelect) {
describe('A select for choosing composition object properties', function () {
import KeySelect from '../../src/input/KeySelect';
describe('A select for choosing composition object properties', function () {
let mockConfig;
let mockBadConfig;
let mockManager;
@ -119,5 +120,4 @@ define(['../../src/input/KeySelect'], function (KeySelect) {
mockObjectSelect.triggerCallback('change', 'object3');
expect(keySelect.getSelected()).toEqual('a');
});
});
});

View File

@ -1,5 +1,28 @@
define(['../../src/input/ObjectSelect'], function (ObjectSelect) {
describe('A select for choosing composition objects', function () {
/*****************************************************************************
* Open MCT, Copyright (c) 2014-2023, 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.
*****************************************************************************/
import ObjectSelect from '../../src/input/ObjectSelect';
describe('A select for choosing composition objects', function () {
let mockConfig;
let mockBadConfig;
let mockManager;
@ -108,5 +131,4 @@ define(['../../src/input/ObjectSelect'], function (ObjectSelect) {
mockManager.triggerCallback('remove');
expect(objectSelect.getSelected()).not.toEqual('key1');
});
});
});

View File

@ -1,5 +1,28 @@
define(['../../src/input/OperationSelect'], function (OperationSelect) {
describe('A select for choosing composition object properties', function () {
/*****************************************************************************
* Open MCT, Copyright (c) 2014-2023, 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.
*****************************************************************************/
import OperationSelect from '../../src/input/OperationSelect';
describe('A select for choosing composition object properties', function () {
let mockConfig;
let mockBadConfig;
let mockManager;
@ -139,5 +162,4 @@ define(['../../src/input/OperationSelect'], function (OperationSelect) {
mockKeySelect.triggerCallback('change', 'c');
expect(operationSelect.getSelected()).toEqual('operation1');
});
});
});

View File

@ -1,5 +1,6 @@
define(['../../src/input/Palette'], function (Palette) {
describe('A generic Open MCT palette input', function () {
import Palette from '../../src/input/Palette';
describe('A generic Open MCT palette input', function () {
let palette;
let callbackSpy1;
let callbackSpy2;
@ -40,5 +41,4 @@ define(['../../src/input/Palette'], function (Palette) {
palette.set('foobar');
expect(palette.getCurrent()).not.toEqual('foobar');
});
});
});

View File

@ -1,5 +1,6 @@
define(['../../src/input/Select'], function (Select) {
describe('A select wrapper', function () {
import Select from '../../src/input/Select';
describe('A select wrapper', function () {
let select;
let testOptions;
let callbackSpy1;
@ -57,5 +58,4 @@ define(['../../src/input/Select'], function (Select) {
select.setSelected('foobar');
expect(select.getSelected()).not.toEqual('foobar');
});
});
});

View File

@ -19,11 +19,11 @@
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
import Tabs from './tabs';
define(['./tabs'], function (Tabs) {
return function plugin() {
export default function plugin() {
return function install(openmct) {
openmct.objectViews.addProvider(new Tabs.default(openmct));
openmct.objectViews.addProvider(new Tabs(openmct));
openmct.types.addType('tabs', {
name: 'Tabs View',
@ -55,5 +55,4 @@ define(['./tabs'], function (Tabs) {
]
});
};
};
});
}

View File

@ -47,7 +47,7 @@ export default class Tabs {
let component = null;
return {
show: function (element, editMode) {
show(element, editMode) {
const { vNode, destroy } = mount(
{
el: element,

View File

@ -20,10 +20,11 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
define(['./src/MeanTelemetryProvider'], function (MeanTelemetryProvider) {
const DEFAULT_SAMPLES = 10;
import MeanTelemetryProvider from './src/MeanTelemetryProvider';
function plugin() {
const DEFAULT_SAMPLES = 10;
export default function plugin() {
return function install(openmct) {
openmct.types.addType('telemetry-mean', {
name: 'Telemetry Filter',
@ -72,7 +73,4 @@ define(['./src/MeanTelemetryProvider'], function (MeanTelemetryProvider) {
});
openmct.telemetry.addProvider(new MeanTelemetryProvider(openmct));
};
}
return plugin;
});
}

View File

@ -20,24 +20,27 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
define(['objectUtils', './TelemetryAverager'], function (objectUtils, TelemetryAverager) {
function MeanTelemetryProvider(openmct) {
import objectUtils from 'objectUtils';
import TelemetryAverager from './TelemetryAverager';
export default function MeanTelemetryProvider(openmct) {
this.openmct = openmct;
this.telemetryAPI = openmct.telemetry;
this.timeAPI = openmct.time;
this.objectAPI = openmct.objects;
this.perObjectProviders = {};
}
}
MeanTelemetryProvider.prototype.canProvideTelemetry = function (domainObject) {
MeanTelemetryProvider.prototype.canProvideTelemetry = function (domainObject) {
return domainObject.type === 'telemetry-mean';
};
};
MeanTelemetryProvider.prototype.supportsRequest =
MeanTelemetryProvider.prototype.supportsRequest =
MeanTelemetryProvider.prototype.supportsSubscribe =
MeanTelemetryProvider.prototype.canProvideTelemetry;
MeanTelemetryProvider.prototype.subscribe = function (domainObject, callback) {
MeanTelemetryProvider.prototype.subscribe = function (domainObject, callback) {
let wrappedUnsubscribe;
let unsubscribeCalled = false;
const objectId = objectUtils.parseKeyString(domainObject.telemetryPoint);
@ -60,9 +63,9 @@ define(['objectUtils', './TelemetryAverager'], function (objectUtils, TelemetryA
wrappedUnsubscribe();
}
};
};
};
MeanTelemetryProvider.prototype.subscribeToAverage = function (domainObject, samples, callback) {
MeanTelemetryProvider.prototype.subscribeToAverage = function (domainObject, samples, callback) {
const telemetryAverager = new TelemetryAverager(
this.telemetryAPI,
this.timeAPI,
@ -73,9 +76,9 @@ define(['objectUtils', './TelemetryAverager'], function (objectUtils, TelemetryA
const createAverageDatum = telemetryAverager.createAverageDatum.bind(telemetryAverager);
return this.telemetryAPI.subscribe(domainObject, createAverageDatum);
};
};
MeanTelemetryProvider.prototype.request = function (domainObject, request) {
MeanTelemetryProvider.prototype.request = function (domainObject, request) {
const objectId = objectUtils.parseKeyString(domainObject.telemetryPoint);
const samples = domainObject.samples;
@ -84,16 +87,16 @@ define(['objectUtils', './TelemetryAverager'], function (objectUtils, TelemetryA
return this.requestAverageTelemetry(linkedDomainObject, request, samples);
}.bind(this)
);
};
};
/**
/**
* @private
*/
MeanTelemetryProvider.prototype.requestAverageTelemetry = function (
MeanTelemetryProvider.prototype.requestAverageTelemetry = function (
domainObject,
request,
samples
) {
) {
const averageData = [];
const addToAverageData = averageData.push.bind(averageData);
const telemetryAverager = new TelemetryAverager(
@ -110,24 +113,21 @@ define(['objectUtils', './TelemetryAverager'], function (objectUtils, TelemetryA
return averageData;
});
};
};
/**
/**
* @private
*/
MeanTelemetryProvider.prototype.getLinkedObject = function (domainObject) {
MeanTelemetryProvider.prototype.getLinkedObject = function (domainObject) {
const objectId = objectUtils.parseKeyString(domainObject.telemetryPoint);
return this.objectAPI.get(objectId);
};
};
function logError(error) {
function logError(error) {
if (error.stack) {
console.error(error.stack);
} else {
console.error(error);
}
}
return MeanTelemetryProvider;
});
}

View File

@ -20,13 +20,13 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
/* eslint-disable no-invalid-this */
define(['./MeanTelemetryProvider', './MockTelemetryApi'], function (
MeanTelemetryProvider,
MockTelemetryApi
) {
const RANGE_KEY = 'value';
describe('The Mean Telemetry Provider', function () {
import MeanTelemetryProvider from './MeanTelemetryProvider';
import MockTelemetryApi from './MockTelemetryApi';
const RANGE_KEY = 'value';
describe('The Mean Telemetry Provider', function () {
let mockApi;
let meanTelemetryProvider;
let mockDomainObject;
@ -619,5 +619,4 @@ define(['./MeanTelemetryProvider', './MockTelemetryApi'], function (
key: timeSystemKey
});
}
});
});

View File

@ -20,8 +20,7 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
define([], function () {
function MockTelemetryApi() {
export default function MockTelemetryApi() {
this.createSpy('subscribe');
this.createSpy('getMetadata');
@ -29,19 +28,19 @@ define([], function () {
this.setDefaultRangeTo('defaultRange');
this.unsubscribe = jasmine.createSpy('unsubscribe');
this.mockReceiveTelemetry = this.mockReceiveTelemetry.bind(this);
}
}
MockTelemetryApi.prototype.subscribe = function () {
MockTelemetryApi.prototype.subscribe = function () {
return this.unsubscribe;
};
};
MockTelemetryApi.prototype.getMetadata = function (object) {
MockTelemetryApi.prototype.getMetadata = function (object) {
return this.metadata;
};
};
MockTelemetryApi.prototype.request = jasmine.createSpy('request');
MockTelemetryApi.prototype.request = jasmine.createSpy('request');
MockTelemetryApi.prototype.getValueFormatter = function (valueMetadata) {
MockTelemetryApi.prototype.getValueFormatter = function (valueMetadata) {
const mockValueFormatter = jasmine.createSpyObj('valueFormatter', ['parse']);
mockValueFormatter.parse.and.callFake(function (value) {
@ -49,34 +48,34 @@ define([], function () {
});
return mockValueFormatter;
};
};
MockTelemetryApi.prototype.mockReceiveTelemetry = function (newTelemetryDatum) {
MockTelemetryApi.prototype.mockReceiveTelemetry = function (newTelemetryDatum) {
const subscriptionCallback = this.subscribe.calls.mostRecent().args[1];
subscriptionCallback(newTelemetryDatum);
};
};
/**
/**
* @private
*/
MockTelemetryApi.prototype.onRequestReturn = function (telemetryData) {
MockTelemetryApi.prototype.onRequestReturn = function (telemetryData) {
this.requestTelemetry = telemetryData;
};
};
/**
/**
* @private
*/
MockTelemetryApi.prototype.setDefaultRangeTo = function (rangeKey) {
MockTelemetryApi.prototype.setDefaultRangeTo = function (rangeKey) {
const mockMetadataValue = {
key: rangeKey
};
this.metadata.valuesForHints.and.returnValue([mockMetadataValue]);
};
};
/**
/**
* @private
*/
MockTelemetryApi.prototype.createMockMetadata = function () {
MockTelemetryApi.prototype.createMockMetadata = function () {
const mockMetadata = jasmine.createSpyObj('metadata', ['value', 'valuesForHints']);
mockMetadata.value.and.callFake(function (key) {
@ -86,16 +85,13 @@ define([], function () {
});
return mockMetadata;
};
};
/**
/**
* @private
*/
MockTelemetryApi.prototype.createSpy = function (functionName) {
MockTelemetryApi.prototype.createSpy = function (functionName) {
this[functionName] = this[functionName].bind(this);
spyOn(this, functionName);
this[functionName].and.callThrough();
};
return MockTelemetryApi;
});
};

View File

@ -20,8 +20,13 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
define([], function () {
function TelemetryAverager(telemetryAPI, timeAPI, domainObject, samples, averageDatumCallback) {
export default function TelemetryAverager(
telemetryAPI,
timeAPI,
domainObject,
samples,
averageDatumCallback
) {
this.telemetryAPI = telemetryAPI;
this.timeAPI = timeAPI;
@ -38,9 +43,9 @@ define([], function () {
this.domainFormatter = undefined;
this.averageDatumCallback = averageDatumCallback;
}
}
TelemetryAverager.prototype.createAverageDatum = function (telemetryDatum) {
TelemetryAverager.prototype.createAverageDatum = function (telemetryDatum) {
this.setDomainKeyAndFormatter();
const timeValue = this.domainFormatter.parse(telemetryDatum);
@ -63,12 +68,12 @@ define([], function () {
meanDatum.value = averageValue;
this.averageDatumCallback(meanDatum);
};
};
/**
/**
* @private
*/
TelemetryAverager.prototype.calculateMean = function () {
TelemetryAverager.prototype.calculateMean = function () {
let sum = 0;
let i = 0;
@ -77,43 +82,40 @@ define([], function () {
}
return sum / this.averagingWindow.length;
};
};
/**
/**
* The mean telemetry filter produces domain values in whatever time
* system is currently selected from the conductor. Because this can
* change dynamically, the averager needs to be updated regularly with
* the current domain.
* @private
*/
TelemetryAverager.prototype.setDomainKeyAndFormatter = function () {
TelemetryAverager.prototype.setDomainKeyAndFormatter = function () {
const domainKey = this.timeAPI.timeSystem().key;
if (domainKey !== this.domainKey) {
this.domainKey = domainKey;
this.domainFormatter = this.getFormatter(domainKey);
}
};
};
/**
/**
* @private
*/
TelemetryAverager.prototype.setRangeKeyAndFormatter = function () {
TelemetryAverager.prototype.setRangeKeyAndFormatter = function () {
const metadatas = this.telemetryAPI.getMetadata(this.domainObject);
const rangeValues = metadatas.valuesForHints(['range']);
this.rangeKey = rangeValues[0].key;
this.rangeFormatter = this.getFormatter(this.rangeKey);
};
};
/**
/**
* @private
*/
TelemetryAverager.prototype.getFormatter = function (key) {
TelemetryAverager.prototype.getFormatter = function (key) {
const objectMetadata = this.telemetryAPI.getMetadata(this.domainObject);
const valueMetadata = objectMetadata.value(key);
return this.telemetryAPI.getValueFormatter(valueMetadata);
};
return TelemetryAverager;
});
};

View File

@ -20,28 +20,18 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
define([
'EventEmitter',
'lodash',
'./collections/TableRowCollection',
'./TelemetryTableRow',
'./TelemetryTableNameColumn',
'./TelemetryTableColumn',
'./TelemetryTableUnitColumn',
'./TelemetryTableConfiguration',
'../../utils/staleness'
], function (
EventEmitter,
_,
TableRowCollection,
TelemetryTableRow,
TelemetryTableNameColumn,
TelemetryTableColumn,
TelemetryTableUnitColumn,
TelemetryTableConfiguration,
StalenessUtils
) {
class TelemetryTable extends EventEmitter {
import EventEmitter from 'EventEmitter';
import _ from 'lodash';
import StalenessUtils from '../../utils/staleness';
import TableRowCollection from './collections/TableRowCollection';
import TelemetryTableColumn from './TelemetryTableColumn';
import TelemetryTableConfiguration from './TelemetryTableConfiguration';
import TelemetryTableNameColumn from './TelemetryTableNameColumn';
import TelemetryTableRow from './TelemetryTableRow';
import TelemetryTableUnitColumn from './TelemetryTableUnitColumn';
export default class TelemetryTable extends EventEmitter {
constructor(domainObject, openmct) {
super();
@ -195,7 +185,7 @@ define([
}
this.stalenessSubscription[keyString] = {};
this.stalenessSubscription[keyString].stalenessUtils = new StalenessUtils.default(
this.stalenessSubscription[keyString].stalenessUtils = new StalenessUtils(
this.openmct,
domainObject
);
@ -470,7 +460,4 @@ define([
this.tableComposition.off('remove', this.removeTelemetryObject);
}
}
}
return TelemetryTable;
});
}

View File

@ -19,8 +19,7 @@
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
define(function () {
class TelemetryTableColumn {
export default class TelemetryTableColumn {
constructor(openmct, metadatum, options = { selectable: false }) {
this.metadatum = metadatum;
this.formatter = openmct.telemetry.getValueFormatter(metadatum);
@ -60,7 +59,4 @@ define(function () {
getParsedValue(telemetryDatum) {
return this.formatter.parse(telemetryDatum);
}
}
return TelemetryTableColumn;
});
}

View File

@ -20,8 +20,10 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
define(['lodash', 'EventEmitter'], function (_, EventEmitter) {
class TelemetryTableConfiguration extends EventEmitter {
import EventEmitter from 'EventEmitter';
import _ from 'lodash';
export default class TelemetryTableConfiguration extends EventEmitter {
constructor(domainObject, openmct) {
super();
@ -162,7 +164,4 @@ define(['lodash', 'EventEmitter'], function (_, EventEmitter) {
destroy() {
this.unlistenFromMutation();
}
}
return TelemetryTableConfiguration;
});
}

View File

@ -19,8 +19,10 @@
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
define(['./TelemetryTableColumn.js'], function (TelemetryTableColumn) {
class TelemetryTableNameColumn extends TelemetryTableColumn {
import TelemetryTableColumn from './TelemetryTableColumn';
export default class TelemetryTableNameColumn extends TelemetryTableColumn {
constructor(openmct, telemetryObject, metadatum) {
super(openmct, metadatum);
@ -34,7 +36,4 @@ define(['./TelemetryTableColumn.js'], function (TelemetryTableColumn) {
getFormattedValue() {
return this.telemetryObject.name;
}
}
return TelemetryTableNameColumn;
});
}

View File

@ -20,8 +20,7 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
define([], function () {
class TelemetryTableRow {
export default class TelemetryTableRow {
constructor(datum, columns, objectKeyString, limitEvaluator, inPlaceUpdateKey) {
this.columns = columns;
@ -101,16 +100,16 @@ define([], function () {
...updatesToDatum
};
}
}
}
/**
/**
* Normalize the structure of datums to assist sorting and merging of columns.
* Maps all sources to keys.
* @private
* @param {*} telemetryDatum
* @param {*} metadataValues
*/
function createNormalizedDatum(datum, columns) {
function createNormalizedDatum(datum, columns) {
const normalizedDatum = JSON.parse(JSON.stringify(datum));
Object.values(columns).forEach((column) => {
@ -121,7 +120,4 @@ define([], function () {
});
return normalizedDatum;
}
return TelemetryTableRow;
});
}

View File

@ -20,8 +20,7 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
define(function () {
return {
export default {
name: 'Telemetry Table',
description:
'Display values for one or more telemetry end points in a scrolling table. Each row is a time-stamped value.',
@ -34,5 +33,4 @@ define(function () {
hiddenColumns: {}
};
}
};
});
};

View File

@ -19,8 +19,9 @@
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
define(['./TelemetryTableColumn.js'], function (TelemetryTableColumn) {
class TelemetryTableUnitColumn extends TelemetryTableColumn {
import TelemetryTableColumn from './TelemetryTableColumn.js';
class TelemetryTableUnitColumn extends TelemetryTableColumn {
constructor(openmct, metadatum) {
super(openmct, metadatum);
this.isUnit = true;
@ -50,7 +51,6 @@ define(['./TelemetryTableColumn.js'], function (TelemetryTableColumn) {
getFormattedValue(telemetryDatum) {
return this.formatter.format(telemetryDatum);
}
}
}
return TelemetryTableUnitColumn;
});
export default TelemetryTableUnitColumn;

View File

@ -19,12 +19,13 @@
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
import EventEmitter from 'EventEmitter';
import _ from 'lodash';
define(['lodash', 'EventEmitter'], function (_, EventEmitter) {
/**
/**
* @constructor
*/
class TableRowCollection extends EventEmitter {
export default class TableRowCollection extends EventEmitter {
constructor() {
super();
@ -383,7 +384,4 @@ define(['lodash', 'EventEmitter'], function (_, EventEmitter) {
destroy() {
this.removeAllListeners();
}
}
return TableRowCollection;
});
}

View File

@ -20,17 +20,17 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
define([], function () {
/**
/**
* This time system supports UTC dates.
* @implements TimeSystem
* @constructor
*/
function UTCTimeSystem() {
class UTCTimeSystem {
/**
* Metadata used to identify the time system in
* the UI
*/
constructor() {
this.key = 'utc';
this.name = 'UTC';
this.cssClass = 'icon-clock';
@ -38,6 +38,6 @@ define([], function () {
this.durationFormat = 'duration';
this.isUTCBased = true;
}
}
return UTCTimeSystem;
});
export default UTCTimeSystem;

View File

@ -20,25 +20,24 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
define([], function () {
/**
/**
* A ToolbarRegistry maintains the definitions for toolbars.
*
* @interface ToolbarRegistry
* @memberof module:openmct
*/
function ToolbarRegistry() {
export default function ToolbarRegistry() {
this.providers = {};
}
}
/**
/**
* Gets toolbar controls from providers which can provide a toolbar for this selection.
*
* @param {object} selection the selection object
* @returns {Object[]} an array of objects defining controls for the toolbar
* @private for platform-internal use
*/
ToolbarRegistry.prototype.get = function (selection) {
ToolbarRegistry.prototype.get = function (selection) {
const providers = this.getAllProviders().filter(function (provider) {
return provider.forSelection(selection);
});
@ -50,30 +49,30 @@ define([], function () {
});
return structure;
};
};
/**
/**
* @private
*/
ToolbarRegistry.prototype.getAllProviders = function () {
ToolbarRegistry.prototype.getAllProviders = function () {
return Object.values(this.providers);
};
};
/**
/**
* @private
*/
ToolbarRegistry.prototype.getByProviderKey = function (key) {
ToolbarRegistry.prototype.getByProviderKey = function (key) {
return this.providers[key];
};
};
/**
/**
* Registers a new type of toolbar.
*
* @param {module:openmct.ToolbarRegistry} provider the provider for this toolbar
* @method addProvider
* @memberof module:openmct.ToolbarRegistry#
*/
ToolbarRegistry.prototype.addProvider = function (provider) {
ToolbarRegistry.prototype.addProvider = function (provider) {
const key = provider.key;
if (key === undefined) {
@ -85,9 +84,9 @@ define([], function () {
}
this.providers[key] = provider;
};
};
/**
/**
* Exposes types of toolbars in Open MCT.
*
* @interface ToolbarProvider
@ -98,7 +97,7 @@ define([], function () {
* @memberof module:openmct
*/
/**
/**
* Checks if this provider can supply toolbar for a selection.
*
* @method forSelection
@ -108,7 +107,7 @@ define([], function () {
* otherwise 'false'.
*/
/**
/**
* Provides controls that comprise a toolbar.
*
* @method toolbar
@ -116,6 +115,3 @@ define([], function () {
* @param {object} selection the selection object
* @returns {Object[]} an array of objects defining controls for the toolbar.
*/
return ToolbarRegistry;
});

View File

@ -20,23 +20,24 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
define(['EventEmitter'], function (EventEmitter) {
const DEFAULT_VIEW_PRIORITY = 100;
import EventEmitter from 'EventEmitter';
/**
const DEFAULT_VIEW_PRIORITY = 100;
/**
* A ViewRegistry maintains the definitions for different kinds of views
* that may occur in different places in the user interface.
* @interface ViewRegistry
* @memberof module:openmct
*/
function ViewRegistry() {
export default function ViewRegistry() {
EventEmitter.apply(this);
this.providers = {};
}
}
ViewRegistry.prototype = Object.create(EventEmitter.prototype);
ViewRegistry.prototype = Object.create(EventEmitter.prototype);
/**
/**
* @private for platform-internal use
* @param {*} item the object to be viewed
* @param {array} objectPath - The current contextual object path of the view object
@ -44,7 +45,7 @@ define(['EventEmitter'], function (EventEmitter) {
* @returns {module:openmct.ViewProvider[]} any providers
* which can provide views of this object
*/
ViewRegistry.prototype.get = function (item, objectPath) {
ViewRegistry.prototype.get = function (item, objectPath) {
if (objectPath === undefined) {
throw 'objectPath must be provided to get applicable views for an object';
}
@ -61,23 +62,23 @@ define(['EventEmitter'], function (EventEmitter) {
return provider.canView(item, objectPath);
})
.sort(byPriority);
};
};
/**
/**
* @private
*/
ViewRegistry.prototype.getAllProviders = function () {
ViewRegistry.prototype.getAllProviders = function () {
return Object.values(this.providers);
};
};
/**
/**
* Register a new type of view.
*
* @param {module:openmct.ViewProvider} provider the provider for this view
* @method addProvider
* @memberof module:openmct.ViewRegistry#
*/
ViewRegistry.prototype.addProvider = function (provider) {
ViewRegistry.prototype.addProvider = function (provider) {
const key = provider.key;
if (key === undefined) {
throw "View providers must have a unique 'key' property defined";
@ -101,27 +102,27 @@ define(['EventEmitter'], function (EventEmitter) {
};
this.providers[key] = provider;
};
};
/**
/**
* @private
*/
ViewRegistry.prototype.getByProviderKey = function (key) {
ViewRegistry.prototype.getByProviderKey = function (key) {
return this.providers[key];
};
};
/**
/**
* Used internally to support seamless usage of new views with old
* views.
* @private
*/
ViewRegistry.prototype.getByVPID = function (vpid) {
ViewRegistry.prototype.getByVPID = function (vpid) {
return this.providers.filter(function (p) {
return p.vpid === vpid;
})[0];
};
};
/**
/**
* A View is used to provide displayable content, and to react to
* associated life cycle events.
*
@ -130,7 +131,7 @@ define(['EventEmitter'], function (EventEmitter) {
* @memberof module:openmct
*/
/**
/**
* Populate the supplied DOM element with the contents of this view.
*
* View implementations should use this method to attach any
@ -142,7 +143,7 @@ define(['EventEmitter'], function (EventEmitter) {
* @memberof module:openmct.View#
*/
/**
/**
* Indicates whether or not the application is in edit mode. This supports
* views that have distinct visual and behavioral elements when the
* navigated object is being edited.
@ -155,7 +156,7 @@ define(['EventEmitter'], function (EventEmitter) {
* @memberof module:openmct.View#
*/
/**
/**
* Release any resources associated with this view.
*
* View implementations should use this method to detach any
@ -166,7 +167,7 @@ define(['EventEmitter'], function (EventEmitter) {
* @memberof module:openmct.View#
*/
/**
/**
* Returns the selection context.
*
* View implementations should use this method to customize
@ -176,7 +177,7 @@ define(['EventEmitter'], function (EventEmitter) {
* @memberof module:openmct.View#
*/
/**
/**
* Exposes types of views in Open MCT.
*
* @interface ViewProvider
@ -189,7 +190,7 @@ define(['EventEmitter'], function (EventEmitter) {
* @memberof module:openmct
*/
/**
/**
* Check if this provider can supply views for a domain object.
*
* When called by Open MCT, this may include additional arguments
@ -207,7 +208,7 @@ define(['EventEmitter'], function (EventEmitter) {
* otherwise 'false'.
*/
/**
/**
* An optional function that defines whether or not this view can be used to edit a given object.
* If not provided, will default to `false` and the view will not support editing. To support editing,
* return true from this function and then -
@ -229,7 +230,7 @@ define(['EventEmitter'], function (EventEmitter) {
* otherwise 'false'.
*/
/**
/**
* Optional method determining the priority of a given view. If this
* function is not defined on a view provider, then a default priority
* of 100 will be applicable for all objects supported by this view.
@ -243,7 +244,7 @@ define(['EventEmitter'], function (EventEmitter) {
* the default view.
*/
/**
/**
* Provide a view of this object.
*
* When called by Open MCT, the following arguments will be passed to it:
@ -257,7 +258,7 @@ define(['EventEmitter'], function (EventEmitter) {
* @returns {module:openmct.View} a view of this domain object
*/
/**
/**
* Provide an edit-mode specific view of this object.
*
* If optionally specified, this function will be called when the application
@ -269,6 +270,3 @@ define(['EventEmitter'], function (EventEmitter) {
* @param {*} object the object to be edit
* @returns {module:openmct.View} an editable view of this domain object
*/
return ViewRegistry;
});

Some files were not shown because too many files have changed in this diff Show More