Compare commits

..

4 Commits

Author SHA1 Message Date
Joshi
5283d06e05 Save window location 2020-05-18 10:43:18 -07:00
Joshi
888695f636 Saves indicator buttons 2020-05-14 14:37:30 -07:00
Joshi
9f0af90663 WIP - Open 2 windows, close them and open the saved 2 windows 2020-05-14 11:53:53 -07:00
Joshi
e93d36ff19 WIP windowLayouts 2020-05-12 10:43:20 -07:00
86 changed files with 407 additions and 372 deletions

View File

@@ -10,8 +10,7 @@ module.exports = {
},
"extends": [
"eslint:recommended",
"plugin:vue/recommended",
"plugin:you-dont-need-lodash-underscore/compatible"
"plugin:vue/recommended"
],
"parser": "vue-eslint-parser",
"parserOptions": {
@@ -23,9 +22,6 @@ module.exports = {
}
},
"rules": {
"you-dont-need-lodash-underscore/omit": "off",
"you-dont-need-lodash-underscore/throttle": "off",
"you-dont-need-lodash-underscore/flatten": "off",
"no-bitwise": "error",
"curly": "error",
"eqeqeq": "error",

4
API.md
View File

@@ -427,8 +427,8 @@ Each telemetry value description has an object defining hints. Keys in this thi
Known hints:
* `domain`: Values with a `domain` hint will be used for the x-axis of a plot, and tables will render columns for these values first.
* `range`: Values with a `range` hint will be used as the y-axis on a plot, and tables will render columns for these values after the `domain` values.
* `domain`: Indicates that the value represents the "input" of a datum. Values with a `domain` hint will be used for the x-axis of a plot, and tables will render columns for these values first.
* `range`: Indicates that the value is the "output" of a datum. Values with a `range` hint will be used as the y-axis on a plot, and tables will render columns for these values after the `domain` values.
* `image`: Indicates that the value may be interpreted as the URL to an image file, in which case appropriate views will be made available.
##### The Time Conductor and Telemetry

View File

@@ -103,7 +103,7 @@ the name chosen could not be mistaken for a topic or master branch.
### Merging
When development is complete on an issue, the first step toward merging it
back into the master branch is to file a Pull Request (PR). The contributions
back into the master branch is to file a Pull Request. The contributions
should meet code, test, and commit message standards as described below,
and the pull request should include a completed author checklist, also
as described below. Pull requests may be assigned to specific team
@@ -114,15 +114,6 @@ request. When the reviewer is satisfied, they should add a comment to
the pull request containing the reviewer checklist (from below) and complete
the merge back to the master branch.
Additionally:
* Every pull request must link to the issue that it addresses. Eg. “Addresses #1234” or “Closes #1234”. This is the responsibility of the pull requests __author__. If no issue exists, create one.
* Every __author__ must include testing instructions. These instructions should identify the areas of code affected, and some minimal test steps. If addressing a bug, reproduction steps should be included, if they were not included in the original issue. If reproduction steps were included on the original issue, and are sufficient, refer to them.
* A pull request that closes an issue should say so in the description. Including the text “Closes #1234” will cause the linked issue to be automatically closed when the pull request is merged. This is the responsibility of the pull requests __author__.
* When a pull request is merged, and the corresponding issue closed, the __reviewer__ must add the tag “unverified” to the original issue. This will indicate that although the issue is closed, it has not been tested yet.
* Every PR must have two reviewers assigned, though only one approval is necessary for merge.
* Changes to API require approval by a senior developer.
* When creating a PR, it is the author's responsibility to apply any priority label from the issue to the PR as well. This helps with prioritization.
## Standards
Contributions to Open MCT are expected to meet the following standards.
@@ -301,7 +292,6 @@ checklist).
2. Unit tests included and/or updated with changes?
3. Command line build passes?
4. Changes have been smoke-tested?
5. Testing instructions included?
### Reviewer Checklist
@@ -309,4 +299,3 @@ checklist).
2. Appropriate unit tests included?
3. Code style and in-line documentation are appropriate?
4. Commit messages meet standards?
5. Has associated issue been labelled `unverified`? (only applicable if this PR closes the issue)

View File

@@ -50,8 +50,7 @@ define([
values: [
{
key: "name",
name: "Name",
format: "string"
name: "Name"
},
{
key: "utc",
@@ -100,7 +99,7 @@ define([
};
GeneratorMetadataProvider.prototype.getMetadata = function (domainObject) {
return Object.assign(
return _.extend(
{},
domainObject.telemetry,
METADATA_BY_TYPE[domainObject.type]

View File

@@ -82,6 +82,7 @@
openmct.install(openmct.plugins.Filters(['table', 'telemetry.plot.overlay']));
openmct.install(openmct.plugins.ObjectMigration());
openmct.install(openmct.plugins.ClearData(['table', 'telemetry.plot.overlay', 'telemetry.plot.stacked']));
openmct.install(openmct.plugins.WindowLayout());
openmct.start();
</script>
</html>

View File

@@ -24,7 +24,6 @@
"d3-time-format": "2.1.x",
"eslint": "5.2.0",
"eslint-plugin-vue": "^6.0.0",
"eslint-plugin-you-dont-need-lodash-underscore": "^6.10.0",
"eventemitter3": "^1.2.0",
"exports-loader": "^0.7.0",
"express": "^4.13.1",
@@ -49,7 +48,7 @@
"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "^3.0.0",
"location-bar": "^3.0.1",
"lodash": "^4.17.12",
"lodash": "^3.10.1",
"markdown-toc": "^0.11.7",
"marked": "^0.3.5",
"mini-css-extract-plugin": "^0.4.1",

View File

@@ -21,7 +21,7 @@
*****************************************************************************/
define(
['objectUtils'],
['../../../../../src/api/objects/object-utils'],
function (objectUtils) {
/**

View File

@@ -26,7 +26,7 @@
* @namespace platform/containment
*/
define(
['objectUtils'],
['../../../src/api/objects/object-utils'],
function (objectUtils) {
function PersistableCompositionPolicy(openmct) {

View File

@@ -81,7 +81,7 @@ define(
baseContext = context || {};
}
var actionContext = Object.assign({}, baseContext);
var actionContext = _.extend({}, baseContext);
actionContext.domainObject = this.domainObject;
return this.actionService.getActions(actionContext);

View File

@@ -121,7 +121,7 @@ define(['lodash'], function (_) {
*/
ExportAsJSONAction.prototype.rewriteLink = function (child, parent) {
this.externalIdentifiers.push(this.getId(child));
var index = parent.composition.findIndex(id => {
var index = _.findIndex(parent.composition, function (id) {
return _.isEqual(child.identifier, id);
});
var copyOfChild = this.copyObject(child);

View File

@@ -19,7 +19,7 @@
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
define(['zepto', 'objectUtils'], function ($, objectUtils) {
define(['zepto', '../../../../src/api/objects/object-utils.js'], function ($, objectUtils) {
/**
* The ImportAsJSONAction is available from context menus and allows a user

View File

@@ -25,7 +25,7 @@
* Module defining GenericSearchProvider. Created by shale on 07/16/2015.
*/
define([
'objectUtils',
'../../../../src/api/objects/object-utils',
'lodash'
], function (
objectUtils,
@@ -191,7 +191,7 @@ define([
}
var domainObject = objectUtils.toNewFormat(model, id);
var composition = this.openmct.composition.registry.find(p => {
var composition = _.find(this.openmct.composition.registry, function (p) {
return p.appliesTo(domainObject);
});

View File

@@ -25,7 +25,7 @@
*/
define(
[
'objectUtils',
'../../../src/api/objects/object-utils',
'lodash'
],
function (
@@ -235,7 +235,7 @@ define(
var defaultRange = metadata.valuesForHints(['range'])[0];
defaultRange = defaultRange ? defaultRange.key : undefined;
var sourceMap = _.keyBy(metadata.values(), 'key');
var sourceMap = _.indexBy(metadata.values(), 'key');
var isLegacyProvider = telemetryAPI.findRequestProvider(domainObject) ===
telemetryAPI.legacyProvider;
@@ -300,7 +300,7 @@ define(
var defaultRange = metadata.valuesForHints(['range'])[0];
defaultRange = defaultRange ? defaultRange.key : undefined;
var sourceMap = _.keyBy(metadata.values(), 'key');
var sourceMap = _.indexBy(metadata.values(), 'key');
var isLegacyProvider = telemetryAPI.findSubscriptionProvider(domainObject) ===
telemetryAPI.legacyProvider;

View File

@@ -28,7 +28,7 @@ define([
'./api/api',
'./api/overlays/OverlayAPI',
'./selection/Selection',
'objectUtils',
'./api/objects/object-utils',
'./plugins/plugins',
'./adapter/indicators/legacy-indicators-plugin',
'./plugins/buildInfo/plugin',
@@ -249,7 +249,7 @@ define([
this.legacyRegistry = new BundleRegistry();
installDefaultBundles(this.legacyRegistry);
// Plugins that are installed by default
// Plugin's that are installed by default
this.install(this.plugins.Plot());
this.install(this.plugins.TelemetryTable());
@@ -350,13 +350,17 @@ define([
* @param {HTMLElement} [domElement] the DOM element in which to run
* MCT; if undefined, MCT will be run in the body of the document
*/
MCT.prototype.start = function (domElement = document.body, isHeadlessMode = false) {
MCT.prototype.start = function (domElement) {
if (!this.plugins.DisplayLayout._installed) {
this.install(this.plugins.DisplayLayout({
showAsView: ['summary-widget']
}));
}
if (!domElement) {
domElement = document.body;
}
this.element = domElement;
this.legacyExtension('runs', {
@@ -396,31 +400,24 @@ define([
// something has depended upon objectService. Cool, right?
this.$injector.get('objectService');
if (!isHeadlessMode) {
var appLayout = new Vue({
components: {
'Layout': Layout.default
},
provide: {
openmct: this
},
template: '<Layout ref="layout"></Layout>'
});
domElement.appendChild(appLayout.$mount().$el);
var appLayout = new Vue({
components: {
'Layout': Layout.default
},
provide: {
openmct: this
},
template: '<Layout ref="layout"></Layout>'
});
domElement.appendChild(appLayout.$mount().$el);
this.layout = appLayout.$refs.layout;
Browse(this);
}
this.layout = appLayout.$refs.layout;
Browse(this);
this.router.start();
this.emit('start');
}.bind(this));
};
MCT.prototype.startHeadless = function () {
let unreachableNode = document.createElement('div');
return this.start(unreachableNode, true);
}
/**
* Install a plugin in MCT.
*

View File

@@ -21,11 +21,11 @@
*****************************************************************************/
define([
'./MCT',
'./plugins/plugins',
'legacyRegistry',
'testUtils'
], function (plugins, legacyRegistry, testUtils) {
describe("MCT", function () {
'legacyRegistry'
], function (MCT, plugins, legacyRegistry) {
xdescribe("MCT", function () {
var openmct;
var mockPlugin;
var mockPlugin2;
@@ -38,7 +38,7 @@ define([
mockListener = jasmine.createSpy('listener');
oldBundles = legacyRegistry.list();
openmct = testUtils.createOpenMct();
openmct = new MCT();
openmct.install(mockPlugin);
openmct.install(mockPlugin2);
@@ -63,11 +63,8 @@ define([
});
describe("start", function () {
let appHolder;
beforeEach(function (done) {
appHolder = document.createElement("div");
openmct.on('start', done);
openmct.start(appHolder);
beforeEach(function () {
openmct.start();
});
it("calls plugins for configuration", function () {
@@ -78,51 +75,25 @@ define([
it("emits a start event", function () {
expect(mockListener).toHaveBeenCalled();
});
it("Renders the application into the provided container element", function () {
let openMctShellElements = appHolder.querySelectorAll('div.l-shell');
expect(openMctShellElements.length).toBe(1);
});
});
describe("startHeadless", function () {
beforeEach(function (done) {
openmct.on('start', done);
openmct.startHeadless();
});
it("calls plugins for configuration", function () {
expect(mockPlugin).toHaveBeenCalledWith(openmct);
expect(mockPlugin2).toHaveBeenCalledWith(openmct);
});
it("emits a start event", function () {
expect(mockListener).toHaveBeenCalled();
});
it("Does not render Open MCT", function () {
let openMctShellElements = document.body.querySelectorAll('div.l-shell');
expect(openMctShellElements.length).toBe(0);
});
});
describe("setAssetPath", function () {
var testAssetPath;
beforeEach(function () {
openmct.legacyExtension = jasmine.createSpy('legacyExtension');
});
it("configures the path for assets", function () {
testAssetPath = "some/path/";
openmct.setAssetPath(testAssetPath);
expect(openmct.getAssetPath()).toBe(testAssetPath);
});
it("adds a trailing /", function () {
testAssetPath = "some/path";
openmct.legacyExtension = jasmine.createSpy('legacyExtension');
openmct.setAssetPath(testAssetPath);
expect(openmct.getAssetPath()).toBe(testAssetPath + "/");
});
it("internally configures the path for assets", function () {
expect(openmct.legacyExtension).toHaveBeenCalledWith(
'constants',
{
key: "ASSETS_PATH",
value: testAssetPath
}
);
});
});
});

View File

@@ -21,7 +21,7 @@
*****************************************************************************/
define([
'objectUtils'
'../../api/objects/object-utils'
], function (objectUtils) {
function ActionDialogDecorator(mct, actionService) {
this.mct = mct;

View File

@@ -20,7 +20,7 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
define(['objectUtils'], function (objectUtils) {
define(['../../api/objects/object-utils'], function (objectUtils) {
function AdapterCapability(domainObject) {
this.domainObject = domainObject;
}

View File

@@ -24,7 +24,7 @@
* Module defining AlternateCompositionCapability. Created by vwoeltje on 11/7/14.
*/
define([
'objectUtils',
'../../api/objects/object-utils',
'../../../platform/core/src/capabilities/ContextualDomainObject'
], function (objectUtils, ContextualDomainObject) {
function AlternateCompositionCapability($injector, domainObject) {

View File

@@ -31,7 +31,6 @@ define([
var capability = viewConstructor(domainObject);
var oldInvoke = capability.invoke.bind(capability);
/* eslint-disable you-dont-need-lodash-underscore/map */
capability.invoke = function () {
var availableViews = oldInvoke();
var newDomainObject = capability
@@ -53,8 +52,6 @@ define([
.map('view')
.value();
};
/* eslint-enable you-dont-need-lodash-underscore/map */
return capability;
};
}

View File

@@ -22,7 +22,7 @@
define([
'../capabilities/AlternateCompositionCapability',
'objectUtils'
'../../api/objects/object-utils'
], function (
AlternateCompositionCapability,
objectUtils

View File

@@ -21,7 +21,7 @@
*****************************************************************************/
define([
'objectUtils'
'../../api/objects/object-utils'
], function (
utils
) {

View File

@@ -78,7 +78,7 @@ define([
};
TimeSettingsURLHandler.prototype.parseQueryParams = function () {
var searchParams = _.pick(this.$location.search(), Object.values(SEARCH));
var searchParams = _.pick(this.$location.search(), _.values(SEARCH));
var parsedParams = {
clock: searchParams[SEARCH.MODE],
timeSystem: searchParams[SEARCH.TIME_SYSTEM]

View File

@@ -21,7 +21,7 @@
*****************************************************************************/
define([
'objectUtils'
'../../api/objects/object-utils'
], function (
utils
) {

View File

@@ -21,7 +21,7 @@
*****************************************************************************/
define([
'objectUtils'
'../../api/objects/object-utils'
], function (
objectUtils
) {

View File

@@ -1,7 +1,7 @@
define([
'./LegacyViewProvider',
'./TypeInspectorViewProvider',
'objectUtils'
'../../api/objects/object-utils'
], function (
LegacyViewProvider,
TypeInspectorViewProvider,

View File

@@ -70,7 +70,7 @@ define([
* @memberof module:openmct.CompositionAPI#
*/
CompositionAPI.prototype.get = function (domainObject) {
var provider = this.registry.find(p => {
var provider = _.find(this.registry, function (p) {
return p.appliesTo(domainObject);
});

View File

@@ -122,7 +122,7 @@ define([
throw new Error('Event not supported by composition: ' + event);
}
var index = this.listeners[event].findIndex(l => {
var index = _.findIndex(this.listeners[event], function (l) {
return l.callback === callback && l.context === context;
});

View File

@@ -22,7 +22,7 @@
define([
'lodash',
'objectUtils'
'../objects/object-utils'
], function (
_,
objectUtils
@@ -143,7 +143,7 @@ define([
var keyString = objectUtils.makeKeyString(domainObject.identifier);
var objectListeners = this.listeningTo[keyString];
var index = objectListeners[event].findIndex(l => {
var index = _.findIndex(objectListeners[event], function (l) {
return l.callback === callback && l.context === context;
});
@@ -196,8 +196,8 @@ define([
* @private
*/
DefaultCompositionProvider.prototype.includes = function (parent, childId) {
return parent.composition.some(composee =>
this.publicAPI.objects.areIdsEqual(composee, childId));
return parent.composition.findIndex(composee =>
this.publicAPI.objects.areIdsEqual(composee, childId)) !== -1;
};
DefaultCompositionProvider.prototype.reorder = function (domainObject, oldIndex, newIndex) {

View File

@@ -21,7 +21,7 @@
*****************************************************************************/
define([
'objectUtils',
'./object-utils.js',
'lodash'
], function (
utils,

View File

@@ -22,7 +22,7 @@
define([
'lodash',
'objectUtils',
'./object-utils',
'./MutableObject',
'./RootRegistry',
'./RootObjectProvider',

View File

@@ -43,7 +43,7 @@ define([
}
RootRegistry.prototype.addRoot = function (key) {
if (isKey(key) || (Array.isArray(key) && key.every(isKey))) {
if (isKey(key) || (_.isArray(key) && _.every(key, isKey))) {
this.providers.push(function () {
return key;
});

View File

@@ -1,5 +1,5 @@
define([
'objectUtils'
'../object-utils'
], function (
objectUtils
) {

View File

@@ -85,9 +85,9 @@ define([
value: +e.value
};
}), 'e.value');
valueMetadata.values = valueMetadata.enumerations.map(e => e.value);
valueMetadata.max = Math.max(valueMetadata.values);
valueMetadata.min = Math.min(valueMetadata.values);
valueMetadata.values = _.pluck(valueMetadata.enumerations, 'value');
valueMetadata.max = _.max(valueMetadata.values);
valueMetadata.min = _.min(valueMetadata.values);
}
valueMetadatas.push(valueMetadata);
@@ -103,7 +103,7 @@ define([
var metadata = domainObject.telemetry || {};
if (this.typeHasTelemetry(domainObject)) {
var typeMetadata = this.typeService.getType(domainObject.type).typeDef.telemetry;
Object.assign(metadata, typeMetadata);
_.extend(metadata, typeMetadata);
if (!metadata.values) {
metadata.values = valueMetadatasFromOldFormat(metadata);
}

View File

@@ -24,7 +24,7 @@ define([
'./TelemetryMetadataManager',
'./TelemetryValueFormatter',
'./DefaultMetadataProvider',
'objectUtils',
'../objects/object-utils',
'lodash'
], function (
TelemetryMetadataManager,
@@ -370,7 +370,7 @@ define([
TelemetryAPI.prototype.commonValuesForHints = function (metadatas, hints) {
var options = metadatas.map(function (metadata) {
var values = metadata.valuesForHints(hints);
return _.keyBy(values, 'key');
return _.indexBy(values, 'key');
}).reduce(function (a, b) {
var results = {};
Object.keys(a).forEach(function (key) {
@@ -383,7 +383,7 @@ define([
var sortKeys = hints.map(function (h) {
return 'hints.' + h;
});
return _.sortBy(options, sortKeys);
return _.sortByAll(options, sortKeys);
};
/**

View File

@@ -57,13 +57,13 @@ define([
if (valueMetadata.format === 'enum') {
if (!valueMetadata.values) {
valueMetadata.values = valueMetadata.enumerations.map(e => e.value);
valueMetadata.values = _.pluck(valueMetadata.enumerations, 'value');
}
if (!valueMetadata.hasOwnProperty('max')) {
valueMetadata.max = Math.max(valueMetadata.values) + 1;
valueMetadata.max = _.max(valueMetadata.values) + 1;
}
if (!valueMetadata.hasOwnProperty('min')) {
valueMetadata.min = Math.min(valueMetadata.values) - 1;
valueMetadata.min = _.min(valueMetadata.values) - 1;
}
}
@@ -121,7 +121,7 @@ define([
return metadata.hints[hint];
}
});
return _.sortBy(matchingMetadata, ...iteratees);
return _.sortByAll(matchingMetadata, ...iteratees);
};
TelemetryMetadataManager.prototype.getFilterableValues = function () {

View File

@@ -75,7 +75,7 @@ export default {
this.items.push(item);
},
removeItem(identifier) {
let index = this.items.findIndex(item => this.openmct.objects.makeKeyString(identifier) === item.key);
let index = _.findIndex(this.items, (item) => this.openmct.objects.makeKeyString(identifier) === item.key);
this.items.splice(index, 1);
},

View File

@@ -102,7 +102,7 @@ export default {
this.compositions.push({composition, addCallback, removeCallback});
},
removePrimary(identifier) {
let index = this.primaryTelemetryObjects.findIndex(primary => this.openmct.objects.makeKeyString(identifier) === primary.key),
let index = _.findIndex(this.primaryTelemetryObjects, (primary) => this.openmct.objects.makeKeyString(identifier) === primary.key),
primary = this.primaryTelemetryObjects[index];
this.$set(this.secondaryTelemetryObjects, primary.key, undefined);
@@ -130,7 +130,7 @@ export default {
removeSecondary(primary) {
return (identifier) => {
let array = this.secondaryTelemetryObjects[primary.key],
index = array.findIndex(secondary => this.openmct.objects.makeKeyString(identifier) === secondary.key);
index = _.findIndex(array, (secondary) => this.openmct.objects.makeKeyString(identifier) === secondary.key);
array.splice(index, 1);

View File

@@ -70,18 +70,15 @@ export default class ConditionClass extends EventEmitter {
return;
}
if (this.isTelemetryUsed(datum.id)) {
this.criteria.forEach(criterion => {
if (this.isAnyOrAllTelemetry(criterion)) {
criterion.getResult(datum, this.conditionManager.telemetryObjects);
} else {
criterion.getResult(datum);
}
});
this.criteria.forEach(criterion => {
if (this.isAnyOrAllTelemetry(criterion)) {
criterion.getResult(datum, this.conditionManager.telemetryObjects);
} else {
criterion.getResult(datum);
}
});
this.result = evaluateResults(this.criteria.map(criterion => criterion.result), this.trigger);
}
this.result = evaluateResults(this.criteria.map(criterion => criterion.result), this.trigger);
}
isAnyOrAllTelemetry(criterion) {

View File

@@ -47,24 +47,17 @@ describe("The condition", function () {
name: "Test Object",
telemetry: {
values: [{
key: "value",
name: "Value",
hints: {
range: 2
}
},
{
key: "utc",
name: "Time",
format: "utc",
key: "some-key",
name: "Some attribute",
hints: {
domain: 1
}
}, {
key: "testSource",
source: "value",
name: "Test",
format: "string"
key: "some-other-key",
name: "Another attribute",
hints: {
range: 1
}
}]
}
};
@@ -143,38 +136,4 @@ describe("The condition", function () {
expect(result).toBeTrue();
expect(conditionObj.criteria.length).toEqual(0);
});
it("gets the result of a condition when new telemetry data is received", function () {
conditionObj.getResult({
value: '0',
utc: 'Hi',
id: testTelemetryObject.identifier.key
});
expect(conditionObj.result).toBeTrue();
});
it("gets the result of a condition when new telemetry data is received", function () {
conditionObj.getResult({
value: '1',
utc: 'Hi',
id: testTelemetryObject.identifier.key
});
expect(conditionObj.result).toBeFalse();
});
it("keeps the old result new telemetry data is not used by it", function () {
conditionObj.getResult({
value: '0',
utc: 'Hi',
id: testTelemetryObject.identifier.key
});
expect(conditionObj.result).toBeTrue();
conditionObj.getResult({
value: '1',
utc: 'Hi',
id: '1234'
});
expect(conditionObj.result).toBeTrue();
});
});

View File

@@ -200,7 +200,7 @@ export default {
this.$emit('telemetryUpdated', this.telemetryObjs);
},
removeTelemetryObject(identifier) {
let index = this.telemetryObjs.findIndex(obj => {
let index = _.findIndex(this.telemetryObjs, (obj) => {
let objId = this.openmct.objects.makeKeyString(obj.identifier);
let id = this.openmct.objects.makeKeyString(identifier);
return objId === id;

View File

@@ -108,7 +108,6 @@ import ConditionError from "@/plugins/condition/components/ConditionError.vue";
import Vue from 'vue';
import PreviewAction from "@/ui/preview/PreviewAction.js";
import {getApplicableStylesForItem} from "@/plugins/condition/utils/styleUtils";
import isEmpty from 'lodash/isEmpty';
export default {
name: 'ConditionalStylesView',
@@ -289,7 +288,7 @@ export default {
delete domainObjectStyles[this.itemId].conditionSetIdentifier;
domainObjectStyles[this.itemId].styles = undefined;
delete domainObjectStyles[this.itemId].styles;
if (isEmpty(domainObjectStyles[this.itemId])) {
if (_.isEmpty(domainObjectStyles[this.itemId])) {
delete domainObjectStyles[this.itemId];
}
} else {
@@ -300,7 +299,7 @@ export default {
domainObjectStyles.styles = undefined;
delete domainObjectStyles.styles;
}
if (isEmpty(domainObjectStyles)) {
if (_.isEmpty(domainObjectStyles)) {
domainObjectStyles = undefined;
}
@@ -338,7 +337,7 @@ export default {
delete domainObjectStyles[this.itemId];
}
});
if (isEmpty(domainObjectStyles)) {
if (_.isEmpty(domainObjectStyles)) {
domainObjectStyles = undefined;
}
this.persist(domainObjectStyles);

View File

@@ -50,7 +50,6 @@
import StyleEditor from "./StyleEditor.vue";
import PreviewAction from "@/ui/preview/PreviewAction.js";
import { getApplicableStylesForItem, getConsolidatedStyleValues, getConditionalStyleForItem } from "@/plugins/condition/utils/styleUtils";
import isEmpty from 'lodash/isEmpty';
export default {
name: 'MultiSelectStylesView',
@@ -179,7 +178,7 @@ export default {
domainObjectStyles[itemId] = undefined;
delete domainObjectStyles[this.itemId];
if (isEmpty(domainObjectStyles)) {
if (_.isEmpty(domainObjectStyles)) {
domainObjectStyles = undefined;
}
this.persist(this.domainObject, domainObjectStyles);
@@ -240,7 +239,7 @@ export default {
if (this.isStaticAndConditionalStyles) {
this.removeConditionalStyles(domainObjectStyles, item.id);
}
if (isEmpty(itemStaticStyle)) {
if (_.isEmpty(itemStaticStyle)) {
itemStaticStyle = undefined;
domainObjectStyles[item.id] = undefined;
} else {

View File

@@ -20,21 +20,25 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
import { createOpenMct } from "testUtils";
import { createOpenMct } from "testTools";
import ConditionPlugin from "./plugin";
let openmct = createOpenMct();
openmct.install(new ConditionPlugin());
let conditionSetDefinition;
let mockConditionSetDomainObject;
let element;
let child;
describe('the plugin', function () {
let conditionSetDefinition;
let mockConditionSetDomainObject;
let element;
let child;
let openmct;
beforeAll((done) => {
openmct = createOpenMct();
openmct.install(new ConditionPlugin());
conditionSetDefinition = openmct.types.get('conditionSet').definition;
const appHolder = document.createElement('div');
appHolder.style.width = '640px';
appHolder.style.height = '480px';
element = document.createElement('div');
child = document.createElement('div');
@@ -51,7 +55,7 @@ describe('the plugin', function () {
conditionSetDefinition.initialize(mockConditionSetDomainObject);
openmct.on('start', done);
openmct.startHeadless();
openmct.start(appHolder);
});
let mockConditionSetObject = {

View File

@@ -20,6 +20,8 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
import _ from 'lodash';
const convertToNumbers = (input) => {
let numberInputs = [];
input.forEach(inputValue => numberInputs.push(Number(inputValue)));
@@ -255,7 +257,7 @@ export const OPERATIONS = [
const lhsValue = input[0] !== undefined ? input[0].toString() : '';
if (input[1]) {
const values = input[1].split(',');
return values.find((value) => lhsValue === value.toString().trim());
return values.find((value) => lhsValue === _.trim(value.toString()));
}
return false;
},
@@ -272,7 +274,7 @@ export const OPERATIONS = [
const lhsValue = input[0] !== undefined ? input[0].toString() : '';
if (input[1]) {
const values = input[1].split(',');
const found = values.find((value) => lhsValue === value.toString().trim());
const found = values.find((value) => lhsValue === _.trim(value.toString()));
return !found;
}
return false;

View File

@@ -19,8 +19,6 @@
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
import isEmpty from 'lodash/isEmpty';
const NONE_VALUE = '__no_value';
const styleProps = {
@@ -156,7 +154,7 @@ export const getApplicableStylesForItem = (domainObject, item) => {
};
export const getStylesWithoutNoneValue = (style) => {
if (isEmpty(style) || !style) {
if (_.isEmpty(style) || !style) {
return;
}
let styleObj = {};

View File

@@ -68,6 +68,7 @@
<script>
import uuid from 'uuid';
import SubobjectView from './SubobjectView.vue'
import TelemetryView from './TelemetryView.vue'
import BoxView from './BoxView.vue'
@@ -75,7 +76,6 @@ import TextView from './TextView.vue'
import LineView from './LineView.vue'
import ImageView from './ImageView.vue'
import EditMarquee from './EditMarquee.vue'
import _ from 'lodash'
const ITEM_TYPE_VIEW_MAP = {
'subobject-view': SubobjectView,
@@ -512,7 +512,7 @@ export default {
}
},
updateTelemetryFormat(item, format) {
let index = this.layoutItems.findIndex(item);
let index = _.findIndex(this.layoutItems, item);
item.format = format;
this.mutate(`configuration.items[${index}]`, item);
}

View File

@@ -40,7 +40,6 @@
<script>
import LayoutDrag from './../LayoutDrag'
import _ from 'lodash'
export default {
inject: ['openmct'],

View File

@@ -62,7 +62,6 @@
<script>
import conditionalStylesMixin from "../mixins/objectStyles-mixin";
import _ from 'lodash';
const START_HANDLE_QUADRANTS = {
1: 'c-frame-edit__handle--sw',

View File

@@ -22,7 +22,7 @@
import Layout from './components/DisplayLayout.vue'
import Vue from 'vue'
import objectUtils from 'objectUtils'
import objectUtils from '../../api/objects/object-utils.js'
import DisplayLayoutType from './DisplayLayoutType.js'
import DisplayLayoutToolbar from './DisplayLayoutToolbar.js'
import AlphaNumericFormatViewProvider from './AlphanumericFormatViewProvider.js'

View File

@@ -62,7 +62,6 @@
<script>
import FilterField from './FilterField.vue';
import ToggleSwitch from '../../../ui/components/ToggleSwitch.vue';
import isEmpty from 'lodash/isEmpty';
export default {
inject: ['openmct'],
@@ -103,7 +102,7 @@ export default {
hasActiveFilters() {
// Should be true when the user has entered any filter values.
return Object.values(this.persistedFilters).some(comparator => {
return (typeof(comparator) === 'object' && !isEmpty(comparator));
return (typeof(comparator) === 'object' && !_.isEmpty(comparator));
});
}
},

View File

@@ -27,8 +27,7 @@
<script>
import FilterObject from './FilterObject.vue';
import GlobalFilters from './GlobalFilters.vue';
import _ from 'lodash';
import GlobalFilters from './GlobalFilters.vue'
const FILTER_VIEW_TITLE = 'Filters applied';
const FILTER_VIEW_TITLE_MIXED = 'Mixed filters applied';

View File

@@ -64,7 +64,6 @@
<script>
import compositionLoader from './composition-loader';
import ListItem from './ListItem.vue';
import _ from 'lodash';
export default {
components: {ListItem},

View File

@@ -220,7 +220,7 @@ export default {
return;
}
const index = _.sortedIndexBy(this.imageHistory, datum, this.timeFormat.format.bind(this.timeFormat));
const index = _.sortedIndex(this.imageHistory, datum, this.timeFormat.format.bind(this.timeFormat));
this.imageHistory.splice(index, 0, datum);
},
updateValues(datum) {

View File

@@ -172,7 +172,6 @@ export default {
&& this.embed.bounds.end !== bounds.end;
const isFixedTimespanMode = !this.openmct.time.clock();
this.openmct.time.stopClock();
window.location.href = link;
let message = '';

View File

@@ -152,7 +152,7 @@ function (
MCTChartController.prototype.destroy = function () {
this.isDestroyed = true;
this.stopListening();
this.lines.forEach(line => line.destroy());
_.invoke(this.lines, 'destroy');
DrawLoader.releaseDrawAPI(this.drawAPI);
};

View File

@@ -44,7 +44,7 @@ define([
this.initialize(options);
}
Object.assign(Collection.prototype, EventEmitter.prototype);
_.extend(Collection.prototype, EventEmitter.prototype);
eventHelpers.extend(Collection.prototype);
Collection.extend = extend;
@@ -105,7 +105,12 @@ define([
};
Collection.prototype.indexOf = function (model) {
return this.models.findIndex(m => m === model);
return _.findIndex(
this.models,
function (m) {
return m === model;
}
);
};
Collection.prototype.remove = function (model) {

View File

@@ -49,7 +49,7 @@ define([
this.initialize(options);
}
Object.assign(Model.prototype, EventEmitter.prototype);
_.extend(Model.prototype, EventEmitter.prototype);
eventHelpers.extend(Model.prototype);
Model.extend = extend;

View File

@@ -146,7 +146,7 @@ define([
strategy = 'minmax';
}
options = Object.assign({}, { size: 1000, strategy, filters: this.filters }, options || {});
options = _.extend({}, { size: 1000, strategy, filters: this.filters }, options || {});
if (!this.unsubscribe) {
this.unsubscribe = this.openmct
@@ -160,7 +160,6 @@ define([
);
}
/* eslint-disable you-dont-need-lodash-underscore/concat */
return this.openmct
.telemetry
.request(this.domainObject, options)
@@ -172,7 +171,6 @@ define([
.value();
this.reset(newPoints);
}.bind(this));
/* eslint-enable you-dont-need-lodash-underscore/concat */
},
/**
* Update x formatter on x change.
@@ -272,7 +270,7 @@ define([
* @private
*/
sortedIndex: function (point) {
return _.sortedIndexBy(this.data, point, this.getXVal);
return _.sortedIndex(this.data, point, this.getXVal);
},
/**
* Update min/max stats for the series.
@@ -324,15 +322,7 @@ 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]);
if (this.isValueInvalid(currentYVal) && this.isValueInvalid(lastYVal)) {
console.warn('[Plot] Invalid Y Values detected');
return;
}
var insertIndex = this.data.length;
if (!appendOnly) {
insertIndex = this.sortedIndex(point);
if (this.getXVal(this.data[insertIndex]) === this.getXVal(point)) {
@@ -342,21 +332,11 @@ define([
return;
}
}
this.updateStats(point);
point.mctLimitState = this.evaluate(point);
this.data.splice(insertIndex, 0, point);
this.emit('add', point, insertIndex, this);
},
/**
*
* @private
*/
isValueInvalid: function (val) {
return Number.isNaN(val) || val === undefined;
},
/**
* Remove a point from the data array and notify listeners.
* @private

View File

@@ -101,11 +101,11 @@ define([
var plotObject = this.plot.get('domainObject');
if (plotObject.type === 'telemetry.plot.overlay') {
var persistedIndex = plotObject.configuration.series.findIndex(s => {
var persistedIndex = _.findIndex(plotObject.configuration.series, function (s) {
return _.isEqual(identifier, s.identifier);
});
var configIndex = this.models.findIndex(m => {
var configIndex = _.findIndex(this.models, function (m) {
return _.isEqual(m.domainObject.identifier, identifier);
});

View File

@@ -182,23 +182,6 @@ define([
this.set('format', yFormat.format.bind(yFormat));
this.set('values', yMetadata.values);
if (!label) {
var labelName = series.map(function (s) {
return s.metadata.value(s.get('yKey')).name;
}).reduce(function (a, b) {
if (a === undefined) {
return b;
}
if (a === b) {
return a;
}
return '';
}, undefined);
if (labelName) {
this.set('label', labelName);
return;
}
var labelUnits = series.map(function (s) {
return s.metadata.value(s.get('yKey')).units;
}).reduce(function (a, b) {
@@ -210,11 +193,22 @@ define([
}
return '';
}, undefined);
if (labelUnits) {
this.set('label', labelUnits);
return;
}
var labelName = series.map(function (s) {
return s.metadata.value(s.get('yKey')).name;
}).reduce(function (a, b) {
if (a === undefined) {
return b;
}
if (a === b) {
return a;
}
return '';
}, undefined);
this.set('label', labelName);
}
},
defaults: function (options) {

View File

@@ -51,7 +51,7 @@ define([
}
}
Object.assign(Draw2D.prototype, EventEmitter.prototype);
_.extend(Draw2D.prototype, EventEmitter.prototype);
eventHelpers.extend(Draw2D.prototype);
// Convert from logical to physical x coordinates

View File

@@ -78,7 +78,7 @@ define([
this.listenTo(this.canvas, "webglcontextlost", this.onContextLost, this);
}
Object.assign(DrawWebGL.prototype, EventEmitter.prototype);
_.extend(DrawWebGL.prototype, EventEmitter.prototype);
eventHelpers.extend(DrawWebGL.prototype);
DrawWebGL.prototype.onContextLost = function (event) {

View File

@@ -23,7 +23,7 @@
define([
'../configuration/configStore',
'../lib/eventHelpers',
'objectUtils',
'../../../../api/objects/object-utils',
'lodash'
], function (
configStore,

View File

@@ -31,7 +31,7 @@ define([
function dynamicPathForKey(key) {
return function (object, model) {
var modelIdentifier = model.get('identifier');
var index = object.configuration.series.findIndex(s => {
var index = _.findIndex(object.configuration.series, function (s) {
return _.isEqual(s.identifier, modelIdentifier);
});
return 'configuration.series[' + index + '].' + key;

View File

@@ -73,10 +73,10 @@ define([
if (range.max === '' || range.max === null || typeof range.max === 'undefined') {
return 'Must specify Maximum';
}
if (Number.isNaN(Number(range.min))) {
if (_.isNaN(Number(range.min))) {
return 'Minimum must be a number.';
}
if (Number.isNaN(Number(range.max))) {
if (_.isNaN(Number(range.max))) {
return 'Maximum must be a number.';
}
if (Number(range.min) > Number(range.max)) {

View File

@@ -325,7 +325,7 @@ define([
} else {
// A history entry is created by startMarquee, need to remove
// if marquee zoom doesn't occur.
this.plotHistory.pop();
this.back();
}
this.$scope.rectangles = [];
this.marquee = undefined;

View File

@@ -76,7 +76,7 @@ define([
if (childObj) {
var index = telemetryObjects.indexOf(childObj);
telemetryObjects.splice(index, 1);
$scope.$broadcast('plot:tickWidth', Math.max(...Object.values(tickWidthMap)));
$scope.$broadcast('plot:tickWidth', _.max(tickWidthMap));
}
}

View File

@@ -51,7 +51,8 @@ define([
'./conditionWidget/plugin',
'./themes/espresso',
'./themes/maelstrom',
'./themes/snow'
'./themes/snow',
'./windowLayout/plugin'
], function (
_,
UTCTimeSystem,
@@ -83,7 +84,8 @@ define([
ConditionWidgetPlugin,
Espresso,
Maelstrom,
Snow
Snow,
WindowLayout
) {
var bundleMap = {
LocalStorage: 'platform/persistence/local',
@@ -192,6 +194,7 @@ define([
plugins.Snow = Snow.default;
plugins.Condition = ConditionPlugin.default;
plugins.ConditionWidget = ConditionWidgetPlugin.default;
plugins.WindowLayout = WindowLayout.default;
return plugins;
});

View File

@@ -1,5 +1,5 @@
define([
'objectUtils'
'../../api/objects/object-utils'
], function (
objectUtils
) {

View File

@@ -1,6 +1,6 @@
define ([
'./ConditionEvaluator',
'objectUtils',
'../../../api/objects/object-utils',
'EventEmitter',
'zepto',
'lodash'
@@ -9,8 +9,7 @@ define ([
objectUtils,
EventEmitter,
$,
_,
_
) {
/**

View File

@@ -5,7 +5,7 @@ define([
'./TestDataManager',
'./WidgetDnD',
'./eventHelpers',
'objectUtils',
'../../../api/objects/object-utils',
'lodash',
'zepto'
], function (

View File

@@ -1,6 +1,6 @@
define([
'./Select',
'objectUtils'
'../../../../api/objects/object-utils'
], function (
Select,
objectUtils

View File

@@ -22,7 +22,7 @@
define([
'./SummaryWidgetEvaluator',
'objectUtils'
'../../../../api/objects/object-utils'
], function (
SummaryWidgetEvaluator,
objectUtils

View File

@@ -23,7 +23,7 @@
define([
'./SummaryWidgetRule',
'../eventHelpers',
'objectUtils',
'../../../../api/objects/object-utils',
'lodash'
], function (
SummaryWidgetRule,
@@ -80,12 +80,10 @@ define([
}
}.bind(this);
/* eslint-disable you-dont-need-lodash-underscore/map */
unsubscribes = _.map(
realtimeStates,
this.subscribeToObjectState.bind(this, updateCallback)
);
/* eslint-enable you-dont-need-lodash-underscore/map */
}.bind(this));
return function () {
@@ -153,13 +151,11 @@ define([
SummaryWidgetEvaluator.prototype.getBaseStateClone = function () {
return this.load()
.then(function () {
/* eslint-disable you-dont-need-lodash-underscore/values */
return _(this.baseState)
.values()
.map(_.clone)
.keyBy('id')
.indexBy('id')
.value();
/* eslint-enable you-dont-need-lodash-underscore/values */
}.bind(this));
};
@@ -186,7 +182,7 @@ define([
* @private.
*/
SummaryWidgetEvaluator.prototype.updateObjectStateFromLAD = function (options, objectState) {
options = Object.assign({}, options, {
options = _.extend({}, options, {
strategy: 'latest',
size: 1
});
@@ -259,12 +255,10 @@ define([
}
}
/* eslint-disable you-dont-need-lodash-underscore/map */
var latestTimestamp = _(state)
.map('timestamps')
.sortBy(timestampKey)
.last();
/* eslint-enable you-dont-need-lodash-underscore/map */
if (!latestTimestamp) {
latestTimestamp = {};

View File

@@ -1,7 +1,7 @@
define([
'../SummaryWidget',
'./SummaryWidgetView',
'objectUtils'
'../../../../api/objects/object-utils'
], function (
SummaryWidgetEditView,
SummaryWidgetView,

View File

@@ -22,7 +22,7 @@
/*jshint latedef: nofunc */
/*global console */
define([
'objectUtils',
'../../../api/objects/object-utils',
'./TelemetryAverager'
], function (objectUtils, TelemetryAverager) {

View File

@@ -21,7 +21,7 @@
*****************************************************************************/
define([
'objectUtils',
'../../api/objects/object-utils',
'./components/table-configuration.vue',
'./TelemetryTableConfiguration',
'vue'

View File

@@ -100,7 +100,7 @@ define([
hasColumnWithKey(columnKey) {
return _.flatten(Object.values(this.columns))
.some(column => column.getKey() === columnKey);
.findIndex(column => column.getKey() === columnKey) !== -1;
}
getColumns() {
@@ -109,10 +109,9 @@ define([
getAllHeaders() {
let flattenedColumns = _.flatten(Object.values(this.columns));
/* eslint-disable you-dont-need-lodash-underscore/uniq */
let headers = _.uniq(flattenedColumns, false, column => column.getKey())
.reduce(fromColumnsToHeadersMap, {});
/* eslint-enable you-dont-need-lodash-underscore/uniq */
function fromColumnsToHeadersMap(headersMap, column) {
headersMap[column.getKey()] = column.getTitle();
return headersMap;

View File

@@ -93,7 +93,7 @@ define(
// same time stamp
let potentialDupes = this.rows.slice(startIx, endIx + 1);
// Search potential dupes for exact dupe
isDuplicate = potentialDupes.some(_.isEqual.bind(undefined, row));
isDuplicate = _.findIndex(potentialDupes, _.isEqual.bind(undefined, row)) > -1;
}
if (!isDuplicate) {
@@ -120,7 +120,7 @@ define(
const firstValue = this.getValueForSortColumn(this.rows[0]);
const lastValue = this.getValueForSortColumn(this.rows[this.rows.length - 1]);
lodashFunction = lodashFunction || _.sortedIndexBy;
lodashFunction = lodashFunction || _.sortedIndex;
if (this.sortOptions.direction === 'asc') {
if (testRowValue > lastValue) {
@@ -201,7 +201,7 @@ define(
sortBy(sortOptions) {
if (arguments.length > 0) {
this.sortOptions = sortOptions;
this.rows = _.orderBy(this.rows, (row) => row.getParsedValue(sortOptions.key) , sortOptions.direction);
this.rows = _.sortByOrder(this.rows, (row) => row.getParsedValue(sortOptions.key) , sortOptions.direction);
this.emit('sort');
}
// Return duplicate to avoid direct modification of underlying object

View File

@@ -17,8 +17,6 @@
</template>
<script>
import _ from 'lodash';
const FILTER_INDICATOR_LABEL = 'Filters:';
const FILTER_INDICATOR_LABEL_MIXED = 'Mixed Filters:';
const FILTER_INDICATOR_TITLE = 'Data filters are being applied to this view.';

View File

@@ -24,39 +24,34 @@ import Vue from 'vue';
import {
createOpenMct,
createMouseEvent
} from 'testUtils';
} from 'testTools';
let openmct;
let tablePlugin;
let element;
let child;
describe("the plugin", () => {
let openmct;
let tablePlugin;
let element;
let child;
beforeEach((done) => {
openmct = createOpenMct();
const appHolder = document.createElement('div');
appHolder.style.width = '640px';
appHolder.style.height = '480px';
// Table Plugin is actually installed by default, but because installing it
// again is harmless it is left here as an examplar for non-default plugins.
tablePlugin = new TablePlugin();
openmct.install(tablePlugin);
openmct = createOpenMct();
element = document.createElement('div');
child = document.createElement('div');
element.appendChild(child);
tablePlugin = new TablePlugin();
openmct.install(tablePlugin);
spyOn(openmct.telemetry, 'request').and.returnValue(Promise.resolve([]));
openmct.on('start', done);
openmct.startHeadless();
openmct.start(appHolder);
});
describe("defines a table object", function () {
it("that is creatable", () => {
let tableType = openmct.types.get('table');
expect(tableType.definition.creatable).toBe(true);
});
})
it("provides a table view for objects with telemetry", () => {
const testTelemetryObject = {
id:"test-object",

View File

@@ -0,0 +1,183 @@
<template>
<div v-if="!isOpener"
class="c-indicator c-indicator--clickable icon-save s-status-caution"
>
<span class="label c-indicator__label">
<button @click="open2Windows">Open 2 Windows</button>
<button @click="closeAllWindows">Close Windows</button>
<button @click="openSavedWindows">Open Saved Windows</button>
</span>
</div>
</template>
<script>
export default {
inject: ['openmct'],
computed: {
isOpener() {
return window.opener;
}
},
mounted() {
this.openWindows = {};
this.windowFeatures = "menubar=yes,location=yes,tabs=yes, resizable=yes,scrollbars=yes, innerHeight=480,innerWidth=640,screenY=100";
window.addEventListener("message", this.receiveMessage, false);
if (window.opener) {
window.opener.postMessage({
status: 'READY',
name: window.name
},'*');
window.addEventListener('beforeunload', () => {
window.opener.postMessage({
status: 'CLOSED',
name: window.name
},'*');
});
window.addEventListener('blur', () => {
window.opener.postMessage({
query: 'QUERY__SIZE',
info: {
innerHeight: window.innerHeight,
innerWidth: window.innerWidth,
screenLeft: window.screenLeft,
screenTop: window.screenTop,
screenWidth: screen.width,
screenHeight: screen.height,
screenAvailableWidth: screen.availWidth,
screenAvailHeight: screen.availHeight,
devicePixelRatio: window.devicePixelRatio,
url: window.location.href
},
name: window.name
},'*');
});
}
},
methods: {
persistWindowInformation() {
window.localStorage.setItem('openmct-windowlayout-items',
JSON.stringify(this.getOpenWindowSpecifications()));
},
getScreenX() {
return !Object.keys(this.openWindows).length ? 100: (screen.width - (Object.keys(this.openWindows).length*640));
},
open2Windows() {
this.openWindow(`${this.windowFeatures},screenX=${this.getScreenX()}`);
this.openWindow(`${this.windowFeatures},screenX=${this.getScreenX()}`);
},
openWindow(windowFeatures) {
let newWindowName = `Open MCT Window ${Object.keys(this.openWindows).length+1}`;
this.openWindows[newWindowName] = { windowReference: window.open(window.location.href, newWindowName, windowFeatures)};
},
moveWindow() {
const key = Object.keys(this.openWindows)[0];
this.openWindows[key].postMessage({
command: 'moveTo',
params: [window.screenLeft + 40, window.screenTop + 40]
}, 'http://localhost:8080');
},
openSavedWindows() {
const persistedWindowObjs = window.localStorage.getItem('openmct-windowlayout-items');
if (persistedWindowObjs) {
const windowObjs = JSON.parse(persistedWindowObjs);
windowObjs.forEach(windowObj => {
let newWindowName = windowObj.name;
const features = `menubar=yes,location=yes,resizable=yes,scrollbars=yes,innerHeight=${windowObj.info.innerHeight || 480},innerWidth=${windowObj.info.innerWidth || 640},screenX=${windowObj.info.screenLeft || this.getScreenX()},screenY=${windowObj.info.screenTop || 100}`;
const windowReference = window.open((windowObj.info.url || window.location.href), newWindowName, features);
this.openWindows[newWindowName] = {
windowReference,
name: newWindowName,
info: windowObj.info
}
});
}
},
closeAllWindows() {
this.persistWindowInformation();
Object.keys(this.openWindows).forEach((windowName => {
const windowObj = this.openWindows[windowName];
windowObj.closedByOpener = true;
windowObj.windowReference.close();
}));
},
receiveMessage(event) {
const { data, origin, source} = event;
switch(origin) {
case 'http://localhost:8080':
if (data) {
if (data.status === 'READY') {
let newWindowReference = this.openWindows[data.name].windowReference;
newWindowReference.postMessage({
command: 'QUERY__SIZE'
}, 'http://localhost:8080');
} else if (data.status === 'CLOSED') {
const closedByOpener = this.openWindows[data.name].closedByOpener;
this.openWindows[data.name] = undefined;
delete this.openWindows[data.name];
if (!closedByOpener) {
this.persistWindowInformation();
}
} else if (data.command) {
switch(data.command) {
case 'QUERY__SIZE':
source.postMessage({
query: data.command,
info: {
innerHeight: window.innerHeight,
innerWidth: window.innerWidth,
screenLeft: window.screenLeft,
screenTop: window.screenTop,
screenWidth: screen.width,
screenHeight: screen.height,
screenAvailableWidth: screen.availWidth,
screenAvailHeight: screen.availHeight,
devicePixelRatio: window.devicePixelRatio,
url: window.location.href
},
name: window.name
}, origin);
break;
default:
window[data.command](...data.params);
this.$nextTick(() => {
source.postMessage({
query: data.command,
name: window.name
}, origin);
});
break;
}
} else if (data.query) {
if (data.info) {
if (!this.openWindows[data.name]) {
return;
}
this.openWindows[data.name].info = data.info;
this.persistWindowInformation();
} else {
if (!this.openWindows[data.name]) {
return;
}
let newWindowReference = this.openWindows[data.name].windowReference;
newWindowReference.postMessage({
command: 'QUERY__SIZE'
}, 'http://localhost:8080');
}
}
}
break;
default:
break;
}
},
getOpenWindowSpecifications() {
return Object.keys(this.openWindows).map(key => {
return {
name: key,
info: this.openWindows[key].info
}
});
}
}
}
</script>

View File

@@ -1,5 +1,5 @@
/*****************************************************************************
* Open MCT, Copyright (c) 2014-2020, United States Government
* Open MCT, Copyright (c) 2014-2019, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
@@ -19,40 +19,25 @@
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
import Vue from 'vue';
import WindowLayout from "./components/WindowLayout.vue";
import NotebookPlugin from './plugin.js';
import {createOpenMct} from "@/testTools";
export default function plugin() {
describe('When the Notebook Snapshot Plugin is installed,', function () {
let openmct = createOpenMct();
return function install(openmct) {
let component = new Vue ({
provide: {
openmct
},
components: {
WindowLayout: WindowLayout
},
template: '<WindowLayout></WindowLayout>'
}),
indicator = {
element: component.$mount().$el
};
const appHolder = document.createElement('div');
appHolder.style.width = '640px';
appHolder.style.height = '480px';
let element = document.createElement('div');
let child = document.createElement('div');
element.appendChild(child);
openmct.install(NotebookPlugin());
let notebookDefinition = openmct.types.get('notebook').definition;
let mockNotebookObject = {
identifier: {
key: 'testNotebookKey',
namespace: ''
},
type: 'notebook'
openmct.indicators.add(indicator);
};
notebookDefinition.initialize(mockNotebookObject);
it('defines a notebook object type with the correct key', () => {
expect(notebookDefinition.key).toEqual(mockNotebookObject.key);
});
it('Global Notebook Indicator is installed', function () {
expect(openmct.indicators.indicatorObjects.length).toEqual(1);
});
});
}

View File

@@ -39,7 +39,7 @@
<script>
import CreateAction from '../../../platform/commonUI/edit/src/creation/CreateAction';
import objectUtils from 'objectUtils';
import objectUtils from '../../api/objects/object-utils';
export default {
inject: ['openmct'],

View File

@@ -42,8 +42,7 @@ const webpackConfig = {
"printj": path.join(__dirname, "node_modules/printj/dist/printj.min.js"),
"styles": path.join(__dirname, "src/styles"),
"MCT": path.join(__dirname, "src/MCT"),
"testUtils": path.join(__dirname, "src/testUtils.js"),
"objectUtils": path.join(__dirname, "src/api/objects/object-utils.js")
"testTools": path.join(__dirname, "src/testTools.js")
}
},
devtool: devMode ? 'eval-source-map' : 'source-map',