Compare commits

...

27 Commits

Author SHA1 Message Date
c46f10de74 add timer plugin 2021-01-11 11:40:11 -08:00
6f51de85db Fix for changed approach to 'type' object (#3636) 2021-01-08 15:27:00 -08:00
f202ae19cb [Search] Index domain object type and provide query lite (index only) option (#3416)
* WIP

* Reverting some files

* reverting

* using type from model, instead of passing in separately

* reverting to remove query lite from search aggregator, as it is no longer necessary

* removing erroneous properties from legacy search results

* removed unnecessary parameters for type since it is included in the model and we have acces too that

* missed one

* removed empty space

* removed unneccessary code

Co-authored-by: Deep Tailor <deep.j.tailor@nasa.gov>
2021-01-08 14:16:01 -08:00
668bd75025 Revert "[Navigation Tree] Whole tree item clickable (#3632)" (#3635)
This reverts commit e6e07cf959.
2021-01-08 12:57:39 -08:00
e6e07cf959 [Navigation Tree] Whole tree item clickable (#3632)
* passing click and context click on tree item down to object label, making the whole tree item interactive

* removed unnecessary code
2021-01-08 11:55:43 -08:00
2f8431905f [Navigation Tree] Fixes initial load navigation request breaks if children haven't loaded in yet (#3630)
* changed logic so people cant navigate up tree til initial load has happened, thus ensuring ancestors have been populated for the first time
2021-01-08 09:38:09 -08:00
23aba14dfe [Notebook] Do not persist notebook objects in notebook Local Storage (#3295)
* [Notebook] Do not persist domain objects on notebooks or snapshots #3291
Co-authored-by: Deep Tailor <deep.j.tailor@nasa.gov>
2021-01-06 15:30:57 -08:00
b0fa955914 [openmct-YAMCS] TelemetryTableRow refactor createNormalizedDatum to include extra datum #3613 (#3614) 2021-01-06 11:38:45 -08:00
98207a3e0d Context click should add a class to tree item (#3619)
* add ability to pass onDestroy callback to menu api show

* fix lint issues

* remove fdescribe

* rename event and variables to contextClickActive

* rename variable to active

* Sanding and polishing CSS related to context-click visual feedback

- Changed CSS `border` approach to `box-shadow` to avoid jumping;
- Removed unwired code and CSS styles for Folder grid and list views;

Co-authored-by: Jamie V <jamie.j.vigliotta@nasa.gov>
Co-authored-by: charlesh88 <charlesh88@gmail.com>
2021-01-04 12:57:18 -08:00
26b81345f2 Various Conditionals bug fixes (#3611)
* Don't apply styles on destroy as destroy should not have any side effects

* Don't show undefined if trigger for condition is not available yet

* Force recalculation of condition result if telemetry is removed

Co-authored-by: Deep Tailor <deep.j.tailor@nasa.gov>
2021-01-04 10:02:43 -08:00
ac2034b243 Adds a simple indicator to display FPS (#3624)
* Adds a simple indicator to display FPS

* ratchet up test coverage threshold
2020-12-28 19:57:36 -08:00
351848ad56 only edit name in browse bar if obj creatable (#3616) 2020-12-22 11:31:30 -08:00
cbac495f93 [LocalTimeSystem] Plugin tests (#3478) 2020-12-18 10:38:02 -08:00
15ef5b7623 [Testing] [Notebook] fix failing notebook tests from three-dot-menu-proto (#3577) 2020-12-18 10:26:20 -08:00
46c7ac944f [Testing] Imagery Plugin Tests (#3606)
* imagery tests initial

* imagery plugin tests

* removing unused code

* added in key events, as well as a utility function for key events

* PR updates
2020-12-18 09:55:51 -08:00
aa4bfab462 Problem copying unitless telemetry values to notebook #3574 (#3589)
Co-authored-by: Jamie V <jamie.j.vigliotta@nasa.gov>
Co-authored-by: Deep Tailor <deep.j.tailor@nasa.gov>
2020-12-18 09:49:08 -08:00
f5cbb37e5a Fix Inspector-based font size and style controls and menus (#3497)
- Moved CSS rule that was pushing the font style control to the right
side of the Inspector to `l-shell__toolbar` rule definition;
- Fixed `menus-to-left` CSS rule and applied to font size and style
menu controls;
- Added a new `menus-no-icon` style for menus that don't have icons,
applied to font size and style menu controls;
2020-12-17 18:43:58 -08:00
8d9079984a [Verve Imagery] Missing JS imagery class (#3603)
* replacing class that was accidentally deleted

* moved to correct div... aye aye ayeee
2020-12-14 15:42:45 -08:00
41783d8939 Fixed minor issues in Code Guidelines (#3596)
There was a missing semi-colon in a code example (oops!) and incorrect capitalization of the `const` keyword (overzealous word processor).
2020-12-11 15:13:51 -08:00
441ad58fe7 Prepare for sprint 1.5.0 (#3594) 2020-12-11 14:12:52 -08:00
06a6a3f773 [Notebook] Link to snapshot should not be a fully qualified url #3445 (#3576)
Co-authored-by: Shefali Joshi <simplyrender@gmail.com>
2020-12-11 09:41:35 -08:00
52fab78625 [Testing] Fixes console errors while running npm test (#3593)
* ERROR: Error: [$injector:unpr] Unknown provider: exportImageServiceProvider <- exportImageService
* [Vue warn]: Injection "stylesManager" not found
* [Vue warn]: Error in mounted hook: "TypeError: identifier is undefined"
2020-12-10 19:44:51 -08:00
5eb6c15959 [Duplicate Action] Fix Display Layout unwanted duplication issue (#3591)
* WIP: refactoring legacy dulicate action

* WIP: debugging duplicate duplicates...

* WIP: fixed duplicate duplicates issue

* added unit tests

* removing old legacy copyaction and renaming duplicate action

* removing fdescribe

* trying to see if a done callback fixes testing issues

* fixed tests

* testing autoflow tests on server

* tweaked autoflow tests to stop failing

* minor updates for new 3 dot menu

* WIP bug fixing

* WIP debugging

* WIP more debuggin

* WIP using parent namespace for all duped objs

* WIP

* WIP
;
;

* cleaning up debugging code

* fixed linting issues

* fixed layout configuration items issue

Co-authored-by: Deep Tailor <deep.j.tailor@nasa.gov>
2020-12-10 09:09:25 -08:00
ce8c31cfa4 [Stacked plots] fixes scroll issue and removed redundant calls to backend (#3585)
* fixes scroll issue and removed redundant calls to backend

* change scroll to auto
2020-12-08 10:10:50 -08:00
d80c0eef8e [Actions] Duplicate Action bug fixes (#3578)
* WIP: refactoring legacy dulicate action

* WIP: debugging duplicate duplicates...

* WIP: fixed duplicate duplicates issue

* added unit tests

* removing old legacy copyaction and renaming duplicate action

* removing fdescribe

* trying to see if a done callback fixes testing issues

* fixed tests

* testing autoflow tests on server

* tweaked autoflow tests to stop failing

* minor updates for new 3 dot menu

* WIP bug fixing

* WIP debugging

* WIP more debuggin

* WIP using parent namespace for all duped objs

* WIP

* WIP
;
;

* cleaning up debugging code

* fixed linting issues

Co-authored-by: Deep Tailor <deep.j.tailor@nasa.gov>
2020-12-07 10:15:41 -08:00
55829dcf05 [Conductor] Remove 24 hour default limit in time conductor (#3512) 2020-12-04 10:34:19 -08:00
d78956327c Action API unit tests (#3527)
* add tests

* add tests for ActionCollection

* add tests for getVisibleActions and getStatusBarActions

Co-authored-by: Shefali Joshi <simplyrender@gmail.com>
2020-12-02 12:53:34 -08:00
50 changed files with 1236 additions and 166 deletions

View File

@ -182,7 +182,7 @@ The following guidelines are provided for anyone contributing source code to the
1. Avoid the use of "magic" values.
eg.
```JavaScript
Const UNAUTHORIZED = 401
const UNAUTHORIZED = 401;
if (responseCode === UNAUTHORIZED)
```
is preferable to

View File

@ -131,10 +131,10 @@
}
],
// maximum recent bounds to retain in conductor history
records: 10,
records: 10
// maximum duration between start and end bounds
// for utc-based time systems this is in milliseconds
limit: ONE_DAY
// limit: ONE_DAY
},
{
name: "Realtime",

View File

@ -86,7 +86,7 @@ module.exports = (config) => {
reports: ['html', 'lcovonly', 'text-summary'],
thresholds: {
global: {
lines: 65
lines: 66
}
}
},

View File

@ -1,6 +1,6 @@
{
"name": "openmct",
"version": "1.4.1-SNAPSHOT",
"version": "1.5.0-SNAPSHOT",
"description": "The Open MCT core platform",
"dependencies": {},
"devDependencies": {

View File

@ -32,7 +32,8 @@
function indexItem(id, model) {
indexedItems.push({
id: id,
name: model.name.toLowerCase()
name: model.name.toLowerCase(),
type: model.type
});
}

View File

@ -125,13 +125,12 @@ define([
* @param topic the topicService.
*/
GenericSearchProvider.prototype.indexOnMutation = function (topic) {
var mutationTopic = topic('mutation'),
provider = this;
let mutationTopic = topic('mutation');
mutationTopic.listen(function (mutatedObject) {
var editor = mutatedObject.getCapability('editor');
mutationTopic.listen(mutatedObject => {
let editor = mutatedObject.getCapability('editor');
if (!editor || !editor.inEditContext()) {
provider.index(
this.index(
mutatedObject.getId(),
mutatedObject.getModel()
);
@ -262,6 +261,7 @@ define([
return {
id: hit.item.id,
model: hit.item.model,
type: hit.item.type,
score: hit.matchCount
};
});

View File

@ -41,7 +41,8 @@
indexedItems.push({
id: id,
vector: vector,
model: model
model: model,
type: model.type
});
}

View File

@ -0,0 +1,225 @@
/*****************************************************************************
* Open MCT, Copyright (c) 2014-2020, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
import ActionCollection from './ActionCollection';
import { createOpenMct, resetApplicationState } from '../../utils/testing';
describe('The ActionCollection', () => {
let openmct;
let actionCollection;
let mockApplicableActions;
let mockObjectPath;
let mockView;
beforeEach(() => {
openmct = createOpenMct();
mockObjectPath = [
{
name: 'mock folder',
type: 'fake-folder',
identifier: {
key: 'mock-folder',
namespace: ''
}
},
{
name: 'mock parent folder',
type: 'fake-folder',
identifier: {
key: 'mock-parent-folder',
namespace: ''
}
}
];
mockView = {
getViewContext: () => {
return {
onlyAppliesToTestCase: true
};
}
};
mockApplicableActions = {
'test-action-object-path': {
name: 'Test Action Object Path',
key: 'test-action-object-path',
cssClass: 'test-action-object-path',
description: 'This is a test action for object path',
group: 'action',
priority: 9,
appliesTo: (objectPath) => {
if (objectPath.length) {
return objectPath[0].type === 'fake-folder';
}
return false;
},
invoke: () => {
}
},
'test-action-view': {
name: 'Test Action View',
key: 'test-action-view',
cssClass: 'test-action-view',
description: 'This is a test action for view',
group: 'action',
priority: 9,
showInStatusBar: true,
appliesTo: (objectPath, view = {}) => {
if (view.getViewContext) {
let viewContext = view.getViewContext();
return viewContext.onlyAppliesToTestCase;
}
return false;
},
invoke: () => {
}
}
};
actionCollection = new ActionCollection(mockApplicableActions, mockObjectPath, mockView, openmct);
});
afterEach(() => {
actionCollection.destroy();
resetApplicationState(openmct);
});
describe("disable method invoked with action keys", () => {
it("marks those actions as isDisabled", () => {
let actionKey = 'test-action-object-path';
let actionsObject = actionCollection.getActionsObject();
let action = actionsObject[actionKey];
expect(action.isDisabled).toBeFalsy();
actionCollection.disable([actionKey]);
actionsObject = actionCollection.getActionsObject();
action = actionsObject[actionKey];
expect(action.isDisabled).toBeTrue();
});
});
describe("enable method invoked with action keys", () => {
it("marks the isDisabled property as false", () => {
let actionKey = 'test-action-object-path';
actionCollection.disable([actionKey]);
let actionsObject = actionCollection.getActionsObject();
let action = actionsObject[actionKey];
expect(action.isDisabled).toBeTrue();
actionCollection.enable([actionKey]);
actionsObject = actionCollection.getActionsObject();
action = actionsObject[actionKey];
expect(action.isDisabled).toBeFalse();
});
});
describe("hide method invoked with action keys", () => {
it("marks those actions as isHidden", () => {
let actionKey = 'test-action-object-path';
let actionsObject = actionCollection.getActionsObject();
let action = actionsObject[actionKey];
expect(action.isHidden).toBeFalsy();
actionCollection.hide([actionKey]);
actionsObject = actionCollection.getActionsObject();
action = actionsObject[actionKey];
expect(action.isHidden).toBeTrue();
});
});
describe("show method invoked with action keys", () => {
it("marks the isHidden property as false", () => {
let actionKey = 'test-action-object-path';
actionCollection.hide([actionKey]);
let actionsObject = actionCollection.getActionsObject();
let action = actionsObject[actionKey];
expect(action.isHidden).toBeTrue();
actionCollection.show([actionKey]);
actionsObject = actionCollection.getActionsObject();
action = actionsObject[actionKey];
expect(action.isHidden).toBeFalse();
});
});
describe("getVisibleActions method", () => {
it("returns an array of non hidden actions", () => {
let action1Key = 'test-action-object-path';
let action2Key = 'test-action-view';
actionCollection.hide([action1Key]);
let visibleActions = actionCollection.getVisibleActions();
expect(Array.isArray(visibleActions)).toBeTrue();
expect(visibleActions.length).toEqual(1);
expect(visibleActions[0].key).toEqual(action2Key);
actionCollection.show([action1Key]);
visibleActions = actionCollection.getVisibleActions();
expect(visibleActions.length).toEqual(2);
});
});
describe("getStatusBarActions method", () => {
it("returns an array of non disabled, non hidden statusBar actions", () => {
let action2Key = 'test-action-view';
let statusBarActions = actionCollection.getStatusBarActions();
expect(Array.isArray(statusBarActions)).toBeTrue();
expect(statusBarActions.length).toEqual(1);
expect(statusBarActions[0].key).toEqual(action2Key);
actionCollection.disable([action2Key]);
statusBarActions = actionCollection.getStatusBarActions();
expect(statusBarActions.length).toEqual(0);
actionCollection.enable([action2Key]);
statusBarActions = actionCollection.getStatusBarActions();
expect(statusBarActions.length).toEqual(1);
expect(statusBarActions[0].key).toEqual(action2Key);
actionCollection.hide([action2Key]);
statusBarActions = actionCollection.getStatusBarActions();
expect(statusBarActions.length).toEqual(0);
});
});
});

View File

@ -22,22 +22,41 @@
import ActionsAPI from './ActionsAPI';
import { createOpenMct, resetApplicationState } from '../../utils/testing';
import ActionCollection from './ActionCollection';
describe('The Actions API', () => {
let openmct;
let actionsAPI;
let mockAction;
let mockObjectPath;
let mockObjectPathAction;
let mockViewContext1;
beforeEach(() => {
openmct = createOpenMct();
actionsAPI = new ActionsAPI(openmct);
mockObjectPathAction = {
name: 'Test Action Object Path',
key: 'test-action-object-path',
cssClass: 'test-action-object-path',
description: 'This is a test action for object path',
group: 'action',
priority: 9,
appliesTo: (objectPath) => {
if (objectPath.length) {
return objectPath[0].type === 'fake-folder';
}
return false;
},
invoke: () => {
}
};
mockAction = {
name: 'Test Action',
key: 'test-action',
cssClass: 'test-action',
description: 'This is a test action',
name: 'Test Action View',
key: 'test-action-view',
cssClass: 'test-action-view',
description: 'This is a test action for view',
group: 'action',
priority: 9,
appliesTo: (objectPath, view = {}) => {
@ -45,8 +64,6 @@ describe('The Actions API', () => {
let viewContext = view.getViewContext();
return viewContext.onlyAppliesToTestCase;
} else if (objectPath.length) {
return objectPath[0].type === 'fake-folder';
}
return false;
@ -100,9 +117,32 @@ describe('The Actions API', () => {
describe("get method", () => {
beforeEach(() => {
actionsAPI.register(mockAction);
actionsAPI.register(mockObjectPathAction);
});
it("returns an object with relevant actions when invoked with objectPath only", () => {
it("returns an ActionCollection when invoked with an objectPath only", () => {
let actionCollection = actionsAPI.get(mockObjectPath);
let instanceOfActionCollection = actionCollection instanceof ActionCollection;
expect(instanceOfActionCollection).toBeTrue();
});
it("returns an ActionCollection when invoked with an objectPath and view", () => {
let actionCollection = actionsAPI.get(mockObjectPath, mockViewContext1);
let instanceOfActionCollection = actionCollection instanceof ActionCollection;
expect(instanceOfActionCollection).toBeTrue();
});
it("returns relevant actions when invoked with objectPath only", () => {
let actionCollection = actionsAPI.get(mockObjectPath);
let action = actionCollection.getActionsObject()[mockObjectPathAction.key];
expect(action.key).toEqual(mockObjectPathAction.key);
expect(action.name).toEqual(mockObjectPathAction.name);
});
it("returns relevant actions when invoked with objectPath and view", () => {
let actionCollection = actionsAPI.get(mockObjectPath, mockViewContext1);
let action = actionCollection.getActionsObject()[mockAction.key];

View File

@ -38,7 +38,7 @@ class MenuAPI {
this._showObjectMenu = this._showObjectMenu.bind(this);
}
showMenu(x, y, actions) {
showMenu(x, y, actions, onDestroy) {
if (this.menuComponent) {
this.menuComponent.dismiss();
}
@ -46,7 +46,8 @@ class MenuAPI {
let options = {
x,
y,
actions
actions,
onDestroy
};
this.menuComponent = new Menu(options);

View File

@ -31,6 +31,7 @@ describe ('The Menu API', () => {
let x;
let y;
let result;
let onDestroy;
beforeEach(() => {
openmct = createOpenMct();
@ -73,7 +74,9 @@ describe ('The Menu API', () => {
let vueComponent;
beforeEach(() => {
menuAPI.showMenu(x, y, actionsArray);
onDestroy = jasmine.createSpy('onDestroy');
menuAPI.showMenu(x, y, actionsArray, onDestroy);
vueComponent = menuAPI.menuComponent.component;
menuComponent = document.querySelector(".c-menu");
@ -120,6 +123,12 @@ describe ('The Menu API', () => {
expect(vueComponent.$destroy).toHaveBeenCalled();
});
it("invokes the onDestroy callback if passed in", () => {
document.body.click();
expect(onDestroy).toHaveBeenCalled();
});
});
});
});

View File

@ -75,7 +75,8 @@ export default class Condition extends EventEmitter {
return;
}
if (this.isTelemetryUsed(datum.id)) {
// if all the criteria in this condition have no telemetry, we want to force the condition result to evaluate
if (this.hasNoTelemetry() || this.isTelemetryUsed(datum.id)) {
this.criteria.forEach(criterion => {
if (this.isAnyOrAllTelemetry(criterion)) {
@ -93,6 +94,12 @@ export default class Condition extends EventEmitter {
return (criterion.telemetry && (criterion.telemetry === 'all' || criterion.telemetry === 'any'));
}
hasNoTelemetry() {
return this.criteria.every((criterion) => {
return !this.isAnyOrAllTelemetry(criterion) && criterion.telemetry === '';
});
}
isTelemetryUsed(id) {
return this.criteria.some(criterion => {
return this.isAnyOrAllTelemetry(criterion) || criterion.telemetryObjectIdAsString === id;
@ -250,10 +257,17 @@ export default class Condition extends EventEmitter {
}
getTriggerDescription() {
return {
conjunction: TRIGGER_CONJUNCTION[this.trigger],
prefix: `${TRIGGER_LABEL[this.trigger]}: `
};
if (this.trigger) {
return {
conjunction: TRIGGER_CONJUNCTION[this.trigger],
prefix: `${TRIGGER_LABEL[this.trigger]}: `
};
} else {
return {
conjunction: '',
prefix: ''
};
}
}
requestLADConditionResult() {

View File

@ -79,6 +79,17 @@ export default class ConditionManager extends EventEmitter {
delete this.subscriptions[id];
delete this.telemetryObjects[id];
this.removeConditionTelemetryObjects();
//force re-computation of condition set result as we might be in a state where
// there is no telemetry datum coming in for a while or at all.
let latestTimestamp = getLatestTimestamp(
{},
{},
this.timeSystems,
this.openmct.time.timeSystem()
);
this.updateConditionResults({id: id});
this.updateCurrentCondition(latestTimestamp);
}
initialize() {
@ -336,14 +347,17 @@ export default class ConditionManager extends EventEmitter {
let timestamp = {};
timestamp[timeSystemKey] = normalizedDatum[timeSystemKey];
this.updateConditionResults(normalizedDatum);
this.updateCurrentCondition(timestamp);
}
updateConditionResults(normalizedDatum) {
//We want to stop when the first condition evaluates to true.
this.conditions.some((condition) => {
condition.updateResult(normalizedDatum);
return condition.result === true;
});
this.updateCurrentCondition(timestamp);
}
updateCurrentCondition(timestamp) {

View File

@ -86,6 +86,7 @@ export default class StyleRuleManager extends EventEmitter {
updateObjectStyleConfig(styleConfiguration) {
if (!styleConfiguration || !styleConfiguration.conditionSetIdentifier) {
this.initialize(styleConfiguration || {});
this.applyStaticStyle();
this.destroy();
} else {
let isNewConditionSet = !this.conditionSetIdentifier
@ -158,7 +159,6 @@ export default class StyleRuleManager extends EventEmitter {
}
destroy() {
this.applyStaticStyle();
if (this.stopProvidingTelemetry) {
this.stopProvidingTelemetry();
delete this.stopProvidingTelemetry;

View File

@ -22,6 +22,7 @@
import { createOpenMct, resetApplicationState } from "utils/testing";
import ConditionPlugin from "./plugin";
import stylesManager from '@/ui/inspector/styles/StylesManager';
import StylesView from "./components/inspector/StylesView.vue";
import Vue from 'vue';
import {getApplicableStylesForItem} from "./utils/styleUtils";
@ -402,7 +403,8 @@ describe('the plugin', function () {
component = new Vue({
provide: {
openmct: openmct,
selection: selection
selection: selection,
stylesManager
},
el: viewContainer,
components: {

View File

@ -233,8 +233,9 @@ export default {
formattedValueForCopy() {
const timeFormatterKey = this.openmct.time.timeSystem().key;
const timeFormatter = this.formats[timeFormatterKey];
const unit = this.unit ? ` ${this.unit}` : '';
return `At ${timeFormatter.format(this.datum)} ${this.domainObject.name} had a value of ${this.telemetryValue} ${this.unit}`;
return `At ${timeFormatter.format(this.datum)} ${this.domainObject.name} had a value of ${this.telemetryValue}${unit}`;
},
requestHistoricalData() {
let bounds = this.openmct.time.bounds();

View File

@ -89,7 +89,7 @@ export default class DuplicateAction {
{
key: "name",
control: "textfield",
name: "Folder Name",
name: "Name",
pattern: "\\S+",
required: true,
cssClass: "l-input-lg"

View File

@ -48,13 +48,14 @@ export default class DuplicateTask {
}
/**
* Execute the duplicate/copy task with the objects provided in the constructor.
* Execute the duplicate/copy task with the objects provided.
* @returns {promise} Which will resolve with a clone of the object
* once complete.
*/
async duplicate(domainObject, parent, filter) {
this.domainObject = domainObject;
this.parent = parent;
this.namespace = parent.identifier.namespace;
this.filter = filter || this.isCreatable;
await this.buildDuplicationPlan();
@ -78,8 +79,9 @@ export default class DuplicateTask {
*/
async buildDuplicationPlan() {
let domainObjectClone = await this.duplicateObject(this.domainObject);
if (domainObjectClone !== this.domainObject) {
domainObjectClone.location = this.getId(this.parent);
domainObjectClone.location = this.getKeyString(this.parent);
}
this.firstClone = domainObjectClone;
@ -96,13 +98,14 @@ export default class DuplicateTask {
let initialCount = this.clones.length;
let dialog = this.openmct.overlays.progressDialog({
progressPerc: 0,
message: `Duplicating ${initialCount} files.`,
message: `Duplicating ${initialCount} objects.`,
iconClass: 'info',
title: 'Duplicating'
});
let clonesDone = Promise.all(this.clones.map(clone => {
let clonesDone = Promise.all(this.clones.map((clone) => {
let percentPersisted = Math.ceil(100 * (++this.persisted / initialCount));
let message = `Duplicating ${initialCount - this.persisted} files.`;
let message = `Duplicating ${initialCount - this.persisted} objects.`;
dialog.updateProgress(percentPersisted, message);
@ -110,6 +113,7 @@ export default class DuplicateTask {
}));
await clonesDone;
dialog.dismiss();
this.openmct.notifications.info(`Duplicated ${this.persisted} objects.`);
@ -141,10 +145,7 @@ export default class DuplicateTask {
async duplicateObject(originalObject) {
// Check if the creatable (or other passed in filter).
if (this.filter(originalObject)) {
// Clone original object
let clone = this.cloneObjectModel(originalObject);
// Get children, if any
let composeesCollection = this.openmct.composition.get(originalObject);
let composees;
@ -152,7 +153,6 @@ export default class DuplicateTask {
composees = await composeesCollection.load();
}
// Recursively duplicate children
return this.duplicateComposees(clone, composees);
}
@ -160,36 +160,6 @@ export default class DuplicateTask {
return originalObject;
}
/**
* Update identifiers in a cloned object model (or part of
* a cloned object model) to reflect new identifiers after
* duplicating.
* @private
*/
rewriteIdentifiers(obj, idMap) {
function lookupValue(value) {
return (typeof value === 'string' && idMap[value]) || value;
}
if (Array.isArray(obj)) {
obj.forEach((value, index) => {
obj[index] = lookupValue(value);
this.rewriteIdentifiers(obj[index], idMap);
});
} else if (obj && typeof obj === 'object') {
Object.keys(obj).forEach((key) => {
let value = obj[key];
obj[key] = lookupValue(value);
if (idMap[key]) {
delete obj[key];
obj[idMap[key]] = value;
}
this.rewriteIdentifiers(value, idMap);
});
}
}
/**
* Given an array of objects composed by a parent, clone them, then
* add them to the parent.
@ -197,34 +167,67 @@ export default class DuplicateTask {
* @returns {*}
*/
async duplicateComposees(clonedParent, composees = []) {
let idMap = {};
let idMappings = [];
let allComposeesDuplicated = composees.reduce(async (previousPromise, nextComposee) => {
await previousPromise;
let clonedComposee = await this.duplicateObject(nextComposee);
idMap[this.getId(nextComposee)] = this.getId(clonedComposee);
await this.composeChild(clonedComposee, clonedParent, clonedComposee !== nextComposee);
if (clonedComposee) {
idMappings.push({
newId: clonedComposee.identifier,
oldId: nextComposee.identifier
});
this.composeChild(clonedComposee, clonedParent, clonedComposee !== nextComposee);
}
return;
}, Promise.resolve());
await allComposeesDuplicated;
this.rewriteIdentifiers(clonedParent, idMap);
clonedParent = this.rewriteIdentifiers(clonedParent, idMappings);
this.clones.push(clonedParent);
return clonedParent;
}
async composeChild(child, parent, setLocation) {
const PERSIST_BOOL = false;
let parentComposition = this.openmct.composition.get(parent);
await parentComposition.load();
parentComposition.add(child, PERSIST_BOOL);
/**
* Update identifiers in a cloned object model (or part of
* a cloned object model) to reflect new identifiers after
* duplicating.
* @private
*/
rewriteIdentifiers(clonedParent, childIdMappings) {
for (let { newId, oldId } of childIdMappings) {
let newIdKeyString = this.openmct.objects.makeKeyString(newId);
let oldIdKeyString = this.openmct.objects.makeKeyString(oldId);
// regex replace keystrings
clonedParent = JSON.stringify(clonedParent).replace(new RegExp(oldIdKeyString, 'g'), newIdKeyString);
// parse reviver to replace identifiers
clonedParent = JSON.parse(clonedParent, (key, value) => {
if (Object.prototype.hasOwnProperty.call(value, 'key')
&& Object.prototype.hasOwnProperty.call(value, 'namespace')
&& value.key === oldId.key
&& value.namespace === oldId.namespace) {
return newId;
} else {
return value;
}
});
}
return clonedParent;
}
composeChild(child, parent, setLocation) {
parent.composition.push(child.identifier);
//If a location is not specified, set it.
if (setLocation && child.location === undefined) {
let parentKeyString = this.getId(parent);
let parentKeyString = this.getKeyString(parent);
child.location = parentKeyString;
}
}
@ -239,7 +242,7 @@ export default class DuplicateTask {
let clone = JSON.parse(JSON.stringify(domainObject));
let identifier = {
key: uuid(),
namespace: domainObject.identifier.namespace
namespace: this.namespace // set to NEW parent's namespace
};
if (clone.modified || clone.persisted || clone.location) {
@ -260,7 +263,7 @@ export default class DuplicateTask {
return clone;
}
getId(domainObject) {
getKeyString(domainObject) {
return this.openmct.objects.makeKeyString(domainObject.identifier);
}

View File

@ -1,7 +1,9 @@
<template>
<tr
class="c-list-item"
:class="{ 'is-alias': item.isAlias === true }"
:class="{
'is-alias': item.isAlias === true
}"
@click="navigate"
>
<td class="c-list-item__name">

View File

@ -36,7 +36,7 @@
<div class="c-imagery__main-image__bg"
:class="{'paused unnsynced': isPaused,'stale':false }"
>
<div class="c-imagery__main-image__image"
<div class="c-imagery__main-image__image js-imageryView-image"
:style="{
'background-image': imageUrl ? `url(${imageUrl})` : 'none',
'filter': `brightness(${filters.brightness}%) contrast(${filters.contrast}%)`

View File

@ -0,0 +1,306 @@
/*****************************************************************************
* Open MCT, Copyright (c) 2014-2020, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
import ImageryPlugin from './plugin.js';
import Vue from 'vue';
import {
createOpenMct,
resetApplicationState,
simulateKeyEvent
} from 'utils/testing';
const ONE_MINUTE = 1000 * 60;
const TEN_MINUTES = ONE_MINUTE * 10;
const MAIN_IMAGE_CLASS = '.js-imageryView-image';
const NEW_IMAGE_CLASS = '.c-imagery__age.c-imagery--new';
const REFRESH_CSS_MS = 500;
function getImageInfo(doc) {
let imageElement = doc.querySelectorAll(MAIN_IMAGE_CLASS)[0];
let timestamp = imageElement.dataset.openmctImageTimestamp;
let identifier = imageElement.dataset.openmctObjectKeystring;
let url = imageElement.style.backgroundImage;
return {
timestamp,
identifier,
url
};
}
function isNew(doc) {
let newIcon = doc.querySelectorAll(NEW_IMAGE_CLASS);
return newIcon.length !== 0;
}
function generateTelemetry(start, count) {
let telemetry = [];
for (let i = 1, l = count + 1; i < l; i++) {
let stringRep = i + 'minute';
let logo = 'images/logo-openmct.svg';
telemetry.push({
"name": stringRep + " Imagery",
"utc": start + (i * ONE_MINUTE),
"url": location.host + '/' + logo + '?time=' + stringRep,
"timeId": stringRep
});
}
return telemetry;
}
describe("The Imagery View Layout", () => {
const imageryKey = 'example.imagery';
const START = Date.now();
const COUNT = 10;
let openmct;
let imageryPlugin;
let parent;
let child;
let timeFormat = 'utc';
let bounds = {
start: START - TEN_MINUTES,
end: START
};
let imageTelemetry = generateTelemetry(START - TEN_MINUTES, COUNT);
let imageryObject = {
identifier: {
namespace: "",
key: "imageryId"
},
name: "Example Imagery",
type: "example.imagery",
location: "parentId",
modified: 0,
persisted: 0,
telemetry: {
values: [
{
"name": "Image",
"key": "url",
"format": "image",
"hints": {
"image": 1,
"priority": 3
},
"source": "url"
},
{
"name": "Name",
"key": "name",
"source": "name",
"hints": {
"priority": 0
}
},
{
"name": "Time",
"key": "utc",
"format": "utc",
"hints": {
"domain": 2,
"priority": 1
},
"source": "utc"
},
{
"name": "Local Time",
"key": "local",
"format": "local-format",
"hints": {
"domain": 1,
"priority": 2
},
"source": "local"
}
]
}
};
// this setups up the app
beforeEach((done) => {
const appHolder = document.createElement('div');
appHolder.style.width = '640px';
appHolder.style.height = '480px';
openmct = createOpenMct();
parent = document.createElement('div');
child = document.createElement('div');
parent.appendChild(child);
spyOn(openmct.telemetry, 'request').and.returnValue(Promise.resolve([]));
imageryPlugin = new ImageryPlugin();
openmct.install(imageryPlugin);
spyOn(openmct.objects, 'get').and.returnValue(Promise.resolve({}));
openmct.time.timeSystem(timeFormat, {
start: 0,
end: 4
});
openmct.on('start', done);
openmct.startHeadless(appHolder);
});
afterEach(() => {
return resetApplicationState(openmct);
});
it("should provide an imagery view only for imagery producing objects", () => {
let applicableViews = openmct.objectViews.get(imageryObject);
let imageryView = applicableViews.find(
viewProvider => viewProvider.key === imageryKey
);
expect(imageryView).toBeDefined();
});
describe("imagery view", () => {
let applicableViews;
let imageryViewProvider;
let imageryView;
beforeEach(async (done) => {
let telemetryRequestResolve;
let telemetryRequestPromise = new Promise((resolve) => {
telemetryRequestResolve = resolve;
});
openmct.telemetry.request.and.callFake(() => {
telemetryRequestResolve(imageTelemetry);
return telemetryRequestPromise;
});
openmct.time.clock('local', {
start: bounds.start,
end: bounds.end + 100
});
applicableViews = openmct.objectViews.get(imageryObject);
imageryViewProvider = applicableViews.find(viewProvider => viewProvider.key === imageryKey);
imageryView = imageryViewProvider.view(imageryObject);
imageryView.show(child);
await telemetryRequestPromise;
await Vue.nextTick();
return done();
});
it("on mount should show the the most recent image", () => {
const imageInfo = getImageInfo(parent);
expect(imageInfo.url.indexOf(imageTelemetry[COUNT - 1].timeId)).not.toEqual(-1);
});
it("should show the clicked thumbnail as the main image", async () => {
const target = imageTelemetry[5].url;
parent.querySelectorAll(`img[src='${target}']`)[0].click();
await Vue.nextTick();
const imageInfo = getImageInfo(parent);
expect(imageInfo.url.indexOf(imageTelemetry[5].timeId)).not.toEqual(-1);
});
it("should show that an image is new", async (done) => {
await Vue.nextTick();
// used in code, need to wait to the 500ms here too
setTimeout(() => {
const imageIsNew = isNew(parent);
expect(imageIsNew).toBeTrue();
done();
}, REFRESH_CSS_MS);
});
it("should show that an image is not new", async (done) => {
const target = imageTelemetry[2].url;
parent.querySelectorAll(`img[src='${target}']`)[0].click();
await Vue.nextTick();
// used in code, need to wait to the 500ms here too
setTimeout(() => {
const imageIsNew = isNew(parent);
expect(imageIsNew).toBeFalse();
done();
}, REFRESH_CSS_MS);
});
it("should navigate via arrow keys", async () => {
let keyOpts = {
element: parent.querySelector('.c-imagery'),
key: 'ArrowLeft',
keyCode: 37,
type: 'keyup'
};
simulateKeyEvent(keyOpts);
await Vue.nextTick();
const imageInfo = getImageInfo(parent);
expect(imageInfo.url.indexOf(imageTelemetry[COUNT - 2].timeId)).not.toEqual(-1);
});
it("should navigate via numerous arrow keys", async () => {
let element = parent.querySelector('.c-imagery');
let type = 'keyup';
let leftKeyOpts = {
element,
type,
key: 'ArrowLeft',
keyCode: 37
};
let rightKeyOpts = {
element,
type,
key: 'ArrowRight',
keyCode: 39
};
// left thrice
simulateKeyEvent(leftKeyOpts);
simulateKeyEvent(leftKeyOpts);
simulateKeyEvent(leftKeyOpts);
// right once
simulateKeyEvent(rightKeyOpts);
await Vue.nextTick();
const imageInfo = getImageInfo(parent);
expect(imageInfo.url.indexOf(imageTelemetry[COUNT - 3].timeId)).not.toEqual(-1);
});
});
});

View File

@ -0,0 +1,114 @@
/*****************************************************************************
* Open MCT, Copyright (c) 2014-2020, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
import {
createOpenMct,
resetApplicationState
} from 'utils/testing';
describe("The local time", () => {
const LOCAL_FORMAT_KEY = 'local-format';
const LOCAL_SYSTEM_KEY = 'local';
const JUNK = "junk";
const TIMESTAMP = -14256000000;
const DATESTRING = '1969-07-20 12:00:00.000 am';
let openmct;
beforeEach((done) => {
openmct = createOpenMct();
openmct.install(openmct.plugins.LocalTimeSystem());
openmct.on('start', done);
openmct.startHeadless();
});
afterEach(() => {
return resetApplicationState(openmct);
});
describe("system", function () {
let localTimeSystem;
beforeEach(() => {
localTimeSystem = openmct.time.timeSystem(LOCAL_SYSTEM_KEY, {
start: 0,
end: 4
});
});
it("is installed", () => {
let timeSystems = openmct.time.getAllTimeSystems();
let local = timeSystems.find(ts => ts.key === LOCAL_SYSTEM_KEY);
expect(local).not.toEqual(-1);
});
it("can be set to be the main time system", () => {
expect(openmct.time.timeSystem().key).toBe(LOCAL_SYSTEM_KEY);
});
it("uses the local-format time format", () => {
expect(localTimeSystem.timeFormat).toBe(LOCAL_FORMAT_KEY);
});
it("is UTC based", () => {
expect(localTimeSystem.isUTCBased).toBe(true);
});
it("defines expected metadata", () => {
expect(localTimeSystem.key).toBe(LOCAL_SYSTEM_KEY);
expect(localTimeSystem.name).toBeDefined();
expect(localTimeSystem.cssClass).toBeDefined();
expect(localTimeSystem.durationFormat).toBeDefined();
});
});
describe("formatter can be obtained from the telemetry API and", () => {
let localTimeFormatter;
let dateString;
let timeStamp;
beforeEach(() => {
localTimeFormatter = openmct.telemetry.getFormatter(LOCAL_FORMAT_KEY);
dateString = localTimeFormatter.format(TIMESTAMP);
timeStamp = localTimeFormatter.parse(DATESTRING);
});
it("will format a timestamp in local time format", () => {
expect(localTimeFormatter.format(TIMESTAMP)).toBe(dateString);
});
it("will parse an local time Date String into milliseconds", () => {
expect(localTimeFormatter.parse(DATESTRING)).toBe(timeStamp);
});
it("will validate correctly", () => {
expect(localTimeFormatter.validate(DATESTRING)).toBe(true);
expect(localTimeFormatter.validate(JUNK)).toBe(false);
});
});
});

View File

@ -225,14 +225,12 @@ export default {
},
createNotebookStorageObject() {
const notebookMeta = {
name: this.internalDomainObject.name,
identifier: this.internalDomainObject.identifier
};
const page = this.getSelectedPage();
const section = this.getSelectedSection();
return {
domainObject: this.internalDomainObject,
notebookMeta,
section,
page
@ -442,10 +440,10 @@ export default {
async updateDefaultNotebook(notebookStorage) {
const defaultNotebookObject = await this.getDefaultNotebookObject();
if (!defaultNotebookObject) {
setDefaultNotebook(this.openmct, notebookStorage);
setDefaultNotebook(this.openmct, notebookStorage, this.internalDomainObject);
} else if (objectUtils.makeKeyString(defaultNotebookObject.identifier) !== objectUtils.makeKeyString(notebookStorage.notebookMeta.identifier)) {
this.removeDefaultClass(defaultNotebookObject);
setDefaultNotebook(this.openmct, notebookStorage);
setDefaultNotebook(this.openmct, notebookStorage, this.internalDomainObject);
}
if (this.defaultSectionId && this.defaultSectionId.length === 0 || this.defaultSectionId !== notebookStorage.section.id) {

View File

@ -143,7 +143,9 @@ export default {
this.openmct.notifications.alert(message);
}
window.location.hash = hash;
const relativeHash = hash.slice(hash.indexOf('#'));
const url = new URL(relativeHash, `${location.protocol}//${location.host}${location.pathname}`);
window.location.hash = url.hash;
},
formatTime(unixTime, timeFormat) {
return Moment.utc(unixTime).format(timeFormat);

View File

@ -44,38 +44,46 @@ export default {
},
data() {
return {
notebookSnapshot: null,
notebookSnapshot: undefined,
notebookTypes: []
};
},
mounted() {
validateNotebookStorageObject();
this.getDefaultNotebookObject();
this.notebookSnapshot = new Snapshot(this.openmct);
this.setDefaultNotebookStatus();
},
methods: {
showMenu(event) {
const notebookTypes = [];
async getDefaultNotebookObject() {
const defaultNotebook = getDefaultNotebook();
const defaultNotebookObject = defaultNotebook && await this.openmct.objects.get(defaultNotebook.notebookMeta.identifier);
return defaultNotebookObject;
},
async showMenu(event) {
const notebookTypes = [];
const elementBoundingClientRect = this.$el.getBoundingClientRect();
const x = elementBoundingClientRect.x;
const y = elementBoundingClientRect.y + elementBoundingClientRect.height;
if (defaultNotebook) {
const domainObject = defaultNotebook.domainObject;
const defaultNotebookObject = await this.getDefaultNotebookObject();
if (defaultNotebookObject) {
const name = defaultNotebookObject.name;
if (domainObject.location) {
const defaultPath = `${domainObject.name} - ${defaultNotebook.section.name} - ${defaultNotebook.page.name}`;
const defaultNotebook = getDefaultNotebook();
const sectionName = defaultNotebook.section.name;
const pageName = defaultNotebook.page.name;
const defaultPath = `${name} - ${sectionName} - ${pageName}`;
notebookTypes.push({
cssClass: 'icon-notebook',
name: `Save to Notebook ${defaultPath}`,
callBack: () => {
return this.snapshot(NOTEBOOK_DEFAULT);
}
});
}
notebookTypes.push({
cssClass: 'icon-notebook',
name: `Save to Notebook ${defaultPath}`,
callBack: () => {
return this.snapshot(NOTEBOOK_DEFAULT);
}
});
}
notebookTypes.push({

View File

@ -20,7 +20,7 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
import { createOpenMct, resetApplicationState } from 'utils/testing';
import { createOpenMct, createMouseEvent, resetApplicationState } from 'utils/testing';
import NotebookPlugin from './plugin';
import Vue from 'vue';
@ -133,4 +133,89 @@ describe("Notebook plugin:", () => {
expect(hasMajorElements).toBe(true);
});
});
describe("Notebook Snapshots view:", () => {
let snapshotIndicator;
let drawerElement;
function clickSnapshotIndicator() {
const indicator = element.querySelector('.icon-camera');
const button = indicator.querySelector('button');
const clickEvent = createMouseEvent('click');
button.dispatchEvent(clickEvent);
}
beforeAll(() => {
snapshotIndicator = openmct.indicators.indicatorObjects
.find(indicator => indicator.key === 'notebook-snapshot-indicator').element;
element.append(snapshotIndicator);
return Vue.nextTick();
});
afterAll(() => {
snapshotIndicator.remove();
snapshotIndicator = undefined;
if (drawerElement) {
drawerElement.remove();
drawerElement = undefined;
}
});
beforeEach(() => {
drawerElement = document.querySelector('.l-shell__drawer');
});
afterEach(() => {
if (drawerElement) {
drawerElement.classList.remove('is-expanded');
}
});
it("has Snapshots indicator", () => {
const hasSnapshotIndicator = snapshotIndicator !== null && snapshotIndicator !== undefined;
expect(hasSnapshotIndicator).toBe(true);
});
it("snapshots container has class isExpanded", () => {
let classes = drawerElement.classList;
const isExpandedBefore = classes.contains('is-expanded');
clickSnapshotIndicator();
classes = drawerElement.classList;
const isExpandedAfterFirstClick = classes.contains('is-expanded');
expect(isExpandedBefore).toBeFalse();
expect(isExpandedAfterFirstClick).toBeTrue();
});
it("snapshots container does not have class isExpanded", () => {
let classes = drawerElement.classList;
const isExpandedBefore = classes.contains('is-expanded');
clickSnapshotIndicator();
classes = drawerElement.classList;
const isExpandedAfterFirstClick = classes.contains('is-expanded');
clickSnapshotIndicator();
classes = drawerElement.classList;
const isExpandedAfterSecondClick = classes.contains('is-expanded');
expect(isExpandedBefore).toBeFalse();
expect(isExpandedAfterFirstClick).toBeTrue();
expect(isExpandedAfterSecondClick).toBeFalse();
});
it("show notebook snapshots container text", () => {
clickSnapshotIndicator();
const notebookSnapshots = drawerElement.querySelector('.l-browse-bar__object-name');
const snapshotsText = notebookSnapshots.textContent.trim();
expect(snapshotsText).toBe('Notebook Snapshots');
});
});
});

View File

@ -7,15 +7,14 @@ export default class Snapshot {
constructor(openmct) {
this.openmct = openmct;
this.snapshotContainer = new SnapshotContainer(openmct);
this.exportImageService = openmct.$injector.get('exportImageService');
this.dialogService = openmct.$injector.get('dialogService');
this.capture = this.capture.bind(this);
this._saveSnapShot = this._saveSnapShot.bind(this);
}
capture(snapshotMeta, notebookType, domElement) {
this.exportImageService.exportPNGtoSRC(domElement, 's-status-taking-snapshot')
const exportImageService = this.openmct.$injector.get('exportImageService');
exportImageService.exportPNGtoSRC(domElement, 's-status-taking-snapshot')
.then(function (blob) {
const reader = new window.FileReader();
reader.readAsDataURL(blob);

View File

@ -23,13 +23,6 @@ import * as NotebookEntries from './notebook-entries';
import { createOpenMct, resetApplicationState } from 'utils/testing';
const notebookStorage = {
domainObject: {
name: 'notebook',
identifier: {
namespace: '',
key: 'test-notebook'
}
},
notebookMeta: {
name: 'notebook',
identifier: {

View File

@ -1,13 +1,12 @@
import objectUtils from 'objectUtils';
const NOTEBOOK_LOCAL_STORAGE = 'notebook-storage';
let currentNotebookObject = null;
let currentNotebookObjectIdentifier = null;
let unlisten = null;
function defaultNotebookObjectChanged(newDomainObject) {
if (newDomainObject.location !== null) {
currentNotebookObject = newDomainObject;
const notebookStorage = getDefaultNotebook();
notebookStorage.domainObject = newDomainObject;
saveDefaultNotebook(notebookStorage);
currentNotebookObjectIdentifier = newDomainObject.identifier;
return;
}
@ -20,10 +19,9 @@ function defaultNotebookObjectChanged(newDomainObject) {
clearDefaultNotebook();
}
function observeDefaultNotebookObject(openmct, notebookStorage) {
const domainObject = notebookStorage.domainObject;
if (currentNotebookObject
&& currentNotebookObject.identifier.key === domainObject.identifier.key) {
function observeDefaultNotebookObject(openmct, notebookMeta, domainObject) {
if (currentNotebookObjectIdentifier
&& objectUtils.makeKeyString(currentNotebookObjectIdentifier) === objectUtils.makeKeyString(notebookMeta.identifier)) {
return;
}
@ -32,7 +30,7 @@ function observeDefaultNotebookObject(openmct, notebookStorage) {
unlisten = null;
}
unlisten = openmct.objects.observe(notebookStorage.domainObject, '*', defaultNotebookObjectChanged);
unlisten = openmct.objects.observe(domainObject, '*', defaultNotebookObjectChanged);
}
function saveDefaultNotebook(notebookStorage) {
@ -40,7 +38,7 @@ function saveDefaultNotebook(notebookStorage) {
}
export function clearDefaultNotebook() {
currentNotebookObject = null;
currentNotebookObjectIdentifier = null;
window.localStorage.setItem(NOTEBOOK_LOCAL_STORAGE, null);
}
@ -50,8 +48,8 @@ export function getDefaultNotebook() {
return JSON.parse(notebookStorage);
}
export function setDefaultNotebook(openmct, notebookStorage) {
observeDefaultNotebookObject(openmct, notebookStorage);
export function setDefaultNotebook(openmct, notebookStorage, domainObject) {
observeDefaultNotebookObject(openmct, notebookStorage.notebookMeta, domainObject);
saveDefaultNotebook(notebookStorage);
}

View File

@ -23,14 +23,15 @@
import * as NotebookStorage from './notebook-storage';
import { createOpenMct, resetApplicationState } from 'utils/testing';
const domainObject = {
name: 'notebook',
identifier: {
namespace: '',
key: 'test-notebook'
}
};
const notebookStorage = {
domainObject: {
name: 'notebook',
identifier: {
namespace: '',
key: 'test-notebook'
}
},
notebookMeta: {
name: 'notebook',
identifier: {
@ -82,7 +83,7 @@ describe('Notebook Storage:', () => {
});
it('has correct notebookstorage on setDefaultNotebook', () => {
NotebookStorage.setDefaultNotebook(openmct, notebookStorage);
NotebookStorage.setDefaultNotebook(openmct, notebookStorage, domainObject);
const defaultNotebook = NotebookStorage.getDefaultNotebook();
expect(JSON.stringify(defaultNotebook)).toBe(JSON.stringify(notebookStorage));
@ -98,7 +99,7 @@ describe('Notebook Storage:', () => {
sectionTitle: 'Section'
};
NotebookStorage.setDefaultNotebook(openmct, notebookStorage);
NotebookStorage.setDefaultNotebook(openmct, notebookStorage, domainObject);
NotebookStorage.setDefaultNotebookSection(section);
const defaultNotebook = NotebookStorage.getDefaultNotebook();
@ -115,7 +116,7 @@ describe('Notebook Storage:', () => {
pageTitle: 'Page'
};
NotebookStorage.setDefaultNotebook(openmct, notebookStorage);
NotebookStorage.setDefaultNotebook(openmct, notebookStorage, domainObject);
NotebookStorage.setDefaultNotebookPage(page);
const defaultNotebook = NotebookStorage.getDefaultNotebook();

View File

@ -0,0 +1,9 @@
# URL Indicator
Adds an indicator which shows the number of frames that the browser is able to render per second. This is a useful proxy for the maximum number of updates that any telemetry display can perform per second. This may be useful during performance testing, but probably should not be enabled by default.
This indicator adds adds about 3% points to CPU usage in the Chrome task manager.
## Installation
```js
openmct.install(openmct.plugins.PerformanceIndicator());
```

View File

@ -0,0 +1,62 @@
/*****************************************************************************
* Open MCT, Copyright (c) 2014-2020, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
export default function PerformanceIndicator() {
return function install(openmct) {
let frames = 0;
let lastCalculated = performance.now();
const indicator = openmct.indicators.simpleIndicator();
indicator.text('~ fps');
indicator.statusClass('s-status-info');
openmct.indicators.add(indicator);
let rafHandle = requestAnimationFrame(incremementFrames);
openmct.on('destroy', () => {
cancelAnimationFrame(rafHandle);
});
function incremementFrames() {
let now = performance.now();
if ((now - lastCalculated) < 1000) {
frames++;
} else {
updateFPS(frames);
lastCalculated = now;
frames = 1;
}
rafHandle = requestAnimationFrame(incremementFrames);
}
function updateFPS(fps) {
indicator.text(`${fps} fps`);
if (fps >= 40) {
indicator.statusClass('s-status-on');
} else if (fps < 40 && fps >= 20) {
indicator.statusClass('s-status-warning');
} else {
indicator.statusClass('s-status-error');
}
}
};
}

View File

@ -0,0 +1,87 @@
/*****************************************************************************
* Open MCT, Copyright (c) 2014-2020, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
import PerformancePlugin from './plugin.js';
import {
createOpenMct,
resetApplicationState
} from 'utils/testing';
describe('the plugin', () => {
let openmct;
let element;
let child;
let performanceIndicator;
let countFramesPromise;
beforeEach((done) => {
openmct = createOpenMct(false);
element = document.createElement('div');
child = document.createElement('div');
element.appendChild(child);
openmct.install(new PerformancePlugin());
countFramesPromise = countFrames();
openmct.on('start', done);
performanceIndicator = openmct.indicators.indicatorObjects.find((indicator) => {
return indicator.text && indicator.text() === '~ fps';
});
openmct.startHeadless();
});
afterEach(() => {
return resetApplicationState(openmct);
});
it('installs the performance indicator', () => {
expect(performanceIndicator).toBeDefined();
});
it('correctly calculates fps', () => {
return countFramesPromise.then((frames) => {
expect(performanceIndicator.text()).toEqual(`${frames} fps`);
});
});
function countFrames() {
let startTime = performance.now();
let frames = 0;
return new Promise((resolve) => {
requestAnimationFrame(function incrementCount() {
let now = performance.now();
if ((now - startTime) < 1000) {
frames++;
requestAnimationFrame(incrementCount);
} else {
resolve(frames);
}
});
});
}
});

View File

@ -39,10 +39,11 @@ define([], function () {
const thisRequest = {
pending: 0
};
currentRequest = thisRequest;
$scope.currentRequest = thisRequest;
const telemetryObjects = $scope.telemetryObjects = [];
const thisTickWidthMap = {};
currentRequest = thisRequest;
$scope.currentRequest = thisRequest;
tickWidthMap = thisTickWidthMap;
if (unlisten) {
@ -52,14 +53,10 @@ define([], function () {
function addChild(child) {
const id = openmct.objects.makeKeyString(child.identifier);
const legacyObject = openmct.legacyObject(child);
thisTickWidthMap[id] = 0;
thisRequest.pending += 1;
objectService.getObjects([id])
.then(function (objects) {
thisRequest.pending -= 1;
const childObj = objects[id];
telemetryObjects.push(childObj);
});
telemetryObjects.push(legacyObject);
}
function removeChild(childIdentifier) {
@ -84,6 +81,7 @@ define([], function () {
}
thisRequest.pending += 1;
openmct.objects.get(domainObject.getId())
.then(function (obj) {
thisRequest.pending -= 1;

View File

@ -60,7 +60,8 @@ define([
'./defaultRootName/plugin',
'./timeline/plugin',
'./viewDatumAction/plugin',
'./interceptors/plugin'
'./interceptors/plugin',
'./performanceIndicator/plugin'
], function (
_,
UTCTimeSystem,
@ -101,7 +102,8 @@ define([
DefaultRootName,
Timeline,
ViewDatumAction,
ObjectInterceptors
ObjectInterceptors,
PerformanceIndicator
) {
const bundleMap = {
LocalStorage: 'platform/persistence/local',
@ -197,6 +199,7 @@ define([
plugins.Timeline = Timeline.default;
plugins.ViewDatumAction = ViewDatumAction.default;
plugins.ObjectInterceptors = ObjectInterceptors.default;
plugins.PerformanceIndicator = PerformanceIndicator.default;
return plugins;
});

View File

@ -100,11 +100,13 @@ define([], function () {
* @param {*} metadataValues
*/
function createNormalizedDatum(datum, columns) {
return Object.values(columns).reduce((normalizedDatum, column) => {
normalizedDatum[column.getKey()] = column.getRawValue(datum);
const normalizedDatum = JSON.parse(JSON.stringify(datum));
return normalizedDatum;
}, {});
Object.values(columns).forEach(column => {
normalizedDatum[column.getKey()] = column.getRawValue(datum);
});
return normalizedDatum;
}
return TelemetryTableRow;

View File

@ -98,6 +98,10 @@ describe('the plugin', function () {
beforeEach((done) => {
planDomainObject = {
identifier: {
key: 'test-object',
namespace: ''
},
type: 'plan',
id: "test-object",
selectFile: {

View File

@ -0,0 +1,29 @@
/*****************************************************************************
* Open MCT, Copyright (c) 2014-2021, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
import TimerViewProvider from './TimerViewProvider';
export default function TimerPlugin() {
return function install(openmct) {
openmct.objectViews.addProvider(new TimerViewProvider(openmct));
};
}

View File

@ -482,7 +482,7 @@ select {
transition: $transIn;
white-space: nowrap;
&:hover {
@include hover {
background: $colorMenuHovBg;
color: $colorMenuHovFg;
&:before {
@ -500,6 +500,10 @@ select {
&:not([class*='icon']):before {
content: ''; // Enable :before so that menu items without an icon still indent properly
}
.menus-no-icon & {
&:before { display: none; }
}
}
}
@ -731,7 +735,6 @@ select {
.c-toolbar {
display: flex;
align-items: center;
justify-content: space-between;
> * {
// First level items

View File

@ -47,6 +47,7 @@ mct-plot {
.c-plot,
.gl-plot {
overflow: hidden;
min-height: 100px;
.s-status-taking-snapshot & {
.c-control-bar {
@ -79,7 +80,8 @@ mct-plot {
display: flex;
flex: 1 1 auto;
flex-direction: column;
overflow: hidden;
overflow-y: auto;
overflow-x: hidden;
}
&--stacked {

View File

@ -552,7 +552,8 @@
}
}
&[class*='--menus-left'] {
&[class*='--menus-left'],
&[class*='menus-to-left'] {
.c-menu {
left: auto; right: 0;
}

View File

@ -3,11 +3,13 @@
<toolbar-select-menu
:options="fontSizeMenuOptions"
@change="setFontSize"
class="menus-to-left menus-no-icon"
/>
<div class="c-toolbar__separator"></div>
<toolbar-select-menu
:options="fontMenuOptions"
@change="setFont"
class="menus-to-left menus-no-icon"
/>
</div>
</template>

View File

@ -20,7 +20,7 @@
</div>
<span
class="l-browse-bar__object-name c-object-label__name c-input-inline"
contenteditable
:contenteditable="type.creatable"
@blur="updateName"
@keydown.enter.prevent
@keyup.enter.prevent="updateNameOnEnterKeyPress"

View File

@ -279,10 +279,12 @@
}
&__toolbar {
// Toolbar in the main shell, used by Display Layouts
$p: $interiorMargin;
background: $editUIBaseColor;
border-radius: $basicCr;
height: $p + 24px; // Need to standardize the height
justify-content: space-between;
padding: $p;
}
}

View File

@ -95,6 +95,10 @@
color: $colorItemTreeSelectedFg;
}
}
&.is-context-clicked {
box-shadow: inset $colorItemTreeSelectedBg 0 0 0 1px;
}
}
}

View File

@ -65,7 +65,7 @@
v-for="(ancestor, index) in focusedAncestors"
:key="ancestor.id"
:node="ancestor"
:show-up="index < focusedAncestors.length - 1"
:show-up="index < focusedAncestors.length - 1 && initialLoad"
:show-down="false"
:left-offset="index * 10 + 'px'"
@resetTree="beginNavigationRequest('handleReset', ancestor)"
@ -156,6 +156,7 @@ export default {
data() {
return {
root: undefined,
initialLoad: false,
isLoading: false,
mainTreeHeight: undefined,
searchLoading: false,
@ -499,6 +500,11 @@ export default {
this.ancestors = ancestors;
this.childItems = children;
// track when FIRST full load of tree happens
if (!this.initialLoad) {
this.initialLoad = true;
}
// any new items added or removed handled here
this.composition.on('add', this.addChild);
this.composition.on('remove', this.removeChild);

View File

@ -11,7 +11,8 @@
class="c-tree__item"
:class="{
'is-alias': isAlias,
'is-navigated-object': navigated
'is-navigated-object': navigated,
'is-context-clicked': contextClickActive
}"
>
<view-control
@ -26,6 +27,7 @@
:object-path="node.objectPath"
:navigate-to-path="navigationPath"
:style="{ paddingLeft: leftOffset }"
@context-click-active="setContextClickActive"
/>
<view-control
v-model="expanded"
@ -91,7 +93,8 @@ export default {
return {
hasComposition: false,
navigated: this.isNavigated(),
expanded: false
expanded: false,
contextClickActive: false
};
},
computed: {
@ -142,6 +145,9 @@ export default {
},
resetTreeHere() {
this.$emit('resetTree', this.node);
},
setContextClickActive(active) {
this.contextClickActive = active;
}
}
};

View File

@ -8,6 +8,11 @@ export default {
}
}
},
data() {
return {
contextClickActive: false
};
},
mounted() {
//TODO: touch support
this.$el.addEventListener('contextmenu', this.showContextMenu);
@ -35,7 +40,13 @@ export default {
let actions = actionsCollection.getVisibleActions();
let sortedActions = this.openmct.actions._groupAndSortActions(actions);
this.openmct.menus.showMenu(event.clientX, event.clientY, sortedActions);
this.openmct.menus.showMenu(event.clientX, event.clientY, sortedActions, this.onContextMenuDestroyed);
this.contextClickActive = true;
this.$emit('context-click-active', true);
},
onContextMenuDestroyed() {
this.contextClickActive = false;
this.$emit('context-click-active', false);
}
}
};

View File

@ -5,7 +5,7 @@
class="l-browse-bar__object-name--w c-object-label"
>
<div class="c-object-label__type-icon"
:class="type.cssClass"
:class="type.definition.cssClass"
></div>
<span class="l-browse-bar__object-name c-object-label__name">
{{ domainObject.name }}

View File

@ -90,6 +90,28 @@ export function resetApplicationState(openmct) {
return promise;
}
// required: key
// optional: element, keyCode, type
export function simulateKeyEvent(opts) {
if (!opts.key) {
console.warn('simulateKeyEvent needs a key');
return;
}
const el = opts.element || document;
const key = opts.key;
const keyCode = opts.keyCode || key;
const type = opts.type || 'keydown';
const event = new Event(type);
event.keyCode = keyCode;
event.key = key;
el.dispatchEvent(event);
}
function clearBuiltinSpy(funcDefinition) {
funcDefinition.object[funcDefinition.functionName] = funcDefinition.nativeFunction;
}