Compare commits
5 Commits
non-editab
...
theme-chan
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ff8d505281 | ||
|
|
98207a3e0d | ||
|
|
26b81345f2 | ||
|
|
ac2034b243 | ||
|
|
351848ad56 |
@@ -86,7 +86,7 @@ module.exports = (config) => {
|
||||
reports: ['html', 'lcovonly', 'text-summary'],
|
||||
thresholds: {
|
||||
global: {
|
||||
lines: 65
|
||||
lines: 66
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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">
|
||||
|
||||
9
src/plugins/performanceIndicator/README.md
Normal file
9
src/plugins/performanceIndicator/README.md
Normal 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());
|
||||
```
|
||||
62
src/plugins/performanceIndicator/plugin.js
Normal file
62
src/plugins/performanceIndicator/plugin.js
Normal 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');
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
87
src/plugins/performanceIndicator/pluginSpec.js
Normal file
87
src/plugins/performanceIndicator/pluginSpec.js
Normal 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);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -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;
|
||||
});
|
||||
|
||||
18
src/plugins/themes/themeMenuItems.js
Normal file
18
src/plugins/themes/themeMenuItems.js
Normal file
@@ -0,0 +1,18 @@
|
||||
import { installTheme } from './installTheme';
|
||||
|
||||
const THEME_LIST = [
|
||||
'espresso',
|
||||
'maelstrom',
|
||||
'snow'
|
||||
];
|
||||
|
||||
export function getThemeItems(openmct) {
|
||||
return THEME_LIST.map(theme => {
|
||||
return {
|
||||
cssClass: '',
|
||||
name: theme,
|
||||
description: `${theme} Theme`,
|
||||
callBack: () => installTheme(openmct, theme)
|
||||
};
|
||||
});
|
||||
}
|
||||
@@ -24,11 +24,14 @@
|
||||
ref="aboutLogo"
|
||||
class="l-shell__app-logo"
|
||||
@click="launchAbout"
|
||||
@contextmenu.prevent="showContextMenu"
|
||||
></div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import AboutDialog from './AboutDialog.vue';
|
||||
import { getThemeItems } from '../../plugins/themes/themeMenuItems';
|
||||
|
||||
import Vue from 'vue';
|
||||
|
||||
export default {
|
||||
@@ -53,6 +56,9 @@ export default {
|
||||
element: vm.$el,
|
||||
size: 'large'
|
||||
});
|
||||
},
|
||||
showContextMenu(event) {
|
||||
this.openmct.menus.showMenu(event.x, event.y, getThemeItems(this.openmct));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -95,6 +95,10 @@
|
||||
color: $colorItemTreeSelectedFg;
|
||||
}
|
||||
}
|
||||
|
||||
&.is-context-clicked {
|
||||
box-shadow: inset $colorItemTreeSelectedBg 0 0 0 1px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user