Compare commits
7 Commits
version-1.
...
fix-plan-g
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9e33a804e5 | ||
|
|
30ca4b707d | ||
|
|
8e3e4c9035 | ||
|
|
27704c9a48 | ||
|
|
c8cfedaa8a | ||
|
|
cb07620488 | ||
|
|
b0203f2272 |
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "openmct",
|
||||
"version": "1.4.0",
|
||||
"version": "1.4.1-SNAPSHOT",
|
||||
"description": "The Open MCT core platform",
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -61,13 +61,21 @@ export default {
|
||||
this.openmct.time.on("timeSystem", this.setScaleAndPlotActivities);
|
||||
this.openmct.time.on("bounds", this.updateViewBounds);
|
||||
this.resizeTimer = setInterval(this.resize, RESIZE_POLL_INTERVAL);
|
||||
this.unlisten = this.openmct.objects.observe(this.domainObject, '*', this.observeForChanges);
|
||||
},
|
||||
destroyed() {
|
||||
clearInterval(this.resizeTimer);
|
||||
this.openmct.time.off("timeSystem", this.setScaleAndPlotActivities);
|
||||
this.openmct.time.off("bounds", this.updateViewBounds);
|
||||
if (this.unlisten) {
|
||||
this.unlisten();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
observeForChanges(mutatedObject) {
|
||||
this.validateJSON(mutatedObject.selectFile.body);
|
||||
this.setScaleAndPlotActivities();
|
||||
},
|
||||
resize() {
|
||||
if (this.$refs.axisHolder.clientWidth !== this.width) {
|
||||
this.setDimensions();
|
||||
@@ -200,7 +208,7 @@ export default {
|
||||
return 0;
|
||||
},
|
||||
// Get the row where the next activity will land.
|
||||
getRowForActivity(rectX, width, defaultActivityRow = 0) {
|
||||
getRowForActivity(rectX, width, minimumActivityRow = 0) {
|
||||
let currentRow;
|
||||
let sortedActivityRows = Object.keys(this.activitiesByRow).sort(this.sortFn);
|
||||
|
||||
@@ -216,17 +224,18 @@ export default {
|
||||
|
||||
for (let i = 0; i < sortedActivityRows.length; i++) {
|
||||
let row = sortedActivityRows[i];
|
||||
if (getOverlap(this.activitiesByRow[row])) {
|
||||
if (row >= minimumActivityRow && getOverlap(this.activitiesByRow[row])) {
|
||||
currentRow = row;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (currentRow === undefined && sortedActivityRows.length) {
|
||||
currentRow = parseInt(sortedActivityRows[sortedActivityRows.length - 1], 10) + ROW_HEIGHT + ROW_PADDING;
|
||||
let row = Math.max(parseInt(sortedActivityRows[sortedActivityRows.length - 1], 10), minimumActivityRow);
|
||||
currentRow = row + ROW_HEIGHT + ROW_PADDING;
|
||||
}
|
||||
|
||||
return (currentRow || defaultActivityRow);
|
||||
return (currentRow || minimumActivityRow);
|
||||
},
|
||||
calculatePlanLayout() {
|
||||
this.activitiesByRow = {};
|
||||
@@ -236,8 +245,9 @@ export default {
|
||||
let groups = Object.keys(this.json);
|
||||
groups.forEach((key, index) => {
|
||||
let activities = this.json[key];
|
||||
//set the currentRow to the beginning of the next logical row
|
||||
currentRow = currentRow + ROW_HEIGHT * index;
|
||||
//set the new group's first row. It should be greater than the largest row of the last group
|
||||
let sortedActivityRows = Object.keys(this.activitiesByRow).sort(this.sortFn);
|
||||
const groupRowStart = sortedActivityRows.length ? parseInt(sortedActivityRows[sortedActivityRows.length - 1], 10) + 1 : 0;
|
||||
let newGroup = true;
|
||||
activities.forEach((activity) => {
|
||||
if (this.isActivityInBounds(activity)) {
|
||||
@@ -256,9 +266,9 @@ export default {
|
||||
const textWidth = textStart + this.getTextWidth(textLines[0]) + TEXT_LEFT_PADDING;
|
||||
|
||||
if (activityNameFitsRect) {
|
||||
currentRow = this.getRowForActivity(rectX, rectWidth);
|
||||
currentRow = this.getRowForActivity(rectX, rectWidth, groupRowStart);
|
||||
} else {
|
||||
currentRow = this.getRowForActivity(rectX, textWidth);
|
||||
currentRow = this.getRowForActivity(rectX, textWidth, groupRowStart);
|
||||
}
|
||||
|
||||
let textY = parseInt(currentRow, 10) + (activityNameFitsRect ? INNER_TEXT_PADDING : OUTER_TEXT_PADDING);
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT Web, Copyright (c) 2014-2015, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
* Open MCT Web 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 Web 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.
|
||||
*****************************************************************************/
|
||||
|
||||
define(["./LocalClock"], function (LocalClock) {
|
||||
describe("The LocalClock class", function () {
|
||||
let clock;
|
||||
let mockTimeout;
|
||||
const timeoutHandle = {};
|
||||
|
||||
beforeEach(function () {
|
||||
mockTimeout = jasmine.createSpy("timeout");
|
||||
mockTimeout.and.returnValue(timeoutHandle);
|
||||
|
||||
clock = new LocalClock(0);
|
||||
clock.start();
|
||||
});
|
||||
|
||||
it("calls listeners on tick with current time", function () {
|
||||
const mockListener = jasmine.createSpy("listener");
|
||||
clock.on('tick', mockListener);
|
||||
clock.tick();
|
||||
expect(mockListener).toHaveBeenCalledWith(jasmine.any(Number));
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,48 +0,0 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT Web, Copyright (c) 2014-2015, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
* Open MCT Web 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 Web 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.
|
||||
*****************************************************************************/
|
||||
|
||||
define(['./UTCTimeSystem'], function (UTCTimeSystem) {
|
||||
describe("The UTCTimeSystem class", function () {
|
||||
let timeSystem;
|
||||
let mockTimeout;
|
||||
|
||||
beforeEach(function () {
|
||||
mockTimeout = jasmine.createSpy("timeout");
|
||||
timeSystem = new UTCTimeSystem(mockTimeout);
|
||||
});
|
||||
|
||||
it("Uses the UTC time format", function () {
|
||||
expect(timeSystem.timeFormat).toBe('utc');
|
||||
});
|
||||
|
||||
it("is UTC based", function () {
|
||||
expect(timeSystem.isUTCBased).toBe(true);
|
||||
});
|
||||
|
||||
it("defines expected metadata", function () {
|
||||
expect(timeSystem.key).toBeDefined();
|
||||
expect(timeSystem.name).toBeDefined();
|
||||
expect(timeSystem.cssClass).toBeDefined();
|
||||
expect(timeSystem.durationFormat).toBeDefined();
|
||||
});
|
||||
});
|
||||
});
|
||||
103
src/plugins/utcTimeSystem/pluginSpec.js
Normal file
103
src/plugins/utcTimeSystem/pluginSpec.js
Normal file
@@ -0,0 +1,103 @@
|
||||
/*****************************************************************************
|
||||
* 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 LocalClock from './LocalClock.js';
|
||||
import UTCTimeSystem from './UTCTimeSystem';
|
||||
import {
|
||||
createOpenMct,
|
||||
resetApplicationState
|
||||
} from 'utils/testing';
|
||||
|
||||
describe("The UTC Time System", () => {
|
||||
const UTC_SYSTEM_AND_FORMAT_KEY = 'utc';
|
||||
let openmct;
|
||||
let utcTimeSystem;
|
||||
let mockTimeout;
|
||||
|
||||
beforeEach(() => {
|
||||
openmct = createOpenMct();
|
||||
openmct.install(openmct.plugins.UTCTimeSystem());
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
return resetApplicationState(openmct);
|
||||
});
|
||||
|
||||
describe("plugin", function () {
|
||||
|
||||
beforeEach(function () {
|
||||
mockTimeout = jasmine.createSpy("timeout");
|
||||
utcTimeSystem = new UTCTimeSystem(mockTimeout);
|
||||
});
|
||||
|
||||
it("is installed", () => {
|
||||
let timeSystems = openmct.time.getAllTimeSystems();
|
||||
let utc = timeSystems.find(ts => ts.key === UTC_SYSTEM_AND_FORMAT_KEY);
|
||||
|
||||
expect(utc).not.toEqual(-1);
|
||||
});
|
||||
|
||||
it("can be set to be the main time system", () => {
|
||||
openmct.time.timeSystem(UTC_SYSTEM_AND_FORMAT_KEY, {
|
||||
start: 0,
|
||||
end: 4
|
||||
});
|
||||
|
||||
expect(openmct.time.timeSystem().key).toBe(UTC_SYSTEM_AND_FORMAT_KEY);
|
||||
});
|
||||
|
||||
it("uses the utc time format", () => {
|
||||
expect(utcTimeSystem.timeFormat).toBe(UTC_SYSTEM_AND_FORMAT_KEY);
|
||||
});
|
||||
|
||||
it("is UTC based", () => {
|
||||
expect(utcTimeSystem.isUTCBased).toBe(true);
|
||||
});
|
||||
|
||||
it("defines expected metadata", () => {
|
||||
expect(utcTimeSystem.key).toBe(UTC_SYSTEM_AND_FORMAT_KEY);
|
||||
expect(utcTimeSystem.name).toBeDefined();
|
||||
expect(utcTimeSystem.cssClass).toBeDefined();
|
||||
expect(utcTimeSystem.durationFormat).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe("LocalClock class", function () {
|
||||
let clock;
|
||||
const timeoutHandle = {};
|
||||
|
||||
beforeEach(function () {
|
||||
mockTimeout = jasmine.createSpy("timeout");
|
||||
mockTimeout.and.returnValue(timeoutHandle);
|
||||
|
||||
clock = new LocalClock(0);
|
||||
clock.start();
|
||||
});
|
||||
|
||||
it("calls listeners on tick with current time", function () {
|
||||
const mockListener = jasmine.createSpy("listener");
|
||||
clock.on('tick', mockListener);
|
||||
clock.tick();
|
||||
expect(mockListener).toHaveBeenCalledWith(jasmine.any(Number));
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -13,8 +13,9 @@
|
||||
}
|
||||
|
||||
&__object-view {
|
||||
display: flex;
|
||||
flex: 1 1 auto;
|
||||
height: 0; // Chrome 73
|
||||
height: 100%; // Chrome 73
|
||||
overflow: auto;
|
||||
|
||||
> div:not([class]) {
|
||||
|
||||
Reference in New Issue
Block a user