diff --git a/.eslintrc.js b/.eslintrc.js index ae67e781bf..3ffa47c379 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -120,6 +120,10 @@ module.exports = { "no-useless-computed-key": "error", // https://eslint.org/docs/rules/rest-spread-spacing "rest-spread-spacing": ["error"], + // https://eslint.org/docs/rules/no-var + "no-var": "error", + // https://eslint.org/docs/rules/one-var + "one-var": ["error", "never"], // https://eslint.org/docs/rules/default-case-last "default-case-last": "error", // https://eslint.org/docs/rules/default-param-last @@ -248,7 +252,8 @@ module.exports = { } ], "no-nested-ternary": "off", - "no-var": "off" + "no-var": "off", + "one-var": "off" } } ] diff --git a/openmct.js b/openmct.js index 11d7d4a68b..1252334419 100644 --- a/openmct.js +++ b/openmct.js @@ -32,6 +32,6 @@ if (document.currentScript) { const MCT = require('./src/MCT'); -var openmct = new MCT(); +const openmct = new MCT(); module.exports = openmct; diff --git a/platform/commonUI/about/test/AboutControllerSpec.js b/platform/commonUI/about/test/AboutControllerSpec.js index de349997fc..31c2a5b420 100644 --- a/platform/commonUI/about/test/AboutControllerSpec.js +++ b/platform/commonUI/about/test/AboutControllerSpec.js @@ -25,9 +25,9 @@ define( function (AboutController) { describe("The About controller", function () { - var testVersions, - mockWindow, - controller; + let testVersions; + let mockWindow; + let controller; beforeEach(function () { testVersions = [ @@ -56,7 +56,6 @@ define( controller.openLicenses(); expect(mockWindow.open).toHaveBeenCalledWith("#/licenses"); }); - }); } diff --git a/src/BundleRegistrySpec.js b/src/BundleRegistrySpec.js index 7d4c2d02e0..9aaf6000f7 100644 --- a/src/BundleRegistrySpec.js +++ b/src/BundleRegistrySpec.js @@ -23,8 +23,8 @@ define(['./BundleRegistry'], function (BundleRegistry) { describe("BundleRegistry", function () { - var testPath, - bundleRegistry; + let testPath; + let bundleRegistry; beforeEach(function () { testPath = 'some/bundle'; @@ -46,7 +46,7 @@ define(['./BundleRegistry'], function (BundleRegistry) { }); describe("when a bundle has been registered", function () { - var testBundleDef; + let testBundleDef; beforeEach(function () { testBundleDef = { someKey: "some value" }; @@ -83,7 +83,6 @@ define(['./BundleRegistry'], function (BundleRegistry) { }); }); }); - }); }); diff --git a/src/MCT.js b/src/MCT.js index c207954b65..227d3eb0b2 100644 --- a/src/MCT.js +++ b/src/MCT.js @@ -292,7 +292,7 @@ define([ let capabilityService = this.$injector.get('capabilityService'); function instantiate(model, keyString) { - var capabilities = capabilityService.getCapabilities(model, keyString); + const capabilities = capabilityService.getCapabilities(model, keyString); model.id = keyString; return new DomainObjectImpl(keyString, model, capabilities); @@ -377,8 +377,8 @@ define([ // TODO: remove with legacy types. this.types.listKeys().forEach(function (typeKey) { - var type = this.types.get(typeKey); - var legacyDefinition = type.toLegacyDefinition(); + const type = this.types.get(typeKey); + const legacyDefinition = type.toLegacyDefinition(); legacyDefinition.key = typeKey; this.legacyExtension('types', legacyDefinition); }.bind(this)); @@ -405,7 +405,7 @@ define([ this.$injector.get('objectService'); if (!isHeadlessMode) { - var appLayout = new Vue({ + const appLayout = new Vue({ components: { 'Layout': Layout.default }, diff --git a/src/MCTSpec.js b/src/MCTSpec.js index 8857c8c454..ed925327f1 100644 --- a/src/MCTSpec.js +++ b/src/MCTSpec.js @@ -26,11 +26,11 @@ define([ 'utils/testing' ], function (plugins, legacyRegistry, testUtils) { describe("MCT", function () { - var openmct; - var mockPlugin; - var mockPlugin2; - var mockListener; - var oldBundles; + let openmct; + let mockPlugin; + let mockPlugin2; + let mockListener; + let oldBundles; beforeEach(function () { mockPlugin = jasmine.createSpy('plugin'); @@ -109,7 +109,7 @@ define([ }); describe("setAssetPath", function () { - var testAssetPath; + let testAssetPath; beforeEach(function () { openmct.legacyExtension = jasmine.createSpy('legacyExtension'); diff --git a/src/adapter/actions/ActionDialogDecorator.js b/src/adapter/actions/ActionDialogDecorator.js index b733fdd230..c9b8755b57 100644 --- a/src/adapter/actions/ActionDialogDecorator.js +++ b/src/adapter/actions/ActionDialogDecorator.js @@ -29,15 +29,15 @@ define([ } ActionDialogDecorator.prototype.getActions = function (context) { - var mct = this.mct; + const mct = this.mct; return this.actionService.getActions(context).map(function (action) { if (action.dialogService) { - var domainObject = objectUtils.toNewFormat( + const domainObject = objectUtils.toNewFormat( context.domainObject.getModel(), objectUtils.parseKeyString(context.domainObject.getId()) ); - var providers = mct.propertyEditors.get(domainObject); + const providers = mct.propertyEditors.get(domainObject); if (providers.length > 0) { action.dialogService = Object.create(action.dialogService); diff --git a/src/adapter/capabilities/APICapabilityDecorator.js b/src/adapter/capabilities/APICapabilityDecorator.js index 99703158c7..42b628de44 100644 --- a/src/adapter/capabilities/APICapabilityDecorator.js +++ b/src/adapter/capabilities/APICapabilityDecorator.js @@ -43,7 +43,7 @@ define([ model, id ) { - var capabilities = this.capabilityService.getCapabilities(model, id); + const capabilities = this.capabilityService.getCapabilities(model, id); if (capabilities.mutation) { capabilities.mutation = synchronizeMutationCapability(capabilities.mutation); diff --git a/src/adapter/capabilities/AlternateCompositionCapability.js b/src/adapter/capabilities/AlternateCompositionCapability.js index cf16efc657..d6ae69d0c9 100644 --- a/src/adapter/capabilities/AlternateCompositionCapability.js +++ b/src/adapter/capabilities/AlternateCompositionCapability.js @@ -46,7 +46,7 @@ define([ } function addChildToComposition(model) { - var existingIndex = model.composition.indexOf(child.getId()); + const existingIndex = model.composition.indexOf(child.getId()); if (existingIndex === -1) { model.composition.push(child.getId()); } @@ -71,16 +71,16 @@ define([ this.getDependencies(); } - var keyString = objectUtils.makeKeyString(child.identifier); - var oldModel = objectUtils.toOldFormat(child); - var newDO = this.instantiate(oldModel, keyString); + const keyString = objectUtils.makeKeyString(child.identifier); + const oldModel = objectUtils.toOldFormat(child); + const newDO = this.instantiate(oldModel, keyString); return new ContextualDomainObject(newDO, this.domainObject); }; AlternateCompositionCapability.prototype.invoke = function () { - var newFormatDO = objectUtils.toNewFormat( + const newFormatDO = objectUtils.toNewFormat( this.domainObject.getModel(), this.domainObject.getId() ); @@ -89,7 +89,7 @@ define([ this.getDependencies(); } - var collection = this.openmct.composition.get(newFormatDO); + const collection = this.openmct.composition.get(newFormatDO); return collection.load() .then(function (children) { @@ -104,5 +104,4 @@ define([ }; return AlternateCompositionCapability; -} -); +}); diff --git a/src/adapter/capabilities/patchViewCapability.js b/src/adapter/capabilities/patchViewCapability.js index bc54ec9c47..a2bf5290eb 100644 --- a/src/adapter/capabilities/patchViewCapability.js +++ b/src/adapter/capabilities/patchViewCapability.js @@ -28,18 +28,18 @@ define([ function patchViewCapability(viewConstructor) { return function makeCapability(domainObject) { - var capability = viewConstructor(domainObject); - var oldInvoke = capability.invoke.bind(capability); + const capability = viewConstructor(domainObject); + const oldInvoke = capability.invoke.bind(capability); /* eslint-disable you-dont-need-lodash-underscore/map */ capability.invoke = function () { - var availableViews = oldInvoke(); - var newDomainObject = capability + const availableViews = oldInvoke(); + const newDomainObject = capability .domainObject .useCapability('adapter'); return _(availableViews).map(function (v, i) { - var vd = { + const vd = { view: v, priority: i + 100 // arbitrary to allow new views to // be defaults by returning priority less than 100. diff --git a/src/adapter/capabilities/synchronizeMutationCapability.js b/src/adapter/capabilities/synchronizeMutationCapability.js index e135662f65..a18fcd87fd 100644 --- a/src/adapter/capabilities/synchronizeMutationCapability.js +++ b/src/adapter/capabilities/synchronizeMutationCapability.js @@ -32,8 +32,8 @@ define([ function synchronizeMutationCapability(mutationConstructor) { return function makeCapability(domainObject) { - var capability = mutationConstructor(domainObject); - var oldListen = capability.listen.bind(capability); + const capability = mutationConstructor(domainObject); + const oldListen = capability.listen.bind(capability); capability.listen = function (listener) { return oldListen(function (newModel) { capability.domainObject.model = diff --git a/src/adapter/directives/MCTView.js b/src/adapter/directives/MCTView.js index 7864eaf6fc..57bf18e293 100644 --- a/src/adapter/directives/MCTView.js +++ b/src/adapter/directives/MCTView.js @@ -27,9 +27,9 @@ define([ return { restrict: 'E', link: function (scope, element, attrs) { - var provider = openmct.objectViews.getByProviderKey(attrs.mctProviderKey); - var view = new provider.view(scope.domainObject.useCapability('adapter')); - var domElement = element[0]; + const provider = openmct.objectViews.getByProviderKey(attrs.mctProviderKey); + const view = new provider.view(scope.domainObject.useCapability('adapter')); + const domElement = element[0]; view.show(domElement); diff --git a/src/adapter/indicators/legacy-indicators-plugin.js b/src/adapter/indicators/legacy-indicators-plugin.js index a65d8ac761..61cbb96fe8 100644 --- a/src/adapter/indicators/legacy-indicators-plugin.js +++ b/src/adapter/indicators/legacy-indicators-plugin.js @@ -20,7 +20,7 @@ * at runtime from the About dialog for additional information. *****************************************************************************/ define([], function () { - var LEGACY_INDICATOR_TEMPLATE = + const LEGACY_INDICATOR_TEMPLATE = ' { + const provider = this.registry.find(p => { return p.appliesTo(domainObject); }); diff --git a/src/api/composition/CompositionAPISpec.js b/src/api/composition/CompositionAPISpec.js index ac4a49ef0a..2d0c1d47df 100644 --- a/src/api/composition/CompositionAPISpec.js +++ b/src/api/composition/CompositionAPISpec.js @@ -7,10 +7,10 @@ define([ ) { describe('The Composition API', function () { - var publicAPI; - var compositionAPI; - var topicService; - var mutationTopic; + let publicAPI; + let compositionAPI; + let topicService; + let mutationTopic; beforeEach(function () { @@ -54,8 +54,8 @@ define([ }); describe('default composition', function () { - var domainObject; - var composition; + let domainObject; + let composition; beforeEach(function () { domainObject = { @@ -88,7 +88,7 @@ define([ }); it('loads composition from domain object', function () { - var listener = jasmine.createSpy('addListener'); + const listener = jasmine.createSpy('addListener'); composition.on('add', listener); return composition.load().then(function () { @@ -102,7 +102,7 @@ define([ }); }); describe('supports reordering of composition', function () { - var listener; + let listener; beforeEach(function () { listener = jasmine.createSpy('reorderListener'); composition.on('reorder', listener); @@ -151,9 +151,9 @@ define([ }); describe('static custom composition', function () { - var customProvider; - var domainObject; - var composition; + let customProvider; + let domainObject; + let composition; beforeEach(function () { // A simple custom provider, returns the same composition for @@ -185,12 +185,12 @@ define([ }); it('supports listening and loading', function () { - var addListener = jasmine.createSpy('addListener'); + const addListener = jasmine.createSpy('addListener'); composition.on('add', addListener); return composition.load().then(function (children) { - var listenObject; - var loadedObject = children[0]; + let listenObject; + const loadedObject = children[0]; expect(addListener).toHaveBeenCalled(); @@ -229,9 +229,9 @@ define([ }); describe('dynamic custom composition', function () { - var customProvider; - var domainObject; - var composition; + let customProvider; + let domainObject; + let composition; beforeEach(function () { // A dynamic provider, loads an empty composition and exposes @@ -258,12 +258,12 @@ define([ }); it('supports listening and loading', function () { - var addListener = jasmine.createSpy('addListener'); - var removeListener = jasmine.createSpy('removeListener'); - var addPromise = new Promise(function (resolve) { + const addListener = jasmine.createSpy('addListener'); + const removeListener = jasmine.createSpy('removeListener'); + const addPromise = new Promise(function (resolve) { addListener.and.callFake(resolve); }); - var removePromise = new Promise(function (resolve) { + const removePromise = new Promise(function (resolve) { removeListener.and.callFake(resolve); }); @@ -282,8 +282,8 @@ define([ jasmine.any(Function), jasmine.any(CompositionCollection) ); - var add = customProvider.on.calls.all()[0].args[2]; - var remove = customProvider.on.calls.all()[1].args[2]; + const add = customProvider.on.calls.all()[0].args[2]; + const remove = customProvider.on.calls.all()[1].args[2]; return composition.load() .then(function () { diff --git a/src/api/composition/CompositionCollection.js b/src/api/composition/CompositionCollection.js index eafc43bca8..c7052bb2c0 100644 --- a/src/api/composition/CompositionCollection.js +++ b/src/api/composition/CompositionCollection.js @@ -128,7 +128,7 @@ define([ throw new Error('Event not supported by composition: ' + event); } - var index = this.listeners[event].findIndex(l => { + const index = this.listeners[event].findIndex(l => { return l.callback === callback && l.context === context; }); diff --git a/src/api/composition/DefaultCompositionProvider.js b/src/api/composition/DefaultCompositionProvider.js index 8fac570351..46c561710d 100644 --- a/src/api/composition/DefaultCompositionProvider.js +++ b/src/api/composition/DefaultCompositionProvider.js @@ -106,8 +106,8 @@ define([ ) { this.establishTopicListener(); - var keyString = objectUtils.makeKeyString(domainObject.identifier); - var objectListeners = this.listeningTo[keyString]; + const keyString = objectUtils.makeKeyString(domainObject.identifier); + let objectListeners = this.listeningTo[keyString]; if (!objectListeners) { objectListeners = this.listeningTo[keyString] = { @@ -140,10 +140,10 @@ define([ callback, context ) { - var keyString = objectUtils.makeKeyString(domainObject.identifier); - var objectListeners = this.listeningTo[keyString]; + const keyString = objectUtils.makeKeyString(domainObject.identifier); + const objectListeners = this.listeningTo[keyString]; - var index = objectListeners[event].findIndex(l => { + const index = objectListeners[event].findIndex(l => { return l.callback === callback && l.context === context; }); @@ -233,7 +233,7 @@ define([ this.publicAPI.objects.mutate(domainObject, 'composition', newComposition); let id = objectUtils.makeKeyString(domainObject.identifier); - var listeners = this.listeningTo[id]; + const listeners = this.listeningTo[id]; if (!listeners) { return; @@ -274,18 +274,18 @@ define([ * @private */ DefaultCompositionProvider.prototype.onMutation = function (oldDomainObject) { - var id = objectUtils.makeKeyString(oldDomainObject.identifier); - var listeners = this.listeningTo[id]; + const id = objectUtils.makeKeyString(oldDomainObject.identifier); + const listeners = this.listeningTo[id]; if (!listeners) { return; } - var oldComposition = listeners.composition.map(objectUtils.makeKeyString); - var newComposition = oldDomainObject.composition.map(objectUtils.makeKeyString); + const oldComposition = listeners.composition.map(objectUtils.makeKeyString); + const newComposition = oldDomainObject.composition.map(objectUtils.makeKeyString); - var added = _.difference(newComposition, oldComposition).map(objectUtils.parseKeyString); - var removed = _.difference(oldComposition, newComposition).map(objectUtils.parseKeyString); + const added = _.difference(newComposition, oldComposition).map(objectUtils.parseKeyString); + const removed = _.difference(oldComposition, newComposition).map(objectUtils.parseKeyString); function notify(value) { return function (listener) { diff --git a/src/api/indicators/IndicatorAPISpec.js b/src/api/indicators/IndicatorAPISpec.js index b5271d3cb7..a5f62ae984 100644 --- a/src/api/indicators/IndicatorAPISpec.js +++ b/src/api/indicators/IndicatorAPISpec.js @@ -30,9 +30,9 @@ define( MCTIndicators ) { xdescribe("The Indicator API", function () { - var openmct; - var directive; - var holderElement; + let openmct; + let directive; + let holderElement; beforeEach(function () { openmct = new MCT(); @@ -41,7 +41,7 @@ define( }); describe("The simple indicator", function () { - var simpleIndicator; + let simpleIndicator; beforeEach(function () { simpleIndicator = openmct.indicators.simpleIndicator(); @@ -97,7 +97,7 @@ define( }); it("Supports registration of a completely custom indicator", function () { - var customIndicator = document.createElement('div'); + const customIndicator = document.createElement('div'); customIndicator.classList.add('customIndicator'); customIndicator.textContent = 'A custom indicator'; diff --git a/src/api/indicators/SimpleIndicator.js b/src/api/indicators/SimpleIndicator.js index c84e09783f..46ab2828b0 100644 --- a/src/api/indicators/SimpleIndicator.js +++ b/src/api/indicators/SimpleIndicator.js @@ -22,7 +22,7 @@ define(['zepto', './res/indicator-template.html'], function ($, indicatorTemplate) { - var DEFAULT_ICON_CLASS = 'icon-info'; + const DEFAULT_ICON_CLASS = 'icon-info'; function SimpleIndicator(openmct) { this.openmct = openmct; diff --git a/src/api/objects/MutableObject.js b/src/api/objects/MutableObject.js index 7768b4452f..a51bee469d 100644 --- a/src/api/objects/MutableObject.js +++ b/src/api/objects/MutableObject.js @@ -27,7 +27,7 @@ define([ utils, _ ) { - var ANY_OBJECT_EVENT = "mutation"; + const ANY_OBJECT_EVENT = "mutation"; /** * The MutableObject wraps a DomainObject and provides getters and @@ -43,7 +43,7 @@ define([ } function qualifiedEventName(object, eventName) { - var keystring = utils.makeKeyString(object.identifier); + const keystring = utils.makeKeyString(object.identifier); return [keystring, eventName].join(':'); } @@ -64,8 +64,8 @@ define([ * @memberof module:openmct.MutableObject# */ MutableObject.prototype.on = function (path, callback) { - var fullPath = qualifiedEventName(this.object, path); - var eventOff = + const fullPath = qualifiedEventName(this.object, path); + const eventOff = this.eventEmitter.off.bind(this.eventEmitter, fullPath, callback); this.eventEmitter.on(fullPath, callback); @@ -83,7 +83,7 @@ define([ _.set(this.object, path, value); _.set(this.object, 'modified', Date.now()); - var handleRecursiveMutation = function (newObject) { + const handleRecursiveMutation = function (newObject) { this.object = newObject; }.bind(this); diff --git a/src/api/objects/ObjectAPI.js b/src/api/objects/ObjectAPI.js index dbd0d0232d..ab85477ee5 100644 --- a/src/api/objects/ObjectAPI.js +++ b/src/api/objects/ObjectAPI.js @@ -155,7 +155,7 @@ define([ */ ObjectAPI.prototype.get = function (identifier) { identifier = utils.parseKeyString(identifier); - var provider = this.getProvider(identifier); + const provider = this.getProvider(identifier); if (!provider) { throw new Error('No Provider Matched'); @@ -232,7 +232,7 @@ define([ * @memberof module:openmct.ObjectAPI# */ ObjectAPI.prototype.mutate = function (domainObject, path, value) { - var mutableObject = + const mutableObject = new MutableObject(this.eventEmitter, domainObject); return mutableObject.set(path, value); @@ -248,7 +248,7 @@ define([ * @memberof module:openmct.ObjectAPI# */ ObjectAPI.prototype.observe = function (domainObject, path, callback) { - var mutableObject = + const mutableObject = new MutableObject(this.eventEmitter, domainObject); mutableObject.on(path, callback); diff --git a/src/api/objects/RootRegistry.js b/src/api/objects/RootRegistry.js index 4f55369ca9..5909c5843d 100644 --- a/src/api/objects/RootRegistry.js +++ b/src/api/objects/RootRegistry.js @@ -31,7 +31,7 @@ define([ } RootRegistry.prototype.getRoots = function () { - var promises = this.providers.map(function (provider) { + const promises = this.providers.map(function (provider) { return provider(); }); diff --git a/src/api/objects/object-utils.js b/src/api/objects/object-utils.js index 8237804799..461275c7c3 100644 --- a/src/api/objects/object-utils.js +++ b/src/api/objects/object-utils.js @@ -58,9 +58,9 @@ define([ return keyString; } - var namespace = '', - key = keyString; - for (var i = 0; i < key.length; i++) { + let namespace = ''; + let key = keyString; + for (let i = 0; i < key.length; i++) { if (key[i] === "\\" && key[i + 1] === ":") { i++; // skip escape character. } else if (key[i] === ":") { diff --git a/src/api/objects/test/RootObjectProviderSpec.js b/src/api/objects/test/RootObjectProviderSpec.js index 569f124980..5cc83a4c2f 100644 --- a/src/api/objects/test/RootObjectProviderSpec.js +++ b/src/api/objects/test/RootObjectProviderSpec.js @@ -25,8 +25,8 @@ define([ RootObjectProvider ) { describe('RootObjectProvider', function () { - var rootRegistry, - rootObjectProvider; + let rootRegistry; + let rootObjectProvider; beforeEach(function () { rootRegistry = jasmine.createSpyObj('rootRegistry', ['getRoots']); diff --git a/src/api/objects/test/RootRegistrySpec.js b/src/api/objects/test/RootRegistrySpec.js index e088c11cb9..aaaad54015 100644 --- a/src/api/objects/test/RootRegistrySpec.js +++ b/src/api/objects/test/RootRegistrySpec.js @@ -25,10 +25,10 @@ define([ RootRegistry ) { describe('RootRegistry', function () { - var idA, - idB, - idC, - registry; + let idA; + let idB; + let idC; + let registry; beforeEach(function () { idA = { diff --git a/src/api/objects/test/object-utilsSpec.js b/src/api/objects/test/object-utilsSpec.js index 213b93e899..25f6ad07e6 100644 --- a/src/api/objects/test/object-utilsSpec.js +++ b/src/api/objects/test/object-utilsSpec.js @@ -6,7 +6,7 @@ define([ describe('objectUtils', function () { describe('keyString util', function () { - var EXPECTATIONS = { + const EXPECTATIONS = { 'ROOT': { namespace: '', key: 'ROOT' @@ -40,20 +40,20 @@ define([ }); it('parses and re-encodes "' + keyString + '"', function () { - var identifier = objectUtils.parseKeyString(keyString); + const identifier = objectUtils.parseKeyString(keyString); expect(objectUtils.makeKeyString(identifier)) .toEqual(keyString); }); it('is idempotent for "' + keyString + '".', function () { - var identifier = objectUtils.parseKeyString(keyString); - var again = objectUtils.parseKeyString(identifier); + const identifier = objectUtils.parseKeyString(keyString); + let again = objectUtils.parseKeyString(identifier); expect(identifier).toEqual(again); again = objectUtils.parseKeyString(again); again = objectUtils.parseKeyString(again); expect(identifier).toEqual(again); - var againKeyString = objectUtils.makeKeyString(again); + let againKeyString = objectUtils.makeKeyString(again); expect(againKeyString).toEqual(keyString); againKeyString = objectUtils.makeKeyString(againKeyString); againKeyString = objectUtils.makeKeyString(againKeyString); diff --git a/src/api/overlays/ProgressDialog.js b/src/api/overlays/ProgressDialog.js index e119bbc864..673270d72f 100644 --- a/src/api/overlays/ProgressDialog.js +++ b/src/api/overlays/ProgressDialog.js @@ -2,7 +2,7 @@ import ProgressDialogComponent from './components/ProgressDialogComponent.vue'; import Overlay from './Overlay'; import Vue from 'vue'; -var component; +let component; class ProgressDialog extends Overlay { constructor({progressPerc, progressText, iconClass, message, title, hint, timestamp, ...options}) { diff --git a/src/api/telemetry/DefaultMetadataProvider.js b/src/api/telemetry/DefaultMetadataProvider.js index f67b958bf7..45f29f271f 100644 --- a/src/api/telemetry/DefaultMetadataProvider.js +++ b/src/api/telemetry/DefaultMetadataProvider.js @@ -52,7 +52,7 @@ define([ * @private */ function valueMetadatasFromOldFormat(metadata) { - var valueMetadatas = []; + const valueMetadatas = []; valueMetadatas.push({ key: 'name', @@ -60,7 +60,7 @@ define([ }); metadata.domains.forEach(function (domain, index) { - var valueMetadata = _.clone(domain); + const valueMetadata = _.clone(domain); valueMetadata.hints = { domain: index + 1 }; @@ -68,7 +68,7 @@ define([ }); metadata.ranges.forEach(function (range, index) { - var valueMetadata = _.clone(range); + const valueMetadata = _.clone(range); valueMetadata.hints = { range: index, priority: index + metadata.domains.length + 1 @@ -100,9 +100,9 @@ define([ * Returns telemetry metadata for a given domain object. */ DefaultMetadataProvider.prototype.getMetadata = function (domainObject) { - var metadata = domainObject.telemetry || {}; + const metadata = domainObject.telemetry || {}; if (this.typeHasTelemetry(domainObject)) { - var typeMetadata = this.typeService.getType(domainObject.type).typeDef.telemetry; + const typeMetadata = this.typeService.getType(domainObject.type).typeDef.telemetry; Object.assign(metadata, typeMetadata); if (!metadata.values) { metadata.values = valueMetadatasFromOldFormat(metadata); diff --git a/src/api/telemetry/TelemetryAPI.js b/src/api/telemetry/TelemetryAPI.js index a5f0f4fc09..26e01bd6e1 100644 --- a/src/api/telemetry/TelemetryAPI.js +++ b/src/api/telemetry/TelemetryAPI.js @@ -205,7 +205,7 @@ define([ * @private */ TelemetryAPI.prototype.findSubscriptionProvider = function () { - var args = Array.prototype.slice.apply(arguments); + const args = Array.prototype.slice.apply(arguments); function supportsDomainObject(provider) { return provider.supportsSubscribe.apply(provider, args); } @@ -217,7 +217,7 @@ define([ * @private */ TelemetryAPI.prototype.findRequestProvider = function (domainObject) { - var args = Array.prototype.slice.apply(arguments); + const args = Array.prototype.slice.apply(arguments); function supportsDomainObject(provider) { return provider.supportsRequest.apply(provider, args); } @@ -282,7 +282,7 @@ define([ } this.standardizeRequestOptions(arguments[1]); - var provider = this.findRequestProvider.apply(this, arguments); + const provider = this.findRequestProvider.apply(this, arguments); if (!provider) { return Promise.reject('No provider found'); } @@ -310,14 +310,14 @@ define([ * the subscription */ TelemetryAPI.prototype.subscribe = function (domainObject, callback, options) { - var provider = this.findSubscriptionProvider(domainObject); + const provider = this.findSubscriptionProvider(domainObject); if (!this.subscribeCache) { this.subscribeCache = {}; } - var keyString = objectUtils.makeKeyString(domainObject.identifier); - var subscriber = this.subscribeCache[keyString]; + const keyString = objectUtils.makeKeyString(domainObject.identifier); + let subscriber = this.subscribeCache[keyString]; if (!subscriber) { subscriber = this.subscribeCache[keyString] = { @@ -357,12 +357,12 @@ define([ */ TelemetryAPI.prototype.getMetadata = function (domainObject) { if (!this.metadataCache.has(domainObject)) { - var metadataProvider = this.findMetadataProvider(domainObject); + const metadataProvider = this.findMetadataProvider(domainObject); if (!metadataProvider) { return; } - var metadata = metadataProvider.getMetadata(domainObject); + const metadata = metadataProvider.getMetadata(domainObject); this.metadataCache.set( domainObject, @@ -379,12 +379,12 @@ define([ * */ TelemetryAPI.prototype.commonValuesForHints = function (metadatas, hints) { - var options = metadatas.map(function (metadata) { - var values = metadata.valuesForHints(hints); + const options = metadatas.map(function (metadata) { + const values = metadata.valuesForHints(hints); return _.keyBy(values, 'key'); }).reduce(function (a, b) { - var results = {}; + const results = {}; Object.keys(a).forEach(function (key) { if (Object.prototype.hasOwnProperty.call(b, key)) { results[key] = a[key]; @@ -393,7 +393,7 @@ define([ return results; }); - var sortKeys = hints.map(function (h) { + const sortKeys = hints.map(function (h) { return 'hints.' + h; }); @@ -428,7 +428,7 @@ define([ */ TelemetryAPI.prototype.getFormatMap = function (metadata) { if (!this.formatMapCache.has(metadata)) { - var formatMap = metadata.values().reduce(function (map, valueMetadata) { + const formatMap = metadata.values().reduce(function (map, valueMetadata) { map[valueMetadata.key] = this.getValueFormatter(valueMetadata); return map; @@ -489,7 +489,7 @@ define([ * @memberof module:openmct.TelemetryAPI~TelemetryProvider# */ TelemetryAPI.prototype.getLimitEvaluator = function (domainObject) { - var provider = this.findLimitEvaluator(domainObject); + const provider = this.findLimitEvaluator(domainObject); if (!provider) { return { evaluate: function () {} diff --git a/src/api/telemetry/TelemetryAPISpec.js b/src/api/telemetry/TelemetryAPISpec.js index 2adc06e038..fbcc28a028 100644 --- a/src/api/telemetry/TelemetryAPISpec.js +++ b/src/api/telemetry/TelemetryAPISpec.js @@ -26,9 +26,9 @@ define([ TelemetryAPI ) { xdescribe('Telemetry API', function () { - var openmct; - var telemetryAPI; - var mockTypeService; + let openmct; + let telemetryAPI; + let mockTypeService; beforeEach(function () { openmct = { @@ -54,8 +54,8 @@ define([ }); describe('telemetry providers', function () { - var telemetryProvider, - domainObject; + let telemetryProvider; + let domainObject; beforeEach(function () { telemetryProvider = jasmine.createSpyObj('telemetryProvider', [ @@ -74,10 +74,10 @@ define([ }); it('provides consistent results without providers', function () { - var unsubscribe = telemetryAPI.subscribe(domainObject); + const unsubscribe = telemetryAPI.subscribe(domainObject); expect(unsubscribe).toEqual(jasmine.any(Function)); - var response = telemetryAPI.request(domainObject); + const response = telemetryAPI.request(domainObject); expect(response).toEqual(jasmine.any(Promise)); }); @@ -86,14 +86,14 @@ define([ telemetryProvider.supportsRequest.and.returnValue(false); telemetryAPI.addProvider(telemetryProvider); - var callback = jasmine.createSpy('callback'); - var unsubscribe = telemetryAPI.subscribe(domainObject, callback); + const callback = jasmine.createSpy('callback'); + const unsubscribe = telemetryAPI.subscribe(domainObject, callback); expect(telemetryProvider.supportsSubscribe) .toHaveBeenCalledWith(domainObject); expect(telemetryProvider.subscribe).not.toHaveBeenCalled(); expect(unsubscribe).toEqual(jasmine.any(Function)); - var response = telemetryAPI.request(domainObject); + const response = telemetryAPI.request(domainObject); expect(telemetryProvider.supportsRequest) .toHaveBeenCalledWith(domainObject, jasmine.any(Object)); expect(telemetryProvider.request).not.toHaveBeenCalled(); @@ -101,13 +101,13 @@ define([ }); it('sends subscribe calls to matching providers', function () { - var unsubFunc = jasmine.createSpy('unsubscribe'); + const unsubFunc = jasmine.createSpy('unsubscribe'); telemetryProvider.subscribe.and.returnValue(unsubFunc); telemetryProvider.supportsSubscribe.and.returnValue(true); telemetryAPI.addProvider(telemetryProvider); - var callback = jasmine.createSpy('callback'); - var unsubscribe = telemetryAPI.subscribe(domainObject, callback); + const callback = jasmine.createSpy('callback'); + const unsubscribe = telemetryAPI.subscribe(domainObject, callback); expect(telemetryProvider.supportsSubscribe.calls.count()).toBe(1); expect(telemetryProvider.supportsSubscribe) .toHaveBeenCalledWith(domainObject); @@ -115,7 +115,7 @@ define([ expect(telemetryProvider.subscribe) .toHaveBeenCalledWith(domainObject, jasmine.any(Function)); - var notify = telemetryProvider.subscribe.calls.mostRecent().args[1]; + const notify = telemetryProvider.subscribe.calls.mostRecent().args[1]; notify('someValue'); expect(callback).toHaveBeenCalledWith('someValue'); @@ -129,19 +129,19 @@ define([ }); it('subscribes once per object', function () { - var unsubFunc = jasmine.createSpy('unsubscribe'); + const unsubFunc = jasmine.createSpy('unsubscribe'); telemetryProvider.subscribe.and.returnValue(unsubFunc); telemetryProvider.supportsSubscribe.and.returnValue(true); telemetryAPI.addProvider(telemetryProvider); - var callback = jasmine.createSpy('callback'); - var callbacktwo = jasmine.createSpy('callback two'); - var unsubscribe = telemetryAPI.subscribe(domainObject, callback); - var unsubscribetwo = telemetryAPI.subscribe(domainObject, callbacktwo); + const callback = jasmine.createSpy('callback'); + const callbacktwo = jasmine.createSpy('callback two'); + const unsubscribe = telemetryAPI.subscribe(domainObject, callback); + const unsubscribetwo = telemetryAPI.subscribe(domainObject, callbacktwo); expect(telemetryProvider.subscribe.calls.count()).toBe(1); - var notify = telemetryProvider.subscribe.calls.mostRecent().args[1]; + const notify = telemetryProvider.subscribe.calls.mostRecent().args[1]; notify('someValue'); expect(callback).toHaveBeenCalledWith('someValue'); expect(callbacktwo).toHaveBeenCalledWith('someValue'); @@ -160,20 +160,20 @@ define([ }); it('only deletes subscription cache when there are no more subscribers', function () { - var unsubFunc = jasmine.createSpy('unsubscribe'); + const unsubFunc = jasmine.createSpy('unsubscribe'); telemetryProvider.subscribe.and.returnValue(unsubFunc); telemetryProvider.supportsSubscribe.and.returnValue(true); telemetryAPI.addProvider(telemetryProvider); - var callback = jasmine.createSpy('callback'); - var callbacktwo = jasmine.createSpy('callback two'); - var callbackThree = jasmine.createSpy('callback three'); - var unsubscribe = telemetryAPI.subscribe(domainObject, callback); - var unsubscribeTwo = telemetryAPI.subscribe(domainObject, callbacktwo); + const callback = jasmine.createSpy('callback'); + const callbacktwo = jasmine.createSpy('callback two'); + const callbackThree = jasmine.createSpy('callback three'); + const unsubscribe = telemetryAPI.subscribe(domainObject, callback); + const unsubscribeTwo = telemetryAPI.subscribe(domainObject, callbacktwo); expect(telemetryProvider.subscribe.calls.count()).toBe(1); unsubscribe(); - var unsubscribeThree = telemetryAPI.subscribe(domainObject, callbackThree); + const unsubscribeThree = telemetryAPI.subscribe(domainObject, callbackThree); // Regression test for where subscription cache was deleted on each unsubscribe, resulting in // superfluous additional subscriptions. If the subscription cache is being deleted on each unsubscribe, // then a subsequent subscribe will result in a new subscription at the provider. @@ -183,13 +183,13 @@ define([ }); it('does subscribe/unsubscribe', function () { - var unsubFunc = jasmine.createSpy('unsubscribe'); + const unsubFunc = jasmine.createSpy('unsubscribe'); telemetryProvider.subscribe.and.returnValue(unsubFunc); telemetryProvider.supportsSubscribe.and.returnValue(true); telemetryAPI.addProvider(telemetryProvider); - var callback = jasmine.createSpy('callback'); - var unsubscribe = telemetryAPI.subscribe(domainObject, callback); + const callback = jasmine.createSpy('callback'); + let unsubscribe = telemetryAPI.subscribe(domainObject, callback); expect(telemetryProvider.subscribe.calls.count()).toBe(1); unsubscribe(); @@ -199,11 +199,11 @@ define([ }); it('subscribes for different object', function () { - var unsubFuncs = []; - var notifiers = []; + const unsubFuncs = []; + const notifiers = []; telemetryProvider.supportsSubscribe.and.returnValue(true); telemetryProvider.subscribe.and.callFake(function (obj, cb) { - var unsubFunc = jasmine.createSpy('unsubscribe ' + unsubFuncs.length); + const unsubFunc = jasmine.createSpy('unsubscribe ' + unsubFuncs.length); unsubFuncs.push(unsubFunc); notifiers.push(cb); @@ -211,14 +211,14 @@ define([ }); telemetryAPI.addProvider(telemetryProvider); - var otherDomainObject = JSON.parse(JSON.stringify(domainObject)); + const otherDomainObject = JSON.parse(JSON.stringify(domainObject)); otherDomainObject.identifier.namespace = 'other'; - var callback = jasmine.createSpy('callback'); - var callbacktwo = jasmine.createSpy('callback two'); + const callback = jasmine.createSpy('callback'); + const callbacktwo = jasmine.createSpy('callback two'); - var unsubscribe = telemetryAPI.subscribe(domainObject, callback); - var unsubscribetwo = telemetryAPI.subscribe(otherDomainObject, callbacktwo); + const unsubscribe = telemetryAPI.subscribe(domainObject, callback); + const unsubscribetwo = telemetryAPI.subscribe(otherDomainObject, callbacktwo); expect(telemetryProvider.subscribe.calls.count()).toBe(2); @@ -239,12 +239,12 @@ define([ }); it('sends requests to matching providers', function () { - var telemPromise = Promise.resolve([]); + const telemPromise = Promise.resolve([]); telemetryProvider.supportsRequest.and.returnValue(true); telemetryProvider.request.and.returnValue(telemPromise); telemetryAPI.addProvider(telemetryProvider); - var result = telemetryAPI.request(domainObject); + const result = telemetryAPI.request(domainObject); expect(result).toBe(telemPromise); expect(telemetryProvider.supportsRequest).toHaveBeenCalledWith( domainObject, diff --git a/src/api/telemetry/TelemetryMetadataManager.js b/src/api/telemetry/TelemetryMetadataManager.js index 5040acbfa3..fb7911ad6b 100644 --- a/src/api/telemetry/TelemetryMetadataManager.js +++ b/src/api/telemetry/TelemetryMetadataManager.js @@ -121,7 +121,7 @@ define([ return hints.every(hasHint, metadata); } - var matchingMetadata = this.valueMetadatas.filter(hasHints); + const matchingMetadata = this.valueMetadatas.filter(hasHints); let iteratees = hints.map(hint => { return (metadata) => { return metadata.hints[hint]; diff --git a/src/api/telemetry/TelemetryValueFormatter.js b/src/api/telemetry/TelemetryValueFormatter.js index c6adda9bd7..7278383e2a 100644 --- a/src/api/telemetry/TelemetryValueFormatter.js +++ b/src/api/telemetry/TelemetryValueFormatter.js @@ -30,7 +30,7 @@ define([ // TODO: needs reference to formatService; function TelemetryValueFormatter(valueMetadata, formatService) { - var numberFormatter = { + const numberFormatter = { parse: function (x) { return Number(x); }, @@ -82,8 +82,8 @@ define([ // Check for formatString support once instead of per format call. if (valueMetadata.formatString) { - var baseFormat = this.formatter.format; - var formatString = valueMetadata.formatString; + const baseFormat = this.formatter.format; + const formatString = valueMetadata.formatString; this.formatter.format = function (value) { return printj.sprintf(formatString, baseFormat.call(this, value)); }; diff --git a/src/api/time/TimeAPI.js b/src/api/time/TimeAPI.js index 481be98df4..6c8568d8f3 100644 --- a/src/api/time/TimeAPI.js +++ b/src/api/time/TimeAPI.js @@ -205,7 +205,7 @@ define(['EventEmitter'], function (EventEmitter) { */ TimeAPI.prototype.bounds = function (newBounds) { if (arguments.length > 0) { - var validationResult = this.validateBounds(newBounds); + const validationResult = this.validateBounds(newBounds); if (validationResult !== true) { throw new Error(validationResult); } @@ -251,7 +251,7 @@ define(['EventEmitter'], function (EventEmitter) { ); } - var timeSystem; + let timeSystem; if (timeSystemOrKey === undefined) { throw "Please provide a time system"; @@ -328,7 +328,7 @@ define(['EventEmitter'], function (EventEmitter) { * using current offsets. */ TimeAPI.prototype.tick = function (timestamp) { - var newBounds = { + const newBounds = { start: timestamp + this.offsets.start, end: timestamp + this.offsets.end }; @@ -357,7 +357,7 @@ define(['EventEmitter'], function (EventEmitter) { */ TimeAPI.prototype.clock = function (keyOrClock, offsets) { if (arguments.length === 2) { - var clock; + let clock; if (typeof keyOrClock === 'string') { clock = this.clocks.get(keyOrClock); @@ -371,7 +371,7 @@ define(['EventEmitter'], function (EventEmitter) { } } - var previousClock = this.activeClock; + const previousClock = this.activeClock; if (previousClock !== undefined) { previousClock.off("tick", this.tick); } @@ -422,15 +422,15 @@ define(['EventEmitter'], function (EventEmitter) { TimeAPI.prototype.clockOffsets = function (offsets) { if (arguments.length > 0) { - var validationResult = this.validateOffsets(offsets); + const validationResult = this.validateOffsets(offsets); if (validationResult !== true) { throw new Error(validationResult); } this.offsets = offsets; - var currentValue = this.activeClock.currentValue(); - var newBounds = { + const currentValue = this.activeClock.currentValue(); + const newBounds = { start: currentValue + offsets.start, end: currentValue + offsets.end }; diff --git a/src/api/time/TimeAPISpec.js b/src/api/time/TimeAPISpec.js index bac3862e0b..63cfec8f72 100644 --- a/src/api/time/TimeAPISpec.js +++ b/src/api/time/TimeAPISpec.js @@ -22,14 +22,14 @@ define(['./TimeAPI'], function (TimeAPI) { describe("The Time API", function () { - var api, - timeSystemKey, - timeSystem, - clockKey, - clock, - bounds, - eventListener, - toi; + let api; + let timeSystemKey; + let timeSystem; + let clockKey; + let clock; + let bounds; + let eventListener; + let toi; beforeEach(function () { api = new TimeAPI(); @@ -162,7 +162,7 @@ define(['./TimeAPI'], function (TimeAPI) { }); it("Allows a registered tick source to be activated", function () { - var mockTickSource = jasmine.createSpyObj("mockTickSource", [ + const mockTickSource = jasmine.createSpyObj("mockTickSource", [ "on", "off", "currentValue" @@ -171,9 +171,9 @@ define(['./TimeAPI'], function (TimeAPI) { }); describe(" when enabling a tick source", function () { - var mockTickSource; - var anotherMockTickSource; - var mockOffsets = { + let mockTickSource; + let anotherMockTickSource; + const mockOffsets = { start: 0, end: 1 }; @@ -229,15 +229,15 @@ define(['./TimeAPI'], function (TimeAPI) { }); it("on tick, observes offsets, and indicates tick in bounds callback", function () { - var mockTickSource = jasmine.createSpyObj("clock", [ + const mockTickSource = jasmine.createSpyObj("clock", [ "on", "off", "currentValue" ]); mockTickSource.currentValue.and.returnValue(100); - var tickCallback; - var boundsCallback = jasmine.createSpy("boundsCallback"); - var clockOffsets = { + let tickCallback; + const boundsCallback = jasmine.createSpy("boundsCallback"); + const clockOffsets = { start: -100, end: 100 }; diff --git a/src/api/types/Type.js b/src/api/types/Type.js index c9fb10e266..86b3ef19c4 100644 --- a/src/api/types/Type.js +++ b/src/api/types/Type.js @@ -55,7 +55,7 @@ define(function () { * @private */ Type.prototype.toLegacyDefinition = function () { - var def = {}; + const def = {}; def.name = this.definition.name; def.cssClass = this.definition.cssClass; def.description = this.definition.description; diff --git a/src/api/types/TypeRegistrySpec.js b/src/api/types/TypeRegistrySpec.js index 27b8efa027..6917d0c9e1 100644 --- a/src/api/types/TypeRegistrySpec.js +++ b/src/api/types/TypeRegistrySpec.js @@ -22,7 +22,7 @@ define(['./TypeRegistry', './Type'], function (TypeRegistry, Type) { describe('The Type API', function () { - var typeRegistryInstance; + let typeRegistryInstance; beforeEach(function () { typeRegistryInstance = new TypeRegistry (); diff --git a/src/plugins/LADTable/components/LADRow.vue b/src/plugins/LADTable/components/LADRow.vue index e64891d414..e36b18fdd4 100644 --- a/src/plugins/LADTable/components/LADRow.vue +++ b/src/plugins/LADTable/components/LADRow.vue @@ -125,8 +125,8 @@ export default { }, methods: { updateValues(datum) { - let newTimestamp = this.getParsedTimestamp(datum), - limit; + let newTimestamp = this.getParsedTimestamp(datum); + let limit; if (this.shouldUpdate(newTimestamp)) { this.timestamp = newTimestamp; @@ -140,9 +140,9 @@ export default { } }, shouldUpdate(newTimestamp) { - let newTimestampInBounds = this.inBounds(newTimestamp), - noExistingTimestamp = this.timestamp === undefined, - newTimestampIsLatest = newTimestamp > this.timestamp; + let newTimestampInBounds = this.inBounds(newTimestamp); + let noExistingTimestamp = this.timestamp === undefined; + let newTimestampIsLatest = newTimestamp > this.timestamp; return newTimestampInBounds && (noExistingTimestamp || newTimestampIsLatest); diff --git a/src/plugins/LADTable/components/LadTableSet.vue b/src/plugins/LADTable/components/LadTableSet.vue index 03cd6966ed..9d30ad032f 100644 --- a/src/plugins/LADTable/components/LadTableSet.vue +++ b/src/plugins/LADTable/components/LadTableSet.vue @@ -110,9 +110,9 @@ export default { this.$set(this.secondaryTelemetryObjects, primary.key, []); this.primaryTelemetryObjects.push(primary); - let composition = this.openmct.composition.get(primary.domainObject), - addCallback = this.addSecondary(primary), - removeCallback = this.removeSecondary(primary); + let composition = this.openmct.composition.get(primary.domainObject); + let addCallback = this.addSecondary(primary); + let removeCallback = this.removeSecondary(primary); composition.on('add', addCallback); composition.on('remove', removeCallback); @@ -125,8 +125,8 @@ export default { }); }, removePrimary(identifier) { - let index = this.primaryTelemetryObjects.findIndex(primary => this.openmct.objects.makeKeyString(identifier) === primary.key), - primary = this.primaryTelemetryObjects[index]; + let index = this.primaryTelemetryObjects.findIndex(primary => this.openmct.objects.makeKeyString(identifier) === primary.key); + let primary = this.primaryTelemetryObjects[index]; this.$delete(this.secondaryTelemetryObjects, primary.key); this.primaryTelemetryObjects.splice(index, 1); @@ -151,8 +151,8 @@ export default { }, removeSecondary(primary) { return (identifier) => { - let array = this.secondaryTelemetryObjects[primary.key], - index = array.findIndex(secondary => this.openmct.objects.makeKeyString(identifier) === secondary.key); + let array = this.secondaryTelemetryObjects[primary.key]; + let index = array.findIndex(secondary => this.openmct.objects.makeKeyString(identifier) === secondary.key); array.splice(index, 1); diff --git a/src/plugins/LADTable/pluginSpec.js b/src/plugins/LADTable/pluginSpec.js index d36bdee887..64160a1c83 100644 --- a/src/plugins/LADTable/pluginSpec.js +++ b/src/plugins/LADTable/pluginSpec.js @@ -43,24 +43,24 @@ function utcTimeFormat(value) { describe("The LAD Table", () => { const ladTableKey = 'LadTable'; - let openmct, - ladPlugin, - parent, - child, - telemetryCount = 3, - timeFormat = 'utc', - mockTelemetry = getMockTelemetry({ - count: telemetryCount, - format: timeFormat - }), - mockObj = getMockObjects({ - objectKeyStrings: ['ladTable', 'telemetry'], - format: timeFormat - }), - bounds = { - start: 0, - end: 4 - }; + let openmct; + let ladPlugin; + let parent; + let child; + let telemetryCount = 3; + let timeFormat = 'utc'; + let mockTelemetry = getMockTelemetry({ + count: telemetryCount, + format: timeFormat + }); + let mockObj = getMockObjects({ + objectKeyStrings: ['ladTable', 'telemetry'], + format: timeFormat + }); + let bounds = { + start: 0, + end: 4 + }; // add telemetry object as composition in lad table mockObj.ladTable.composition.push(mockObj.telemetry.identifier); @@ -98,10 +98,11 @@ describe("The LAD Table", () => { }); it("should provide a table view only for lad table objects", () => { - let applicableViews = openmct.objectViews.get(mockObj.ladTable), - ladTableView = applicableViews.find( - (viewProvider) => viewProvider.key === ladTableKey - ); + let applicableViews = openmct.objectViews.get(mockObj.ladTable); + + let ladTableView = applicableViews.find( + (viewProvider) => viewProvider.key === ladTableKey + ); expect(applicableViews.length).toEqual(1); expect(ladTableView).toBeDefined(); @@ -129,38 +130,39 @@ describe("The LAD Table", () => { }); describe("table view", () => { - let applicableViews, - ladTableViewProvider, - ladTableView, - anotherTelemetryObj = getMockObjects({ - objectKeyStrings: ['telemetry'], - overwrite: { - telemetry: { - name: "New Telemetry Object", - identifier: { - namespace: "", - key: "another-telemetry-object" - } + let applicableViews; + let ladTableViewProvider; + let ladTableView; + let anotherTelemetryObj = getMockObjects({ + objectKeyStrings: ['telemetry'], + overwrite: { + telemetry: { + name: "New Telemetry Object", + identifier: { + namespace: "", + key: "another-telemetry-object" } } - }).telemetry; + } + }).telemetry; // add another telemetry object as composition in lad table to test multi rows mockObj.ladTable.composition.push(anotherTelemetryObj.identifier); beforeEach(async () => { - let telemetryRequestResolve, - telemetryObjectResolve, - anotherTelemetryObjectResolve; + let telemetryRequestResolve; + let telemetryObjectResolve; + let anotherTelemetryObjectResolve; let telemetryRequestPromise = new Promise((resolve) => { - telemetryRequestResolve = resolve; - }), - telemetryObjectPromise = new Promise((resolve) => { - telemetryObjectResolve = resolve; - }), - anotherTelemetryObjectPromise = new Promise((resolve) => { - anotherTelemetryObjectResolve = resolve; - }); + telemetryRequestResolve = resolve; + }); + let telemetryObjectPromise = new Promise((resolve) => { + telemetryObjectResolve = resolve; + }); + let anotherTelemetryObjectPromise = new Promise((resolve) => { + anotherTelemetryObjectResolve = resolve; + }); + openmct.telemetry.request.and.callFake(() => { telemetryRequestResolve(mockTelemetry); @@ -208,8 +210,9 @@ describe("The LAD Table", () => { }); it("should show the name provided for the the telemetry producing object", () => { - const rowName = parent.querySelector(TABLE_BODY_FIRST_ROW_FIRST_DATA).innerText, - expectedName = mockObj.telemetry.name; + const rowName = parent.querySelector(TABLE_BODY_FIRST_ROW_FIRST_DATA).innerText; + + const expectedName = mockObj.telemetry.name; expect(rowName).toBe(expectedName); }); @@ -235,29 +238,34 @@ describe("The LAD Table", () => { describe("The LAD Table Set", () => { const ladTableSetKey = 'LadTableSet'; - let openmct, - ladPlugin, - parent, - child, - telemetryCount = 3, - timeFormat = 'utc', - mockTelemetry = getMockTelemetry({ - count: telemetryCount, - format: timeFormat - }), - mockObj = getMockObjects({ - objectKeyStrings: ['ladTable', 'ladTableSet', 'telemetry'] - }), - bounds = { - start: 0, - end: 4 - }; + let openmct; + let ladPlugin; + let parent; + let child; + let telemetryCount = 3; + let timeFormat = 'utc'; + + let mockTelemetry = getMockTelemetry({ + count: telemetryCount, + format: timeFormat + }); + + let mockObj = getMockObjects({ + objectKeyStrings: ['ladTable', 'ladTableSet', 'telemetry'] + }); + + let bounds = { + start: 0, + end: 4 + }; + // add mock telemetry to lad table and lad table to lad table set (composition) mockObj.ladTable.composition.push(mockObj.telemetry.identifier); mockObj.ladTableSet.composition.push(mockObj.ladTable.identifier); beforeEach((done) => { const appHolder = document.createElement('div'); + appHolder.style.width = '640px'; appHolder.style.height = '480px'; @@ -288,10 +296,11 @@ describe("The LAD Table Set", () => { }); it("should provide a lad table set view only for lad table set objects", () => { - let applicableViews = openmct.objectViews.get(mockObj.ladTableSet), - ladTableSetView = applicableViews.find( - (viewProvider) => viewProvider.key === ladTableSetKey - ); + let applicableViews = openmct.objectViews.get(mockObj.ladTableSet); + + let ladTableSetView = applicableViews.find( + (viewProvider) => viewProvider.key === ladTableSetKey + ); expect(applicableViews.length).toEqual(1); expect(ladTableSetView).toBeDefined(); @@ -319,44 +328,50 @@ describe("The LAD Table Set", () => { }); describe("table view", () => { - let applicableViews, - ladTableSetViewProvider, - ladTableSetView, - otherObj = getMockObjects({ - objectKeyStrings: ['ladTable'], - overwrite: { - ladTable: { - name: "New LAD Table Object", - identifier: { - namespace: "", - key: "another-lad-object" - } + let applicableViews; + let ladTableSetViewProvider; + let ladTableSetView; + + let otherObj = getMockObjects({ + objectKeyStrings: ['ladTable'], + overwrite: { + ladTable: { + name: "New LAD Table Object", + identifier: { + namespace: "", + key: "another-lad-object" } } - }); + } + }); // add another lad table (with telemetry object) object to the lad table set for multi row test otherObj.ladTable.composition.push(mockObj.telemetry.identifier); mockObj.ladTableSet.composition.push(otherObj.ladTable.identifier); beforeEach(async () => { - let telemetryRequestResolve, - ladObjectResolve, - anotherLadObjectResolve; + let telemetryRequestResolve; + let ladObjectResolve; + let anotherLadObjectResolve; + let telemetryRequestPromise = new Promise((resolve) => { - telemetryRequestResolve = resolve; - }), - ladObjectPromise = new Promise((resolve) => { - ladObjectResolve = resolve; - }), - anotherLadObjectPromise = new Promise((resolve) => { - anotherLadObjectResolve = resolve; - }); + telemetryRequestResolve = resolve; + }); + + let ladObjectPromise = new Promise((resolve) => { + ladObjectResolve = resolve; + }); + + let anotherLadObjectPromise = new Promise((resolve) => { + anotherLadObjectResolve = resolve; + }); + openmct.telemetry.request.and.callFake(() => { telemetryRequestResolve(mockTelemetry); return telemetryRequestPromise; }); + openmct.objects.get.and.callFake((obj) => { if (obj.key === 'lad-object') { ladObjectResolve(mockObj.ladObject); @@ -389,6 +404,7 @@ describe("The LAD Table Set", () => { it("should show one row per lad table object in the composition", () => { const rowCount = parent.querySelectorAll(LAD_SET_TABLE_HEADERS).length; + expect(rowCount).toBe(mockObj.ladTableSet.composition.length); pending(); }); diff --git a/src/plugins/URLIndicatorPlugin/URLIndicator.js b/src/plugins/URLIndicatorPlugin/URLIndicator.js index ff78535415..88fd5e6734 100644 --- a/src/plugins/URLIndicatorPlugin/URLIndicator.js +++ b/src/plugins/URLIndicatorPlugin/URLIndicator.js @@ -29,15 +29,15 @@ define( // 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. - var CONNECTED = { - statusClass: "s-status-on" - }, - PENDING = { - statusClass: "s-status-warning-lo" - }, - DISCONNECTED = { - statusClass: "s-status-warning-hi" - }; + const CONNECTED = { + statusClass: "s-status-on" + }; + const PENDING = { + statusClass: "s-status-warning-lo" + }; + const DISCONNECTED = { + statusClass: "s-status-warning-hi" + }; function URLIndicator(options, simpleIndicator) { this.bindMethods(); this.count = 0; diff --git a/src/plugins/URLIndicatorPlugin/URLIndicatorPlugin.js b/src/plugins/URLIndicatorPlugin/URLIndicatorPlugin.js index ddd942e0f2..edc5826efa 100644 --- a/src/plugins/URLIndicatorPlugin/URLIndicatorPlugin.js +++ b/src/plugins/URLIndicatorPlugin/URLIndicatorPlugin.js @@ -23,8 +23,8 @@ define(['./URLIndicator'], function URLIndicatorPlugin(URLIndicator) { return function (opts) { return function install(openmct) { - var simpleIndicator = openmct.indicators.simpleIndicator(); - var urlIndicator = new URLIndicator(opts, simpleIndicator); + const simpleIndicator = openmct.indicators.simpleIndicator(); + const urlIndicator = new URLIndicator(opts, simpleIndicator); openmct.indicators.add(simpleIndicator); diff --git a/src/plugins/URLIndicatorPlugin/URLIndicatorSpec.js b/src/plugins/URLIndicatorPlugin/URLIndicatorSpec.js index 60cb2abc09..7df9500a8f 100644 --- a/src/plugins/URLIndicatorPlugin/URLIndicatorSpec.js +++ b/src/plugins/URLIndicatorPlugin/URLIndicatorSpec.js @@ -33,14 +33,14 @@ define( MCT, $ ) { - var defaultAjaxFunction = $.ajax; + const defaultAjaxFunction = $.ajax; describe("The URLIndicator", function () { - var openmct; - var indicatorElement; - var pluginOptions; - var ajaxOptions; - var urlIndicator; // eslint-disable-line + let openmct; + let indicatorElement; + let pluginOptions; + let ajaxOptions; + let urlIndicator; // eslint-disable-line beforeEach(function () { jasmine.clock().install(); diff --git a/src/plugins/autoflow/AutoflowTabularController.js b/src/plugins/autoflow/AutoflowTabularController.js index c8489393bd..28d4e3a2af 100644 --- a/src/plugins/autoflow/AutoflowTabularController.js +++ b/src/plugins/autoflow/AutoflowTabularController.js @@ -58,8 +58,8 @@ define([ * @private */ AutoflowTabularController.prototype.addRow = function (childObject) { - var identifier = childObject.identifier; - var id = [identifier.namespace, identifier.key].join(":"); + const identifier = childObject.identifier; + const id = [identifier.namespace, identifier.key].join(":"); if (!this.rows[id]) { this.rows[id] = { @@ -84,7 +84,7 @@ define([ * @private */ AutoflowTabularController.prototype.removeRow = function (identifier) { - var id = [identifier.namespace, identifier.key].join(":"); + const id = [identifier.namespace, identifier.key].join(":"); if (this.rows[id]) { this.data.items = this.data.items.filter(function (item) { diff --git a/src/plugins/autoflow/AutoflowTabularPlugin.js b/src/plugins/autoflow/AutoflowTabularPlugin.js index 7748fb2a39..8c0763256d 100644 --- a/src/plugins/autoflow/AutoflowTabularPlugin.js +++ b/src/plugins/autoflow/AutoflowTabularPlugin.js @@ -27,7 +27,7 @@ define([ ) { return function (options) { return function (openmct) { - var views = (openmct.mainViews || openmct.objectViews); + const views = (openmct.mainViews || openmct.objectViews); views.addProvider({ name: "Autoflow Tabular", diff --git a/src/plugins/autoflow/AutoflowTabularPluginSpec.js b/src/plugins/autoflow/AutoflowTabularPluginSpec.js index 26315b8c3b..cff04253ff 100644 --- a/src/plugins/autoflow/AutoflowTabularPluginSpec.js +++ b/src/plugins/autoflow/AutoflowTabularPluginSpec.js @@ -28,9 +28,9 @@ define([ './dom-observer' ], function (AutoflowTabularPlugin, AutoflowTabularConstants, MCT, $, DOMObserver) { describe("AutoflowTabularPlugin", function () { - var testType; - var testObject; - var mockmct; + let testType; + let testObject; + let mockmct; beforeEach(function () { testType = "some-type"; @@ -44,7 +44,7 @@ define([ spyOn(mockmct.telemetry, 'request'); spyOn(mockmct.telemetry, 'subscribe'); - var plugin = new AutoflowTabularPlugin({ type: testType }); + const plugin = new AutoflowTabularPlugin({ type: testType }); plugin(mockmct); }); @@ -53,7 +53,7 @@ define([ }); describe("installs a view provider which", function () { - var provider; + let provider; beforeEach(function () { provider = @@ -69,17 +69,17 @@ define([ }); describe("provides a view which", function () { - var testKeys; - var testChildren; - var testContainer; - var testHistories; - var mockComposition; - var mockMetadata; - var mockEvaluator; - var mockUnsubscribes; - var callbacks; - var view; - var domObserver; + let testKeys; + let testChildren; + let testContainer; + let testHistories; + let mockComposition; + let mockMetadata; + let mockEvaluator; + let mockUnsubscribes; + let callbacks; + let view; + let domObserver; function waitsForChange() { return new Promise(function (resolve) { @@ -143,7 +143,7 @@ define([ mockmct.telemetry.getMetadata.and.returnValue(mockMetadata); mockmct.telemetry.getValueFormatter.and.callFake(function (metadatum) { - var mockFormatter = jasmine.createSpyObj('formatter', ['format']); + const mockFormatter = jasmine.createSpyObj('formatter', ['format']); mockFormatter.format.and.callFake(function (datum) { return datum[metadatum.hint]; }); @@ -152,13 +152,13 @@ define([ }); mockmct.telemetry.limitEvaluator.and.returnValue(mockEvaluator); mockmct.telemetry.subscribe.and.callFake(function (obj, callback) { - var key = obj.identifier.key; + const key = obj.identifier.key; callbacks[key] = callback; return mockUnsubscribes[key]; }); mockmct.telemetry.request.and.callFake(function (obj, request) { - var key = obj.identifier.key; + const key = obj.identifier.key; return Promise.resolve([testHistories[key]]); }); @@ -182,7 +182,7 @@ define([ describe("when rows have been populated", function () { function rowsMatch() { - var rows = $(testContainer).find(".l-autoflow-row").length; + const rows = $(testContainer).find(".l-autoflow-row").length; return rows === testChildren.length; } @@ -192,7 +192,7 @@ define([ }); it("adds rows on composition change", function () { - var child = { + const child = { identifier: { namespace: "test", key: "123" @@ -206,7 +206,7 @@ define([ }); it("removes rows on composition change", function () { - var child = testChildren.pop(); + const child = testChildren.pop(); emitEvent(mockComposition, 'remove', child.identifier); return domObserver.when(rowsMatch); @@ -224,8 +224,8 @@ define([ }); it("provides a button to change column width", function () { - var initialWidth = AutoflowTabularConstants.INITIAL_COLUMN_WIDTH; - var nextWidth = + const initialWidth = AutoflowTabularConstants.INITIAL_COLUMN_WIDTH; + const nextWidth = initialWidth + AutoflowTabularConstants.COLUMN_WIDTH_STEP; expect($(testContainer).find('.l-autoflow-col').css('width')) @@ -234,7 +234,7 @@ define([ $(testContainer).find('.change-column-width').click(); function widthHasChanged() { - var width = $(testContainer).find('.l-autoflow-col').css('width'); + const width = $(testContainer).find('.l-autoflow-col').css('width'); return width !== initialWidth + 'px'; } @@ -259,15 +259,15 @@ define([ return domObserver.when(rowTextDefined).then(function () { testKeys.forEach(function (key, index) { - var datum = testHistories[key]; - var $cell = $(testContainer).find(".l-autoflow-row").eq(index).find(".r"); + const datum = testHistories[key]; + const $cell = $(testContainer).find(".l-autoflow-row").eq(index).find(".r"); expect($cell.text()).toEqual(String(datum.range)); }); }); }); it("displays incoming telemetry", function () { - var testData = testKeys.map(function (key, index) { + const testData = testKeys.map(function (key, index) { return { key: key, range: index * 100, @@ -281,14 +281,14 @@ define([ return waitsForChange().then(function () { testData.forEach(function (datum, index) { - var $cell = $(testContainer).find(".l-autoflow-row").eq(index).find(".r"); + const $cell = $(testContainer).find(".l-autoflow-row").eq(index).find(".r"); expect($cell.text()).toEqual(String(datum.range)); }); }); }); it("updates classes for limit violations", function () { - var testClass = "some-limit-violation"; + const testClass = "some-limit-violation"; mockEvaluator.evaluate.and.returnValue({ cssClass: testClass }); testKeys.forEach(function (key) { callbacks[key]({ @@ -299,24 +299,24 @@ define([ return waitsForChange().then(function () { testKeys.forEach(function (datum, index) { - var $cell = $(testContainer).find(".l-autoflow-row").eq(index).find(".r"); + const $cell = $(testContainer).find(".l-autoflow-row").eq(index).find(".r"); expect($cell.hasClass(testClass)).toBe(true); }); }); }); it("automatically flows to new columns", function () { - var rowHeight = AutoflowTabularConstants.ROW_HEIGHT; - var sliderHeight = AutoflowTabularConstants.SLIDER_HEIGHT; - var count = testKeys.length; - var $container = $(testContainer); - var promiseChain = Promise.resolve(); + const rowHeight = AutoflowTabularConstants.ROW_HEIGHT; + const sliderHeight = AutoflowTabularConstants.SLIDER_HEIGHT; + const count = testKeys.length; + const $container = $(testContainer); + let promiseChain = Promise.resolve(); function columnsHaveAutoflowed() { - var itemsHeight = $container.find('.l-autoflow-items').height(); - var availableHeight = itemsHeight - sliderHeight; - var availableRows = Math.max(Math.floor(availableHeight / rowHeight), 1); - var columns = Math.ceil(count / availableRows); + const itemsHeight = $container.find('.l-autoflow-items').height(); + const availableHeight = itemsHeight - sliderHeight; + const availableRows = Math.max(Math.floor(availableHeight / rowHeight), 1); + const columns = Math.ceil(count / availableRows); return $container.find('.l-autoflow-col').length === columns; } @@ -338,7 +338,7 @@ define([ return domObserver.when(columnsHaveAutoflowed); } - for (var height = 0; height < rowHeight * count * 2; height += rowHeight / 2) { + for (let height = 0; height < rowHeight * count * 2; height += rowHeight / 2) { // eslint-disable-next-line no-invalid-this promiseChain = promiseChain.then(setHeight.bind(this, height)); } @@ -349,7 +349,7 @@ define([ }); it("loads composition exactly once", function () { - var testObj = testChildren.pop(); + const testObj = testChildren.pop(); emitEvent(mockComposition, 'remove', testObj.identifier); testChildren.push(testObj); emitEvent(mockComposition, 'add', testObj); diff --git a/src/plugins/autoflow/AutoflowTabularRowController.js b/src/plugins/autoflow/AutoflowTabularRowController.js index f4c998d834..37831d19a9 100644 --- a/src/plugins/autoflow/AutoflowTabularRowController.js +++ b/src/plugins/autoflow/AutoflowTabularRowController.js @@ -54,7 +54,7 @@ define([], function () { * @private */ AutoflowTabularRowController.prototype.updateRowData = function (datum) { - var violations = this.evaluator.evaluate(datum, this.ranges[0]); + const violations = this.evaluator.evaluate(datum, this.ranges[0]); this.initialized = true; this.data.classes = violations ? violations.cssClass : ""; diff --git a/src/plugins/autoflow/AutoflowTabularView.js b/src/plugins/autoflow/AutoflowTabularView.js index 1d76045be5..df0c73246b 100644 --- a/src/plugins/autoflow/AutoflowTabularView.js +++ b/src/plugins/autoflow/AutoflowTabularView.js @@ -31,17 +31,17 @@ define([ VueView, autoflowTemplate ) { - var ROW_HEIGHT = AutoflowTabularConstants.ROW_HEIGHT; - var SLIDER_HEIGHT = AutoflowTabularConstants.SLIDER_HEIGHT; - var INITIAL_COLUMN_WIDTH = AutoflowTabularConstants.INITIAL_COLUMN_WIDTH; - var MAX_COLUMN_WIDTH = AutoflowTabularConstants.MAX_COLUMN_WIDTH; - var COLUMN_WIDTH_STEP = AutoflowTabularConstants.COLUMN_WIDTH_STEP; + 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) { - var data = { + const data = { items: [], columns: [], width: INITIAL_COLUMN_WIDTH, @@ -49,9 +49,9 @@ define([ updated: "No updates", rowCount: 1 }; - var controller = + const controller = new AutoflowTabularController(domainObject, data, openmct); - var interval; + let interval; VueView.call(this, { data: data, @@ -62,9 +62,9 @@ define([ ? INITIAL_COLUMN_WIDTH : data.width; }, reflow: function () { - var column = []; - var index = 0; - var filteredItems = + let column = []; + let index = 0; + const filteredItems = data.items.filter(function (item) { return item.name.toLowerCase() .indexOf(data.filter.toLowerCase()) !== -1; @@ -104,11 +104,11 @@ define([ mounted: function () { controller.activate(); - var updateRowHeight = function () { - var tabularArea = this.$refs.autoflowItems; - var height = tabularArea ? tabularArea.clientHeight : 0; - var available = height - SLIDER_HEIGHT; - var rows = Math.max(1, Math.floor(available / ROW_HEIGHT)); + const updateRowHeight = function () { + const tabularArea = this.$refs.autoflowItems; + const height = tabularArea ? tabularArea.clientHeight : 0; + const available = height - SLIDER_HEIGHT; + const rows = Math.max(1, Math.floor(available / ROW_HEIGHT)); data.rowCount = rows; }.bind(this); diff --git a/src/plugins/autoflow/VueView.js b/src/plugins/autoflow/VueView.js index 0e251eb47a..3a35222705 100644 --- a/src/plugins/autoflow/VueView.js +++ b/src/plugins/autoflow/VueView.js @@ -22,7 +22,7 @@ define(['vue'], function (Vue) { function VueView(options) { - var vm = new Vue(options); + const vm = new Vue(options); this.show = function (container) { container.appendChild(vm.$mount().$el); }; diff --git a/src/plugins/autoflow/dom-observer.js b/src/plugins/autoflow/dom-observer.js index 985335fe0f..2b05540e27 100644 --- a/src/plugins/autoflow/dom-observer.js +++ b/src/plugins/autoflow/dom-observer.js @@ -33,12 +33,12 @@ define([], function () { resolve(); } else { //Latch condition not true yet, create observer on DOM and test again on change. - var config = { + const config = { attributes: true, childList: true, subtree: true }; - var observer = new MutationObserver(function () { + const observer = new MutationObserver(function () { if (latchFunction()) { resolve(); } diff --git a/src/plugins/buildInfo/plugin.js b/src/plugins/buildInfo/plugin.js index d9b699c0e6..25d067e5f7 100644 --- a/src/plugins/buildInfo/plugin.js +++ b/src/plugins/buildInfo/plugin.js @@ -25,8 +25,8 @@ define([ ) { return function (buildInfo) { return function (openmct) { - var aliases = { timestamp: "Built" }; - var descriptions = { + const aliases = { timestamp: "Built" }; + const descriptions = { timestamp: "The date on which this version of Open MCT was built.", revision: "A unique revision identifier for the client sources.", branch: "The name of the branch that was used during the build." diff --git a/src/plugins/buildInfo/pluginSpec.js b/src/plugins/buildInfo/pluginSpec.js index 500ed09ed9..2ca7058844 100644 --- a/src/plugins/buildInfo/pluginSpec.js +++ b/src/plugins/buildInfo/pluginSpec.js @@ -24,8 +24,8 @@ define([ './plugin' ], function (plugin) { describe("The buildInfo plugin", function () { - var mockmct; - var testInfo; + let mockmct; + let testInfo; beforeEach(function () { mockmct = jasmine.createSpyObj('openmct', ['legacyExtension']); diff --git a/src/plugins/clearData/plugin.js b/src/plugins/clearData/plugin.js index ecc4d2ef8a..de22d6df08 100644 --- a/src/plugins/clearData/plugin.js +++ b/src/plugins/clearData/plugin.js @@ -37,17 +37,18 @@ define([ return function install(openmct) { if (installIndicator) { let component = new Vue ({ - provide: { - openmct - }, - components: { - GlobalClearIndicator: GlobaClearIndicator.default - }, - template: '' - }), - indicator = { - element: component.$mount().$el - }; + provide: { + openmct + }, + components: { + GlobalClearIndicator: GlobaClearIndicator.default + }, + template: '' + }); + + let indicator = { + element: component.$mount().$el + }; openmct.indicators.add(indicator); } diff --git a/src/plugins/clearData/test/clearDataActionSpec.js b/src/plugins/clearData/test/clearDataActionSpec.js index 18f62dcf6d..97f5012263 100644 --- a/src/plugins/clearData/test/clearDataActionSpec.js +++ b/src/plugins/clearData/test/clearDataActionSpec.js @@ -24,21 +24,23 @@ import ClearDataActionPlugin from '../plugin.js'; import ClearDataAction from '../clearDataAction.js'; describe('When the Clear Data Plugin is installed,', function () { - var mockObjectViews = jasmine.createSpyObj('objectViews', ['emit']), - mockIndicatorProvider = jasmine.createSpyObj('indicators', ['add']), - mockContextMenuProvider = jasmine.createSpyObj('contextMenu', ['registerAction']), - openmct = { - objectViews: mockObjectViews, - indicators: mockIndicatorProvider, - contextMenu: mockContextMenuProvider, - install: function (plugin) { - plugin(this); - } - }, - mockObjectPath = [ - {name: 'mockObject1'}, - {name: 'mockObject2'} - ]; + const mockObjectViews = jasmine.createSpyObj('objectViews', ['emit']); + const mockIndicatorProvider = jasmine.createSpyObj('indicators', ['add']); + const mockContextMenuProvider = jasmine.createSpyObj('contextMenu', ['registerAction']); + + const openmct = { + objectViews: mockObjectViews, + indicators: mockIndicatorProvider, + contextMenu: mockContextMenuProvider, + install: function (plugin) { + plugin(this); + } + }; + + const mockObjectPath = [ + {name: 'mockObject1'}, + {name: 'mockObject2'} + ]; it('Global Clear Indicator is installed', function () { openmct.install(ClearDataActionPlugin([])); diff --git a/src/plugins/condition/ConditionSpec.js b/src/plugins/condition/ConditionSpec.js index 645412a863..916ba9fd9a 100644 --- a/src/plugins/condition/ConditionSpec.js +++ b/src/plugins/condition/ConditionSpec.js @@ -24,13 +24,13 @@ import Condition from "./Condition"; import {TRIGGER} from "./utils/constants"; import TelemetryCriterion from "./criterion/TelemetryCriterion"; -let openmct = {}, - testConditionDefinition, - testTelemetryObject, - conditionObj, - conditionManager, - mockTelemetryReceived, - mockTimeSystems; +let openmct = {}; +let testConditionDefinition; +let testTelemetryObject; +let conditionObj; +let conditionManager; +let mockTelemetryReceived; +let mockTimeSystems; describe("The condition", function () { diff --git a/src/plugins/condition/components/ConditionCollection.vue b/src/plugins/condition/components/ConditionCollection.vue index e0b83c9069..0b6147814e 100644 --- a/src/plugins/condition/components/ConditionCollection.vue +++ b/src/plugins/condition/components/ConditionCollection.vue @@ -194,7 +194,7 @@ export default { } if (new_index >= arr.length) { - var k = new_index - arr.length; + let k = new_index - arr.length; while ((k--) + 1) { arr.push(undefined); } diff --git a/src/plugins/condition/components/inspector/ConditionSetSelectorDialog.vue b/src/plugins/condition/components/inspector/ConditionSetSelectorDialog.vue index 1943f77136..7f66f71527 100644 --- a/src/plugins/condition/components/inspector/ConditionSetSelectorDialog.vue +++ b/src/plugins/condition/components/inspector/ConditionSetSelectorDialog.vue @@ -127,10 +127,10 @@ export default { this.searchService.query(this.searchValue).then(children => { this.filteredTreeItems = children.hits.map(child => { - let context = child.object.getCapability('context'), - object = child.object.useCapability('adapter'), - objectPath = [], - navigateToParent; + let context = child.object.getCapability('context'); + let object = child.object.useCapability('adapter'); + let objectPath = []; + let navigateToParent; if (context) { objectPath = context.getPath().slice(1) diff --git a/src/plugins/condition/criterion/TelemetryCriterionSpec.js b/src/plugins/condition/criterion/TelemetryCriterionSpec.js index ca4176321c..fe3b9fc701 100644 --- a/src/plugins/condition/criterion/TelemetryCriterionSpec.js +++ b/src/plugins/condition/criterion/TelemetryCriterionSpec.js @@ -23,12 +23,12 @@ import TelemetryCriterion from "./TelemetryCriterion"; import { getMockTelemetry } from "utils/testing"; -let openmct = {}, - mockListener, - testCriterionDefinition, - testTelemetryObject, - telemetryCriterion, - mockTelemetry = getMockTelemetry(); +let openmct = {}; +let mockListener; +let testCriterionDefinition; +let testTelemetryObject; +let telemetryCriterion; +let mockTelemetry = getMockTelemetry(); describe("The telemetry criterion", function () { diff --git a/src/plugins/displayLayout/DisplayLayoutToolbar.js b/src/plugins/displayLayout/DisplayLayoutToolbar.js index cedbd28b19..12770e919c 100644 --- a/src/plugins/displayLayout/DisplayLayoutToolbar.js +++ b/src/plugins/displayLayout/DisplayLayoutToolbar.js @@ -41,90 +41,92 @@ define(['lodash'], function (_) { }, toolbar: function (selectedObjects) { const DIALOG_FORM = { - 'text': { - name: "Text Element Properties", - sections: [ - { - rows: [ - { - key: "text", - control: "textfield", - name: "Text", - required: true - } - ] - } - ] - }, - 'image': { - name: "Image Properties", - sections: [ - { - rows: [ - { - key: "url", - control: "textfield", - name: "Image URL", - "cssClass": "l-input-lg", - required: true - } - ] - } - ] - } - }, - VIEW_TYPES = { - 'telemetry-view': { - value: 'telemetry-view', - name: 'Alphanumeric', - class: 'icon-alphanumeric' - }, - 'telemetry.plot.overlay': { - value: 'telemetry.plot.overlay', - name: 'Overlay Plot', - class: "icon-plot-overlay" - }, - 'telemetry.plot.stacked': { - value: "telemetry.plot.stacked", - name: "Stacked Plot", - class: "icon-plot-stacked" - }, - 'table': { - value: 'table', - name: 'Table', - class: 'icon-tabular-realtime' - } - }, - APPLICABLE_VIEWS = { - 'telemetry-view': [ - VIEW_TYPES['telemetry.plot.overlay'], - VIEW_TYPES['telemetry.plot.stacked'], - VIEW_TYPES.table - ], - 'telemetry.plot.overlay': [ - VIEW_TYPES['telemetry.plot.stacked'], - VIEW_TYPES.table, - VIEW_TYPES['telemetry-view'] - ], - 'telemetry.plot.stacked': [ - VIEW_TYPES['telemetry.plot.overlay'], - VIEW_TYPES.table, - VIEW_TYPES['telemetry-view'] - ], - 'table': [ - VIEW_TYPES['telemetry.plot.overlay'], - VIEW_TYPES['telemetry.plot.stacked'], - VIEW_TYPES['telemetry-view'] - ], - 'telemetry-view-multi': [ - VIEW_TYPES['telemetry.plot.overlay'], - VIEW_TYPES['telemetry.plot.stacked'], - VIEW_TYPES.table - ], - 'telemetry.plot.overlay-multi': [ - VIEW_TYPES['telemetry.plot.stacked'] + 'text': { + name: "Text Element Properties", + sections: [ + { + rows: [ + { + key: "text", + control: "textfield", + name: "Text", + required: true + } + ] + } ] - }; + }, + 'image': { + name: "Image Properties", + sections: [ + { + rows: [ + { + key: "url", + control: "textfield", + name: "Image URL", + "cssClass": "l-input-lg", + required: true + } + ] + } + ] + } + }; + + const VIEW_TYPES = { + 'telemetry-view': { + value: 'telemetry-view', + name: 'Alphanumeric', + class: 'icon-alphanumeric' + }, + 'telemetry.plot.overlay': { + value: 'telemetry.plot.overlay', + name: 'Overlay Plot', + class: "icon-plot-overlay" + }, + 'telemetry.plot.stacked': { + value: "telemetry.plot.stacked", + name: "Stacked Plot", + class: "icon-plot-stacked" + }, + 'table': { + value: 'table', + name: 'Table', + class: 'icon-tabular-realtime' + } + }; + + const APPLICABLE_VIEWS = { + 'telemetry-view': [ + VIEW_TYPES['telemetry.plot.overlay'], + VIEW_TYPES['telemetry.plot.stacked'], + VIEW_TYPES.table + ], + 'telemetry.plot.overlay': [ + VIEW_TYPES['telemetry.plot.stacked'], + VIEW_TYPES.table, + VIEW_TYPES['telemetry-view'] + ], + 'telemetry.plot.stacked': [ + VIEW_TYPES['telemetry.plot.overlay'], + VIEW_TYPES.table, + VIEW_TYPES['telemetry-view'] + ], + 'table': [ + VIEW_TYPES['telemetry.plot.overlay'], + VIEW_TYPES['telemetry.plot.stacked'], + VIEW_TYPES['telemetry-view'] + ], + 'telemetry-view-multi': [ + VIEW_TYPES['telemetry.plot.overlay'], + VIEW_TYPES['telemetry.plot.stacked'], + VIEW_TYPES.table + ], + 'telemetry.plot.overlay-multi': [ + VIEW_TYPES['telemetry.plot.stacked'] + ] + }; function getUserInput(form) { return openmct.$injector.get('dialogService').getUserInput(form, {}); @@ -494,8 +496,8 @@ define(['lodash'], function (_) { } function getPropertyFromPath(object, path) { - let splitPath = path.split('.'), - property = Object.assign({}, object); + let splitPath = path.split('.'); + let property = Object.assign({}, object); while (splitPath.length && property) { property = property[splitPath.shift()]; @@ -568,9 +570,9 @@ define(['lodash'], function (_) { function getViewSwitcherMenu(selectedParent, selectionPath, selection) { if (selection.length === 1) { - let displayLayoutContext = selectionPath[1].context, - selectedItemContext = selectionPath[0].context, - selectedItemType = selectedItemContext.item.type; + let displayLayoutContext = selectionPath[1].context; + let selectedItemContext = selectionPath[0].context; + let selectedItemType = selectedItemContext.item.type; if (selectedItemContext.layoutItem.type === 'telemetry-view') { selectedItemType = 'telemetry-view'; diff --git a/src/plugins/displayLayout/LayoutDrag.js b/src/plugins/displayLayout/LayoutDrag.js index 17e475e25b..d49b659035 100644 --- a/src/plugins/displayLayout/LayoutDrag.js +++ b/src/plugins/displayLayout/LayoutDrag.js @@ -95,7 +95,7 @@ define( * original position, in pixels */ LayoutDrag.prototype.getAdjustedPositionAndDimensions = function (pixelDelta) { - var gridDelta = toGridDelta(this.gridSize, pixelDelta); + const gridDelta = toGridDelta(this.gridSize, pixelDelta); return { position: max(add( @@ -110,7 +110,7 @@ define( }; LayoutDrag.prototype.getAdjustedPosition = function (pixelDelta) { - var gridDelta = toGridDelta(this.gridSize, pixelDelta); + const gridDelta = toGridDelta(this.gridSize, pixelDelta); return { position: max(add( diff --git a/src/plugins/displayLayout/components/DisplayLayout.vue b/src/plugins/displayLayout/components/DisplayLayout.vue index 322d6efbbe..509c50533d 100644 --- a/src/plugins/displayLayout/components/DisplayLayout.vue +++ b/src/plugins/displayLayout/components/DisplayLayout.vue @@ -429,9 +429,9 @@ export default { return; } - let keyString = this.openmct.objects.makeKeyString(item.identifier), - telemetryViewCount = this.telemetryViewMap[keyString], - objectViewCount = this.objectViewMap[keyString]; + let keyString = this.openmct.objects.makeKeyString(item.identifier); + let telemetryViewCount = this.telemetryViewMap[keyString]; + let objectViewCount = this.objectViewMap[keyString]; if (item.type === 'telemetry-view') { telemetryViewCount = --this.telemetryViewMap[keyString]; @@ -464,8 +464,8 @@ export default { this.layoutItems.forEach(this.trackItem); }, isItemAlreadyTracked(child) { - let found = false, - keyString = this.openmct.objects.makeKeyString(child.identifier); + let found = false; + let keyString = this.openmct.objects.makeKeyString(child.identifier); this.layoutItems.forEach(item => { if (item.identifier) { @@ -603,13 +603,13 @@ export default { }, createNewDomainObject(domainObject, composition, viewType, nameExtension, model) { let identifier = { - key: uuid(), - namespace: this.internalDomainObject.identifier.namespace - }, - type = this.openmct.types.get(viewType), - parentKeyString = this.openmct.objects.makeKeyString(this.internalDomainObject.identifier), - objectName = nameExtension ? `${domainObject.name}-${nameExtension}` : domainObject.name, - object = {}; + key: uuid(), + namespace: this.internalDomainObject.identifier.namespace + }; + let type = this.openmct.types.get(viewType); + let parentKeyString = this.openmct.objects.makeKeyString(this.internalDomainObject.identifier); + let objectName = nameExtension ? `${domainObject.name}-${nameExtension}` : domainObject.name; + let object = {}; if (model) { object = _.cloneDeep(model); @@ -649,8 +649,8 @@ export default { }); selectItemsArray.forEach((id) => { - let refId = `layout-item-${id}`, - component = this.$refs[refId] && this.$refs[refId][0]; + let refId = `layout-item-${id}`; + let component = this.$refs[refId] && this.$refs[refId][0]; if (component) { component.immediatelySelect = event; @@ -659,15 +659,15 @@ export default { }); }, duplicateItem(selectedItems) { - let objectStyles = this.internalDomainObject.configuration.objectStyles || {}, - selectItemsArray = [], - newDomainObjectsArray = []; + let objectStyles = this.internalDomainObject.configuration.objectStyles || {}; + let selectItemsArray = []; + let newDomainObjectsArray = []; selectedItems.forEach(selectedItem => { - let layoutItem = selectedItem[0].context.layoutItem, - domainObject = selectedItem[0].context.item, - layoutItemStyle = objectStyles[layoutItem.id], - copy = _.cloneDeep(layoutItem); + let layoutItem = selectedItem[0].context.layoutItem; + let domainObject = selectedItem[0].context.item; + let layoutItemStyle = objectStyles[layoutItem.id]; + let copy = _.cloneDeep(layoutItem); copy.id = uuid(); selectItemsArray.push(copy.id); @@ -710,16 +710,16 @@ export default { }, mergeMultipleTelemetryViews(selection, viewType) { let identifiers = selection.map(selectedItem => { - return selectedItem[0].context.layoutItem.identifier; - }), - firstDomainObject = selection[0][0].context.item, - firstLayoutItem = selection[0][0].context.layoutItem, - position = [firstLayoutItem.x, firstLayoutItem.y], - mockDomainObject = { - name: 'Merged Telemetry Views', - identifier: firstDomainObject.identifier - }, - newDomainObject = this.createNewDomainObject(mockDomainObject, identifiers, viewType); + return selectedItem[0].context.layoutItem.identifier; + }); + let firstDomainObject = selection[0][0].context.item; + let firstLayoutItem = selection[0][0].context.layoutItem; + let position = [firstLayoutItem.x, firstLayoutItem.y]; + let mockDomainObject = { + name: 'Merged Telemetry Views', + identifier: firstDomainObject.identifier + }; + let newDomainObject = this.createNewDomainObject(mockDomainObject, identifiers, viewType); this.composition.add(newDomainObject); this.addItem('subobject-view', newDomainObject, position); @@ -727,18 +727,18 @@ export default { this.initSelectIndex = this.layoutItems.length - 1; }, mergeMultipleOverlayPlots(selection, viewType) { - let overlayPlots = selection.map(selectedItem => selectedItem[0].context.item), - overlayPlotIdentifiers = overlayPlots.map(overlayPlot => overlayPlot.identifier), - firstOverlayPlot = overlayPlots[0], - firstLayoutItem = selection[0][0].context.layoutItem, - position = [firstLayoutItem.x, firstLayoutItem.y], - mockDomainObject = { - name: 'Merged Overlay Plots', - identifier: firstOverlayPlot.identifier - }, - newDomainObject = this.createNewDomainObject(mockDomainObject, overlayPlotIdentifiers, viewType), - newDomainObjectKeyString = this.openmct.objects.makeKeyString(newDomainObject.identifier), - internalDomainObjectKeyString = this.openmct.objects.makeKeyString(this.internalDomainObject.identifier); + let overlayPlots = selection.map(selectedItem => selectedItem[0].context.item); + let overlayPlotIdentifiers = overlayPlots.map(overlayPlot => overlayPlot.identifier); + let firstOverlayPlot = overlayPlots[0]; + let firstLayoutItem = selection[0][0].context.layoutItem; + let position = [firstLayoutItem.x, firstLayoutItem.y]; + let mockDomainObject = { + name: 'Merged Overlay Plots', + identifier: firstOverlayPlot.identifier + }; + let newDomainObject = this.createNewDomainObject(mockDomainObject, overlayPlotIdentifiers, viewType); + let newDomainObjectKeyString = this.openmct.objects.makeKeyString(newDomainObject.identifier); + let internalDomainObjectKeyString = this.openmct.objects.makeKeyString(this.internalDomainObject.identifier); this.composition.add(newDomainObject); this.addItem('subobject-view', newDomainObject, position); @@ -762,10 +762,10 @@ export default { } }, switchViewType(context, viewType, selection) { - let domainObject = context.item, - layoutItem = context.layoutItem, - position = [layoutItem.x, layoutItem.y], - layoutType = 'subobject-view'; + let domainObject = context.item; + let layoutItem = context.layoutItem; + let position = [layoutItem.x, layoutItem.y]; + let layoutType = 'subobject-view'; if (layoutItem.type === 'telemetry-view') { let newDomainObject = this.createNewDomainObject(domainObject, [domainObject.identifier], viewType); @@ -776,8 +776,8 @@ export default { this.getTelemetryIdentifiers(domainObject).then((identifiers) => { if (viewType === 'telemetry-view') { identifiers.forEach((identifier, index) => { - let positionX = position[0] + (index * DUPLICATE_OFFSET), - positionY = position[1] + (index * DUPLICATE_OFFSET); + let positionX = position[0] + (index * DUPLICATE_OFFSET); + let positionY = position[1] + (index * DUPLICATE_OFFSET); this.convertToTelemetryView(identifier, [positionX, positionY]); }); diff --git a/src/plugins/displayLayout/components/SubobjectView.vue b/src/plugins/displayLayout/components/SubobjectView.vue index e0a1587646..5341a3a707 100644 --- a/src/plugins/displayLayout/components/SubobjectView.vue +++ b/src/plugins/displayLayout/components/SubobjectView.vue @@ -43,10 +43,10 @@ import ObjectFrame from '../../../ui/components/ObjectFrame.vue'; import LayoutFrame from './LayoutFrame.vue'; -const MINIMUM_FRAME_SIZE = [320, 180], - DEFAULT_DIMENSIONS = [10, 10], - DEFAULT_POSITION = [1, 1], - DEFAULT_HIDDEN_FRAME_TYPES = ['hyperlink', 'summary-widget', 'conditionWidget']; +const MINIMUM_FRAME_SIZE = [320, 180]; +const DEFAULT_DIMENSIONS = [10, 10]; +const DEFAULT_POSITION = [1, 1]; +const DEFAULT_HIDDEN_FRAME_TYPES = ['hyperlink', 'summary-widget', 'conditionWidget']; function getDefaultDimensions(gridSize) { return MINIMUM_FRAME_SIZE.map((min, index) => { diff --git a/src/plugins/displayLayout/components/TelemetryView.vue b/src/plugins/displayLayout/components/TelemetryView.vue index 9d1253badb..81e1d610fd 100644 --- a/src/plugins/displayLayout/components/TelemetryView.vue +++ b/src/plugins/displayLayout/components/TelemetryView.vue @@ -75,9 +75,9 @@ import LayoutFrame from './LayoutFrame.vue'; import printj from 'printj'; import conditionalStylesMixin from "../mixins/objectStyles-mixin"; -const DEFAULT_TELEMETRY_DIMENSIONS = [10, 5], - DEFAULT_POSITION = [1, 1], - CONTEXT_MENU_ACTIONS = ['viewHistoricalData']; +const DEFAULT_TELEMETRY_DIMENSIONS = [10, 5]; +const DEFAULT_POSITION = [1, 1]; +const CONTEXT_MENU_ACTIONS = ['viewHistoricalData']; export default { makeDefinition(openmct, gridSize, domainObject, position) { @@ -144,8 +144,9 @@ export default { return displayMode === 'all' || displayMode === 'value'; }, unit() { - let value = this.item.value, - unit = this.metadata.value(value).unit; + let value = this.item.value; + + let unit = this.metadata.value(value).unit; return unit; }, diff --git a/src/plugins/flexibleLayout/components/container.vue b/src/plugins/flexibleLayout/components/container.vue index 2d7072916e..c793fa5e13 100644 --- a/src/plugins/flexibleLayout/components/container.vue +++ b/src/plugins/flexibleLayout/components/container.vue @@ -147,16 +147,16 @@ export default { return true; } - let frameId = event.dataTransfer.getData('frameid'), - containerIndex = Number(event.dataTransfer.getData('containerIndex')); + let frameId = event.dataTransfer.getData('frameid'); + let containerIndex = Number(event.dataTransfer.getData('containerIndex')); if (!frameId) { return false; } if (containerIndex === this.index) { - let frame = this.container.frames.filter((f) => f.id === frameId)[0], - framePos = this.container.frames.indexOf(frame); + let frame = this.container.frames.filter((f) => f.id === frameId)[0]; + let framePos = this.container.frames.indexOf(frame); if (index === -1) { return framePos !== 0; @@ -190,15 +190,15 @@ export default { ); }, startFrameResizing(index) { - let beforeFrame = this.frames[index], - afterFrame = this.frames[index + 1]; + let beforeFrame = this.frames[index]; + let afterFrame = this.frames[index + 1]; this.maxMoveSize = beforeFrame.size + afterFrame.size; }, frameResizing(index, delta, event) { - let percentageMoved = Math.round(delta / this.getElSize() * 100), - beforeFrame = this.frames[index], - afterFrame = this.frames[index + 1]; + let percentageMoved = Math.round(delta / this.getElSize() * 100); + let beforeFrame = this.frames[index]; + let afterFrame = this.frames[index + 1]; beforeFrame.size = this.getFrameSize(beforeFrame.size + percentageMoved); afterFrame.size = this.getFrameSize(afterFrame.size - percentageMoved); diff --git a/src/plugins/flexibleLayout/components/flexibleLayout.vue b/src/plugins/flexibleLayout/components/flexibleLayout.vue index 557404420e..16b327f836 100644 --- a/src/plugins/flexibleLayout/components/flexibleLayout.vue +++ b/src/plugins/flexibleLayout/components/flexibleLayout.vue @@ -196,8 +196,8 @@ export default { this.persist(); }, deleteContainer(containerId) { - let container = this.containers.filter(c => c.id === containerId)[0], - containerIndex = this.containers.indexOf(container); + let container = this.containers.filter(c => c.id === containerId)[0]; + let containerIndex = this.containers.indexOf(container); /* remove associated domainObjects from composition @@ -273,9 +273,9 @@ export default { return false; } - let containerId = event.dataTransfer.getData('containerid'), - container = this.containers.filter((c) => c.id === containerId)[0], - containerPos = this.containers.indexOf(container); + let containerId = event.dataTransfer.getData('containerid'); + let container = this.containers.filter((c) => c.id === containerId)[0]; + let containerPos = this.containers.indexOf(container); if (index === -1) { return containerPos !== 0; @@ -291,15 +291,15 @@ export default { } }, startContainerResizing(index) { - let beforeContainer = this.containers[index], - afterContainer = this.containers[index + 1]; + let beforeContainer = this.containers[index]; + let afterContainer = this.containers[index + 1]; this.maxMoveSize = beforeContainer.size + afterContainer.size; }, containerResizing(index, delta, event) { - let percentageMoved = Math.round(delta / this.getElSize() * 100), - beforeContainer = this.containers[index], - afterContainer = this.containers[index + 1]; + let percentageMoved = Math.round(delta / this.getElSize() * 100); + let beforeContainer = this.containers[index]; + let afterContainer = this.containers[index + 1]; beforeContainer.size = this.getContainerSize(beforeContainer.size + percentageMoved); afterContainer.size = this.getContainerSize(afterContainer.size - percentageMoved); diff --git a/src/plugins/flexibleLayout/components/frame.vue b/src/plugins/flexibleLayout/components/frame.vue index 1869d61256..235196fbec 100644 --- a/src/plugins/flexibleLayout/components/frame.vue +++ b/src/plugins/flexibleLayout/components/frame.vue @@ -1,3 +1,4 @@ + /***************************************************************************** * Open MCT, Copyright (c) 2014-2018, United States Government * as represented by the Administrator of the National Aeronautics and Space @@ -127,8 +128,8 @@ export default { }); }, initDrag(event) { - let type = this.openmct.types.get(this.domainObject.type), - iconClass = type.definition ? type.definition.cssClass : 'icon-object-unknown'; + let type = this.openmct.types.get(this.domainObject.type); + let iconClass = type.definition ? type.definition.cssClass : 'icon-object-unknown'; if (this.dragGhost) { let originalClassName = this.dragGhost.classList[0]; diff --git a/src/plugins/flexibleLayout/components/resizeHandle.vue b/src/plugins/flexibleLayout/components/resizeHandle.vue index cca52a68ab..adf81bbe8f 100644 --- a/src/plugins/flexibleLayout/components/resizeHandle.vue +++ b/src/plugins/flexibleLayout/components/resizeHandle.vue @@ -73,7 +73,9 @@ export default { mousemove(event) { event.preventDefault(); - let elSize, mousePos, delta; + let elSize; + let mousePos; + let delta; if (this.orientation === 'horizontal') { elSize = this.$el.getBoundingClientRect().x; diff --git a/src/plugins/flexibleLayout/toolbarProvider.js b/src/plugins/flexibleLayout/toolbarProvider.js index fe146c4477..eabe463e21 100644 --- a/src/plugins/flexibleLayout/toolbarProvider.js +++ b/src/plugins/flexibleLayout/toolbarProvider.js @@ -33,16 +33,15 @@ function ToolbarProvider(openmct) { && (context.type === 'flexible-layout' || context.type === 'container' || context.type === 'frame')); }, toolbar: function (selection) { - - let selectionPath = selection[0], - primary = selectionPath[0], - secondary = selectionPath[1], - tertiary = selectionPath[2], - deleteFrame, - toggleContainer, - deleteContainer, - addContainer, - toggleFrame; + let selectionPath = selection[0]; + let primary = selectionPath[0]; + let secondary = selectionPath[1]; + let tertiary = selectionPath[2]; + let deleteFrame; + let toggleContainer; + let deleteContainer; + let addContainer; + let toggleFrame; toggleContainer = { control: 'toggle-button', @@ -155,8 +154,8 @@ function ToolbarProvider(openmct) { control: "button", domainObject: primary.context.item, method: function () { - let removeContainer = secondary.context.deleteContainer, - containerId = primary.context.containerId; + let removeContainer = secondary.context.deleteContainer; + let containerId = primary.context.containerId; let prompt = openmct.overlays.dialog({ iconClass: 'alert', diff --git a/src/plugins/folderView/components/ListView.vue b/src/plugins/folderView/components/ListView.vue index 34801d3569..3a1b22dd89 100644 --- a/src/plugins/folderView/components/ListView.vue +++ b/src/plugins/folderView/components/ListView.vue @@ -71,9 +71,9 @@ export default { mixins: [compositionLoader], inject: ['domainObject', 'openmct'], data() { - let sortBy = 'model.name', - ascending = true, - persistedSortOrder = window.localStorage.getItem('openmct-listview-sort-order'); + let sortBy = 'model.name'; + let ascending = true; + let persistedSortOrder = window.localStorage.getItem('openmct-listview-sort-order'); if (persistedSortOrder) { let parsed = JSON.parse(persistedSortOrder); diff --git a/src/plugins/folderView/components/composition-loader.js b/src/plugins/folderView/components/composition-loader.js index d8f4997ba7..33aab1a658 100644 --- a/src/plugins/folderView/components/composition-loader.js +++ b/src/plugins/folderView/components/composition-loader.js @@ -33,7 +33,7 @@ export default { }, methods: { add(child, index, anything) { - var type = this.openmct.types.get(child.type) || unknownObjectType; + const type = this.openmct.types.get(child.type) || unknownObjectType; this.items.push({ model: child, type: type.definition, diff --git a/src/plugins/localTimeSystem/LocalTimeFormat.js b/src/plugins/localTimeSystem/LocalTimeFormat.js index a33537174c..719dc7c42c 100644 --- a/src/plugins/localTimeSystem/LocalTimeFormat.js +++ b/src/plugins/localTimeSystem/LocalTimeFormat.js @@ -25,14 +25,14 @@ define([ ], function ( moment ) { + const DATE_FORMAT = "YYYY-MM-DD h:mm:ss.SSS a"; - var DATE_FORMAT = "YYYY-MM-DD h:mm:ss.SSS a", - DATE_FORMATS = [ - DATE_FORMAT, - "YYYY-MM-DD h:mm:ss a", - "YYYY-MM-DD h:mm a", - "YYYY-MM-DD" - ]; + const DATE_FORMATS = [ + DATE_FORMAT, + "YYYY-MM-DD h:mm:ss a", + "YYYY-MM-DD h:mm a", + "YYYY-MM-DD" + ]; /** * @typedef Scale diff --git a/src/plugins/newFolderAction/newFolderAction.js b/src/plugins/newFolderAction/newFolderAction.js index fcc12b95e2..6232ac5a5a 100644 --- a/src/plugins/newFolderAction/newFolderAction.js +++ b/src/plugins/newFolderAction/newFolderAction.js @@ -49,23 +49,25 @@ export default class NewFolderAction { }; } invoke(objectPath) { - let domainObject = objectPath[0], - parentKeystring = this._openmct.objects.makeKeyString(domainObject.identifier), - composition = this._openmct.composition.get(domainObject), - dialogService = this._openmct.$injector.get('dialogService'), - folderType = this._openmct.types.get('folder'); + let domainObject = objectPath[0]; + let parentKeystring = this._openmct.objects.makeKeyString(domainObject.identifier); + let composition = this._openmct.composition.get(domainObject); + let dialogService = this._openmct.$injector.get('dialogService'); + let folderType = this._openmct.types.get('folder'); dialogService.getUserInput(this._dialogForm, {name: 'Unnamed Folder'}).then((userInput) => { - let name = userInput.name, - identifier = { - key: uuid(), - namespace: domainObject.identifier.namespace - }, - objectModel = { - identifier, - type: 'folder', - location: parentKeystring - }; + let name = userInput.name; + + let identifier = { + key: uuid(), + namespace: domainObject.identifier.namespace + }; + + let objectModel = { + identifier, + type: 'folder', + location: parentKeystring + }; folderType.definition.initialize(objectModel); objectModel.name = name || 'New Folder'; diff --git a/src/plugins/newFolderAction/pluginSpec.js b/src/plugins/newFolderAction/pluginSpec.js index 8a1253b1e7..f2daf4a7fc 100644 --- a/src/plugins/newFolderAction/pluginSpec.js +++ b/src/plugins/newFolderAction/pluginSpec.js @@ -25,14 +25,14 @@ import { } from 'utils/testing'; describe("the plugin", () => { - let openmct, - compositionAPI, - newFolderAction, - mockObjectPath, - mockDialogService, - mockComposition, - mockPromise, - newFolderName = 'New Folder'; + let openmct; + let compositionAPI; + let newFolderAction; + let mockObjectPath; + let mockDialogService; + let mockComposition; + let mockPromise; + let newFolderName = 'New Folder'; beforeEach((done) => { openmct = createOpenMct(); diff --git a/src/plugins/notebook/components/notebook-entry.vue b/src/plugins/notebook/components/notebook-entry.vue index ef41eded38..53d72c904e 100644 --- a/src/plugins/notebook/components/notebook-entry.vue +++ b/src/plugins/notebook/components/notebook-entry.vue @@ -249,7 +249,7 @@ export default { selectTextInsideElement(element) { const range = document.createRange(); range.selectNodeContents(element); - var selection = window.getSelection(); + let selection = window.getSelection(); selection.removeAllRanges(); selection.addRange(range); }, diff --git a/src/plugins/notificationIndicator/plugin.js b/src/plugins/notificationIndicator/plugin.js index d870d67c90..877c7b5109 100644 --- a/src/plugins/notificationIndicator/plugin.js +++ b/src/plugins/notificationIndicator/plugin.js @@ -25,18 +25,19 @@ import NotificationIndicator from './components/NotificationIndicator.vue'; export default function plugin() { return function install(openmct) { let component = new Vue ({ - provide: { - openmct - }, - components: { - NotificationIndicator: NotificationIndicator - }, - template: '' - }), - indicator = { - key: 'notifications-indicator', - element: component.$mount().$el - }; + provide: { + openmct + }, + components: { + NotificationIndicator: NotificationIndicator + }, + template: '' + }); + + let indicator = { + key: 'notifications-indicator', + element: component.$mount().$el + }; openmct.indicators.add(indicator); }; diff --git a/src/plugins/notificationIndicator/pluginSpec.js b/src/plugins/notificationIndicator/pluginSpec.js index f2b9011da3..78e775a489 100644 --- a/src/plugins/notificationIndicator/pluginSpec.js +++ b/src/plugins/notificationIndicator/pluginSpec.js @@ -28,12 +28,12 @@ import { } from 'utils/testing'; describe('the plugin', () => { - let notificationIndicatorPlugin, - openmct, - indicatorObject, - indicatorElement, - parentElement, - mockMessages = ['error', 'test', 'notifications']; + let notificationIndicatorPlugin; + let openmct; + let indicatorObject; + let indicatorElement; + let parentElement; + let mockMessages = ['error', 'test', 'notifications']; beforeEach((done) => { openmct = createOpenMct(); @@ -73,5 +73,4 @@ describe('the plugin', () => { expect(notificationCountElement.innerText).toEqual(mockMessages.length.toString()); }); }); - }); diff --git a/src/plugins/plot/plugin.js b/src/plugins/plot/plugin.js index 8cfc11f421..34af293d01 100644 --- a/src/plugins/plot/plugin.js +++ b/src/plugins/plot/plugin.js @@ -62,7 +62,7 @@ define([ PlotTemplate ) { - var installed = false; + let installed = false; function PlotPlugin() { return function install(openmct) { diff --git a/src/plugins/plot/src/PlotViewPolicy.js b/src/plugins/plot/src/PlotViewPolicy.js index e4bc1d97a7..a5b63b8707 100644 --- a/src/plugins/plot/src/PlotViewPolicy.js +++ b/src/plugins/plot/src/PlotViewPolicy.js @@ -35,7 +35,7 @@ define( } PlotViewPolicy.prototype.hasNumericTelemetry = function (domainObject) { - var adaptedObject = domainObject.useCapability('adapter'); + const adaptedObject = domainObject.useCapability('adapter'); if (!adaptedObject.telemetry) { return domainObject.hasCapability('delegation') @@ -43,8 +43,8 @@ define( .doesDelegateCapability('telemetry'); } - var metadata = this.openmct.telemetry.getMetadata(adaptedObject); - var rangeValues = metadata.valuesForHints(['range']); + const metadata = this.openmct.telemetry.getMetadata(adaptedObject); + const rangeValues = metadata.valuesForHints(['range']); if (rangeValues.length === 0) { return false; } diff --git a/src/plugins/plot/src/chart/MCTChartController.js b/src/plugins/plot/src/chart/MCTChartController.js index c2c06dea3f..096af92aa8 100644 --- a/src/plugins/plot/src/chart/MCTChartController.js +++ b/src/plugins/plot/src/chart/MCTChartController.js @@ -39,9 +39,8 @@ function ( DrawLoader, eventHelpers ) { - - var MARKER_SIZE = 6.0, - HIGHLIGHT_SIZE = MARKER_SIZE * 2.0; + const MARKER_SIZE = 6.0; + const HIGHLIGHT_SIZE = MARKER_SIZE * 2.0; /** * Offsetter adjusts x and y values by a fixed amount, @@ -94,14 +93,14 @@ function ( return; } - var elements = this.seriesElements.get(series); + const elements = this.seriesElements.get(series); elements.lines.forEach(function (line) { this.lines.splice(this.lines.indexOf(line), 1); line.destroy(); }, this); elements.lines = []; - var newLine = this.lineForSeries(series); + const newLine = this.lineForSeries(series); if (newLine) { elements.lines.push(newLine); this.lines.push(newLine); @@ -113,7 +112,7 @@ function ( return; } - var elements = this.seriesElements.get(series); + const elements = this.seriesElements.get(series); if (elements.alarmSet) { elements.alarmSet.destroy(); this.alarmSets.splice(this.alarmSets.indexOf(elements.alarmSet), 1); @@ -130,14 +129,14 @@ function ( return; } - var elements = this.seriesElements.get(series); + const elements = this.seriesElements.get(series); elements.pointSets.forEach(function (pointSet) { this.pointSets.splice(this.pointSets.indexOf(pointSet), 1); pointSet.destroy(); }, this); elements.pointSets = []; - var pointSet = this.pointSetForSeries(series); + const pointSet = this.pointSetForSeries(series); if (pointSet) { elements.pointSets.push(pointSet); this.pointSets.push(pointSet); @@ -177,7 +176,7 @@ function ( return; } - var offsets = { + const offsets = { x: series.getXVal(offsetPoint), y: series.getYVal(offsetPoint) }; @@ -212,10 +211,10 @@ function ( DrawLoader.releaseDrawAPI(this.drawAPI); // Have to throw away the old canvas elements and replace with new // canvas elements in order to get new drawing contexts. - var div = document.createElement('div'); + const div = document.createElement('div'); div.innerHTML = this.TEMPLATE; - var mainCanvas = div.querySelectorAll("canvas")[1]; - var overlayCanvas = div.querySelectorAll("canvas")[0]; + const mainCanvas = div.querySelectorAll("canvas")[1]; + const overlayCanvas = div.querySelectorAll("canvas")[0]; this.canvas.parentNode.replaceChild(mainCanvas, this.canvas); this.canvas = mainCanvas; this.overlay.parentNode.replaceChild(overlayCanvas, this.overlay); @@ -225,7 +224,7 @@ function ( }; MCTChartController.prototype.removeChartElement = function (series) { - var elements = this.seriesElements.get(series); + const elements = this.seriesElements.get(series); elements.lines.forEach(function (line) { this.lines.splice(this.lines.indexOf(line), 1); @@ -282,18 +281,18 @@ function ( }; MCTChartController.prototype.makeChartElement = function (series) { - var elements = { + const elements = { lines: [], pointSets: [] }; - var line = this.lineForSeries(series); + const line = this.lineForSeries(series); if (line) { elements.lines.push(line); this.lines.push(line); } - var pointSet = this.pointSetForSeries(series); + const pointSet = this.pointSetForSeries(series); if (pointSet) { elements.pointSets.push(pointSet); this.pointSets.push(pointSet); @@ -338,21 +337,22 @@ function ( }; MCTChartController.prototype.updateViewport = function () { - var xRange = this.config.xAxis.get('displayRange'), - yRange = this.config.yAxis.get('displayRange'); + const xRange = this.config.xAxis.get('displayRange'); + const yRange = this.config.yAxis.get('displayRange'); if (!xRange || !yRange) { return; } - var dimensions = [ - xRange.max - xRange.min, - yRange.max - yRange.min - ], - origin = [ - this.offset.x(xRange.min), - this.offset.y(yRange.min) - ]; + const dimensions = [ + xRange.max - xRange.min, + yRange.max - yRange.min + ]; + + const origin = [ + this.offset.x(xRange.min), + this.offset.y(yRange.min) + ]; this.drawAPI.setDimensions( dimensions, @@ -399,13 +399,14 @@ function ( }; MCTChartController.prototype.drawHighlight = function (highlight) { - var points = new Float32Array([ - this.offset.xVal(highlight.point, highlight.series), - this.offset.yVal(highlight.point, highlight.series) - ]), - color = highlight.series.get('color').asRGBAArray(), - pointCount = 1, - shape = highlight.series.get('markerShape'); + const points = new Float32Array([ + this.offset.xVal(highlight.point, highlight.series), + this.offset.yVal(highlight.point, highlight.series) + ]); + + const color = highlight.series.get('color').asRGBAArray(); + const pointCount = 1; + const shape = highlight.series.get('markerShape'); this.drawAPI.drawPoints(points, color, pointCount, HIGHLIGHT_SIZE, shape); }; diff --git a/src/plugins/plot/src/chart/MCTChartDirective.js b/src/plugins/plot/src/chart/MCTChartDirective.js index 69632e2131..4c7e617888 100644 --- a/src/plugins/plot/src/chart/MCTChartDirective.js +++ b/src/plugins/plot/src/chart/MCTChartDirective.js @@ -29,7 +29,7 @@ define([ MCTChartController ) { - var TEMPLATE = ""; + let TEMPLATE = ""; TEMPLATE += TEMPLATE; /** @@ -43,8 +43,8 @@ define([ template: TEMPLATE, link: function ($scope, $element, attrs, ctrl) { ctrl.TEMPLATE = TEMPLATE; - var mainCanvas = $element.find("canvas")[1]; - var overlayCanvas = $element.find("canvas")[0]; + const mainCanvas = $element.find("canvas")[1]; + const overlayCanvas = $element.find("canvas")[0]; if (ctrl.initializeCanvas(mainCanvas, overlayCanvas)) { ctrl.draw(); diff --git a/src/plugins/plot/src/chart/MCTChartLineLinear.js b/src/plugins/plot/src/chart/MCTChartLineLinear.js index b7dea64415..5363e3d588 100644 --- a/src/plugins/plot/src/chart/MCTChartLineLinear.js +++ b/src/plugins/plot/src/chart/MCTChartLineLinear.js @@ -26,7 +26,7 @@ define([ MCTChartSeriesElement ) { - var MCTChartLineLinear = MCTChartSeriesElement.extend({ + const MCTChartLineLinear = MCTChartSeriesElement.extend({ addPoint: function (point, start, count) { this.buffer[start] = point.x; this.buffer[start + 1] = point.y; diff --git a/src/plugins/plot/src/chart/MCTChartLineStepAfter.js b/src/plugins/plot/src/chart/MCTChartLineStepAfter.js index c8f37c48b4..142d8b7095 100644 --- a/src/plugins/plot/src/chart/MCTChartLineStepAfter.js +++ b/src/plugins/plot/src/chart/MCTChartLineStepAfter.js @@ -26,7 +26,7 @@ define([ MCTChartSeriesElement ) { - var MCTChartLineStepAfter = MCTChartSeriesElement.extend({ + const MCTChartLineStepAfter = MCTChartSeriesElement.extend({ removePoint: function (point, index, count) { if (index > 0 && index / 2 < this.count) { this.buffer[index + 1] = this.buffer[index - 1]; diff --git a/src/plugins/plot/src/chart/MCTChartPointSet.js b/src/plugins/plot/src/chart/MCTChartPointSet.js index 2e593442d6..5918927f23 100644 --- a/src/plugins/plot/src/chart/MCTChartPointSet.js +++ b/src/plugins/plot/src/chart/MCTChartPointSet.js @@ -26,7 +26,7 @@ define([ MCTChartSeriesElement ) { - var MCTChartPointSet = MCTChartSeriesElement.extend({ + const MCTChartPointSet = MCTChartSeriesElement.extend({ addPoint: function (point, start, count) { this.buffer[start] = point.x; this.buffer[start + 1] = point.y; diff --git a/src/plugins/plot/src/chart/MCTChartSeriesElement.js b/src/plugins/plot/src/chart/MCTChartSeriesElement.js index fd8e5642e3..2f141d6bad 100644 --- a/src/plugins/plot/src/chart/MCTChartSeriesElement.js +++ b/src/plugins/plot/src/chart/MCTChartSeriesElement.js @@ -69,11 +69,11 @@ define([ }; MCTChartSeriesElement.prototype.removeSegments = function (index, count) { - var target = index, - start = index + count, - end = this.count * 2; + const target = index; + const start = index + count; + const end = this.count * 2; this.buffer.copyWithin(target, start, end); - for (var zero = end - count; zero < end; zero++) { + for (let zero = end - count; zero < end; zero++) { this.buffer[zero] = 0; } }; @@ -83,8 +83,8 @@ define([ }; MCTChartSeriesElement.prototype.remove = function (point, index, series) { - var vertexCount = this.vertexCountForPointAtIndex(index); - var removalPoint = this.startIndexForPointAtIndex(index); + const vertexCount = this.vertexCountForPointAtIndex(index); + const removalPoint = this.startIndexForPointAtIndex(index); this.removeSegments(removalPoint, vertexCount); @@ -108,8 +108,8 @@ define([ }; MCTChartSeriesElement.prototype.append = function (point, index, series) { - var pointsRequired = this.vertexCountForPointAtIndex(index); - var insertionPoint = this.startIndexForPointAtIndex(index); + const pointsRequired = this.vertexCountForPointAtIndex(index); + const insertionPoint = this.startIndexForPointAtIndex(index); this.growIfNeeded(pointsRequired); this.makeInsertionPoint(insertionPoint, pointsRequired); this.addPoint( @@ -127,8 +127,8 @@ define([ this.isTempBuffer = true; } - var target = insertionPoint + pointsRequired, - start = insertionPoint; + const target = insertionPoint + pointsRequired; + let start = insertionPoint; for (; start < target; start++) { this.buffer.splice(start, 0, 0); } @@ -146,8 +146,8 @@ define([ }; MCTChartSeriesElement.prototype.growIfNeeded = function (pointsRequired) { - var remainingPoints = this.buffer.length - this.count * 2; - var temp; + const remainingPoints = this.buffer.length - this.count * 2; + let temp; if (remainingPoints <= pointsRequired) { temp = new Float32Array(this.buffer.length + 20000); diff --git a/src/plugins/plot/src/configuration/Collection.js b/src/plugins/plot/src/configuration/Collection.js index b6f427564c..90e4190241 100644 --- a/src/plugins/plot/src/configuration/Collection.js +++ b/src/plugins/plot/src/configuration/Collection.js @@ -93,7 +93,7 @@ define([ Collection.prototype.add = function (model) { model = this.modelFn(model); - var index = this.models.length; + const index = this.models.length; this.models.push(model); this.emit('add', model, index); }; @@ -109,7 +109,7 @@ define([ }; Collection.prototype.remove = function (model) { - var index = this.indexOf(model); + const index = this.indexOf(model); if (index === -1) { throw new Error('model not found in collection.'); diff --git a/src/plugins/plot/src/configuration/LegendModel.js b/src/plugins/plot/src/configuration/LegendModel.js index 82dd22cc26..22540e0a9b 100644 --- a/src/plugins/plot/src/configuration/LegendModel.js +++ b/src/plugins/plot/src/configuration/LegendModel.js @@ -28,7 +28,7 @@ define([ /** * TODO: doc strings. */ - var LegendModel = Model.extend({ + const LegendModel = Model.extend({ listenToSeriesCollection: function (seriesCollection) { this.seriesCollection = seriesCollection; this.listenTo(this.seriesCollection, 'add', this.setHeight, this); @@ -37,7 +37,7 @@ define([ this.set('expanded', this.get('expandByDefault')); }, setHeight: function () { - var expanded = this.get('expanded'); + const expanded = this.get('expanded'); if (this.get('position') !== 'top') { this.set('height', '0px'); } else { diff --git a/src/plugins/plot/src/configuration/Model.js b/src/plugins/plot/src/configuration/Model.js index 8a6cc80984..878f624d0a 100644 --- a/src/plugins/plot/src/configuration/Model.js +++ b/src/plugins/plot/src/configuration/Model.js @@ -40,7 +40,7 @@ define([ this.id = options.id; this.model = options.model; this.collection = options.collection; - var defaults = this.defaults(options); + const defaults = this.defaults(options); if (!this.model) { this.model = options.model = defaults; } else { @@ -86,14 +86,14 @@ define([ }; Model.prototype.set = function (attribute, value) { - var oldValue = this.model[attribute]; + const oldValue = this.model[attribute]; this.model[attribute] = value; this.emit('change', attribute, value, oldValue, this); this.emit('change:' + attribute, value, oldValue, this); }; Model.prototype.unset = function (attribute) { - var oldValue = this.model[attribute]; + const oldValue = this.model[attribute]; delete this.model[attribute]; this.emit('change', attribute, undefined, oldValue, this); this.emit('change:' + attribute, undefined, oldValue, this); diff --git a/src/plugins/plot/src/configuration/PlotConfigurationModel.js b/src/plugins/plot/src/configuration/PlotConfigurationModel.js index 9fcd2719f7..7f5cb670c1 100644 --- a/src/plugins/plot/src/configuration/PlotConfigurationModel.js +++ b/src/plugins/plot/src/configuration/PlotConfigurationModel.js @@ -44,7 +44,7 @@ define([ * handle setting defaults and updating in response to various changes. * */ - var PlotConfigurationModel = Model.extend({ + const PlotConfigurationModel = Model.extend({ /** * Initializes all sub models and then passes references to submodels @@ -91,7 +91,7 @@ define([ * Retrieve the persisted series config for a given identifier. */ getPersistedSeriesConfig: function (identifier) { - var domainObject = this.get('domainObject'); + const domainObject = this.get('domainObject'); if (!domainObject.configuration || !domainObject.configuration.series) { return; } @@ -105,8 +105,8 @@ define([ * Retrieve the persisted filters for a given identifier. */ getPersistedFilters: function (identifier) { - var domainObject = this.get('domainObject'), - keystring = this.openmct.objects.makeKeyString(identifier); + const domainObject = this.get('domainObject'); + const keystring = this.openmct.objects.makeKeyString(identifier); if (!domainObject.configuration || !domainObject.configuration.filters) { return; diff --git a/src/plugins/plot/src/configuration/PlotSeries.js b/src/plugins/plot/src/configuration/PlotSeries.js index b9eceb47b8..4225a695fb 100644 --- a/src/plugins/plot/src/configuration/PlotSeries.js +++ b/src/plugins/plot/src/configuration/PlotSeries.js @@ -70,7 +70,7 @@ define([ * telemetry point. * `formats`: the Open MCT format map for this telemetry point. */ - var PlotSeries = Model.extend({ + const PlotSeries = Model.extend({ constructor: function (options) { this.metadata = options .openmct @@ -97,7 +97,7 @@ define([ * Set defaults for telemetry series. */ defaults: function (options) { - var range = this.metadata.valuesForHints(['range'])[0]; + const range = this.metadata.valuesForHints(['range'])[0]; return { name: options.domainObject.name, @@ -174,7 +174,7 @@ define([ .telemetry .request(this.domainObject, options) .then(function (points) { - var newPoints = _(this.data) + const newPoints = _(this.data) .concat(points) .sortBy(this.getXVal) .uniq(true, point => [this.getXVal(point), this.getYVal(point)].join()) @@ -187,7 +187,7 @@ define([ * Update x formatter on x change. */ onXKeyChange: function (xKey) { - var format = this.formats[xKey]; + const format = this.formats[xKey]; this.getXVal = format.parse.bind(format); }, /** @@ -199,7 +199,7 @@ define([ return; } - var valueMetadata = this.metadata.value(newKey); + const valueMetadata = this.metadata.value(newKey); if (!this.persistedConfig || !this.persistedConfig.interpolate) { if (valueMetadata.format === 'enum') { this.set('interpolate', 'stepAfter'); @@ -211,7 +211,7 @@ define([ this.evaluate = function (datum) { return this.limitEvaluator.evaluate(datum, valueMetadata); }.bind(this); - var format = this.formats[newKey]; + const format = this.formats[newKey]; this.getYVal = format.parse.bind(format); }, @@ -249,17 +249,17 @@ define([ * Return the point closest to a given x value. */ nearestPoint: function (xValue) { - var insertIndex = this.sortedIndex(xValue), - lowPoint = this.data[insertIndex - 1], - highPoint = this.data[insertIndex], - indexVal = this.getXVal(xValue), - lowDistance = lowPoint - ? indexVal - this.getXVal(lowPoint) - : Number.POSITIVE_INFINITY, - highDistance = highPoint - ? this.getXVal(highPoint) - indexVal - : Number.POSITIVE_INFINITY, - nearestPoint = highDistance < lowDistance ? highPoint : lowPoint; + const insertIndex = this.sortedIndex(xValue); + const lowPoint = this.data[insertIndex - 1]; + const highPoint = this.data[insertIndex]; + const indexVal = this.getXVal(xValue); + const lowDistance = lowPoint + ? indexVal - this.getXVal(lowPoint) + : Number.POSITIVE_INFINITY; + const highDistance = highPoint + ? this.getXVal(highPoint) - indexVal + : Number.POSITIVE_INFINITY; + const nearestPoint = highDistance < lowDistance ? highPoint : lowPoint; return nearestPoint; }, @@ -291,9 +291,9 @@ define([ * @private */ updateStats: function (point) { - var value = this.getYVal(point); - var stats = this.get('stats'); - var changed = false; + const value = this.getYVal(point); + let stats = this.get('stats'); + let changed = false; if (!stats) { stats = { minValue: value, @@ -338,9 +338,9 @@ define([ * a point to the end without dupe checking. */ add: function (point, appendOnly) { - var insertIndex = this.data.length, - currentYVal = this.getYVal(point), - lastYVal = this.getYVal(this.data[insertIndex - 1]); + let insertIndex = this.data.length; + const currentYVal = this.getYVal(point); + const lastYVal = this.getYVal(this.data[insertIndex - 1]); if (this.isValueInvalid(currentYVal) && this.isValueInvalid(lastYVal)) { console.warn('[Plot] Invalid Y Values detected'); @@ -378,7 +378,7 @@ define([ * @private */ remove: function (point) { - var index = this.data.indexOf(point); + const index = this.data.indexOf(point); this.data.splice(index, 1); this.emit('remove', point, index, this); }, @@ -393,16 +393,16 @@ define([ * @param {number} range.max maximum x value to keep. */ purgeRecordsOutsideRange: function (range) { - var startIndex = this.sortedIndex(range.min); - var endIndex = this.sortedIndex(range.max) + 1; - var pointsToRemove = startIndex + (this.data.length - endIndex + 1); + const startIndex = this.sortedIndex(range.min); + const endIndex = this.sortedIndex(range.max) + 1; + const pointsToRemove = startIndex + (this.data.length - endIndex + 1); if (pointsToRemove > 0) { if (pointsToRemove < 1000) { this.data.slice(0, startIndex).forEach(this.remove, this); this.data.slice(endIndex, this.data.length).forEach(this.remove, this); this.resetStats(); } else { - var newData = this.data.slice(startIndex, endIndex); + const newData = this.data.slice(startIndex, endIndex); this.reset(newData); } } diff --git a/src/plugins/plot/src/configuration/SeriesCollection.js b/src/plugins/plot/src/configuration/SeriesCollection.js index 03c623d398..3e235e28ae 100644 --- a/src/plugins/plot/src/configuration/SeriesCollection.js +++ b/src/plugins/plot/src/configuration/SeriesCollection.js @@ -33,7 +33,7 @@ define([ _ ) { - var SeriesCollection = Collection.extend({ + const SeriesCollection = Collection.extend({ modelClass: PlotSeries, initialize: function (options) { this.plot = options.plot; @@ -43,7 +43,7 @@ define([ this.listenTo(this, 'remove', this.onSeriesRemove, this); this.listenTo(this.plot, 'change:domainObject', this.trackPersistedConfig, this); - var domainObject = this.plot.get('domainObject'); + const domainObject = this.plot.get('domainObject'); if (domainObject.telemetry) { this.addTelemetryObject(domainObject); } else { @@ -52,22 +52,22 @@ define([ }, trackPersistedConfig: function (domainObject) { domainObject.configuration.series.forEach(function (seriesConfig) { - var series = this.byIdentifier(seriesConfig.identifier); + const series = this.byIdentifier(seriesConfig.identifier); if (series) { series.persistedConfig = seriesConfig; } }, this); }, watchTelemetryContainer: function (domainObject) { - var composition = this.openmct.composition.get(domainObject); + const composition = this.openmct.composition.get(domainObject); this.listenTo(composition, 'add', this.addTelemetryObject, this); this.listenTo(composition, 'remove', this.removeTelemetryObject, this); composition.load(); }, addTelemetryObject: function (domainObject, index) { - var seriesConfig = this.plot.getPersistedSeriesConfig(domainObject.identifier); - var filters = this.plot.getPersistedFilters(domainObject.identifier); - var plotObject = this.plot.get('domainObject'); + let seriesConfig = this.plot.getPersistedSeriesConfig(domainObject.identifier); + const filters = this.plot.getPersistedFilters(domainObject.identifier); + const plotObject = this.plot.get('domainObject'); if (!seriesConfig) { seriesConfig = { @@ -99,14 +99,14 @@ define([ })); }, removeTelemetryObject: function (identifier) { - var plotObject = this.plot.get('domainObject'); + const plotObject = this.plot.get('domainObject'); if (plotObject.type === 'telemetry.plot.overlay') { - var persistedIndex = plotObject.configuration.series.findIndex(s => { + const persistedIndex = plotObject.configuration.series.findIndex(s => { return _.isEqual(identifier, s.identifier); }); - var configIndex = this.models.findIndex(m => { + const configIndex = this.models.findIndex(m => { return _.isEqual(m.domainObject.identifier, identifier); }); @@ -122,8 +122,8 @@ define([ // to defer mutation of our plot object, otherwise we might // mutate an outdated version of the plotObject. setTimeout(function () { - var newPlotObject = this.plot.get('domainObject'); - var cSeries = newPlotObject.configuration.series.slice(); + const newPlotObject = this.plot.get('domainObject'); + const cSeries = newPlotObject.configuration.series.slice(); cSeries.splice(persistedIndex, 1); this.openmct.objects.mutate(newPlotObject, 'configuration.series', cSeries); }.bind(this)); @@ -131,7 +131,7 @@ define([ } }, onSeriesAdd: function (series) { - var seriesColor = series.get('color'); + let seriesColor = series.get('color'); if (seriesColor) { if (!(seriesColor instanceof color.Color)) { seriesColor = color.Color.fromHexString(seriesColor); @@ -152,7 +152,7 @@ define([ }, updateColorPalette: function (newColor, oldColor) { this.palette.remove(newColor); - var seriesWithColor = this.filter(function (series) { + const seriesWithColor = this.filter(function (series) { return series.get('color') === newColor; })[0]; if (!seriesWithColor) { @@ -161,7 +161,7 @@ define([ }, byIdentifier: function (identifier) { return this.filter(function (series) { - var seriesIdentifier = series.get('identifier'); + const seriesIdentifier = series.get('identifier'); return seriesIdentifier.namespace === identifier.namespace && seriesIdentifier.key === identifier.key; diff --git a/src/plugins/plot/src/configuration/XAxisModel.js b/src/plugins/plot/src/configuration/XAxisModel.js index fa4ad78e79..bbd99aff30 100644 --- a/src/plugins/plot/src/configuration/XAxisModel.js +++ b/src/plugins/plot/src/configuration/XAxisModel.js @@ -28,7 +28,7 @@ define([ /** * TODO: doc strings. */ - var XAxisModel = Model.extend({ + const XAxisModel = Model.extend({ initialize: function (options) { this.plot = options.plot; this.set('label', options.model.name || ''); @@ -51,10 +51,10 @@ define([ this.listenTo(this, 'change:key', this.changeKey, this); }, changeKey: function (newKey) { - var series = this.plot.series.first(); + const series = this.plot.series.first(); if (series) { - var xMetadata = series.metadata.value(newKey); - var xFormat = series.formats[newKey]; + const xMetadata = series.metadata.value(newKey); + const xFormat = series.formats[newKey]; this.set('label', xMetadata.name); this.set('format', xFormat.format.bind(xFormat)); } else { @@ -70,9 +70,9 @@ define([ }); }, defaults: function (options) { - var bounds = options.openmct.time.bounds(); - var timeSystem = options.openmct.time.timeSystem(); - var format = options.openmct.$injector.get('formatService') + const bounds = options.openmct.time.bounds(); + const timeSystem = options.openmct.time.timeSystem(); + const format = options.openmct.$injector.get('formatService') .getFormat(timeSystem.timeFormat); return { diff --git a/src/plugins/plot/src/configuration/YAxisModel.js b/src/plugins/plot/src/configuration/YAxisModel.js index b89e105738..148cf5f442 100644 --- a/src/plugins/plot/src/configuration/YAxisModel.js +++ b/src/plugins/plot/src/configuration/YAxisModel.js @@ -48,7 +48,7 @@ define([ * disabled. * */ - var YAxisModel = Model.extend({ + const YAxisModel = Model.extend({ initialize: function (options) { this.plot = options.plot; this.listenTo(this, 'change:stats', this.calculateAutoscaleExtents, this); @@ -82,7 +82,7 @@ define([ } }, applyPadding: function (range) { - var padding = Math.abs(range.max - range.min) * this.get('autoscalePadding'); + let padding = Math.abs(range.max - range.min) * this.get('autoscalePadding'); if (padding === 0) { padding = 1; } @@ -116,8 +116,8 @@ define([ return; } - var stats = this.get('stats'); - var changed = false; + const stats = this.get('stats'); + let changed = false; if (stats.min > seriesStats.minValue) { changed = true; stats.min = seriesStats.minValue; @@ -171,9 +171,9 @@ define([ * Update yAxis format, values, and label from known series. */ updateFromSeries: function (series) { - var plotModel = this.plot.get('domainObject'); - var label = _.get(plotModel, 'configuration.yAxis.label'); - var sampleSeries = series.first(); + const plotModel = this.plot.get('domainObject'); + const label = _.get(plotModel, 'configuration.yAxis.label'); + const sampleSeries = series.first(); if (!sampleSeries) { if (!label) { this.unset('label'); @@ -182,13 +182,13 @@ define([ return; } - var yKey = sampleSeries.get('yKey'); - var yMetadata = sampleSeries.metadata.value(yKey); - var yFormat = sampleSeries.formats[yKey]; + const yKey = sampleSeries.get('yKey'); + const yMetadata = sampleSeries.metadata.value(yKey); + const yFormat = sampleSeries.formats[yKey]; this.set('format', yFormat.format.bind(yFormat)); this.set('values', yMetadata.values); if (!label) { - var labelName = series.map(function (s) { + const labelName = series.map(function (s) { return s.metadata.value(s.get('yKey')).name; }).reduce(function (a, b) { if (a === undefined) { @@ -208,7 +208,7 @@ define([ return; } - var labelUnits = series.map(function (s) { + const labelUnits = series.map(function (s) { return s.metadata.value(s.get('yKey')).units; }).reduce(function (a, b) { if (a === undefined) { diff --git a/src/plugins/plot/src/configuration/configStore.js b/src/plugins/plot/src/configuration/configStore.js index c5e925b10f..e23b3aaf18 100644 --- a/src/plugins/plot/src/configuration/configStore.js +++ b/src/plugins/plot/src/configuration/configStore.js @@ -42,7 +42,7 @@ define([ return this.store[id]; }; - var STORE = new ConfigStore(); + const STORE = new ConfigStore(); return STORE; }); diff --git a/src/plugins/plot/src/draw/Draw2D.js b/src/plugins/plot/src/draw/Draw2D.js index ad83aee669..d5dd145eff 100644 --- a/src/plugins/plot/src/draw/Draw2D.js +++ b/src/plugins/plot/src/draw/Draw2D.js @@ -66,7 +66,7 @@ define([ // Set the color to be used for drawing operations Draw2D.prototype.setColor = function (color) { - var mappedColor = color.map(function (c, i) { + const mappedColor = color.map(function (c, i) { return i < 3 ? Math.floor(c * 255) : (c); }).join(','); this.c2d.strokeStyle = "rgba(" + mappedColor + ")"; @@ -85,7 +85,7 @@ define([ }; Draw2D.prototype.drawLine = function (buf, color, points) { - var i; + let i; this.setColor(color); @@ -108,10 +108,10 @@ define([ }; Draw2D.prototype.drawSquare = function (min, max, color) { - var x1 = this.x(min[0]), - y1 = this.y(min[1]), - w = this.x(max[0]) - x1, - h = this.y(max[1]) - y1; + const x1 = this.x(min[0]); + const y1 = this.y(min[1]); + const w = this.x(max[0]) - x1; + const h = this.y(max[1]) - y1; this.setColor(color); this.c2d.fillRect(x1, y1, w, h); @@ -145,12 +145,12 @@ define([ }; Draw2D.prototype.drawLimitPoints = function (points, color, pointSize) { - var limitSize = pointSize * 2; - var offset = limitSize / 2; + const limitSize = pointSize * 2; + const offset = limitSize / 2; this.setColor(color); - for (var i = 0; i < points.length; i++) { + for (let i = 0; i < points.length; i++) { this.drawLimitPoint( this.x(points[i].x) - offset, this.y(points[i].y) - offset, diff --git a/src/plugins/plot/src/draw/DrawLoader.js b/src/plugins/plot/src/draw/DrawLoader.js index 9d776db36f..cbe0bd89c5 100644 --- a/src/plugins/plot/src/draw/DrawLoader.js +++ b/src/plugins/plot/src/draw/DrawLoader.js @@ -27,7 +27,7 @@ define( ], function (DrawWebGL, Draw2D) { - var CHARTS = [ + const CHARTS = [ { MAX_INSTANCES: 16, API: DrawWebGL, @@ -53,7 +53,7 @@ define( the draw API to. */ getDrawAPI: function (canvas, overlay) { - var api; + let api; CHARTS.forEach(function (CHART_TYPE) { if (api) { @@ -89,7 +89,7 @@ define( * Returns a fallback draw api. */ getFallbackDrawAPI: function (canvas, overlay) { - var api = new CHARTS[1].API(canvas, overlay); + const api = new CHARTS[1].API(canvas, overlay); CHARTS[1].ALLOCATIONS.push(api); return api; diff --git a/src/plugins/plot/src/draw/DrawWebGL.js b/src/plugins/plot/src/draw/DrawWebGL.js index 7cf73489a9..1243e7c879 100644 --- a/src/plugins/plot/src/draw/DrawWebGL.js +++ b/src/plugins/plot/src/draw/DrawWebGL.js @@ -285,16 +285,16 @@ define([ }; DrawWebGL.prototype.drawLimitPoints = function (points, color, pointSize) { - var limitSize = pointSize * 2; - var offset = limitSize / 2; + const limitSize = pointSize * 2; + const offset = limitSize / 2; - var mappedColor = color.map(function (c, i) { + const mappedColor = color.map(function (c, i) { return i < 3 ? Math.floor(c * 255) : (c); }).join(','); this.c2d.strokeStyle = "rgba(" + mappedColor + ")"; this.c2d.fillStyle = "rgba(" + mappedColor + ")"; - for (var i = 0; i < points.length; i++) { + for (let i = 0; i < points.length; i++) { this.drawLimitPoint( this.x(points[i].x) - offset, this.y(points[i].y) - offset, diff --git a/src/plugins/plot/src/inspector/HideElementPoolDirective.js b/src/plugins/plot/src/inspector/HideElementPoolDirective.js index 60932dc66f..5ac7fbdb07 100644 --- a/src/plugins/plot/src/inspector/HideElementPoolDirective.js +++ b/src/plugins/plot/src/inspector/HideElementPoolDirective.js @@ -30,7 +30,7 @@ define(function () { return { restrict: "A", link: function ($scope, $element) { - var splitter = $element.parent(); + let splitter = $element.parent(); while (splitter[0].tagName !== 'MCT-SPLIT-PANE') { splitter = splitter.parent(); @@ -40,7 +40,7 @@ define(function () { '.split-pane-component.pane.bottom', 'mct-splitter' ].forEach(function (selector) { - var element = splitter[0].querySelectorAll(selector)[0]; + const element = splitter[0].querySelectorAll(selector)[0]; element.style.maxHeight = '0px'; element.style.minHeight = '0px'; }); diff --git a/src/plugins/plot/src/inspector/InspectorRegion.js b/src/plugins/plot/src/inspector/InspectorRegion.js index b1795c02a4..90c4ffee48 100644 --- a/src/plugins/plot/src/inspector/InspectorRegion.js +++ b/src/plugins/plot/src/inspector/InspectorRegion.js @@ -46,7 +46,7 @@ define( * @private */ InspectorRegion.prototype.buildRegion = function () { - var metadataRegion = { + const metadataRegion = { name: 'metadata', title: 'Metadata Region', // Which modes should the region part be visible in? If diff --git a/src/plugins/plot/src/inspector/PlotBrowseRegion.js b/src/plugins/plot/src/inspector/PlotBrowseRegion.js index 98985efe60..4026eeb326 100644 --- a/src/plugins/plot/src/inspector/PlotBrowseRegion.js +++ b/src/plugins/plot/src/inspector/PlotBrowseRegion.js @@ -1,3 +1,4 @@ + /***************************************************************************** * Open MCT, Copyright (c) 2014-2018, United States Government * as represented by the Administrator of the National Aeronautics and Space @@ -26,7 +27,7 @@ define([ Region ) { - var PlotBrowseRegion = new Region({ + const PlotBrowseRegion = new Region({ name: "plot-options", title: "Plot Options", modes: ['browse'], diff --git a/src/plugins/plot/src/inspector/PlotEditRegion.js b/src/plugins/plot/src/inspector/PlotEditRegion.js index 23419dead3..233e425108 100644 --- a/src/plugins/plot/src/inspector/PlotEditRegion.js +++ b/src/plugins/plot/src/inspector/PlotEditRegion.js @@ -26,7 +26,7 @@ define([ Region ) { - var PlotEditRegion = new Region({ + const PlotEditRegion = new Region({ name: "plot-options", title: "Plot Options", modes: ['edit'], diff --git a/src/plugins/plot/src/inspector/PlotInspector.js b/src/plugins/plot/src/inspector/PlotInspector.js index faa615af1e..f038634723 100644 --- a/src/plugins/plot/src/inspector/PlotInspector.js +++ b/src/plugins/plot/src/inspector/PlotInspector.js @@ -30,7 +30,7 @@ define([ PlotEditRegion ) { - var plotInspector = new InspectorRegion(); + const plotInspector = new InspectorRegion(); plotInspector.addRegion(PlotBrowseRegion); plotInspector.addRegion(PlotEditRegion); diff --git a/src/plugins/plot/src/inspector/PlotLegendFormController.js b/src/plugins/plot/src/inspector/PlotLegendFormController.js index 601e5437ea..8c16219b7d 100644 --- a/src/plugins/plot/src/inspector/PlotLegendFormController.js +++ b/src/plugins/plot/src/inspector/PlotLegendFormController.js @@ -26,7 +26,7 @@ define([ PlotModelFormController ) { - var PlotLegendFormController = PlotModelFormController.extend({ + const PlotLegendFormController = PlotModelFormController.extend({ fields: [ { modelProp: 'position', diff --git a/src/plugins/plot/src/inspector/PlotModelFormController.js b/src/plugins/plot/src/inspector/PlotModelFormController.js index 8aa770f4f2..144d8d1189 100644 --- a/src/plugins/plot/src/inspector/PlotModelFormController.js +++ b/src/plugins/plot/src/inspector/PlotModelFormController.js @@ -121,7 +121,7 @@ define([ formProp = prop; } - var formPath = 'form.' + formProp; + const formPath = 'form.' + formProp; let self = this; if (!coerce) { @@ -137,7 +137,7 @@ define([ } if (objectPath && !_.isFunction(objectPath)) { - var staticObjectPath = objectPath; + const staticObjectPath = objectPath; objectPath = function () { return staticObjectPath; }; @@ -149,7 +149,7 @@ define([ } }); this.model.listenTo(this.$scope, 'change:' + formPath, (newVal, oldVal) => { - var validationResult = validate(newVal, this.model); + const validationResult = validate(newVal, this.model); if (validationResult === true) { delete this.$scope.validation[formProp]; } else { diff --git a/src/plugins/plot/src/inspector/PlotOptionsController.js b/src/plugins/plot/src/inspector/PlotOptionsController.js index 152d107110..5120e7bfdb 100644 --- a/src/plugins/plot/src/inspector/PlotOptionsController.js +++ b/src/plugins/plot/src/inspector/PlotOptionsController.js @@ -52,7 +52,7 @@ define([ }; PlotOptionsController.prototype.setUpScope = function () { - var config = configStore.get(this.configId); + const config = configStore.get(this.configId); if (!config) { this.$timeout(this.setUpScope.bind(this)); diff --git a/src/plugins/plot/src/inspector/PlotSeriesFormController.js b/src/plugins/plot/src/inspector/PlotSeriesFormController.js index 362b7b6aec..b3db63491d 100644 --- a/src/plugins/plot/src/inspector/PlotSeriesFormController.js +++ b/src/plugins/plot/src/inspector/PlotSeriesFormController.js @@ -32,8 +32,8 @@ define([ function dynamicPathForKey(key) { return function (object, model) { - var modelIdentifier = model.get('identifier'); - var index = object.configuration.series.findIndex(s => { + const modelIdentifier = model.get('identifier'); + const index = object.configuration.series.findIndex(s => { return _.isEqual(s.identifier, modelIdentifier); }); @@ -41,22 +41,22 @@ define([ }; } - var PlotSeriesFormController = PlotModelFormController.extend({ + const PlotSeriesFormController = PlotModelFormController.extend({ /** * Set the color for the current plot series. If the new color was * already assigned to a different plot series, then swap the colors. */ setColor: function (color) { - var oldColor = this.model.get('color'); - var otherSeriesWithColor = this.model.collection.filter(function (s) { + const oldColor = this.model.get('color'); + const otherSeriesWithColor = this.model.collection.filter(function (s) { return s.get('color') === color; })[0]; this.model.set('color', color); - var getPath = dynamicPathForKey('color'); - var seriesColorPath = getPath(this.domainObject, this.model); + const getPath = dynamicPathForKey('color'); + const seriesColorPath = getPath(this.domainObject, this.model); this.openmct.objects.mutate( this.domainObject, @@ -67,7 +67,7 @@ define([ if (otherSeriesWithColor) { otherSeriesWithColor.set('color', oldColor); - var otherSeriesColorPath = getPath( + const otherSeriesColorPath = getPath( this.domainObject, otherSeriesWithColor ); @@ -86,7 +86,7 @@ define([ initialize: function () { this.$scope.setColor = this.setColor.bind(this); - var metadata = this.model.metadata; + const metadata = this.model.metadata; this.$scope.yKeyOptions = metadata .valuesForHints(['range']) .map(function (o) { diff --git a/src/plugins/plot/src/inspector/PlotYAxisFormController.js b/src/plugins/plot/src/inspector/PlotYAxisFormController.js index a060f1112b..5e75a6291d 100644 --- a/src/plugins/plot/src/inspector/PlotYAxisFormController.js +++ b/src/plugins/plot/src/inspector/PlotYAxisFormController.js @@ -26,7 +26,7 @@ define([ PlotModelFormController ) { - var PlotYAxisFormController = PlotModelFormController.extend({ + const PlotYAxisFormController = PlotModelFormController.extend({ fields: [ { modelProp: 'label', @@ -53,7 +53,7 @@ define([ }; } - var newRange = {}; + const newRange = {}; if (typeof range.min !== 'undefined' && range.min !== null) { newRange.min = Number(range.min); } diff --git a/src/plugins/plot/src/lib/color.js b/src/plugins/plot/src/lib/color.js index 04e29278d9..3130e79680 100644 --- a/src/plugins/plot/src/lib/color.js +++ b/src/plugins/plot/src/lib/color.js @@ -22,7 +22,7 @@ define(function () { - var COLOR_PALETTE = [ + const COLOR_PALETTE = [ [0x20, 0xB2, 0xAA], [0x9A, 0xCD, 0x32], [0xFF, 0x8C, 0x00], @@ -56,7 +56,7 @@ define(function () { ]; function isDefaultColor(color) { - var a = color.asIntegerArray(); + const a = color.asIntegerArray(); return COLOR_PALETTE.some(function (b) { return a[0] === b[0] && a[1] === b[1] && a[2] === b[2]; @@ -139,11 +139,11 @@ define(function () { * @constructor */ function ColorPalette() { - var allColors = this.allColors = COLOR_PALETTE.map(function (color) { + const allColors = this.allColors = COLOR_PALETTE.map(function (color) { return new Color(color); }); this.colorGroups = [[], [], []]; - for (var i = 0; i < allColors.length; i++) { + for (let i = 0; i < allColors.length; i++) { this.colorGroups[i % 3].push(allColors[i]); } @@ -174,7 +174,7 @@ define(function () { }; ColorPalette.prototype.getByHexString = function (hexString) { - var color = Color.fromHexString(hexString); + const color = Color.fromHexString(hexString); return color; }; diff --git a/src/plugins/plot/src/lib/eventHelpers.js b/src/plugins/plot/src/lib/eventHelpers.js index e0a3c96835..1288f15d42 100644 --- a/src/plugins/plot/src/lib/eventHelpers.js +++ b/src/plugins/plot/src/lib/eventHelpers.js @@ -27,13 +27,13 @@ define([ ) { - var helperFunctions = { + const helperFunctions = { listenTo: function (object, event, callback, context) { if (!this._listeningTo) { this._listeningTo = []; } - var listener = { + const listener = { object: object, event: event, callback: callback, @@ -41,7 +41,7 @@ define([ _cb: context ? callback.bind(context) : callback }; if (object.$watch && event.indexOf('change:') === 0) { - var scopePath = event.replace('change:', ''); + const scopePath = event.replace('change:', ''); listener.unlisten = object.$watch(scopePath, listener._cb, true); } else if (object.$on) { listener.unlisten = object.$on(event, listener._cb); diff --git a/src/plugins/plot/src/lib/extend.js b/src/plugins/plot/src/lib/extend.js index 3cf7daa686..d0a85a82e0 100644 --- a/src/plugins/plot/src/lib/extend.js +++ b/src/plugins/plot/src/lib/extend.js @@ -29,9 +29,10 @@ define([ function extend(props) { // eslint-disable-next-line no-invalid-this - var parent = this, - child, - Surrogate; + const parent = this; + + let child; + let Surrogate; if (props && Object.prototype.hasOwnProperty.call(props, 'constructor')) { child = props.constructor; diff --git a/src/plugins/plot/src/plot/LinearScale.js b/src/plugins/plot/src/plot/LinearScale.js index 47fac1664e..2a13c087be 100644 --- a/src/plugins/plot/src/plot/LinearScale.js +++ b/src/plugins/plot/src/plot/LinearScale.js @@ -59,10 +59,10 @@ define([ return; } - var domainOffset = domainValue - this._domain.min, - rangeFraction = domainOffset - this._domainDenominator, - rangeOffset = rangeFraction * this._rangeDenominator, - rangeValue = rangeOffset + this._range.min; + const domainOffset = domainValue - this._domain.min; + const rangeFraction = domainOffset - this._domainDenominator; + const rangeOffset = rangeFraction * this._rangeDenominator; + const rangeValue = rangeOffset + this._range.min; return rangeValue; }; @@ -72,10 +72,10 @@ define([ return; } - var rangeOffset = rangeValue - this._range.min, - domainFraction = rangeOffset / this._rangeDenominator, - domainOffset = domainFraction * this._domainDenominator, - domainValue = domainOffset + this._domain.min; + const rangeOffset = rangeValue - this._range.min; + const domainFraction = rangeOffset / this._rangeDenominator; + const domainOffset = domainFraction * this._domainDenominator; + const domainValue = domainOffset + this._domain.min; return domainValue; }; diff --git a/src/plugins/plot/src/plot/MCTPlotController.js b/src/plugins/plot/src/plot/MCTPlotController.js index c2309b6340..904c27ee9b 100644 --- a/src/plugins/plot/src/plot/MCTPlotController.js +++ b/src/plugins/plot/src/plot/MCTPlotController.js @@ -123,8 +123,8 @@ define([ // set yAxisLabel if none is set yet if (this.$scope.yAxisLabel === 'none') { - let yKey = this.$scope.series[0].model.yKey, - yKeyModel = this.$scope.yKeyOptions.filter(o => o.key === yKey)[0]; + let yKey = this.$scope.series[0].model.yKey; + let yKeyModel = this.$scope.yKeyOptions.filter(o => o.key === yKey)[0]; this.$scope.yAxisLabel = yKeyModel.name; } @@ -151,7 +151,7 @@ define([ this.$scope.tickWidth = width; } else { // Otherwise, only accept tick with if it's larger. - var newWidth = Math.max(width, this.$scope.tickWidth); + const newWidth = Math.max(width, this.$scope.tickWidth); if (newWidth !== this.$scope.tickWidth) { this.$scope.tickWidth = newWidth; this.$scope.$digest(); @@ -314,9 +314,9 @@ define([ }; MCTPlotController.prototype.endMarquee = function () { - var startPixels = this.marquee.startPixels; - var endPixels = this.marquee.endPixels; - var marqueeDistance = Math.sqrt( + const startPixels = this.marquee.startPixels; + const endPixels = this.marquee.endPixels; + const marqueeDistance = Math.sqrt( Math.pow(startPixels.x - endPixels.x, 2) + Math.pow(startPixels.y - endPixels.y, 2) ); @@ -342,8 +342,8 @@ define([ }; MCTPlotController.prototype.zoom = function (zoomDirection, zoomFactor) { - var currentXaxis = this.$scope.xAxis.get('displayRange'), - currentYaxis = this.$scope.yAxis.get('displayRange'); + const currentXaxis = this.$scope.xAxis.get('displayRange'); + const currentYaxis = this.$scope.yAxis.get('displayRange'); // when there is no plot data, the ranges can be undefined // in which case we should not perform zoom @@ -354,8 +354,8 @@ define([ this.freeze(); this.trackHistory(); - var xAxisDist = (currentXaxis.max - currentXaxis.min) * zoomFactor, - yAxisDist = (currentYaxis.max - currentYaxis.min) * zoomFactor; + const xAxisDist = (currentXaxis.max - currentXaxis.min) * zoomFactor; + const yAxisDist = (currentYaxis.max - currentYaxis.min) * zoomFactor; if (zoomDirection === 'in') { this.$scope.xAxis.set('displayRange', { @@ -390,8 +390,8 @@ define([ return; } - let xDisplayRange = this.$scope.xAxis.get('displayRange'), - yDisplayRange = this.$scope.yAxis.get('displayRange'); + let xDisplayRange = this.$scope.xAxis.get('displayRange'); + let yDisplayRange = this.$scope.yAxis.get('displayRange'); // when there is no plot data, the ranges can be undefined // in which case we should not perform zoom @@ -402,16 +402,16 @@ define([ this.freeze(); window.clearTimeout(this.stillZooming); - let xAxisDist = (xDisplayRange.max - xDisplayRange.min), - yAxisDist = (yDisplayRange.max - yDisplayRange.min), - xDistMouseToMax = xDisplayRange.max - this.positionOverPlot.x, - xDistMouseToMin = this.positionOverPlot.x - xDisplayRange.min, - yDistMouseToMax = yDisplayRange.max - this.positionOverPlot.y, - yDistMouseToMin = this.positionOverPlot.y - yDisplayRange.min, - xAxisMaxDist = xDistMouseToMax / xAxisDist, - xAxisMinDist = xDistMouseToMin / xAxisDist, - yAxisMaxDist = yDistMouseToMax / yAxisDist, - yAxisMinDist = yDistMouseToMin / yAxisDist; + let xAxisDist = (xDisplayRange.max - xDisplayRange.min); + let yAxisDist = (yDisplayRange.max - yDisplayRange.min); + let xDistMouseToMax = xDisplayRange.max - this.positionOverPlot.x; + let xDistMouseToMin = this.positionOverPlot.x - xDisplayRange.min; + let yDistMouseToMax = yDisplayRange.max - this.positionOverPlot.y; + let yDistMouseToMin = this.positionOverPlot.y - yDisplayRange.min; + let xAxisMaxDist = xDistMouseToMax / xAxisDist; + let xAxisMinDist = xDistMouseToMin / xAxisDist; + let yAxisMaxDist = yDistMouseToMax / yAxisDist; + let yAxisMinDist = yDistMouseToMin / yAxisDist; let plotHistoryStep; @@ -474,10 +474,10 @@ define([ return; } - var dX = this.pan.start.x - this.positionOverPlot.x, - dY = this.pan.start.y - this.positionOverPlot.y, - xRange = this.config.xAxis.get('displayRange'), - yRange = this.config.yAxis.get('displayRange'); + const dX = this.pan.start.x - this.positionOverPlot.x; + const dY = this.pan.start.y - this.positionOverPlot.y; + const xRange = this.config.xAxis.get('displayRange'); + const yRange = this.config.yAxis.get('displayRange'); this.config.xAxis.set('displayRange', { min: xRange.min + dX, @@ -514,7 +514,7 @@ define([ }; MCTPlotController.prototype.back = function () { - var previousAxisRanges = this.plotHistory.pop(); + const previousAxisRanges = this.plotHistory.pop(); if (this.plotHistory.length === 0) { this.clear(); diff --git a/src/plugins/plot/src/plot/MCTTicksController.js b/src/plugins/plot/src/plot/MCTTicksController.js index 78961ac438..31258158ae 100644 --- a/src/plugins/plot/src/plot/MCTTicksController.js +++ b/src/plugins/plot/src/plot/MCTTicksController.js @@ -27,18 +27,17 @@ define([ _, eventHelpers ) { - - var e10 = Math.sqrt(50), - e5 = Math.sqrt(10), - e2 = Math.sqrt(2); + const e10 = Math.sqrt(50); + const e5 = Math.sqrt(10); + const e2 = Math.sqrt(2); /** * Nicely formatted tick steps from d3-array. */ function tickStep(start, stop, count) { - var step0 = Math.abs(stop - start) / Math.max(0, count), - step1 = Math.pow(10, Math.floor(Math.log(step0) / Math.LN10)), - error = step0 / step1; + const step0 = Math.abs(stop - start) / Math.max(0, count); + let step1 = Math.pow(10, Math.floor(Math.log(step0) / Math.LN10)); + const error = step0 / step1; if (error >= e10) { step1 *= 10; } else if (error >= e5) { @@ -55,13 +54,13 @@ define([ * ticks to precise values. */ function getPrecision(step) { - var exponential = step.toExponential(), - i = exponential.indexOf('e'); + const exponential = step.toExponential(); + const i = exponential.indexOf('e'); if (i === -1) { return 0; } - var precision = Math.max(0, -(Number(exponential.slice(i + 1)))); + let precision = Math.max(0, -(Number(exponential.slice(i + 1)))); if (precision > 20) { precision = 20; @@ -74,8 +73,8 @@ define([ * Linear tick generation from d3-array. */ function ticks(start, stop, count) { - var step = tickStep(start, stop, count), - precision = getPrecision(step); + const step = tickStep(start, stop, count); + const precision = getPrecision(step); return _.range( Math.ceil(start / step) * step, @@ -87,9 +86,9 @@ define([ } function commonPrefix(a, b) { - var maxLen = Math.min(a.length, b.length); - var breakpoint = 0; - for (var i = 0; i < maxLen; i++) { + const maxLen = Math.min(a.length, b.length); + let breakpoint = 0; + for (let i = 0; i < maxLen; i++) { if (a[i] !== b[i]) { break; } @@ -103,9 +102,9 @@ define([ } function commonSuffix(a, b) { - var maxLen = Math.min(a.length, b.length); - var breakpoint = 0; - for (var i = 0; i <= maxLen; i++) { + const maxLen = Math.min(a.length, b.length); + let breakpoint = 0; + for (let i = 0; i <= maxLen; i++) { if (a[a.length - i] !== b[b.length - i]) { break; } @@ -164,9 +163,9 @@ define([ }; MCTTicksController.prototype.getTicks = function () { - var number = this.tickCount; - var clampRange = this.axis.get('values'); - var range = this.axis.get('displayRange'); + const number = this.tickCount; + const clampRange = this.axis.get('values'); + const range = this.axis.get('displayRange'); if (clampRange) { return clampRange.filter(function (value) { return value <= range.max && value >= range.min; @@ -177,7 +176,7 @@ define([ }; MCTTicksController.prototype.updateTicks = function () { - var range = this.axis.get('displayRange'); + const range = this.axis.get('displayRange'); if (!range) { delete this.$scope.min; delete this.$scope.max; @@ -189,7 +188,7 @@ define([ return; } - var format = this.axis.get('format'); + const format = this.axis.get('format'); if (!format) { return; } @@ -198,7 +197,7 @@ define([ this.$scope.max = range.max; this.$scope.interval = Math.abs(range.min - range.max); if (this.shouldRegenerateTicks(range)) { - var newTicks = this.getTicks(); + let newTicks = this.getTicks(); this.tickRange = { min: Math.min.apply(Math, newTicks), max: Math.max.apply(Math, newTicks), @@ -214,11 +213,11 @@ define([ }, this); if (newTicks.length && typeof newTicks[0].text === 'string') { - var tickText = newTicks.map(function (t) { + const tickText = newTicks.map(function (t) { return t.text; }); - var prefix = tickText.reduce(commonPrefix); - var suffix = tickText.reduce(commonSuffix); + const prefix = tickText.reduce(commonPrefix); + const suffix = tickText.reduce(commonSuffix); newTicks.forEach(function (t, i) { t.fullText = t.text; if (suffix.length) { @@ -248,11 +247,12 @@ define([ MCTTicksController.prototype.doTickUpdate = function () { if (this.shouldCheckWidth) { this.$scope.$digest(); - var element = this.$element[0], - tickElements = element.querySelectorAll('.gl-plot-tick > span'), - tickWidth = Number([].reduce.call(tickElements, function (memo, first) { - return Math.max(memo, first.offsetWidth); - }, 0)); + const element = this.$element[0]; + const tickElements = element.querySelectorAll('.gl-plot-tick > span'); + + const tickWidth = Number([].reduce.call(tickElements, function (memo, first) { + return Math.max(memo, first.offsetWidth); + }, 0)); this.$scope.tickWidth = tickWidth; this.$scope.$emit('plot:tickWidth', tickWidth); diff --git a/src/plugins/plot/src/services/ExportImageService.js b/src/plugins/plot/src/services/ExportImageService.js index 862e93ca4e..74967a577a 100644 --- a/src/plugins/plot/src/services/ExportImageService.js +++ b/src/plugins/plot/src/services/ExportImageService.js @@ -52,32 +52,34 @@ define( * @returns {promise} */ ExportImageService.prototype.renderElement = function (element, imageType, className) { + const dialogService = this.dialogService; - var dialogService = this.dialogService, - dialog = dialogService.showBlockingMessage({ - title: "Capturing...", - hint: "Capturing an image", - unknownProgress: true, - severity: "info", - delay: true - }); + const dialog = dialogService.showBlockingMessage({ + title: "Capturing...", + hint: "Capturing an image", + unknownProgress: true, + severity: "info", + delay: true + }); - var mimeType = "image/png"; + let mimeType = "image/png"; if (imageType === "jpg") { mimeType = "image/jpeg"; } + let exportId = undefined; + let oldId = undefined; if (className) { - var exportId = 'export-element-' + this.exportCount; + exportId = 'export-element-' + this.exportCount; this.exportCount++; - var oldId = element.id; + oldId = element.id; element.id = exportId; } return html2canvas(element, { onclone: function (document) { if (className) { - var clonedElement = document.getElementById(exportId); + const clonedElement = document.getElementById(exportId); clonedElement.classList.add(className); } @@ -93,7 +95,7 @@ define( }, function (error) { console.log('error capturing image', error); dialog.dismiss(); - var errorDialog = dialogService.showBlockingMessage({ + const errorDialog = dialogService.showBlockingMessage({ title: "Error capturing image", severity: "error", hint: "Image was not captured successfully!", @@ -153,12 +155,11 @@ define( if (!HTMLCanvasElement.prototype.toBlob) { Object.defineProperty(HTMLCanvasElement.prototype, "toBlob", { value: function (callback, mimeType, quality) { + const binStr = atob(this.toDataURL(mimeType, quality).split(',')[1]); + const len = binStr.length; + const arr = new Uint8Array(len); - var binStr = atob(this.toDataURL(mimeType, quality).split(',')[1]), - len = binStr.length, - arr = new Uint8Array(len); - - for (var i = 0; i < len; i++) { + for (let i = 0; i < len; i++) { arr[i] = binStr.charCodeAt(i); } diff --git a/src/plugins/plot/src/telemetry/PlotController.js b/src/plugins/plot/src/telemetry/PlotController.js index a1a3ffb8b1..2981275aa4 100644 --- a/src/plugins/plot/src/telemetry/PlotController.js +++ b/src/plugins/plot/src/telemetry/PlotController.js @@ -102,7 +102,7 @@ define([ } this.startLoading(); - var options = { + const options = { size: this.$element[0].offsetWidth, domain: this.config.xAxis.get('key') }; @@ -150,10 +150,10 @@ define([ }; PlotController.prototype.getConfig = function (domainObject) { - var configId = domainObject.getId(); - var config = configStore.get(configId); + const configId = domainObject.getId(); + let config = configStore.get(configId); if (!config) { - var newDomainObject = domainObject.useCapability('adapter'); + const newDomainObject = domainObject.useCapability('adapter'); config = new PlotConfigurationModel({ id: configId, domainObject: newDomainObject, @@ -202,7 +202,7 @@ define([ * Track latest display bounds. Forces update when not receiving ticks. */ PlotController.prototype.updateDisplayBounds = function (bounds, isTick) { - var newRange = { + const newRange = { min: bounds.start, max: bounds.end }; @@ -216,7 +216,7 @@ define([ // Drop any data that is more than 1x (max-min) before min. // Limit these purges to once a second. if (!this.nextPurge || this.nextPurge < Date.now()) { - var keepRange = { + const keepRange = { min: newRange.min - (newRange.max - newRange.min), max: newRange.max }; @@ -247,7 +247,7 @@ define([ PlotController.prototype.synchronized = function (value) { if (typeof value !== 'undefined') { this._synchronized = value; - var isUnsynced = !value && this.openmct.time.clock(); + const isUnsynced = !value && this.openmct.time.clock(); if (this.$scope.domainObject.getCapability('status')) { this.$scope.domainObject.getCapability('status') .set('timeconductor-unsynced', isUnsynced); @@ -263,8 +263,8 @@ define([ * @private */ PlotController.prototype.onUserViewportChangeEnd = function () { - var xDisplayRange = this.config.xAxis.get('displayRange'); - var xRange = this.config.xAxis.get('range'); + const xDisplayRange = this.config.xAxis.get('displayRange'); + const xRange = this.config.xAxis.get('range'); if (!this.skipReloadOnInteraction) { this.loadMoreData(xDisplayRange); @@ -290,7 +290,7 @@ define([ * Export view as JPG. */ PlotController.prototype.exportJPG = function () { - var plotElement = this.$element.children()[1]; + const plotElement = this.$element.children()[1]; this.exportImageService.exportJPG(plotElement, 'plot.jpg', 'export-plot'); }; @@ -299,7 +299,7 @@ define([ * Export view as PNG. */ PlotController.prototype.exportPNG = function () { - var plotElement = this.$element.children()[1]; + const plotElement = this.$element.children()[1]; this.exportImageService.exportPNG(plotElement, 'plot.png', 'export-plot'); }; diff --git a/src/plugins/plot/src/telemetry/StackedPlotController.js b/src/plugins/plot/src/telemetry/StackedPlotController.js index 4ca7a10d4e..391d466185 100644 --- a/src/plugins/plot/src/telemetry/StackedPlotController.js +++ b/src/plugins/plot/src/telemetry/StackedPlotController.js @@ -22,11 +22,11 @@ define([], function () { function StackedPlotController($scope, openmct, objectService, $element, exportImageService) { - var tickWidth = 0, - composition, - currentRequest, - unlisten, - tickWidthMap = {}; + let tickWidth = 0; + let composition; + let currentRequest; + let unlisten; + let tickWidthMap = {}; this.$element = $element; this.exportImageService = exportImageService; @@ -36,13 +36,13 @@ define([], function () { $scope.telemetryObjects = []; function onDomainObjectChange(domainObject) { - var thisRequest = { + const thisRequest = { pending: 0 }; currentRequest = thisRequest; $scope.currentRequest = thisRequest; - var telemetryObjects = $scope.telemetryObjects = []; - var thisTickWidthMap = {}; + const telemetryObjects = $scope.telemetryObjects = []; + const thisTickWidthMap = {}; tickWidthMap = thisTickWidthMap; if (unlisten) { @@ -51,25 +51,25 @@ define([], function () { } function addChild(child) { - var id = openmct.objects.makeKeyString(child.identifier); + const id = openmct.objects.makeKeyString(child.identifier); thisTickWidthMap[id] = 0; thisRequest.pending += 1; objectService.getObjects([id]) .then(function (objects) { thisRequest.pending -= 1; - var childObj = objects[id]; + const childObj = objects[id]; telemetryObjects.push(childObj); }); } function removeChild(childIdentifier) { - var id = openmct.objects.makeKeyString(childIdentifier); + const id = openmct.objects.makeKeyString(childIdentifier); delete thisTickWidthMap[id]; - var childObj = telemetryObjects.filter(function (c) { + const childObj = telemetryObjects.filter(function (c) { return c.getId() === id; })[0]; if (childObj) { - var index = telemetryObjects.indexOf(childObj); + const index = telemetryObjects.indexOf(childObj); telemetryObjects.splice(index, 1); $scope.$broadcast('plot:tickWidth', Math.max(...Object.values(tickWidthMap))); } diff --git a/src/plugins/plugins.js b/src/plugins/plugins.js index ab6b4c9e30..8dc1e82777 100644 --- a/src/plugins/plugins.js +++ b/src/plugins/plugins.js @@ -91,14 +91,14 @@ define([ NotificationIndicator, NewFolderAction ) { - var bundleMap = { + const bundleMap = { LocalStorage: 'platform/persistence/local', MyItems: 'platform/features/my-items', CouchDB: 'platform/persistence/couch', Elasticsearch: 'platform/persistence/elastic' }; - var plugins = _.mapValues(bundleMap, function (bundleName, pluginName) { + const plugins = _.mapValues(bundleMap, function (bundleName, pluginName) { return function pluginConstructor() { return function (openmct) { openmct.legacyRegistry.enable(bundleName); @@ -129,7 +129,7 @@ define([ plugins.CouchDB = function (url) { return function (openmct) { if (url) { - var bundleName = "config/couch"; + const bundleName = "config/couch"; openmct.legacyRegistry.register(bundleName, { "extensions": { "constants": [ @@ -151,7 +151,7 @@ define([ plugins.Elasticsearch = function (url) { return function (openmct) { if (url) { - var bundleName = "config/elastic"; + const bundleName = "config/elastic"; openmct.legacyRegistry.register(bundleName, { "extensions": { "constants": [ diff --git a/src/plugins/staticRootPlugin/StaticModelProvider.js b/src/plugins/staticRootPlugin/StaticModelProvider.js index 9a05d52e4f..2783d5d532 100644 --- a/src/plugins/staticRootPlugin/StaticModelProvider.js +++ b/src/plugins/staticRootPlugin/StaticModelProvider.js @@ -10,11 +10,11 @@ define([ * exist in the same namespace as the rootIdentifier. */ function rewriteObjectIdentifiers(importData, rootIdentifier) { - var rootId = importData.rootId; - var objectString = JSON.stringify(importData.openmct); + const rootId = importData.rootId; + let objectString = JSON.stringify(importData.openmct); Object.keys(importData.openmct).forEach(function (originalId, i) { - var newId; + let newId; if (originalId === rootId) { newId = objectUtils.makeKeyString(rootIdentifier); } else { @@ -60,8 +60,8 @@ define([ * an object provider to fetch those objects. */ function StaticModelProvider(importData, rootIdentifier) { - var oldFormatObjectMap = rewriteObjectIdentifiers(importData, rootIdentifier); - var newFormatObjectMap = convertToNewObjects(oldFormatObjectMap); + const oldFormatObjectMap = rewriteObjectIdentifiers(importData, rootIdentifier); + const newFormatObjectMap = convertToNewObjects(oldFormatObjectMap); this.objectMap = setRootLocation(newFormatObjectMap, rootIdentifier); } @@ -69,7 +69,7 @@ define([ * Standard "Get". */ StaticModelProvider.prototype.get = function (identifier) { - var keyString = objectUtils.makeKeyString(identifier); + const keyString = objectUtils.makeKeyString(identifier); if (this.objectMap[keyString]) { return this.objectMap[keyString]; } diff --git a/src/plugins/staticRootPlugin/StaticModelProviderSpec.js b/src/plugins/staticRootPlugin/StaticModelProviderSpec.js index 34031f3506..07118ddebf 100644 --- a/src/plugins/staticRootPlugin/StaticModelProviderSpec.js +++ b/src/plugins/staticRootPlugin/StaticModelProviderSpec.js @@ -8,10 +8,10 @@ define([ describe('StaticModelProvider', function () { - var staticProvider; + let staticProvider; beforeEach(function () { - var staticData = JSON.parse(JSON.stringify(testStaticData)); + const staticData = JSON.parse(JSON.stringify(testStaticData)); staticProvider = new StaticModelProvider(staticData, { namespace: 'my-import', key: 'root' @@ -19,7 +19,7 @@ define([ }); describe('rootObject', function () { - var rootModel; + let rootModel; beforeEach(function () { rootModel = staticProvider.get({ @@ -52,9 +52,9 @@ define([ }); describe('childObjects', function () { - var swg; - var layout; - var fixed; + let swg; + let layout; + let fixed; beforeEach(function () { swg = staticProvider.get({ diff --git a/src/plugins/staticRootPlugin/plugin.js b/src/plugins/staticRootPlugin/plugin.js index ecbf433b8a..59029eff27 100644 --- a/src/plugins/staticRootPlugin/plugin.js +++ b/src/plugins/staticRootPlugin/plugin.js @@ -9,12 +9,12 @@ define([ */ function StaticRootPlugin(namespace, exportUrl) { - var rootIdentifier = { + const rootIdentifier = { namespace: namespace, key: 'root' }; - var cachedProvider; + let cachedProvider; function loadProvider() { return fetch(exportUrl) diff --git a/src/plugins/summaryWidget/SummaryWidgetsCompositionPolicy.js b/src/plugins/summaryWidget/SummaryWidgetsCompositionPolicy.js index b5ac48ae3f..adeabd1079 100644 --- a/src/plugins/summaryWidget/SummaryWidgetsCompositionPolicy.js +++ b/src/plugins/summaryWidget/SummaryWidgetsCompositionPolicy.js @@ -29,8 +29,8 @@ define( } SummaryWidgetsCompositionPolicy.prototype.allow = function (parent, child) { - var parentType = parent.getCapability('type'); - var newStyleChild = child.useCapability('adapter'); + const parentType = parent.getCapability('type'); + const newStyleChild = child.useCapability('adapter'); if (parentType.instanceOf('summary-widget') && !this.openmct.telemetry.isTelemetryObject(newStyleChild)) { return false; diff --git a/src/plugins/summaryWidget/plugin.js b/src/plugins/summaryWidget/plugin.js index 592ab40bcc..9b618339d5 100755 --- a/src/plugins/summaryWidget/plugin.js +++ b/src/plugins/summaryWidget/plugin.js @@ -14,7 +14,7 @@ define([ function plugin() { - var widgetType = { + const widgetType = { name: 'Summary Widget', description: 'A compact status update for collections of telemetry-producing items', creatable: true, diff --git a/src/plugins/summaryWidget/src/Condition.js b/src/plugins/summaryWidget/src/Condition.js index 45996529ed..997ad67b4f 100644 --- a/src/plugins/summaryWidget/src/Condition.js +++ b/src/plugins/summaryWidget/src/Condition.js @@ -44,7 +44,7 @@ define([ this.remove = this.remove.bind(this); this.duplicate = this.duplicate.bind(this); - var self = this; + const self = this; /** * Event handler for a change in one of this conditions' custom selects @@ -70,9 +70,9 @@ define([ * @private */ function onValueInput(event) { - var elem = event.target, - value = isNaN(Number(elem.value)) ? elem.value : Number(elem.value), - inputIndex = self.valueInputs.indexOf(elem); + const elem = event.target; + const value = isNaN(Number(elem.value)) ? elem.value : Number(elem.value); + const inputIndex = self.valueInputs.indexOf(elem); self.eventEmitter.emit('change', { value: value, @@ -156,7 +156,7 @@ define([ * callbacks with the cloned configuration and this rule's index */ Condition.prototype.duplicate = function () { - var sourceCondition = JSON.parse(JSON.stringify(this.config)); + const sourceCondition = JSON.parse(JSON.stringify(this.config)); this.eventEmitter.emit('duplicate', { sourceCondition: sourceCondition, index: this.index @@ -171,13 +171,13 @@ define([ * @param {string} operation The key of currently selected operation */ Condition.prototype.generateValueInputs = function (operation) { - var evaluator = this.conditionManager.getEvaluator(), - inputArea = $('.t-value-inputs', this.domElement), - inputCount, - inputType, - newInput, - index = 0, - emitChange = false; + const evaluator = this.conditionManager.getEvaluator(); + const inputArea = $('.t-value-inputs', this.domElement); + let inputCount; + let inputType; + let newInput; + let index = 0; + let emitChange = false; inputArea.html(''); this.valueInputs = []; diff --git a/src/plugins/summaryWidget/src/ConditionEvaluator.js b/src/plugins/summaryWidget/src/ConditionEvaluator.js index 50b95a8d94..6431690a93 100644 --- a/src/plugins/summaryWidget/src/ConditionEvaluator.js +++ b/src/plugins/summaryWidget/src/ConditionEvaluator.js @@ -258,12 +258,12 @@ define([], function () { * @return {boolean} The boolean value of the conditions */ ConditionEvaluator.prototype.execute = function (conditions, mode) { - var active = false, - conditionValue, - conditionDefined = false, - self = this, - firstRuleEvaluated = false, - compositionObjs = this.compositionObjs; + let active = false; + let conditionValue; + let conditionDefined = false; + const self = this; + let firstRuleEvaluated = false; + const compositionObjs = this.compositionObjs; if (mode === 'js') { active = this.executeJavaScriptCondition(conditions); @@ -328,11 +328,11 @@ define([], function () { * @return {boolean} The value of this condition */ ConditionEvaluator.prototype.executeCondition = function (object, key, operation, values) { - var cache = (this.useTestCache ? this.testCache : this.subscriptionCache), - telemetryValue, - op, - input, - validator; + const cache = (this.useTestCache ? this.testCache : this.subscriptionCache); + let telemetryValue; + let op; + let input; + let validator; if (cache[object] && typeof cache[object][key] !== 'undefined') { let value = cache[object][key]; @@ -361,7 +361,7 @@ define([], function () { * @returns {boolean} */ ConditionEvaluator.prototype.validateNumberInput = function (input) { - var valid = true; + let valid = true; input.forEach(function (value) { valid = valid && (typeof value === 'number'); }); @@ -376,7 +376,7 @@ define([], function () { * @returns {boolean} */ ConditionEvaluator.prototype.validateStringInput = function (input) { - var valid = true; + let valid = true; input.forEach(function (value) { valid = valid && (typeof value === 'string'); }); @@ -441,7 +441,7 @@ define([], function () { * @return {string} The key for an HTML5 input type */ ConditionEvaluator.prototype.getInputType = function (key) { - var type; + let type; if (this.operations[key]) { type = this.operations[key].appliesTo[0]; } diff --git a/src/plugins/summaryWidget/src/ConditionManager.js b/src/plugins/summaryWidget/src/ConditionManager.js index 6e7eaf07e2..ff90bc7bc7 100644 --- a/src/plugins/summaryWidget/src/ConditionManager.js +++ b/src/plugins/summaryWidget/src/ConditionManager.js @@ -82,10 +82,10 @@ define ([ * @return {string} The ID of the rule to display on the widget */ ConditionManager.prototype.executeRules = function (ruleOrder, rules) { - var self = this, - activeId = ruleOrder[0], - rule, - conditions; + const self = this; + let activeId = ruleOrder[0]; + let rule; + let conditions; ruleOrder.forEach(function (ruleId) { rule = rules[ruleId]; @@ -125,11 +125,11 @@ define ([ * has completed and types have been parsed */ ConditionManager.prototype.parsePropertyTypes = function (object) { - var objectId = objectUtils.makeKeyString(object.identifier); + const objectId = objectUtils.makeKeyString(object.identifier); this.telemetryTypesById[objectId] = {}; Object.values(this.telemetryMetadataById[objectId]).forEach(function (valueMetadata) { - var type; + let type; if (valueMetadata.enumerations !== undefined) { type = 'enum'; } else if (Object.prototype.hasOwnProperty.call(valueMetadata.hints, 'range')) { @@ -186,11 +186,11 @@ define ([ * @private */ ConditionManager.prototype.onCompositionAdd = function (obj) { - var compositionKeys, - telemetryAPI = this.openmct.telemetry, - objId = objectUtils.makeKeyString(obj.identifier), - telemetryMetadata, - self = this; + let compositionKeys; + const telemetryAPI = this.openmct.telemetry; + const objId = objectUtils.makeKeyString(obj.identifier); + let telemetryMetadata; + const self = this; if (telemetryAPI.isTelemetryObject(obj)) { self.compositionObjs[objId] = obj; @@ -243,7 +243,7 @@ define ([ * @private */ ConditionManager.prototype.onCompositionRemove = function (identifier) { - var objectId = objectUtils.makeKeyString(identifier); + const objectId = objectUtils.makeKeyString(identifier); // FIXME: this should just update by listener. _.remove(this.domainObject.composition, function (id) { return id.key === identifier.key @@ -286,7 +286,7 @@ define ([ * @return {string} The human-readable name of the domain object */ ConditionManager.prototype.getObjectName = function (id) { - var name; + let name; if (this.keywordLabels[id]) { name = this.keywordLabels[id]; diff --git a/src/plugins/summaryWidget/src/Rule.js b/src/plugins/summaryWidget/src/Rule.js index 229692bd54..d9217f0e0c 100644 --- a/src/plugins/summaryWidget/src/Rule.js +++ b/src/plugins/summaryWidget/src/Rule.js @@ -31,7 +31,7 @@ define([ */ function Rule(ruleConfig, domainObject, openmct, conditionManager, widgetDnD, container) { eventHelpers.extend(this); - var self = this; + const self = this; const THUMB_ICON_CLASS = 'c-sw__icon js-sw__icon'; this.config = ruleConfig; @@ -125,7 +125,7 @@ define([ * @private */ function onTriggerInput(event) { - var elem = event.target; + const elem = event.target; self.config.trigger = encodeMsg(elem.value); self.generateDescription(); self.updateDomainObject(); @@ -140,7 +140,7 @@ define([ * @private */ function onTextInput(elem, inputKey) { - var text = encodeMsg(elem.value); + const text = encodeMsg(elem.value); self.config[inputKey] = text; self.updateDomainObject(); if (inputKey === 'name') { @@ -188,7 +188,7 @@ define([ this.thumbnailLabel.html(self.config.label); Object.keys(this.colorInputs).forEach(function (inputKey) { - var input = self.colorInputs[inputKey]; + const input = self.colorInputs[inputKey]; input.set(self.config.style[inputKey]); onColorInput(self.config.style[inputKey], inputKey); @@ -330,9 +330,9 @@ define([ * registered remove callbacks */ Rule.prototype.remove = function () { - var ruleOrder = this.domainObject.configuration.ruleOrder, - ruleConfigById = this.domainObject.configuration.ruleConfigById, - self = this; + const ruleOrder = this.domainObject.configuration.ruleOrder; + const ruleConfigById = this.domainObject.configuration.ruleConfigById; + const self = this; ruleConfigById[self.config.id] = undefined; _.remove(ruleOrder, function (ruleId) { @@ -350,7 +350,7 @@ define([ * callback with the cloned configuration as an argument if one has been registered */ Rule.prototype.duplicate = function () { - var sourceRule = JSON.parse(JSON.stringify(this.config)); + const sourceRule = JSON.parse(JSON.stringify(this.config)); sourceRule.expanded = true; this.eventEmitter.emit('duplicate', sourceRule); }; @@ -364,15 +364,15 @@ define([ * consisting of sourceCondition and index fields */ Rule.prototype.initCondition = function (config) { - var ruleConfigById = this.domainObject.configuration.ruleConfigById, - newConfig, - sourceIndex = config && config.index, - defaultConfig = { - object: '', - key: '', - operation: '', - values: [] - }; + const ruleConfigById = this.domainObject.configuration.ruleConfigById; + let newConfig; + const sourceIndex = config && config.index; + const defaultConfig = { + object: '', + key: '', + operation: '', + values: [] + }; newConfig = (config !== undefined ? config.sourceCondition : defaultConfig); if (sourceIndex !== undefined) { @@ -391,16 +391,16 @@ define([ * Build {Condition} objects from configuration and rebuild associated view */ Rule.prototype.refreshConditions = function () { - var self = this, - $condition = null, - loopCnt = 0, - triggerContextStr = self.config.trigger === 'any' ? ' or ' : ' and '; + const self = this; + let $condition = null; + let loopCnt = 0; + const triggerContextStr = self.config.trigger === 'any' ? ' or ' : ' and '; self.conditions = []; $('.t-condition', this.domElement).remove(); this.config.conditions.forEach(function (condition, index) { - var newCondition = new Condition(condition, index, self.conditionManager); + const newCondition = new Condition(condition, index, self.conditionManager); newCondition.on('remove', self.removeCondition, self); newCondition.on('duplicate', self.initCondition, self); newCondition.on('change', self.onConditionChange, self); @@ -435,8 +435,8 @@ define([ * @param {number} removeIndex The index of the condition to remove */ Rule.prototype.removeCondition = function (removeIndex) { - var ruleConfigById = this.domainObject.configuration.ruleConfigById, - conditions = ruleConfigById[this.config.id].conditions; + const ruleConfigById = this.domainObject.configuration.ruleConfigById; + const conditions = ruleConfigById[this.config.id].conditions; _.remove(conditions, function (condition, index) { return index === removeIndex; @@ -453,13 +453,13 @@ define([ * Build a human-readable description from this rule's conditions */ Rule.prototype.generateDescription = function () { - var description = '', - manager = this.conditionManager, - evaluator = manager.getEvaluator(), - name, - property, - operation, - self = this; + let description = ''; + const manager = this.conditionManager; + const evaluator = manager.getEvaluator(); + let name; + let property; + let operation; + const self = this; if (this.config.conditions && this.config.id !== 'default') { if (self.config.trigger === 'js') { diff --git a/src/plugins/summaryWidget/src/SummaryWidget.js b/src/plugins/summaryWidget/src/SummaryWidget.js index 50cb19e157..e3561d7b9b 100644 --- a/src/plugins/summaryWidget/src/SummaryWidget.js +++ b/src/plugins/summaryWidget/src/SummaryWidget.js @@ -21,7 +21,7 @@ define([ ) { //default css configuration for new rules - var DEFAULT_PROPS = { + const DEFAULT_PROPS = { 'color': '#cccccc', 'background-color': '#666666', 'border-color': 'rgba(0,0,0,0)' @@ -78,8 +78,8 @@ define([ this.addHyperlink(domainObject.url, domainObject.openNewTab); this.watchForChanges(openmct, domainObject); - var id = objectUtils.makeKeyString(this.domainObject.identifier), - self = this; + const id = objectUtils.makeKeyString(this.domainObject.identifier); + const self = this; /** * Toggles the configuration area for test data in the view @@ -148,7 +148,7 @@ define([ * Widget's view. */ SummaryWidget.prototype.show = function (container) { - var self = this; + const self = this; this.container = container; $(container).append(this.domElement); $('.widget-test-data', this.domElement).append(this.testDataManager.getDOM()); @@ -188,9 +188,9 @@ define([ * Update the view from the current rule configuration and order */ SummaryWidget.prototype.refreshRules = function () { - var self = this, - ruleOrder = self.domainObject.configuration.ruleOrder, - rules = self.rulesById; + const self = this; + const ruleOrder = self.domainObject.configuration.ruleOrder; + const rules = self.rulesById; self.ruleArea.html(''); Object.values(ruleOrder).forEach(function (ruleId) { self.ruleArea.append(rules[ruleId].getDOM()); @@ -201,8 +201,8 @@ define([ }; SummaryWidget.prototype.addOrRemoveDragIndicator = function () { - var rules = this.domainObject.configuration.ruleOrder; - var rulesById = this.rulesById; + const rules = this.domainObject.configuration.ruleOrder; + const rulesById = this.rulesById; rules.forEach(function (ruleKey, index, array) { if (array.length > 2 && index > 0) { @@ -218,7 +218,7 @@ define([ */ SummaryWidget.prototype.updateWidget = function () { const WIDGET_ICON_CLASS = 'c-sw__icon js-sw__icon'; - var activeRule = this.rulesById[this.activeId]; + const activeRule = this.rulesById[this.activeId]; this.applyStyle($('#widget', this.domElement), activeRule.getProperty('style')); $('#widget', this.domElement).prop('title', activeRule.getProperty('message')); $('#widgetLabel', this.domElement).html(activeRule.getProperty('label')); @@ -240,9 +240,9 @@ define([ * Add a new rule to this widget */ SummaryWidget.prototype.addRule = function () { - var ruleCount = 0, - ruleId, - ruleOrder = this.domainObject.configuration.ruleOrder; + let ruleCount = 0; + let ruleId; + const ruleOrder = this.domainObject.configuration.ruleOrder; while (Object.keys(this.rulesById).includes('rule' + ruleCount)) { ruleCount++; @@ -264,11 +264,11 @@ define([ * instantiated */ SummaryWidget.prototype.duplicateRule = function (sourceConfig) { - var ruleCount = 0, - ruleId, - sourceRuleId = sourceConfig.id, - ruleOrder = this.domainObject.configuration.ruleOrder, - ruleIds = Object.keys(this.rulesById); + let ruleCount = 0; + let ruleId; + const sourceRuleId = sourceConfig.id; + const ruleOrder = this.domainObject.configuration.ruleOrder; + const ruleIds = Object.keys(this.rulesById); while (ruleIds.includes('rule' + ruleCount)) { ruleCount = ++ruleCount; @@ -293,8 +293,8 @@ define([ * @param {string} ruleName The initial human-readable name of this rule */ SummaryWidget.prototype.initRule = function (ruleId, ruleName) { - var ruleConfig, - styleObj = {}; + let ruleConfig; + const styleObj = {}; Object.assign(styleObj, DEFAULT_PROPS); if (!this.domainObject.configuration.ruleConfigById[ruleId]) { @@ -335,9 +335,9 @@ define([ * and dropTarget fields */ SummaryWidget.prototype.reorder = function (event) { - var ruleOrder = this.domainObject.configuration.ruleOrder, - sourceIndex = ruleOrder.indexOf(event.draggingId), - targetIndex; + const ruleOrder = this.domainObject.configuration.ruleOrder; + const sourceIndex = ruleOrder.indexOf(event.draggingId); + let targetIndex; if (event.draggingId !== event.dropTarget) { ruleOrder.splice(sourceIndex, 1); diff --git a/src/plugins/summaryWidget/src/TestDataItem.js b/src/plugins/summaryWidget/src/TestDataItem.js index e1b804ab62..32b737a90e 100644 --- a/src/plugins/summaryWidget/src/TestDataItem.js +++ b/src/plugins/summaryWidget/src/TestDataItem.js @@ -44,7 +44,7 @@ define([ this.remove = this.remove.bind(this); this.duplicate = this.duplicate.bind(this); - var self = this; + const self = this; /** * A change event handler for this item's select inputs, which also invokes @@ -72,8 +72,9 @@ define([ * @private */ function onValueInput(event) { - var elem = event.target, - value = (isNaN(elem.valueAsNumber) ? elem.value : elem.valueAsNumber); + const elem = event.target; + const value = (isNaN(elem.valueAsNumber) ? elem.value : elem.valueAsNumber); + if (elem.tagName.toUpperCase() === 'INPUT') { self.eventEmitter.emit('change', { value: value, @@ -146,7 +147,7 @@ define([ * remove callbacks */ TestDataItem.prototype.remove = function () { - var self = this; + const self = this; this.eventEmitter.emit('remove', self.index); this.stopListening(); @@ -160,8 +161,9 @@ define([ * duplicate callbacks with the cloned configuration as an argument */ TestDataItem.prototype.duplicate = function () { - var sourceItem = JSON.parse(JSON.stringify(this.config)), - self = this; + const sourceItem = JSON.parse(JSON.stringify(this.config)); + const self = this; + this.eventEmitter.emit('duplicate', { sourceItem: sourceItem, index: self.index @@ -174,10 +176,10 @@ define([ * @param {string} key The key of currently selected telemetry property */ TestDataItem.prototype.generateValueInput = function (key) { - var evaluator = this.conditionManager.getEvaluator(), - inputArea = $('.t-value-inputs', this.domElement), - dataType = this.conditionManager.getTelemetryPropertyType(this.config.object, key), - inputType = evaluator.getInputTypeById(dataType); + const evaluator = this.conditionManager.getEvaluator(); + const inputArea = $('.t-value-inputs', this.domElement); + const dataType = this.conditionManager.getTelemetryPropertyType(this.config.object, key); + const inputType = evaluator.getInputTypeById(dataType); inputArea.html(''); if (inputType) { diff --git a/src/plugins/summaryWidget/src/TestDataManager.js b/src/plugins/summaryWidget/src/TestDataManager.js index fd19552c4a..819cc5ee3f 100644 --- a/src/plugins/summaryWidget/src/TestDataManager.js +++ b/src/plugins/summaryWidget/src/TestDataManager.js @@ -21,7 +21,7 @@ define([ */ function TestDataManager(domainObject, conditionManager, openmct) { eventHelpers.extend(this); - var self = this; + const self = this; this.domainObject = domainObject; this.manager = conditionManager; @@ -43,7 +43,7 @@ define([ * @private */ function toggleTestData(event) { - var elem = event.target; + const elem = event.target; self.evaluator.useTestData(elem.checked); self.updateTestCache(); } @@ -73,13 +73,13 @@ define([ * this rule from, optional */ TestDataManager.prototype.initItem = function (config) { - var sourceIndex = config && config.index, - defaultItem = { - object: '', - key: '', - value: '' - }, - newItem; + const sourceIndex = config && config.index; + const defaultItem = { + object: '', + key: '', + value: '' + }; + let newItem; newItem = (config !== undefined ? config.sourceItem : defaultItem); if (sourceIndex !== undefined) { @@ -131,7 +131,7 @@ define([ * update the view accordingly */ TestDataManager.prototype.refreshItems = function () { - var self = this; + const self = this; if (this.items) { this.items.forEach(function (item) { this.stopListening(item); @@ -142,7 +142,7 @@ define([ $('.t-test-data-item', this.domElement).remove(); this.config.forEach(function (item, index) { - var newItem = new TestDataItem(item, index, self.manager); + const newItem = new TestDataItem(item, index, self.manager); self.listenTo(newItem, 'remove', self.removeItem, self); self.listenTo(newItem, 'duplicate', self.initItem, self); self.listenTo(newItem, 'change', self.onItemChange, self); @@ -166,10 +166,10 @@ define([ * as expected by a {ConditionEvaluator} */ TestDataManager.prototype.generateTestCache = function () { - var testCache = this.testCache, - manager = this.manager, - compositionObjs = manager.getComposition(), - metadata; + let testCache = this.testCache; + const manager = this.manager; + const compositionObjs = manager.getComposition(); + let metadata; testCache = {}; Object.keys(compositionObjs).forEach(function (id) { diff --git a/src/plugins/summaryWidget/src/WidgetDnD.js b/src/plugins/summaryWidget/src/WidgetDnD.js index 75388ff204..e9ee2f0400 100644 --- a/src/plugins/summaryWidget/src/WidgetDnD.js +++ b/src/plugins/summaryWidget/src/WidgetDnD.js @@ -71,14 +71,14 @@ define([ * @return {string} The ID of the rule whose drag indicator should be displayed */ WidgetDnD.prototype.getDropLocation = function (event) { - var ruleOrder = this.ruleOrder, - rulesById = this.rulesById, - draggingId = this.draggingId, - offset, - y, - height, - dropY = event.pageY, - target = ''; + const ruleOrder = this.ruleOrder; + const rulesById = this.rulesById; + const draggingId = this.draggingId; + let offset; + let y; + let height; + const dropY = event.pageY; + let target = ''; ruleOrder.forEach(function (ruleId, index) { offset = rulesById[ruleId].getDOM().offset(); @@ -107,7 +107,7 @@ define([ * @param {string} ruleId The identifier of the rule which is being dragged */ WidgetDnD.prototype.dragStart = function (ruleId) { - var ruleOrder = this.ruleOrder; + const ruleOrder = this.ruleOrder; this.draggingId = ruleId; this.draggingRulePrevious = ruleOrder[ruleOrder.indexOf(ruleId) - 1]; this.rulesById[this.draggingRulePrevious].showDragIndicator(); @@ -123,7 +123,7 @@ define([ * @param {Event} event The mousemove event that triggered this callback */ WidgetDnD.prototype.drag = function (event) { - var dragTarget; + let dragTarget; if (this.draggingId && this.draggingId !== '') { event.preventDefault(); dragTarget = this.getDropLocation(event); @@ -147,8 +147,8 @@ define([ * @param {Event} event The mouseup event that triggered this callback */ WidgetDnD.prototype.drop = function (event) { - var dropTarget = this.getDropLocation(event), - draggingId = this.draggingId; + let dropTarget = this.getDropLocation(event); + const draggingId = this.draggingId; if (this.draggingId && this.draggingId !== '') { if (!this.rulesById[dropTarget]) { diff --git a/src/plugins/summaryWidget/src/eventHelpers.js b/src/plugins/summaryWidget/src/eventHelpers.js index 433010b948..bd911a8110 100644 --- a/src/plugins/summaryWidget/src/eventHelpers.js +++ b/src/plugins/summaryWidget/src/eventHelpers.js @@ -21,13 +21,13 @@ *****************************************************************************/ define([], function () { - var helperFunctions = { + const helperFunctions = { listenTo: function (object, event, callback, context) { if (!this._listeningTo) { this._listeningTo = []; } - var listener = { + const listener = { object: object, event: event, callback: callback, @@ -35,7 +35,7 @@ define([], function () { _cb: context ? callback.bind(context) : callback }; if (object.$watch && event.indexOf('change:') === 0) { - var scopePath = event.replace('change:', ''); + const scopePath = event.replace('change:', ''); listener.unlisten = object.$watch(scopePath, listener._cb, true); } else if (object.$on) { listener.unlisten = object.$on(event, listener._cb); diff --git a/src/plugins/summaryWidget/src/input/ColorPalette.js b/src/plugins/summaryWidget/src/input/ColorPalette.js index 162e3ddedf..0bbe236419 100644 --- a/src/plugins/summaryWidget/src/input/ColorPalette.js +++ b/src/plugins/summaryWidget/src/input/ColorPalette.js @@ -8,7 +8,7 @@ function ( ) { //The colors that will be used to instantiate this palette if none are provided - var DEFAULT_COLORS = [ + const DEFAULT_COLORS = [ '#000000', '#434343', '#666666', '#999999', '#b7b7b7', '#cccccc', '#d9d9d9', '#efefef', '#f3f3f3', '#ffffff', '#980000', '#ff0000', '#ff9900', '#ffff00', '#00ff00', '#00ffff', '#4a86e8', '#0000ff', '#9900ff', '#ff00ff', '#e6b8af', '#f4cccc', '#fce5cd', '#fff2cc', '#d9ead3', '#d0e0e3', '#c9daf8', '#cfe2f3', '#d9d2e9', '#ead1dc', @@ -33,8 +33,8 @@ function ( this.palette.setNullOption('rgba(0,0,0,0)'); - var domElement = $(this.palette.getDOM()), - self = this; + const domElement = $(this.palette.getDOM()); + const self = this; $('.c-button--menu', domElement).addClass('c-button--swatched'); $('.t-swatch', domElement).addClass('color-swatch'); @@ -42,7 +42,7 @@ function ( $('.c-palette__item', domElement).each(function () { // eslint-disable-next-line no-invalid-this - var elem = this; + const elem = this; $(elem).css('background-color', elem.dataset.item); }); @@ -52,7 +52,7 @@ function ( * @private */ function updateSwatch() { - var color = self.palette.getCurrent(); + const color = self.palette.getCurrent(); $('.color-swatch', domElement).css('background-color', color); } diff --git a/src/plugins/summaryWidget/src/input/IconPalette.js b/src/plugins/summaryWidget/src/input/IconPalette.js index ea6e6fbd32..cdc011d5da 100644 --- a/src/plugins/summaryWidget/src/input/IconPalette.js +++ b/src/plugins/summaryWidget/src/input/IconPalette.js @@ -6,7 +6,7 @@ define([ $ ) { //The icons that will be used to instantiate this palette if none are provided - var DEFAULT_ICONS = [ + const DEFAULT_ICONS = [ 'icon-alert-rect', 'icon-alert-triangle', 'icon-arrow-down', @@ -48,8 +48,8 @@ define([ this.palette.setNullOption(' '); this.oldIcon = this.palette.current || ' '; - var domElement = $(this.palette.getDOM()), - self = this; + const domElement = $(this.palette.getDOM()); + const self = this; $('.c-button--menu', domElement).addClass('c-button--swatched'); $('.t-swatch', domElement).addClass('icon-swatch'); @@ -57,7 +57,7 @@ define([ $('.c-palette-item', domElement).each(function () { // eslint-disable-next-line no-invalid-this - var elem = this; + const elem = this; $(elem).addClass(elem.dataset.item); }); diff --git a/src/plugins/summaryWidget/src/input/KeySelect.js b/src/plugins/summaryWidget/src/input/KeySelect.js index 3467842cf4..7be2b8dbb3 100644 --- a/src/plugins/summaryWidget/src/input/KeySelect.js +++ b/src/plugins/summaryWidget/src/input/KeySelect.js @@ -18,10 +18,10 @@ define([ * @param {function} changeCallback A change event callback to register with this * select on initialization */ - var NULLVALUE = '- Select Field -'; + const NULLVALUE = '- Select Field -'; function KeySelect(config, objectSelect, manager, changeCallback) { - var self = this; + const self = this; this.config = config; this.objectSelect = objectSelect; @@ -42,7 +42,7 @@ define([ * @private */ function onObjectChange(key) { - var selected = self.manager.metadataLoadCompleted() ? self.select.getSelected() : self.config.key; + const selected = self.manager.metadataLoadCompleted() ? self.select.getSelected() : self.config.key; self.telemetryMetadata = self.manager.getTelemetryMetadata(key) || {}; self.generateOptions(); self.select.setSelected(selected); @@ -77,7 +77,7 @@ define([ * Populate this select with options based on its current composition */ KeySelect.prototype.generateOptions = function () { - var items = Object.entries(this.telemetryMetadata).map(function (metaDatum) { + const items = Object.entries(this.telemetryMetadata).map(function (metaDatum) { return [metaDatum[0], metaDatum[1].name]; }); items.splice(0, 0, ['', NULLVALUE]); diff --git a/src/plugins/summaryWidget/src/input/ObjectSelect.js b/src/plugins/summaryWidget/src/input/ObjectSelect.js index 5e73e08bb8..4b2a8a20be 100644 --- a/src/plugins/summaryWidget/src/input/ObjectSelect.js +++ b/src/plugins/summaryWidget/src/input/ObjectSelect.js @@ -18,7 +18,7 @@ define([ * display regardless of the composition state */ function ObjectSelect(config, manager, baseOptions) { - var self = this; + const self = this; this.config = config; this.manager = manager; @@ -52,7 +52,7 @@ define([ * @private */ function onCompositionRemove() { - var selected = self.select.getSelected(); + const selected = self.select.getSelected(); self.generateOptions(); self.select.setSelected(selected); } @@ -80,7 +80,7 @@ define([ * Populate this select with options based on its current composition */ ObjectSelect.prototype.generateOptions = function () { - var items = Object.values(this.compositionObjs).map(function (obj) { + const items = Object.values(this.compositionObjs).map(function (obj) { return [objectUtils.makeKeyString(obj.identifier), obj.name]; }); this.baseOptions.forEach(function (option, index) { diff --git a/src/plugins/summaryWidget/src/input/OperationSelect.js b/src/plugins/summaryWidget/src/input/OperationSelect.js index 244481bdca..1e1f7a889b 100644 --- a/src/plugins/summaryWidget/src/input/OperationSelect.js +++ b/src/plugins/summaryWidget/src/input/OperationSelect.js @@ -20,11 +20,11 @@ define([ * @param {function} changeCallback A change event callback to register with this * select on initialization */ - var NULLVALUE = '- Select Comparison -'; + const NULLVALUE = '- Select Comparison -'; function OperationSelect(config, keySelect, manager, changeCallback) { eventHelpers.extend(this); - var self = this; + const self = this; this.config = config; this.keySelect = keySelect; @@ -49,7 +49,7 @@ define([ * @private */ function onKeyChange(key) { - var selected = self.config.operation; + const selected = self.config.operation; if (self.manager.metadataLoadCompleted()) { self.loadOptions(key); self.generateOptions(); @@ -86,10 +86,10 @@ define([ * Populate this select with options based on its current composition */ OperationSelect.prototype.generateOptions = function () { - var self = this, - items = this.operationKeys.map(function (operation) { - return [operation, self.evaluator.getOperationText(operation)]; - }); + const self = this; + const items = this.operationKeys.map(function (operation) { + return [operation, self.evaluator.getOperationText(operation)]; + }); items.splice(0, 0, ['', NULLVALUE]); this.select.setOptions(items); @@ -106,9 +106,9 @@ define([ * @param {string} key The telemetry property to load operations for */ OperationSelect.prototype.loadOptions = function (key) { - var self = this, - operations = self.evaluator.getOperationKeys(), - type; + const self = this; + const operations = self.evaluator.getOperationKeys(); + let type; type = self.manager.getTelemetryPropertyType(self.config.object, key); diff --git a/src/plugins/summaryWidget/src/input/Palette.js b/src/plugins/summaryWidget/src/input/Palette.js index b08408ffd8..ff1d3b5500 100644 --- a/src/plugins/summaryWidget/src/input/Palette.js +++ b/src/plugins/summaryWidget/src/input/Palette.js @@ -22,7 +22,7 @@ define([ function Palette(cssClass, container, items) { eventHelpers.extend(this); - var self = this; + const self = this; this.cssClass = cssClass; this.items = items; @@ -45,7 +45,7 @@ define([ self.setNullOption(this.nullOption); self.items.forEach(function (item) { - var itemElement = $('
'); $('.c-palette__items', self.domElement).append(itemElement); self.itemElements[item] = itemElement; @@ -67,8 +67,8 @@ define([ * @private */ function handleItemClick(event) { - var elem = event.currentTarget, - item = elem.dataset.item; + const elem = event.currentTarget; + const item = elem.dataset.item; self.set(item); $('.c-menu', self.domElement).hide(); } @@ -124,7 +124,7 @@ define([ * @param {string} item The key of the item to set as selected */ Palette.prototype.set = function (item) { - var self = this; + const self = this; if (this.items.includes(item) || item === this.nullOption) { this.value = item; if (item === this.nullOption) { diff --git a/src/plugins/summaryWidget/src/input/Select.js b/src/plugins/summaryWidget/src/input/Select.js index 7dcd70e22d..3f89034caf 100644 --- a/src/plugins/summaryWidget/src/input/Select.js +++ b/src/plugins/summaryWidget/src/input/Select.js @@ -18,7 +18,7 @@ define([ function Select() { eventHelpers.extend(this); - var self = this; + const self = this; this.domElement = $(selectTemplate); this.options = []; @@ -34,8 +34,8 @@ define([ * @private */ function onChange(event) { - var elem = event.target, - value = self.options[$(elem).prop('selectedIndex')]; + const elem = event.target; + const value = self.options[$(elem).prop('selectedIndex')]; self.eventEmitter.emit('change', value[0]); } @@ -71,8 +71,8 @@ define([ * model */ Select.prototype.populate = function () { - var self = this, - selectedIndex = 0; + const self = this; + let selectedIndex = 0; selectedIndex = $('select', this.domElement).prop('selectedIndex'); $('option', this.domElement).remove(); @@ -112,8 +112,8 @@ define([ * @param {string} value The value to set as the selected option */ Select.prototype.setSelected = function (value) { - var selectedIndex = 0, - selectedOption; + let selectedIndex = 0; + let selectedOption; this.options.forEach (function (option, index) { if (option[0] === value) { diff --git a/src/plugins/summaryWidget/src/telemetry/EvaluatorPool.js b/src/plugins/summaryWidget/src/telemetry/EvaluatorPool.js index 50e1f69246..fe4ce1629f 100644 --- a/src/plugins/summaryWidget/src/telemetry/EvaluatorPool.js +++ b/src/plugins/summaryWidget/src/telemetry/EvaluatorPool.js @@ -35,8 +35,8 @@ define([ } EvaluatorPool.prototype.get = function (domainObject) { - var objectId = objectUtils.makeKeyString(domainObject.identifier); - var poolEntry = this.byObjectId[objectId]; + const objectId = objectUtils.makeKeyString(domainObject.identifier); + let poolEntry = this.byObjectId[objectId]; if (!poolEntry) { poolEntry = { leases: 0, @@ -53,7 +53,7 @@ define([ }; EvaluatorPool.prototype.release = function (evaluator) { - var poolEntry = this.byEvaluator.get(evaluator); + const poolEntry = this.byEvaluator.get(evaluator); poolEntry.leases -= 1; if (poolEntry.leases === 0) { evaluator.destroy(); diff --git a/src/plugins/summaryWidget/src/telemetry/EvaluatorPoolSpec.js b/src/plugins/summaryWidget/src/telemetry/EvaluatorPoolSpec.js index 3ce33d75b2..e7e6d367c3 100644 --- a/src/plugins/summaryWidget/src/telemetry/EvaluatorPoolSpec.js +++ b/src/plugins/summaryWidget/src/telemetry/EvaluatorPoolSpec.js @@ -28,10 +28,10 @@ define([ SummaryWidgetEvaluator ) { describe('EvaluatorPool', function () { - var pool; - var openmct; - var objectA; - var objectB; + let pool; + let openmct; + let objectA; + let objectB; beforeEach(function () { openmct = { @@ -39,7 +39,7 @@ define([ objects: jasmine.createSpyObj('objectAPI', ['observe']) }; openmct.composition.get.and.callFake(function () { - var compositionCollection = jasmine.createSpyObj( + const compositionCollection = jasmine.createSpyObj( 'compositionCollection', [ 'load', @@ -76,27 +76,27 @@ define([ }); it('returns new evaluators for different objects', function () { - var evaluatorA = pool.get(objectA); - var evaluatorB = pool.get(objectB); + const evaluatorA = pool.get(objectA); + const evaluatorB = pool.get(objectB); expect(evaluatorA).not.toBe(evaluatorB); }); it('returns the same evaluator for the same object', function () { - var evaluatorA = pool.get(objectA); - var evaluatorB = pool.get(objectA); + const evaluatorA = pool.get(objectA); + const evaluatorB = pool.get(objectA); expect(evaluatorA).toBe(evaluatorB); - var evaluatorC = pool.get(JSON.parse(JSON.stringify(objectA))); + const evaluatorC = pool.get(JSON.parse(JSON.stringify(objectA))); expect(evaluatorA).toBe(evaluatorC); }); it('returns new evaluator when old is released', function () { - var evaluatorA = pool.get(objectA); - var evaluatorB = pool.get(objectA); + const evaluatorA = pool.get(objectA); + const evaluatorB = pool.get(objectA); expect(evaluatorA).toBe(evaluatorB); pool.release(evaluatorA); pool.release(evaluatorB); - var evaluatorC = pool.get(objectA); + const evaluatorC = pool.get(objectA); expect(evaluatorA).not.toBe(evaluatorC); }); }); diff --git a/src/plugins/summaryWidget/src/telemetry/SummaryWidgetCondition.js b/src/plugins/summaryWidget/src/telemetry/SummaryWidgetCondition.js index 1982f27fd0..f96b520160 100644 --- a/src/plugins/summaryWidget/src/telemetry/SummaryWidgetCondition.js +++ b/src/plugins/summaryWidget/src/telemetry/SummaryWidgetCondition.js @@ -41,10 +41,10 @@ define([ } SummaryWidgetCondition.prototype.evaluate = function (telemetryState) { - var stateKeys = Object.keys(telemetryState); - var state; - var result; - var i; + const stateKeys = Object.keys(telemetryState); + let state; + let result; + let i; if (this.object === 'any') { for (i = 0; i < stateKeys.length; i++) { @@ -72,7 +72,7 @@ define([ }; SummaryWidgetCondition.prototype.evaluateState = function (state) { - var testValues = [ + const testValues = [ state.formats[this.key].parse(state.lastDatum) ].concat(this.values); diff --git a/src/plugins/summaryWidget/src/telemetry/SummaryWidgetConditionSpec.js b/src/plugins/summaryWidget/src/telemetry/SummaryWidgetConditionSpec.js index 1db4f60da9..74e87a3498 100644 --- a/src/plugins/summaryWidget/src/telemetry/SummaryWidgetConditionSpec.js +++ b/src/plugins/summaryWidget/src/telemetry/SummaryWidgetConditionSpec.js @@ -27,14 +27,14 @@ define([ ) { describe('SummaryWidgetCondition', function () { - var condition; - var telemetryState; + let condition; + let telemetryState; beforeEach(function () { // Format map intentionally uses different keys than those present // in datum, which serves to verify conditions use format map to get // data. - var formatMap = { + const formatMap = { adjusted: { parse: function (datum) { return datum.value + 10; diff --git a/src/plugins/summaryWidget/src/telemetry/SummaryWidgetEvaluator.js b/src/plugins/summaryWidget/src/telemetry/SummaryWidgetEvaluator.js index 33d3f165b8..42c24623eb 100644 --- a/src/plugins/summaryWidget/src/telemetry/SummaryWidgetEvaluator.js +++ b/src/plugins/summaryWidget/src/telemetry/SummaryWidgetEvaluator.js @@ -48,7 +48,7 @@ define([ this.updateRules.bind(this) ); - var composition = openmct.composition.get(domainObject); + const composition = openmct.composition.get(domainObject); this.listenTo(composition, 'add', this.addChild, this); this.listenTo(composition, 'remove', this.removeChild, this); @@ -62,8 +62,8 @@ define([ * Subscribes to realtime telemetry for the given summary widget. */ SummaryWidgetEvaluator.prototype.subscribe = function (callback) { - var active = true; - var unsubscribes = []; + let active = true; + let unsubscribes = []; this.getBaseStateClone() .then(function (realtimeStates) { @@ -71,8 +71,8 @@ define([ return; } - var updateCallback = function () { - var datum = this.evaluateState( + const updateCallback = function () { + const datum = this.evaluateState( realtimeStates, this.openmct.time.timeSystem().key ); @@ -104,7 +104,7 @@ define([ SummaryWidgetEvaluator.prototype.requestLatest = function (options) { return this.getBaseStateClone() .then(function (ladState) { - var promises = Object.values(ladState) + const promises = Object.values(ladState) .map(this.updateObjectStateFromLAD.bind(this, options)); return Promise.all(promises) @@ -124,9 +124,9 @@ define([ }; SummaryWidgetEvaluator.prototype.addChild = function (childObject) { - var childId = objectUtils.makeKeyString(childObject.identifier); - var metadata = this.openmct.telemetry.getMetadata(childObject); - var formats = this.openmct.telemetry.getFormatMap(metadata); + const childId = objectUtils.makeKeyString(childObject.identifier); + const metadata = this.openmct.telemetry.getMetadata(childObject); + const formats = this.openmct.telemetry.getFormatMap(metadata); this.baseState[childId] = { id: childId, @@ -137,7 +137,7 @@ define([ }; SummaryWidgetEvaluator.prototype.removeChild = function (childObject) { - var childId = objectUtils.makeKeyString(childObject.identifier); + const childId = objectUtils.makeKeyString(childObject.identifier); delete this.baseState[childId]; }; @@ -212,7 +212,7 @@ define([ * @private. */ SummaryWidgetEvaluator.prototype.getTimestamps = function (childId, datum) { - var timestampedDatum = {}; + const timestampedDatum = {}; this.openmct.time.getAllTimeSystems().forEach(function (timeSystem) { timestampedDatum[timeSystem.key] = this.baseState[childId].formats[timeSystem.key].parse(datum); @@ -227,7 +227,7 @@ define([ * @private */ SummaryWidgetEvaluator.prototype.makeDatumFromRule = function (ruleIndex, baseDatum) { - var rule = this.rules[ruleIndex]; + const rule = this.rules[ruleIndex]; baseDatum.ruleLabel = rule.label; baseDatum.ruleName = rule.name; @@ -249,21 +249,22 @@ define([ * @private. */ SummaryWidgetEvaluator.prototype.evaluateState = function (state, timestampKey) { - var hasRequiredData = Object.keys(state).reduce(function (itDoes, k) { + const hasRequiredData = Object.keys(state).reduce(function (itDoes, k) { return itDoes && state[k].lastDatum; }, true); if (!hasRequiredData) { return; } - for (var i = this.rules.length - 1; i > 0; i--) { + let i; + for (i = this.rules.length - 1; i > 0; i--) { if (this.rules[i].evaluate(state, false)) { break; } } /* eslint-disable you-dont-need-lodash-underscore/map */ - var latestTimestamp = _(state) + let latestTimestamp = _(state) .map('timestamps') .sortBy(timestampKey) .last(); @@ -273,7 +274,7 @@ define([ latestTimestamp = {}; } - var baseDatum = _.clone(latestTimestamp); + const baseDatum = _.clone(latestTimestamp); return this.makeDatumFromRule(i, baseDatum); }; diff --git a/src/plugins/summaryWidget/src/telemetry/SummaryWidgetMetadataProvider.js b/src/plugins/summaryWidget/src/telemetry/SummaryWidgetMetadataProvider.js index f3dfaa441e..131d8c5b1d 100644 --- a/src/plugins/summaryWidget/src/telemetry/SummaryWidgetMetadataProvider.js +++ b/src/plugins/summaryWidget/src/telemetry/SummaryWidgetMetadataProvider.js @@ -48,8 +48,8 @@ define([ }; SummaryWidgetMetadataProvider.prototype.getMetadata = function (domainObject) { - var ruleOrder = domainObject.configuration.ruleOrder || []; - var enumerations = ruleOrder + const ruleOrder = domainObject.configuration.ruleOrder || []; + const enumerations = ruleOrder .filter(function (ruleId) { return Boolean(domainObject.configuration.ruleConfigById[ruleId]); }) @@ -60,7 +60,7 @@ define([ }; }); - var metadata = { + const metadata = { // Generally safe assumption is that we have one domain per timeSystem. values: this.getDomains().concat([ { diff --git a/src/plugins/summaryWidget/src/telemetry/SummaryWidgetRule.js b/src/plugins/summaryWidget/src/telemetry/SummaryWidgetRule.js index 40a0900b30..f0cc38f7ed 100644 --- a/src/plugins/summaryWidget/src/telemetry/SummaryWidgetRule.js +++ b/src/plugins/summaryWidget/src/telemetry/SummaryWidgetRule.js @@ -44,8 +44,8 @@ define([ * matches. */ SummaryWidgetRule.prototype.evaluate = function (telemetryState) { - var i; - var result; + let i; + let result; if (this.trigger === 'all') { for (i = 0; i < this.conditions.length; i++) { diff --git a/src/plugins/summaryWidget/src/telemetry/SummaryWidgetRuleSpec.js b/src/plugins/summaryWidget/src/telemetry/SummaryWidgetRuleSpec.js index 2a527715f8..25cc44dfe9 100644 --- a/src/plugins/summaryWidget/src/telemetry/SummaryWidgetRuleSpec.js +++ b/src/plugins/summaryWidget/src/telemetry/SummaryWidgetRuleSpec.js @@ -27,11 +27,11 @@ define([ ) { describe('SummaryWidgetRule', function () { - var rule; - var telemetryState; + let rule; + let telemetryState; beforeEach(function () { - var formatMap = { + const formatMap = { raw: { parse: function (datum) { return datum.value; diff --git a/src/plugins/summaryWidget/src/telemetry/SummaryWidgetTelemetryProvider.js b/src/plugins/summaryWidget/src/telemetry/SummaryWidgetTelemetryProvider.js index e1488c0db4..527b38c03c 100644 --- a/src/plugins/summaryWidget/src/telemetry/SummaryWidgetTelemetryProvider.js +++ b/src/plugins/summaryWidget/src/telemetry/SummaryWidgetTelemetryProvider.js @@ -39,7 +39,7 @@ define([ return Promise.resolve([]); } - var evaluator = this.pool.get(domainObject); + const evaluator = this.pool.get(domainObject); return evaluator.requestLatest(options) .then(function (latestDatum) { @@ -54,8 +54,8 @@ define([ }; SummaryWidgetTelemetryProvider.prototype.subscribe = function (domainObject, callback) { - var evaluator = this.pool.get(domainObject); - var unsubscribe = evaluator.subscribe(callback); + const evaluator = this.pool.get(domainObject); + const unsubscribe = evaluator.subscribe(callback); return function () { this.pool.release(evaluator); diff --git a/src/plugins/summaryWidget/src/telemetry/SummaryWidgetTelemetryProviderSpec.js b/src/plugins/summaryWidget/src/telemetry/SummaryWidgetTelemetryProviderSpec.js index 28ad0c3f3d..3adb8d7661 100644 --- a/src/plugins/summaryWidget/src/telemetry/SummaryWidgetTelemetryProviderSpec.js +++ b/src/plugins/summaryWidget/src/telemetry/SummaryWidgetTelemetryProviderSpec.js @@ -27,15 +27,15 @@ define([ ) { xdescribe('SummaryWidgetTelemetryProvider', function () { - var telemObjectA; - var telemObjectB; - var summaryWidgetObject; - var openmct; - var telemUnsubscribes; - var unobserver; - var composition; - var telemetryProvider; - var loader; + let telemObjectA; + let telemObjectB; + let summaryWidgetObject; + let openmct; + let telemUnsubscribes; + let unobserver; + let composition; + let telemetryProvider; + let loader; beforeEach(function () { telemObjectA = { @@ -206,7 +206,7 @@ define([ telemUnsubscribes = []; openmct.telemetry.subscribe.and.callFake(function () { - var unsubscriber = jasmine.createSpy('unsubscriber' + telemUnsubscribes.length); + const unsubscriber = jasmine.createSpy('unsubscriber' + telemUnsubscribes.length); telemUnsubscribes.push(unsubscriber); return unsubscriber; @@ -265,7 +265,7 @@ define([ }); it('provides realtime telemetry', function () { - var callback = jasmine.createSpy('callback'); + const callback = jasmine.createSpy('callback'); telemetryProvider.subscribe(summaryWidgetObject, callback); return loader.promise.then(function () { @@ -279,8 +279,8 @@ define([ expect(openmct.telemetry.subscribe) .toHaveBeenCalledWith(telemObjectB, jasmine.any(Function)); - var aCallback = openmct.telemetry.subscribe.calls.all()[0].args[1]; - var bCallback = openmct.telemetry.subscribe.calls.all()[1].args[1]; + const aCallback = openmct.telemetry.subscribe.calls.all()[0].args[1]; + const bCallback = openmct.telemetry.subscribe.calls.all()[1].args[1]; aCallback({ t: 123, @@ -370,8 +370,8 @@ define([ }); describe('providing lad telemetry', function () { - var responseDatums; - var resultsShouldBe; + let responseDatums; + let resultsShouldBe; beforeEach(function () { openmct.telemetry.request.and.callFake(function (rObj, options) { diff --git a/src/plugins/summaryWidget/src/telemetry/operations.js b/src/plugins/summaryWidget/src/telemetry/operations.js index 67629c8a57..e4916d913e 100644 --- a/src/plugins/summaryWidget/src/telemetry/operations.js +++ b/src/plugins/summaryWidget/src/telemetry/operations.js @@ -25,7 +25,7 @@ define([ ], function ( ) { - var OPERATIONS = { + const OPERATIONS = { equalTo: { operation: function (input) { return input[0] === input[1]; diff --git a/src/plugins/summaryWidget/src/views/SummaryWidgetView.js b/src/plugins/summaryWidget/src/views/SummaryWidgetView.js index 71aae1b332..bf01ece913 100644 --- a/src/plugins/summaryWidget/src/views/SummaryWidgetView.js +++ b/src/plugins/summaryWidget/src/views/SummaryWidgetView.js @@ -47,7 +47,7 @@ define([ this.widget.removeAttribute('target'); } - var renderTracker = {}; + const renderTracker = {}; this.renderTracker = renderTracker; this.openmct.telemetry.request(this.domainObject, { strategy: 'latest', diff --git a/src/plugins/summaryWidget/test/ConditionEvaluatorSpec.js b/src/plugins/summaryWidget/test/ConditionEvaluatorSpec.js index e3a8fcaf5a..49ff638a49 100644 --- a/src/plugins/summaryWidget/test/ConditionEvaluatorSpec.js +++ b/src/plugins/summaryWidget/test/ConditionEvaluatorSpec.js @@ -1,19 +1,19 @@ define(['../src/ConditionEvaluator'], function (ConditionEvaluator) { describe('A Summary Widget Rule Evaluator', function () { - var evaluator, - testEvaluator, - testOperation, - mockCache, - mockTestCache, - mockComposition, - mockConditions, - mockConditionsEmpty, - mockConditionsUndefined, - mockConditionsAnyTrue, - mockConditionsAllTrue, - mockConditionsAnyFalse, - mockConditionsAllFalse, - mockOperations; + let evaluator; + let testEvaluator; + let testOperation; + let mockCache; + let mockTestCache; + let mockComposition; + let mockConditions; + let mockConditionsEmpty; + let mockConditionsUndefined; + let mockConditionsAnyTrue; + let mockConditionsAllTrue; + let mockConditionsAnyFalse; + let mockConditionsAllFalse; + let mockOperations; beforeEach(function () { mockCache = { diff --git a/src/plugins/summaryWidget/test/ConditionManagerSpec.js b/src/plugins/summaryWidget/test/ConditionManagerSpec.js index 86f3e0d440..aa254a4200 100644 --- a/src/plugins/summaryWidget/test/ConditionManagerSpec.js +++ b/src/plugins/summaryWidget/test/ConditionManagerSpec.js @@ -22,29 +22,29 @@ define(['../src/ConditionManager'], function (ConditionManager) { xdescribe('A Summary Widget Condition Manager', function () { - var conditionManager, - mockDomainObject, - mockCompObject1, - mockCompObject2, - mockCompObject3, - mockMetadata, - mockTelemetryCallbacks, - mockEventCallbacks, - unsubscribeSpies, - unregisterSpies, - mockMetadataManagers, - mockComposition, - mockOpenMCT, - mockTelemetryAPI, - addCallbackSpy, - loadCallbackSpy, - removeCallbackSpy, - telemetryCallbackSpy, - metadataCallbackSpy, - telemetryRequests, - mockTelemetryValues, - mockTelemetryValues2, - mockConditionEvaluator; + let conditionManager; + let mockDomainObject; + let mockCompObject1; + let mockCompObject2; + let mockCompObject3; + let mockMetadata; + let mockTelemetryCallbacks; + let mockEventCallbacks; + let unsubscribeSpies; + let unregisterSpies; + let mockMetadataManagers; + let mockComposition; + let mockOpenMCT; + let mockTelemetryAPI; + let addCallbackSpy; + let loadCallbackSpy; + let removeCallbackSpy; + let telemetryCallbackSpy; + let metadataCallbackSpy; + let telemetryRequests; + let mockTelemetryValues; + let mockTelemetryValues2; + let mockConditionEvaluator; beforeEach(function () { mockDomainObject = { @@ -217,7 +217,7 @@ define(['../src/ConditionManager'], function (ConditionManager) { 'triggerTelemetryCallback' ]); mockTelemetryAPI.request.and.callFake(function (obj) { - var req = { + const req = { object: obj }; req.promise = new Promise(function (resolve, reject) { @@ -283,7 +283,7 @@ define(['../src/ConditionManager'], function (ConditionManager) { }); it('maintains lists of global metadata, and does not duplicate repeated fields', function () { - var allKeys = { + const allKeys = { property1: { key: 'property1', name: 'Property 1', @@ -389,18 +389,18 @@ define(['../src/ConditionManager'], function (ConditionManager) { it('evalutes a set of rules and returns the id of the' + 'last active rule, or the first if no rules are active', function () { - var mockRuleOrder = ['default', 'rule0', 'rule1'], - mockRules = { - default: { - getProperty: function () {} - }, - rule0: { - getProperty: function () {} - }, - rule1: { - getProperty: function () {} - } - }; + const mockRuleOrder = ['default', 'rule0', 'rule1']; + const mockRules = { + default: { + getProperty: function () {} + }, + rule0: { + getProperty: function () {} + }, + rule1: { + getProperty: function () {} + } + }; mockConditionEvaluator.execute.and.returnValue(false); expect(conditionManager.executeRules(mockRuleOrder, mockRules)).toEqual('default'); diff --git a/src/plugins/summaryWidget/test/ConditionSpec.js b/src/plugins/summaryWidget/test/ConditionSpec.js index fc8a9b7559..dd11e86c78 100644 --- a/src/plugins/summaryWidget/test/ConditionSpec.js +++ b/src/plugins/summaryWidget/test/ConditionSpec.js @@ -22,15 +22,15 @@ define(['../src/Condition', 'zepto'], function (Condition, $) { xdescribe('A summary widget condition', function () { - var testCondition, - mockConfig, - mockConditionManager, - mockContainer, - mockEvaluator, - changeSpy, - duplicateSpy, - removeSpy, - generateValuesSpy; + let testCondition; + let mockConfig; + let mockConditionManager; + let mockContainer; + let mockEvaluator; + let changeSpy; + let duplicateSpy; + let removeSpy; + let generateValuesSpy; beforeEach(function () { mockContainer = $(document.createElement('div')); diff --git a/src/plugins/summaryWidget/test/RuleSpec.js b/src/plugins/summaryWidget/test/RuleSpec.js index 4d77b5bd96..4d6c5b7149 100644 --- a/src/plugins/summaryWidget/test/RuleSpec.js +++ b/src/plugins/summaryWidget/test/RuleSpec.js @@ -1,17 +1,17 @@ define(['../src/Rule', 'zepto'], function (Rule, $) { describe('A Summary Widget Rule', function () { - var mockRuleConfig, - mockDomainObject, - mockOpenMCT, - mockConditionManager, - mockWidgetDnD, - mockEvaluator, - mockContainer, - testRule, - removeSpy, - duplicateSpy, - changeSpy, - conditionChangeSpy; + let mockRuleConfig; + let mockDomainObject; + let mockOpenMCT; + let mockConditionManager; + let mockWidgetDnD; + let mockEvaluator; + let mockContainer; + let testRule; + let removeSpy; + let duplicateSpy; + let changeSpy; + let conditionChangeSpy; beforeEach(function () { mockRuleConfig = { diff --git a/src/plugins/summaryWidget/test/SummaryWidgetSpec.js b/src/plugins/summaryWidget/test/SummaryWidgetSpec.js index 6fd1301888..eb4ffb60b0 100644 --- a/src/plugins/summaryWidget/test/SummaryWidgetSpec.js +++ b/src/plugins/summaryWidget/test/SummaryWidgetSpec.js @@ -22,16 +22,16 @@ define(['../src/SummaryWidget', 'zepto'], function (SummaryWidget, $) { xdescribe('The Summary Widget', function () { - var summaryWidget, - mockDomainObject, - mockOldDomainObject, - mockOpenMCT, - mockObjectService, - mockStatusCapability, - mockComposition, - mockContainer, - listenCallback, - listenCallbackSpy; + let summaryWidget; + let mockDomainObject; + let mockOldDomainObject; + let mockOpenMCT; + let mockObjectService; + let mockStatusCapability; + let mockComposition; + let mockContainer; + let listenCallback; + let listenCallbackSpy; beforeEach(function () { mockDomainObject = { @@ -134,7 +134,7 @@ define(['../src/SummaryWidget', 'zepto'], function (SummaryWidget, $) { }); it('allows duplicating a rule from source configuration', function () { - var sourceConfig = JSON.parse(JSON.stringify(mockDomainObject.configuration.ruleConfigById.default)); + const sourceConfig = JSON.parse(JSON.stringify(mockDomainObject.configuration.ruleConfigById.default)); summaryWidget.duplicateRule(sourceConfig); expect(Object.keys(mockDomainObject.configuration.ruleConfigById).length).toEqual(2); }); @@ -186,7 +186,7 @@ define(['../src/SummaryWidget', 'zepto'], function (SummaryWidget, $) { it('adds hyperlink to the widget button and sets newTab preference', function () { summaryWidget.addHyperlink('https://www.nasa.gov', 'newTab'); - var widgetButton = $('#widget', mockContainer); + const widgetButton = $('#widget', mockContainer); expect(widgetButton.attr('href')).toEqual('https://www.nasa.gov'); expect(widgetButton.attr('target')).toEqual('_blank'); diff --git a/src/plugins/summaryWidget/test/SummaryWidgetViewPolicySpec.js b/src/plugins/summaryWidget/test/SummaryWidgetViewPolicySpec.js index f9f6a24493..37abc13010 100644 --- a/src/plugins/summaryWidget/test/SummaryWidgetViewPolicySpec.js +++ b/src/plugins/summaryWidget/test/SummaryWidgetViewPolicySpec.js @@ -27,9 +27,9 @@ define([ ) { describe('SummaryWidgetViewPolicy', function () { - var policy; - var domainObject; - var view; + let policy; + let domainObject; + let view; beforeEach(function () { policy = new SummaryWidgetViewPolicy(); domainObject = jasmine.createSpyObj('domainObject', [ diff --git a/src/plugins/summaryWidget/test/TestDataItemSpec.js b/src/plugins/summaryWidget/test/TestDataItemSpec.js index 6ef0119c79..dffa6c6f22 100644 --- a/src/plugins/summaryWidget/test/TestDataItemSpec.js +++ b/src/plugins/summaryWidget/test/TestDataItemSpec.js @@ -1,14 +1,14 @@ define(['../src/TestDataItem', 'zepto'], function (TestDataItem, $) { describe('A summary widget test data item', function () { - var testDataItem, - mockConfig, - mockConditionManager, - mockContainer, - mockEvaluator, - changeSpy, - duplicateSpy, - removeSpy, - generateValueSpy; + let testDataItem; + let mockConfig; + let mockConditionManager; + let mockContainer; + let mockEvaluator; + let changeSpy; + let duplicateSpy; + let removeSpy; + let generateValueSpy; beforeEach(function () { mockContainer = $(document.createElement('div')); diff --git a/src/plugins/summaryWidget/test/TestDataManagerSpec.js b/src/plugins/summaryWidget/test/TestDataManagerSpec.js index 15d93d5636..70042250d3 100644 --- a/src/plugins/summaryWidget/test/TestDataManagerSpec.js +++ b/src/plugins/summaryWidget/test/TestDataManagerSpec.js @@ -1,14 +1,14 @@ define(['../src/TestDataManager', 'zepto'], function (TestDataManager, $) { describe('A Summary Widget Rule', function () { - var mockDomainObject, - mockOpenMCT, - mockConditionManager, - mockEvaluator, - mockContainer, - mockTelemetryMetadata, - testDataManager, - mockCompObject1, - mockCompObject2; + let mockDomainObject; + let mockOpenMCT; + let mockConditionManager; + let mockEvaluator; + let mockContainer; + let mockTelemetryMetadata; + let testDataManager; + let mockCompObject1; + let mockCompObject2; beforeEach(function () { mockDomainObject = { diff --git a/src/plugins/summaryWidget/test/input/ColorPaletteSpec.js b/src/plugins/summaryWidget/test/input/ColorPaletteSpec.js index d3908e49e9..d169ef748a 100644 --- a/src/plugins/summaryWidget/test/input/ColorPaletteSpec.js +++ b/src/plugins/summaryWidget/test/input/ColorPaletteSpec.js @@ -1,6 +1,7 @@ define(['../../src/input/ColorPalette'], function (ColorPalette) { describe('An Open MCT color palette', function () { - var colorPalette, changeCallback; + let colorPalette; + let changeCallback; beforeEach(function () { changeCallback = jasmine.createSpy('changeCallback'); diff --git a/src/plugins/summaryWidget/test/input/IconPaletteSpec.js b/src/plugins/summaryWidget/test/input/IconPaletteSpec.js index 9533795233..6bb80a6be5 100644 --- a/src/plugins/summaryWidget/test/input/IconPaletteSpec.js +++ b/src/plugins/summaryWidget/test/input/IconPaletteSpec.js @@ -1,6 +1,7 @@ define(['../../src/input/IconPalette'], function (IconPalette) { describe('An Open MCT icon palette', function () { - var iconPalette, changeCallback; + let iconPalette; + let changeCallback; beforeEach(function () { changeCallback = jasmine.createSpy('changeCallback'); diff --git a/src/plugins/summaryWidget/test/input/KeySelectSpec.js b/src/plugins/summaryWidget/test/input/KeySelectSpec.js index 2505232bc8..374b310d38 100644 --- a/src/plugins/summaryWidget/test/input/KeySelectSpec.js +++ b/src/plugins/summaryWidget/test/input/KeySelectSpec.js @@ -1,6 +1,11 @@ define(['../../src/input/KeySelect'], function (KeySelect) { describe('A select for choosing composition object properties', function () { - var mockConfig, mockBadConfig, mockManager, keySelect, mockMetadata, mockObjectSelect; + let mockConfig; + let mockBadConfig; + let mockManager; + let keySelect; + let mockMetadata; + let mockObjectSelect; beforeEach(function () { mockConfig = { object: 'object1', diff --git a/src/plugins/summaryWidget/test/input/ObjectSelectSpec.js b/src/plugins/summaryWidget/test/input/ObjectSelectSpec.js index f72818a1ec..90d3c8c41f 100644 --- a/src/plugins/summaryWidget/test/input/ObjectSelectSpec.js +++ b/src/plugins/summaryWidget/test/input/ObjectSelectSpec.js @@ -1,6 +1,10 @@ define(['../../src/input/ObjectSelect'], function (ObjectSelect) { describe('A select for choosing composition objects', function () { - var mockConfig, mockBadConfig, mockManager, objectSelect, mockComposition; + let mockConfig; + let mockBadConfig; + let mockManager; + let objectSelect; + let mockComposition; beforeEach(function () { mockConfig = { object: 'key1' diff --git a/src/plugins/summaryWidget/test/input/OperationSelectSpec.js b/src/plugins/summaryWidget/test/input/OperationSelectSpec.js index 33f9fdad09..2f1a3c38fa 100644 --- a/src/plugins/summaryWidget/test/input/OperationSelectSpec.js +++ b/src/plugins/summaryWidget/test/input/OperationSelectSpec.js @@ -1,7 +1,13 @@ define(['../../src/input/OperationSelect'], function (OperationSelect) { describe('A select for choosing composition object properties', function () { - var mockConfig, mockBadConfig, mockManager, operationSelect, mockOperations, - mockPropertyTypes, mockKeySelect, mockEvaluator; + let mockConfig; + let mockBadConfig; + let mockManager; + let operationSelect; + let mockOperations; + let mockPropertyTypes; + let mockKeySelect; + let mockEvaluator; beforeEach(function () { mockConfig = { diff --git a/src/plugins/summaryWidget/test/input/PaletteSpec.js b/src/plugins/summaryWidget/test/input/PaletteSpec.js index 32260975aa..25f6819f95 100644 --- a/src/plugins/summaryWidget/test/input/PaletteSpec.js +++ b/src/plugins/summaryWidget/test/input/PaletteSpec.js @@ -1,6 +1,8 @@ define(['../../src/input/Palette'], function (Palette) { describe('A generic Open MCT palette input', function () { - var palette, callbackSpy1, callbackSpy2; + let palette; + let callbackSpy1; + let callbackSpy2; beforeEach(function () { palette = new Palette('someClass', 'someContainer', ['item1', 'item2', 'item3']); diff --git a/src/plugins/summaryWidget/test/input/SelectSpec.js b/src/plugins/summaryWidget/test/input/SelectSpec.js index b48836317c..bd895507fa 100644 --- a/src/plugins/summaryWidget/test/input/SelectSpec.js +++ b/src/plugins/summaryWidget/test/input/SelectSpec.js @@ -1,6 +1,9 @@ define(['../../src/input/Select'], function (Select) { describe('A select wrapper', function () { - var select, testOptions, callbackSpy1, callbackSpy2; + let select; + let testOptions; + let callbackSpy1; + let callbackSpy2; beforeEach(function () { select = new Select(); testOptions = [['item1', 'Item 1'], ['item2', 'Item 2'], ['item3', 'Item 3']]; diff --git a/src/plugins/tabs/components/tabs.vue b/src/plugins/tabs/components/tabs.vue index a34a60cbab..49a4b9846a 100644 --- a/src/plugins/tabs/components/tabs.vue +++ b/src/plugins/tabs/components/tabs.vue @@ -59,7 +59,7 @@ import { deleteSearchParam } from 'utils/openmctLocation'; -var unknownObjectType = { +const unknownObjectType = { definition: { cssClass: 'icon-object-unknown', name: 'Unknown Type' @@ -180,12 +180,12 @@ export default { this.composition.remove(childDomainObject); }, addItem(domainObject) { - let type = this.openmct.types.get(domainObject.type) || unknownObjectType, - tabItem = { - domainObject, - type: type, - key: this.openmct.objects.makeKeyString(domainObject.identifier) - }; + let type = this.openmct.types.get(domainObject.type) || unknownObjectType; + let tabItem = { + domainObject, + type: type, + key: this.openmct.objects.makeKeyString(domainObject.identifier) + }; this.tabsList.push(tabItem); @@ -200,9 +200,9 @@ export default { }, removeItem(identifier) { let pos = this.tabsList.findIndex(tab => - tab.domainObject.identifier.namespace === identifier.namespace && tab.domainObject.identifier.key === identifier.key - ), - tabToBeRemoved = this.tabsList[pos]; + tab.domainObject.identifier.namespace === identifier.namespace && tab.domainObject.identifier.key === identifier.key + ); + let tabToBeRemoved = this.tabsList[pos]; this.tabsList.splice(pos, 1); diff --git a/src/plugins/telemetryMean/plugin.js b/src/plugins/telemetryMean/plugin.js index 1c96efeb31..561c627bec 100755 --- a/src/plugins/telemetryMean/plugin.js +++ b/src/plugins/telemetryMean/plugin.js @@ -21,7 +21,7 @@ *****************************************************************************/ define(['./src/MeanTelemetryProvider'], function (MeanTelemetryProvider) { - var DEFAULT_SAMPLES = 10; + const DEFAULT_SAMPLES = 10; function plugin() { return function install(openmct) { diff --git a/src/plugins/telemetryMean/src/MeanTelemetryProvider.js b/src/plugins/telemetryMean/src/MeanTelemetryProvider.js index 7669712924..72422cf3e6 100644 --- a/src/plugins/telemetryMean/src/MeanTelemetryProvider.js +++ b/src/plugins/telemetryMean/src/MeanTelemetryProvider.js @@ -42,10 +42,10 @@ define([ MeanTelemetryProvider.prototype.canProvideTelemetry; MeanTelemetryProvider.prototype.subscribe = function (domainObject, callback) { - var wrappedUnsubscribe; - var unsubscribeCalled = false; - var objectId = objectUtils.parseKeyString(domainObject.telemetryPoint); - var samples = domainObject.samples; + let wrappedUnsubscribe; + let unsubscribeCalled = false; + const objectId = objectUtils.parseKeyString(domainObject.telemetryPoint); + const samples = domainObject.samples; this.objectAPI.get(objectId) .then(function (linkedDomainObject) { @@ -64,15 +64,15 @@ define([ }; MeanTelemetryProvider.prototype.subscribeToAverage = function (domainObject, samples, callback) { - var telemetryAverager = new TelemetryAverager(this.telemetryAPI, this.timeAPI, domainObject, samples, callback); - var createAverageDatum = telemetryAverager.createAverageDatum.bind(telemetryAverager); + const telemetryAverager = new TelemetryAverager(this.telemetryAPI, this.timeAPI, domainObject, samples, callback); + const createAverageDatum = telemetryAverager.createAverageDatum.bind(telemetryAverager); return this.telemetryAPI.subscribe(domainObject, createAverageDatum); }; MeanTelemetryProvider.prototype.request = function (domainObject, request) { - var objectId = objectUtils.parseKeyString(domainObject.telemetryPoint); - var samples = domainObject.samples; + const objectId = objectUtils.parseKeyString(domainObject.telemetryPoint); + const samples = domainObject.samples; return this.objectAPI.get(objectId).then(function (linkedDomainObject) { return this.requestAverageTelemetry(linkedDomainObject, request, samples); @@ -83,10 +83,10 @@ define([ * @private */ MeanTelemetryProvider.prototype.requestAverageTelemetry = function (domainObject, request, samples) { - var averageData = []; - var addToAverageData = averageData.push.bind(averageData); - var telemetryAverager = new TelemetryAverager(this.telemetryAPI, this.timeAPI, domainObject, samples, addToAverageData); - var createAverageDatum = telemetryAverager.createAverageDatum.bind(telemetryAverager); + const averageData = []; + const addToAverageData = averageData.push.bind(averageData); + const telemetryAverager = new TelemetryAverager(this.telemetryAPI, this.timeAPI, domainObject, samples, addToAverageData); + const createAverageDatum = telemetryAverager.createAverageDatum.bind(telemetryAverager); return this.telemetryAPI.request(domainObject, request).then(function (telemetryData) { telemetryData.forEach(createAverageDatum); @@ -99,7 +99,7 @@ define([ * @private */ MeanTelemetryProvider.prototype.getLinkedObject = function (domainObject) { - var objectId = objectUtils.parseKeyString(domainObject.telemetryPoint); + const objectId = objectUtils.parseKeyString(domainObject.telemetryPoint); return this.objectAPI.get(objectId); }; diff --git a/src/plugins/telemetryMean/src/MeanTelemetryProviderSpec.js b/src/plugins/telemetryMean/src/MeanTelemetryProviderSpec.js index c2e6ac208c..62076d9705 100644 --- a/src/plugins/telemetryMean/src/MeanTelemetryProviderSpec.js +++ b/src/plugins/telemetryMean/src/MeanTelemetryProviderSpec.js @@ -27,14 +27,14 @@ define([ MeanTelemetryProvider, MockTelemetryApi ) { - var RANGE_KEY = 'value'; + const RANGE_KEY = 'value'; describe("The Mean Telemetry Provider", function () { - var mockApi; - var meanTelemetryProvider; - var mockDomainObject; - var associatedObject; - var allPromises; + let mockApi; + let meanTelemetryProvider; + let mockDomainObject; + let associatedObject; + let allPromises; beforeEach(function () { allPromises = []; @@ -45,15 +45,15 @@ define([ }); it("supports telemetry-mean objects only", function () { - var mockTelemetryMeanObject = mockObjectWithType('telemetry-mean'); - var mockOtherObject = mockObjectWithType('other'); + const mockTelemetryMeanObject = mockObjectWithType('telemetry-mean'); + const mockOtherObject = mockObjectWithType('other'); expect(meanTelemetryProvider.canProvideTelemetry(mockTelemetryMeanObject)).toBe(true); expect(meanTelemetryProvider.canProvideTelemetry(mockOtherObject)).toBe(false); }); describe("the subscribe function", function () { - var subscriptionCallback; + let subscriptionCallback; beforeEach(function () { subscriptionCallback = jasmine.createSpy('subscriptionCallback'); @@ -66,7 +66,7 @@ define([ }); it("returns a function that unsubscribes from the associated object", function () { - var unsubscribe = meanTelemetryProvider.subscribe(mockDomainObject); + const unsubscribe = meanTelemetryProvider.subscribe(mockDomainObject); return waitForPromises() .then(unsubscribe) @@ -77,7 +77,7 @@ define([ }); it("returns an average only when the sample size is reached", function () { - var inputTelemetry = [ + const inputTelemetry = [ { 'utc': 1, 'defaultRange': 123.1231 @@ -107,7 +107,7 @@ define([ }); it("correctly averages a sample of five values", function () { - var inputTelemetry = [ + const inputTelemetry = [ { 'utc': 1, 'defaultRange': 123.1231 @@ -129,7 +129,7 @@ define([ 'defaultRange': 1.1231 } ]; - var expectedAverages = [{ + const expectedAverages = [{ 'utc': 5, 'value': 222.44888 }]; @@ -143,7 +143,7 @@ define([ }); it("correctly averages a sample of ten values", function () { - var inputTelemetry = [ + const inputTelemetry = [ { 'utc': 1, 'defaultRange': 123.1231 @@ -185,7 +185,7 @@ define([ 'defaultRange': 0.543 } ]; - var expectedAverages = [{ + const expectedAverages = [{ 'utc': 10, 'value': 451.07815 }]; @@ -199,7 +199,7 @@ define([ }); it("only averages values within its sample window", function () { - var inputTelemetry = [ + const inputTelemetry = [ { 'utc': 1, 'defaultRange': 123.1231 @@ -241,7 +241,7 @@ define([ 'defaultRange': 0.543 } ]; - var expectedAverages = [ + const expectedAverages = [ { 'utc': 5, 'value': 222.44888 @@ -276,7 +276,7 @@ define([ .then(expectAveragesForTelemetry.bind(this, expectedAverages)); }); describe("given telemetry input with range values", function () { - var inputTelemetry; + let inputTelemetry; beforeEach(function () { inputTelemetry = [{ @@ -287,7 +287,7 @@ define([ setSampleSize(1); }); it("uses the 'rangeKey' input range, when it is the default, to calculate the average", function () { - var averageTelemetryForRangeKey = [{ + const averageTelemetryForRangeKey = [{ 'utc': 1, 'value': 5678 }]; @@ -301,7 +301,7 @@ define([ }); it("uses the 'otherKey' input range, when it is the default, to calculate the average", function () { - var averageTelemetryForOtherKey = [{ + const averageTelemetryForOtherKey = [{ 'utc': 1, 'value': 9999 }]; @@ -315,7 +315,7 @@ define([ }); }); describe("given telemetry input with range values", function () { - var inputTelemetry; + let inputTelemetry; beforeEach(function () { inputTelemetry = [{ @@ -326,7 +326,7 @@ define([ setSampleSize(1); }); it("uses the 'rangeKey' input range, when it is the default, to calculate the average", function () { - var averageTelemetryForRangeKey = [{ + const averageTelemetryForRangeKey = [{ 'utc': 1, 'value': 5678 }]; @@ -340,7 +340,7 @@ define([ }); it("uses the 'otherKey' input range, when it is the default, to calculate the average", function () { - var averageTelemetryForOtherKey = [{ + const averageTelemetryForOtherKey = [{ 'utc': 1, 'value': 9999 }]; @@ -385,7 +385,7 @@ define([ }); it("returns an average only when the sample size is reached", function () { - var inputTelemetry = [ + const inputTelemetry = [ { 'utc': 1, 'defaultRange': 123.1231 @@ -413,7 +413,7 @@ define([ }); it("correctly averages a sample of five values", function () { - var inputTelemetry = [ + const inputTelemetry = [ { 'utc': 1, 'defaultRange': 123.1231 @@ -446,7 +446,7 @@ define([ }); it("correctly averages a sample of ten values", function () { - var inputTelemetry = [ + const inputTelemetry = [ { 'utc': 1, 'defaultRange': 123.1231 @@ -499,7 +499,7 @@ define([ }); it("only averages values within its sample window", function () { - var inputTelemetry = [ + const inputTelemetry = [ { 'utc': 1, 'defaultRange': 123.1231 @@ -552,7 +552,7 @@ define([ }); function expectAverageToBe(expectedValue, averageData) { - var averageDatum = averageData[averageData.length - 1]; + const averageDatum = averageData[averageData.length - 1]; expect(averageDatum[RANGE_KEY]).toBe(expectedValue); } @@ -594,7 +594,7 @@ define([ } function resolvePromiseWith(value) { - var promise = Promise.resolve(value); + const promise = Promise.resolve(value); allPromises.push(promise); return promise; diff --git a/src/plugins/telemetryMean/src/MockTelemetryApi.js b/src/plugins/telemetryMean/src/MockTelemetryApi.js index 2ee71ab406..8e5f6d146b 100644 --- a/src/plugins/telemetryMean/src/MockTelemetryApi.js +++ b/src/plugins/telemetryMean/src/MockTelemetryApi.js @@ -43,7 +43,7 @@ define([], function () { MockTelemetryApi.prototype.request = jasmine.createSpy('request'); MockTelemetryApi.prototype.getValueFormatter = function (valueMetadata) { - var mockValueFormatter = jasmine.createSpyObj("valueFormatter", [ + const mockValueFormatter = jasmine.createSpyObj("valueFormatter", [ "parse" ]); @@ -55,7 +55,7 @@ define([], function () { }; MockTelemetryApi.prototype.mockReceiveTelemetry = function (newTelemetryDatum) { - var subscriptionCallback = this.subscribe.calls.mostRecent().args[1]; + const subscriptionCallback = this.subscribe.calls.mostRecent().args[1]; subscriptionCallback(newTelemetryDatum); }; @@ -70,7 +70,7 @@ define([], function () { * @private */ MockTelemetryApi.prototype.setDefaultRangeTo = function (rangeKey) { - var mockMetadataValue = { + const mockMetadataValue = { key: rangeKey }; this.metadata.valuesForHints.and.returnValue([mockMetadataValue]); @@ -80,7 +80,7 @@ define([], function () { * @private */ MockTelemetryApi.prototype.createMockMetadata = function () { - var mockMetadata = jasmine.createSpyObj("metadata", [ + const mockMetadata = jasmine.createSpyObj("metadata", [ 'value', 'valuesForHints' ]); diff --git a/src/plugins/telemetryMean/src/TelemetryAverager.js b/src/plugins/telemetryMean/src/TelemetryAverager.js index a6bf8dec17..856f9eeebe 100644 --- a/src/plugins/telemetryMean/src/TelemetryAverager.js +++ b/src/plugins/telemetryMean/src/TelemetryAverager.js @@ -44,8 +44,8 @@ define([], function () { TelemetryAverager.prototype.createAverageDatum = function (telemetryDatum) { this.setDomainKeyAndFormatter(); - var timeValue = this.domainFormatter.parse(telemetryDatum); - var rangeValue = this.rangeFormatter.parse(telemetryDatum); + const timeValue = this.domainFormatter.parse(telemetryDatum); + const rangeValue = this.rangeFormatter.parse(telemetryDatum); this.averagingWindow.push(rangeValue); @@ -57,9 +57,9 @@ define([], function () { this.averagingWindow.shift(); } - var averageValue = this.calculateMean(); + const averageValue = this.calculateMean(); - var meanDatum = {}; + const meanDatum = {}; meanDatum[this.domainKey] = timeValue; meanDatum.value = averageValue; @@ -70,8 +70,8 @@ define([], function () { * @private */ TelemetryAverager.prototype.calculateMean = function () { - var sum = 0; - var i = 0; + let sum = 0; + let i = 0; for (; i < this.averagingWindow.length; i++) { sum += this.averagingWindow[i]; @@ -88,7 +88,7 @@ define([], function () { * @private */ TelemetryAverager.prototype.setDomainKeyAndFormatter = function () { - var domainKey = this.timeAPI.timeSystem().key; + const domainKey = this.timeAPI.timeSystem().key; if (domainKey !== this.domainKey) { this.domainKey = domainKey; this.domainFormatter = this.getFormatter(domainKey); @@ -99,8 +99,8 @@ define([], function () { * @private */ TelemetryAverager.prototype.setRangeKeyAndFormatter = function () { - var metadatas = this.telemetryAPI.getMetadata(this.domainObject); - var rangeValues = metadatas.valuesForHints(['range']); + const metadatas = this.telemetryAPI.getMetadata(this.domainObject); + const rangeValues = metadatas.valuesForHints(['range']); this.rangeKey = rangeValues[0].key; this.rangeFormatter = this.getFormatter(this.rangeKey); @@ -110,8 +110,8 @@ define([], function () { * @private */ TelemetryAverager.prototype.getFormatter = function (key) { - var objectMetadata = this.telemetryAPI.getMetadata(this.domainObject); - var valueMetadata = objectMetadata.value(key); + const objectMetadata = this.telemetryAPI.getMetadata(this.domainObject); + const valueMetadata = objectMetadata.value(key); return this.telemetryAPI.getValueFormatter(valueMetadata); }; diff --git a/src/plugins/telemetryTable/TelemetryTable.js b/src/plugins/telemetryTable/TelemetryTable.js index fe907bf2e5..3f1c45a22a 100644 --- a/src/plugins/telemetryTable/TelemetryTable.js +++ b/src/plugins/telemetryTable/TelemetryTable.js @@ -274,10 +274,10 @@ define([ } buildOptionsFromConfiguration(telemetryObject) { - let keyString = this.openmct.objects.makeKeyString(telemetryObject.identifier), - filters = this.domainObject.configuration - && this.domainObject.configuration.filters - && this.domainObject.configuration.filters[keyString]; + let keyString = this.openmct.objects.makeKeyString(telemetryObject.identifier); + let filters = this.domainObject.configuration + && this.domainObject.configuration.filters + && this.domainObject.configuration.filters[keyString]; return {filters} || {}; } diff --git a/src/plugins/telemetryTable/components/table.vue b/src/plugins/telemetryTable/components/table.vue index 21d950af36..8942bd9e56 100644 --- a/src/plugins/telemetryTable/components/table.vue +++ b/src/plugins/telemetryTable/components/table.vue @@ -496,11 +496,11 @@ export default { this.scrollW = (this.scrollable.offsetWidth - this.scrollable.clientWidth) + 1; }, calculateColumnWidths() { - let columnWidths = {}, - totalWidth = 0, - headerKeys = Object.keys(this.headers), - sizingTableRow = this.sizingTable.children[0], - sizingCells = sizingTableRow.children; + let columnWidths = {}; + let totalWidth = 0; + let headerKeys = Object.keys(this.headers); + let sizingTableRow = this.sizingTable.children[0]; + let sizingCells = sizingTableRow.children; headerKeys.forEach((headerKey, headerIndex, array) => { if (this.isAutosizeEnabled) { @@ -754,8 +754,8 @@ export default { }, unmarkRow(rowIndex) { if (this.markedRows.length > 1) { - let row = this.visibleRows[rowIndex], - positionInMarkedArray = this.markedRows.indexOf(row); + let row = this.visibleRows[rowIndex]; + let positionInMarkedArray = this.markedRows.indexOf(row); row.marked = false; this.markedRows.splice(positionInMarkedArray, 1); @@ -820,9 +820,9 @@ export default { let lastRowToBeMarked = this.visibleRows[rowIndex]; - let allRows = this.table.filteredRows.getRows(), - firstRowIndex = allRows.indexOf(this.markedRows[0]), - lastRowIndex = allRows.indexOf(lastRowToBeMarked); + let allRows = this.table.filteredRows.getRows(); + let firstRowIndex = allRows.indexOf(this.markedRows[0]); + let lastRowIndex = allRows.indexOf(lastRowToBeMarked); //supports backward selection if (lastRowIndex < firstRowIndex) { @@ -831,7 +831,7 @@ export default { let baseRow = this.markedRows[0]; - for (var i = firstRowIndex; i <= lastRowIndex; i++) { + for (let i = firstRowIndex; i <= lastRowIndex; i++) { let row = allRows[i]; row.marked = true; diff --git a/src/plugins/timeConductor/DatePicker.vue b/src/plugins/timeConductor/DatePicker.vue index 307970c55e..45592284d8 100644 --- a/src/plugins/timeConductor/DatePicker.vue +++ b/src/plugins/timeConductor/DatePicker.vue @@ -143,12 +143,12 @@ export default { methods: { generateTable() { let m = moment.utc({ - year: this.picker.year, - month: this.picker.month - }).day(0), - table = [], - row, - col; + year: this.picker.year, + month: this.picker.month + }).day(0); + let table = []; + let row; + let col; for (row = 0; row < 6; row += 1) { table.push([]); diff --git a/src/plugins/timeConductor/plugin.js b/src/plugins/timeConductor/plugin.js index 0399754215..f47a394517 100644 --- a/src/plugins/timeConductor/plugin.js +++ b/src/plugins/timeConductor/plugin.js @@ -57,13 +57,13 @@ function hasRequiredOptions(config) { } function validateConfiguration(config, openmct) { - var systems = openmct.time.getAllTimeSystems() + const systems = openmct.time.getAllTimeSystems() .reduce(function (m, ts) { m[ts.key] = ts; return m; }, {}); - var clocks = openmct.time.getAllClocks() + const clocks = openmct.time.getAllClocks() .reduce(function (m, c) { m[c.key] = c; @@ -108,7 +108,7 @@ export default function (config) { let configResult = hasRequiredOptions(config) || validateConfiguration(config, openmct); throwIfError(configResult); - var defaults = config.menuOptions[0]; + const defaults = config.menuOptions[0]; if (defaults.clock) { openmct.time.clock(defaults.clock, defaults.clockOffsets); openmct.time.timeSystem(defaults.timeSystem, openmct.time.bounds()); diff --git a/src/plugins/timeConductor/utcMultiTimeFormat.js b/src/plugins/timeConductor/utcMultiTimeFormat.js index eb0c6eb5b8..47ae1f42f8 100644 --- a/src/plugins/timeConductor/utcMultiTimeFormat.js +++ b/src/plugins/timeConductor/utcMultiTimeFormat.js @@ -23,14 +23,14 @@ import moment from 'moment'; export default function multiFormat(date) { - var momentified = moment.utc(date); + const momentified = moment.utc(date); /** * Uses logic from d3 Time-Scales, v3 of the API. See * https://github.com/d3/d3-3.x-api-reference/blob/master/Time-Scales.md * * Licensed */ - var format = [ + const format = [ [".SSS", function (m) { return m.milliseconds(); }], diff --git a/src/plugins/utcTimeSystem/LocalClock.js b/src/plugins/utcTimeSystem/LocalClock.js index 5b87ec3876..fb8269cf16 100644 --- a/src/plugins/utcTimeSystem/LocalClock.js +++ b/src/plugins/utcTimeSystem/LocalClock.js @@ -67,7 +67,7 @@ define(['EventEmitter'], function (EventEmitter) { * @private */ LocalClock.prototype.tick = function () { - var now = Date.now(); + const now = Date.now(); this.emit("tick", now); this.lastTick = now; this.timeoutHandle = setTimeout(this.tick.bind(this), this.period); @@ -81,7 +81,7 @@ define(['EventEmitter'], function (EventEmitter) { * @returns {function} a function for deregistering the provided listener */ LocalClock.prototype.on = function (event) { - var result = EventEmitter.prototype.on.apply(this, arguments); + const result = EventEmitter.prototype.on.apply(this, arguments); if (this.listeners(event).length === 1) { this.start(); @@ -98,7 +98,7 @@ define(['EventEmitter'], function (EventEmitter) { * @returns {function} a function for deregistering the provided listener */ LocalClock.prototype.off = function (event) { - var result = EventEmitter.prototype.off.apply(this, arguments); + const result = EventEmitter.prototype.off.apply(this, arguments); if (this.listeners(event).length === 0) { this.stop(); diff --git a/src/plugins/utcTimeSystem/LocalClockSpec.js b/src/plugins/utcTimeSystem/LocalClockSpec.js index 2cc5aabed8..a1b3722f3b 100644 --- a/src/plugins/utcTimeSystem/LocalClockSpec.js +++ b/src/plugins/utcTimeSystem/LocalClockSpec.js @@ -22,9 +22,9 @@ define(["./LocalClock"], function (LocalClock) { describe("The LocalClock class", function () { - var clock, - mockTimeout, - timeoutHandle = {}; + let clock; + let mockTimeout; + const timeoutHandle = {}; beforeEach(function () { mockTimeout = jasmine.createSpy("timeout"); @@ -35,7 +35,7 @@ define(["./LocalClock"], function (LocalClock) { }); it("calls listeners on tick with current time", function () { - var mockListener = jasmine.createSpy("listener"); + const mockListener = jasmine.createSpy("listener"); clock.on('tick', mockListener); clock.tick(); expect(mockListener).toHaveBeenCalledWith(jasmine.any(Number)); diff --git a/src/plugins/utcTimeSystem/UTCTimeSystemSpec.js b/src/plugins/utcTimeSystem/UTCTimeSystemSpec.js index bc8f5e98b0..3f634e4176 100644 --- a/src/plugins/utcTimeSystem/UTCTimeSystemSpec.js +++ b/src/plugins/utcTimeSystem/UTCTimeSystemSpec.js @@ -22,8 +22,8 @@ define(['./UTCTimeSystem'], function (UTCTimeSystem) { describe("The UTCTimeSystem class", function () { - var timeSystem, - mockTimeout; + let timeSystem; + let mockTimeout; beforeEach(function () { mockTimeout = jasmine.createSpy("timeout"); diff --git a/src/plugins/utcTimeSystem/plugin.js b/src/plugins/utcTimeSystem/plugin.js index e3e212ec9f..44dcef5901 100644 --- a/src/plugins/utcTimeSystem/plugin.js +++ b/src/plugins/utcTimeSystem/plugin.js @@ -33,7 +33,7 @@ define([ */ return function () { return function (openmct) { - var timeSystem = new UTCTimeSystem(); + const timeSystem = new UTCTimeSystem(); openmct.time.addTimeSystem(timeSystem); openmct.time.addClock(new LocalClock(100)); }; diff --git a/src/selection/Selection.js b/src/selection/Selection.js index 5c8c646e9a..7f15751d8e 100644 --- a/src/selection/Selection.js +++ b/src/selection/Selection.js @@ -224,14 +224,15 @@ define( element: element }; - var capture = this.capture.bind(this, selectable); - var selectCapture = this.selectCapture.bind(this, selectable); + const capture = this.capture.bind(this, selectable); + const selectCapture = this.selectCapture.bind(this, selectable); element.addEventListener('click', capture, true); element.addEventListener('click', selectCapture); + let unlisten = undefined; if (context.item) { - var unlisten = this.openmct.objects.observe(context.item, "*", function (newItem) { + unlisten = this.openmct.objects.observe(context.item, "*", function (newItem) { context.item = newItem; }); } @@ -248,7 +249,7 @@ define( element.removeEventListener('click', capture, true); element.removeEventListener('click', selectCapture); - if (unlisten) { + if (unlisten !== undefined) { unlisten(); } }; diff --git a/src/ui/components/ObjectFrame.vue b/src/ui/components/ObjectFrame.vue index 2115c0acd6..d3ae5b92b1 100644 --- a/src/ui/components/ObjectFrame.vue +++ b/src/ui/components/ObjectFrame.vue @@ -106,9 +106,9 @@ export default { } }, data() { - let objectType = this.openmct.types.get(this.domainObject.type), - cssClass = objectType && objectType.definition ? objectType.definition.cssClass : 'icon-object-unknown', - complexContent = !SIMPLE_CONTENT_TYPES.includes(this.domainObject.type); + let objectType = this.openmct.types.get(this.domainObject.type); + let cssClass = objectType && objectType.definition ? objectType.definition.cssClass : 'icon-object-unknown'; + let complexContent = !SIMPLE_CONTENT_TYPES.includes(this.domainObject.type); return { cssClass, @@ -127,9 +127,9 @@ export default { }, methods: { expand() { - let objectView = this.$refs.objectView, - parentElement = objectView.$el, - childElement = parentElement.children[0]; + let objectView = this.$refs.objectView; + let parentElement = objectView.$el; + let childElement = parentElement.children[0]; this.openmct.overlays.overlay({ element: this.getOverlayElement(childElement), diff --git a/src/ui/components/ObjectView.vue b/src/ui/components/ObjectView.vue index 4a4ddbf40b..01df6a74d8 100644 --- a/src/ui/components/ObjectView.vue +++ b/src/ui/components/ObjectView.vue @@ -291,8 +291,8 @@ export default { }, clearData(domainObject) { if (domainObject) { - let clearKeyString = this.openmct.objects.makeKeyString(domainObject.identifier), - currentObjectKeyString = this.openmct.objects.makeKeyString(this.currentObject.identifier); + let clearKeyString = this.openmct.objects.makeKeyString(domainObject.identifier); + let currentObjectKeyString = this.openmct.objects.makeKeyString(this.currentObject.identifier); if (clearKeyString === currentObjectKeyString) { if (this.currentView.onClearData) { @@ -306,9 +306,9 @@ export default { } }, isEditingAllowed() { - let browseObject = this.openmct.layout.$refs.browseObject.currentObject, - objectPath = this.currentObjectPath || this.objectPath, - parentObject = objectPath[1]; + let browseObject = this.openmct.layout.$refs.browseObject.currentObject; + let objectPath = this.currentObjectPath || this.objectPath; + let parentObject = objectPath[1]; return [browseObject, parentObject, this.currentObject].every(object => object && !object.locked); } diff --git a/src/ui/layout/Layout.vue b/src/ui/layout/Layout.vue index 97e8e78e34..3884570cd7 100644 --- a/src/ui/layout/Layout.vue +++ b/src/ui/layout/Layout.vue @@ -143,7 +143,7 @@ export default { }, methods: { enterFullScreen() { - var docElm = document.documentElement; + let docElm = document.documentElement; if (docElm.requestFullscreen) { docElm.requestFullscreen(); diff --git a/src/ui/layout/mct-tree.vue b/src/ui/layout/mct-tree.vue index 16dc6122de..c75352e93e 100644 --- a/src/ui/layout/mct-tree.vue +++ b/src/ui/layout/mct-tree.vue @@ -104,10 +104,10 @@ export default { this.searchService.query(this.searchValue).then(children => { this.filteredTreeItems = children.hits.map(child => { - let context = child.object.getCapability('context'), - object = child.object.useCapability('adapter'), - objectPath = [], - navigateToParent; + let context = child.object.getCapability('context'); + let object = child.object.useCapability('adapter'); + let objectPath = []; + let navigateToParent; if (context) { objectPath = context.getPath().slice(1) diff --git a/src/ui/registries/InspectorViewRegistry.js b/src/ui/registries/InspectorViewRegistry.js index b969872ca9..7e6d569369 100644 --- a/src/ui/registries/InspectorViewRegistry.js +++ b/src/ui/registries/InspectorViewRegistry.js @@ -61,7 +61,7 @@ define([], function () { * @memberof module:openmct.InspectorViewRegistry# */ InspectorViewRegistry.prototype.addProvider = function (provider) { - var key = provider.key; + const key = provider.key; if (key === undefined) { throw "View providers must have a unique 'key' property defined"; diff --git a/src/ui/registries/ToolbarRegistry.js b/src/ui/registries/ToolbarRegistry.js index 0872010e35..97ec814fd6 100644 --- a/src/ui/registries/ToolbarRegistry.js +++ b/src/ui/registries/ToolbarRegistry.js @@ -40,11 +40,11 @@ define([], function () { * @private for platform-internal use */ ToolbarRegistry.prototype.get = function (selection) { - var providers = this.getAllProviders().filter(function (provider) { + const providers = this.getAllProviders().filter(function (provider) { return provider.forSelection(selection); }); - var structure = []; + const structure = []; providers.forEach(provider => { provider.toolbar(selection).forEach(item => structure.push(item)); @@ -75,7 +75,7 @@ define([], function () { * @memberof module:openmct.ToolbarRegistry# */ ToolbarRegistry.prototype.addProvider = function (provider) { - var key = provider.key; + const key = provider.key; if (key === undefined) { throw "Toolbar providers must have a unique 'key' property defined."; diff --git a/src/ui/registries/ViewRegistry.js b/src/ui/registries/ViewRegistry.js index 0ccff56502..7a91e304ef 100644 --- a/src/ui/registries/ViewRegistry.js +++ b/src/ui/registries/ViewRegistry.js @@ -71,7 +71,7 @@ define(['EventEmitter'], function (EventEmitter) { * @memberof module:openmct.ViewRegistry# */ ViewRegistry.prototype.addProvider = function (provider) { - var key = provider.key; + const key = provider.key; if (key === undefined) { throw "View providers must have a unique 'key' property defined"; } diff --git a/src/utils/testing.js b/src/utils/testing.js index b74948ff47..a646bf115d 100644 --- a/src/utils/testing.js +++ b/src/utils/testing.js @@ -21,8 +21,8 @@ *****************************************************************************/ import MCT from 'MCT'; -let nativeFunctions = [], - mockObjects = setMockObjects(); +let nativeFunctions = []; +let mockObjects = setMockObjects(); export function createOpenMct() { const openmct = new MCT(); @@ -95,8 +95,8 @@ function clearBuiltinSpy(funcDefinition) { } export function getLatestTelemetry(telemetry = [], opts = {}) { - let latest = [], - timeFormat = opts.timeFormat || 'utc'; + let latest = []; + let timeFormat = opts.timeFormat || 'utc'; if (telemetry.length) { latest = telemetry.reduce((prev, cur) => { @@ -145,10 +145,10 @@ export function getMockObjects(opts = {}) { // build out custom telemetry mappings if necessary if (requestedMocks.telemetry && opts.telemetryConfig) { - let keys = opts.telemetryConfig.keys, - format = opts.telemetryConfig.format || 'utc', - hints = opts.telemetryConfig.hints, - values; + let keys = opts.telemetryConfig.keys; + let format = opts.telemetryConfig.format || 'utc'; + let hints = opts.telemetryConfig.hints; + let values; // if utc, keep default if (format === 'utc') { @@ -213,12 +213,12 @@ export function getMockObjects(opts = {}) { // format: 'local' // }) export function getMockTelemetry(opts = {}) { - let count = opts.count || 2, - format = opts.format || 'utc', - name = opts.name || 'Mock Telemetry Datum', - keyCount = 2, - keys = false, - telemetry = []; + let count = opts.count || 2; + let format = opts.format || 'utc'; + let name = opts.name || 'Mock Telemetry Datum'; + let keyCount = 2; + let keys = false; + let telemetry = []; if (opts.keys && Array.isArray(opts.keys)) { keyCount = opts.keys.length; @@ -234,8 +234,8 @@ export function getMockTelemetry(opts = {}) { }; for (let k = 1; k < keyCount + 1; k++) { - let key = keys ? keys[k - 1] : 'some-key-' + k, - value = keys ? keys[k - 1] + ' value ' + i : 'some value ' + i + '-' + k; + let key = keys ? keys[k - 1] : 'some-key-' + k; + let value = keys ? keys[k - 1] + ' value ' + i : 'some value ' + i + '-' + k; datum[key] = value; }