mirror of
https://github.com/nasa/openmct.git
synced 2025-07-04 05:53:23 +00:00
Compare commits
11 Commits
bar-graph-
...
vue-hack
Author | SHA1 | Date | |
---|---|---|---|
62ff404bb3 | |||
8243cf5d7b | |||
c4c1fea17f | |||
5e920e90ce | |||
886db23eb6 | |||
0ccb546a2e | |||
271f8ed38f | |||
650f84e95c | |||
b70af5a1bb | |||
0af21632db | |||
e2f1ff5442 |
@ -28,6 +28,15 @@ define([
|
|||||||
domain: 2
|
domain: 2
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
key: "cos",
|
||||||
|
name: "Cosine",
|
||||||
|
unit: "deg",
|
||||||
|
formatString: '%0.2f',
|
||||||
|
hints: {
|
||||||
|
domain: 3
|
||||||
|
}
|
||||||
|
},
|
||||||
// Need to enable "LocalTimeSystem" plugin to make use of this
|
// Need to enable "LocalTimeSystem" plugin to make use of this
|
||||||
// {
|
// {
|
||||||
// key: "local",
|
// key: "local",
|
||||||
@ -109,6 +118,100 @@ define([
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
'example.spectral-generator': {
|
||||||
|
values: [
|
||||||
|
{
|
||||||
|
key: "name",
|
||||||
|
name: "Name",
|
||||||
|
format: "string"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "utc",
|
||||||
|
name: "Time",
|
||||||
|
format: "utc",
|
||||||
|
hints: {
|
||||||
|
domain: 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "wavelength",
|
||||||
|
name: "Wavelength",
|
||||||
|
unit: "Hz",
|
||||||
|
formatString: '%0.2f',
|
||||||
|
hints: {
|
||||||
|
domain: 2,
|
||||||
|
spectralAttribute: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "cos",
|
||||||
|
name: "Cosine",
|
||||||
|
unit: "deg",
|
||||||
|
formatString: '%0.2f',
|
||||||
|
hints: {
|
||||||
|
range: 2,
|
||||||
|
spectralAttribute: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
'example.spectral-aggregate-generator': {
|
||||||
|
values: [
|
||||||
|
{
|
||||||
|
key: "name",
|
||||||
|
name: "Name",
|
||||||
|
format: "string"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "utc",
|
||||||
|
name: "Time",
|
||||||
|
format: "utc",
|
||||||
|
hints: {
|
||||||
|
domain: 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "ch1",
|
||||||
|
name: "Channel 1",
|
||||||
|
format: "string",
|
||||||
|
hints: {
|
||||||
|
range: 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "ch2",
|
||||||
|
name: "Channel 2",
|
||||||
|
format: "string",
|
||||||
|
hints: {
|
||||||
|
range: 2
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "ch3",
|
||||||
|
name: "Channel 3",
|
||||||
|
format: "string",
|
||||||
|
hints: {
|
||||||
|
range: 3
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "ch4",
|
||||||
|
name: "Channel 4",
|
||||||
|
format: "string",
|
||||||
|
hints: {
|
||||||
|
range: 4
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "ch5",
|
||||||
|
name: "Channel 5",
|
||||||
|
format: "string",
|
||||||
|
hints: {
|
||||||
|
range: 5
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
86
example/generator/SpectralAggregateGeneratorProvider.js
Normal file
86
example/generator/SpectralAggregateGeneratorProvider.js
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* 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.
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
define([
|
||||||
|
|
||||||
|
], function (
|
||||||
|
|
||||||
|
) {
|
||||||
|
|
||||||
|
function SpectralAggregateGeneratorProvider() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function pointForTimestamp(timestamp, count, name) {
|
||||||
|
return {
|
||||||
|
name: name,
|
||||||
|
utc: String(Math.floor(timestamp / count) * count),
|
||||||
|
ch1: String(Math.floor(timestamp / count) % 1),
|
||||||
|
ch2: String(Math.floor(timestamp / count) % 2),
|
||||||
|
ch3: String(Math.floor(timestamp / count) % 3),
|
||||||
|
ch4: String(Math.floor(timestamp / count) % 4),
|
||||||
|
ch5: String(Math.floor(timestamp / count) % 5)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
SpectralAggregateGeneratorProvider.prototype.supportsSubscribe = function (domainObject) {
|
||||||
|
return domainObject.type === 'example.spectral-aggregate-generator';
|
||||||
|
};
|
||||||
|
|
||||||
|
SpectralAggregateGeneratorProvider.prototype.subscribe = function (domainObject, callback) {
|
||||||
|
var count = 5000;
|
||||||
|
|
||||||
|
var interval = setInterval(function () {
|
||||||
|
var now = Date.now();
|
||||||
|
var datum = pointForTimestamp(now, count, domainObject.name);
|
||||||
|
callback(datum);
|
||||||
|
}, count);
|
||||||
|
|
||||||
|
return function () {
|
||||||
|
clearInterval(interval);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
SpectralAggregateGeneratorProvider.prototype.supportsRequest = function (domainObject, options) {
|
||||||
|
return domainObject.type === 'example.spectral-aggregate-generator';
|
||||||
|
};
|
||||||
|
|
||||||
|
SpectralAggregateGeneratorProvider.prototype.request = function (domainObject, options) {
|
||||||
|
var start = options.start;
|
||||||
|
var end = Math.min(Date.now(), options.end); // no future values
|
||||||
|
var count = 5000;
|
||||||
|
if (options.strategy === 'latest' || options.size === 1) {
|
||||||
|
start = end;
|
||||||
|
}
|
||||||
|
|
||||||
|
var data = [];
|
||||||
|
while (start <= end && data.length < 5000) {
|
||||||
|
data.push(pointForTimestamp(start, count, domainObject.name));
|
||||||
|
start += count;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Promise.resolve(data);
|
||||||
|
};
|
||||||
|
|
||||||
|
return SpectralAggregateGeneratorProvider;
|
||||||
|
|
||||||
|
});
|
102
example/generator/SpectralGeneratorProvider.js
Normal file
102
example/generator/SpectralGeneratorProvider.js
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* 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.
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
define([
|
||||||
|
'./WorkerInterface'
|
||||||
|
], function (
|
||||||
|
WorkerInterface
|
||||||
|
) {
|
||||||
|
|
||||||
|
var REQUEST_DEFAULTS = {
|
||||||
|
amplitude: 1,
|
||||||
|
wavelength: 1,
|
||||||
|
period: 10,
|
||||||
|
offset: 0,
|
||||||
|
dataRateInHz: 1,
|
||||||
|
randomness: 0,
|
||||||
|
phase: 0
|
||||||
|
};
|
||||||
|
|
||||||
|
function SpectralGeneratorProvider() {
|
||||||
|
this.workerInterface = new WorkerInterface();
|
||||||
|
}
|
||||||
|
|
||||||
|
SpectralGeneratorProvider.prototype.canProvideTelemetry = function (domainObject) {
|
||||||
|
return domainObject.type === 'example.spectral-generator';
|
||||||
|
};
|
||||||
|
|
||||||
|
SpectralGeneratorProvider.prototype.supportsRequest =
|
||||||
|
SpectralGeneratorProvider.prototype.supportsSubscribe =
|
||||||
|
SpectralGeneratorProvider.prototype.canProvideTelemetry;
|
||||||
|
|
||||||
|
SpectralGeneratorProvider.prototype.makeWorkerRequest = function (domainObject, request = {}) {
|
||||||
|
var props = [
|
||||||
|
'amplitude',
|
||||||
|
'wavelength',
|
||||||
|
'period',
|
||||||
|
'offset',
|
||||||
|
'dataRateInHz',
|
||||||
|
'phase',
|
||||||
|
'randomness'
|
||||||
|
];
|
||||||
|
|
||||||
|
var workerRequest = {};
|
||||||
|
|
||||||
|
props.forEach(function (prop) {
|
||||||
|
if (domainObject.telemetry && Object.prototype.hasOwnProperty.call(domainObject.telemetry, prop)) {
|
||||||
|
workerRequest[prop] = domainObject.telemetry[prop];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (request && Object.prototype.hasOwnProperty.call(request, prop)) {
|
||||||
|
workerRequest[prop] = request[prop];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Object.prototype.hasOwnProperty.call(workerRequest, prop)) {
|
||||||
|
workerRequest[prop] = REQUEST_DEFAULTS[prop];
|
||||||
|
}
|
||||||
|
|
||||||
|
workerRequest[prop] = Number(workerRequest[prop]);
|
||||||
|
});
|
||||||
|
|
||||||
|
workerRequest.name = domainObject.name;
|
||||||
|
|
||||||
|
return workerRequest;
|
||||||
|
};
|
||||||
|
|
||||||
|
SpectralGeneratorProvider.prototype.request = function (domainObject, request) {
|
||||||
|
var workerRequest = this.makeWorkerRequest(domainObject, request);
|
||||||
|
workerRequest.start = request.start;
|
||||||
|
workerRequest.end = request.end;
|
||||||
|
workerRequest.spectra = true;
|
||||||
|
|
||||||
|
return this.workerInterface.request(workerRequest);
|
||||||
|
};
|
||||||
|
|
||||||
|
SpectralGeneratorProvider.prototype.subscribe = function (domainObject, callback) {
|
||||||
|
var workerRequest = this.makeWorkerRequest(domainObject, {});
|
||||||
|
workerRequest.spectra = true;
|
||||||
|
|
||||||
|
return this.workerInterface.subscribe(workerRequest, callback);
|
||||||
|
};
|
||||||
|
|
||||||
|
return SpectralGeneratorProvider;
|
||||||
|
});
|
@ -54,23 +54,38 @@
|
|||||||
var start = Date.now();
|
var start = Date.now();
|
||||||
var step = 1000 / data.dataRateInHz;
|
var step = 1000 / data.dataRateInHz;
|
||||||
var nextStep = start - (start % step) + step;
|
var nextStep = start - (start % step) + step;
|
||||||
|
let work;
|
||||||
|
if (data.spectra) {
|
||||||
|
work = function (now) {
|
||||||
|
while (nextStep < now) {
|
||||||
|
const messageCopy = Object.create(message);
|
||||||
|
message.data.start = nextStep - (60 * 1000);
|
||||||
|
message.data.end = nextStep;
|
||||||
|
onRequest(messageCopy);
|
||||||
|
nextStep += step;
|
||||||
|
}
|
||||||
|
|
||||||
function work(now) {
|
return nextStep;
|
||||||
while (nextStep < now) {
|
};
|
||||||
self.postMessage({
|
} else {
|
||||||
id: message.id,
|
work = function (now) {
|
||||||
data: {
|
while (nextStep < now) {
|
||||||
name: data.name,
|
self.postMessage({
|
||||||
utc: nextStep,
|
id: message.id,
|
||||||
yesterday: nextStep - 60 * 60 * 24 * 1000,
|
data: {
|
||||||
sin: sin(nextStep, data.period, data.amplitude, data.offset, data.phase, data.randomness),
|
name: data.name,
|
||||||
cos: cos(nextStep, data.period, data.amplitude, data.offset, data.phase, data.randomness)
|
utc: nextStep,
|
||||||
}
|
yesterday: nextStep - 60 * 60 * 24 * 1000,
|
||||||
});
|
sin: sin(nextStep, data.period, data.amplitude, data.offset, data.phase, data.randomness),
|
||||||
nextStep += step;
|
wavelength: wavelength(start, nextStep),
|
||||||
}
|
cos: cos(nextStep, data.period, data.amplitude, data.offset, data.phase, data.randomness)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
nextStep += step;
|
||||||
|
}
|
||||||
|
|
||||||
return nextStep;
|
return nextStep;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
subscriptions[message.id] = work;
|
subscriptions[message.id] = work;
|
||||||
@ -111,13 +126,21 @@
|
|||||||
utc: nextStep,
|
utc: nextStep,
|
||||||
yesterday: nextStep - 60 * 60 * 24 * 1000,
|
yesterday: nextStep - 60 * 60 * 24 * 1000,
|
||||||
sin: sin(nextStep, period, amplitude, offset, phase, randomness),
|
sin: sin(nextStep, period, amplitude, offset, phase, randomness),
|
||||||
|
wavelength: wavelength(start, nextStep),
|
||||||
cos: cos(nextStep, period, amplitude, offset, phase, randomness)
|
cos: cos(nextStep, period, amplitude, offset, phase, randomness)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
self.postMessage({
|
self.postMessage({
|
||||||
id: message.id,
|
id: message.id,
|
||||||
data: data
|
data: request.spectra ? {
|
||||||
|
wavelength: data.map((item) => {
|
||||||
|
return item.wavelength;
|
||||||
|
}),
|
||||||
|
cos: data.map((item) => {
|
||||||
|
return item.cos;
|
||||||
|
})
|
||||||
|
} : data
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,6 +154,10 @@
|
|||||||
* Math.sin(phase + (timestamp / period / 1000 * Math.PI * 2)) + (amplitude * Math.random() * randomness) + offset;
|
* Math.sin(phase + (timestamp / period / 1000 * Math.PI * 2)) + (amplitude * Math.random() * randomness) + offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function wavelength(start, nextStep) {
|
||||||
|
return (nextStep - start) / 10;
|
||||||
|
}
|
||||||
|
|
||||||
function sendError(error, message) {
|
function sendError(error, message) {
|
||||||
self.postMessage({
|
self.postMessage({
|
||||||
error: error.name + ': ' + error.message,
|
error: error.name + ': ' + error.message,
|
||||||
|
@ -24,11 +24,15 @@ define([
|
|||||||
"./GeneratorProvider",
|
"./GeneratorProvider",
|
||||||
"./SinewaveLimitProvider",
|
"./SinewaveLimitProvider",
|
||||||
"./StateGeneratorProvider",
|
"./StateGeneratorProvider",
|
||||||
|
"./SpectralGeneratorProvider",
|
||||||
|
"./SpectralAggregateGeneratorProvider",
|
||||||
"./GeneratorMetadataProvider"
|
"./GeneratorMetadataProvider"
|
||||||
], function (
|
], function (
|
||||||
GeneratorProvider,
|
GeneratorProvider,
|
||||||
SinewaveLimitProvider,
|
SinewaveLimitProvider,
|
||||||
StateGeneratorProvider,
|
StateGeneratorProvider,
|
||||||
|
SpectralGeneratorProvider,
|
||||||
|
SpectralAggregateGeneratorProvider,
|
||||||
GeneratorMetadataProvider
|
GeneratorMetadataProvider
|
||||||
) {
|
) {
|
||||||
|
|
||||||
@ -61,6 +65,37 @@ define([
|
|||||||
|
|
||||||
openmct.telemetry.addProvider(new StateGeneratorProvider());
|
openmct.telemetry.addProvider(new StateGeneratorProvider());
|
||||||
|
|
||||||
|
openmct.types.addType("example.spectral-generator", {
|
||||||
|
name: "Spectral Generator",
|
||||||
|
description: "For development use. Generates example streaming telemetry data using a simple sine wave algorithm.",
|
||||||
|
cssClass: "icon-generator-telemetry",
|
||||||
|
creatable: true,
|
||||||
|
initialize: function (object) {
|
||||||
|
object.telemetry = {
|
||||||
|
period: 10,
|
||||||
|
amplitude: 1,
|
||||||
|
wavelength: 1,
|
||||||
|
frequency: 1,
|
||||||
|
offset: 0,
|
||||||
|
dataRateInHz: 1,
|
||||||
|
phase: 0,
|
||||||
|
randomness: 0
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
openmct.telemetry.addProvider(new SpectralGeneratorProvider());
|
||||||
|
|
||||||
|
openmct.types.addType("example.spectral-aggregate-generator", {
|
||||||
|
name: "Spectral Aggregate Generator",
|
||||||
|
description: "For development use. Generates example streaming telemetry data using a simple state algorithm.",
|
||||||
|
cssClass: "icon-generator-telemetry",
|
||||||
|
creatable: true,
|
||||||
|
initialize: function (object) {
|
||||||
|
object.telemetry = {};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
openmct.telemetry.addProvider(new SpectralAggregateGeneratorProvider());
|
||||||
|
|
||||||
openmct.types.addType("generator", {
|
openmct.types.addType("generator", {
|
||||||
name: "Sine Wave Generator",
|
name: "Sine Wave Generator",
|
||||||
description: "For development use. Generates example streaming telemetry data using a simple sine wave algorithm.",
|
description: "For development use. Generates example streaming telemetry data using a simple sine wave algorithm.",
|
||||||
|
@ -44,9 +44,11 @@ define(
|
|||||||
setText(result.name);
|
setText(result.name);
|
||||||
scope.ngModel[scope.field] = result;
|
scope.ngModel[scope.field] = result;
|
||||||
control.$setValidity("file-input", true);
|
control.$setValidity("file-input", true);
|
||||||
|
scope.$digest();
|
||||||
}, function () {
|
}, function () {
|
||||||
setText('Select File');
|
setText('Select File');
|
||||||
control.$setValidity("file-input", false);
|
control.$setValidity("file-input", false);
|
||||||
|
scope.$digest();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -263,7 +263,6 @@ define([
|
|||||||
// Plugins that are installed by default
|
// Plugins that are installed by default
|
||||||
|
|
||||||
this.install(this.plugins.Plot());
|
this.install(this.plugins.Plot());
|
||||||
this.install(this.plugins.Chart());
|
|
||||||
this.install(this.plugins.TelemetryTable.default());
|
this.install(this.plugins.TelemetryTable.default());
|
||||||
this.install(PreviewPlugin.default());
|
this.install(PreviewPlugin.default());
|
||||||
this.install(LegacyIndicatorsPlugin());
|
this.install(LegacyIndicatorsPlugin());
|
||||||
@ -289,6 +288,8 @@ define([
|
|||||||
this.install(this.plugins.ObjectInterceptors());
|
this.install(this.plugins.ObjectInterceptors());
|
||||||
this.install(this.plugins.NonEditableFolder());
|
this.install(this.plugins.NonEditableFolder());
|
||||||
this.install(this.plugins.DeviceClassifier());
|
this.install(this.plugins.DeviceClassifier());
|
||||||
|
|
||||||
|
this._isVue = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
MCT.prototype = Object.create(EventEmitter.prototype);
|
MCT.prototype = Object.create(EventEmitter.prototype);
|
||||||
|
@ -81,14 +81,8 @@ define([
|
|||||||
return models;
|
return models;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.apiFetch(missingIds)
|
//Temporary fix for missing models - don't retry using this.apiFetch
|
||||||
.then(function (apiResults) {
|
return models;
|
||||||
Object.keys(apiResults).forEach(function (k) {
|
|
||||||
models[k] = apiResults[k];
|
|
||||||
});
|
|
||||||
|
|
||||||
return models;
|
|
||||||
});
|
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ class ActionsAPI extends EventEmitter {
|
|||||||
return actionsObject;
|
return actionsObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
_groupAndSortActions(actionsArray) {
|
_groupAndSortActions(actionsArray = []) {
|
||||||
if (!Array.isArray(actionsArray) && typeof actionsArray === 'object') {
|
if (!Array.isArray(actionsArray) && typeof actionsArray === 'object') {
|
||||||
actionsArray = Object.keys(actionsArray).map(key => actionsArray[key]);
|
actionsArray = Object.keys(actionsArray).map(key => actionsArray[key]);
|
||||||
}
|
}
|
||||||
|
2
src/api/objects/ConflictError.js
Normal file
2
src/api/objects/ConflictError.js
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
export default class ConflictError extends Error {
|
||||||
|
}
|
@ -26,6 +26,7 @@ import RootRegistry from './RootRegistry';
|
|||||||
import RootObjectProvider from './RootObjectProvider';
|
import RootObjectProvider from './RootObjectProvider';
|
||||||
import EventEmitter from 'EventEmitter';
|
import EventEmitter from 'EventEmitter';
|
||||||
import InterceptorRegistry from './InterceptorRegistry';
|
import InterceptorRegistry from './InterceptorRegistry';
|
||||||
|
import ConflictError from './ConflictError';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utilities for loading, saving, and manipulating domain objects.
|
* Utilities for loading, saving, and manipulating domain objects.
|
||||||
@ -34,6 +35,7 @@ import InterceptorRegistry from './InterceptorRegistry';
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
function ObjectAPI(typeRegistry, openmct) {
|
function ObjectAPI(typeRegistry, openmct) {
|
||||||
|
this.openmct = openmct;
|
||||||
this.typeRegistry = typeRegistry;
|
this.typeRegistry = typeRegistry;
|
||||||
this.eventEmitter = new EventEmitter();
|
this.eventEmitter = new EventEmitter();
|
||||||
this.providers = {};
|
this.providers = {};
|
||||||
@ -47,6 +49,10 @@ function ObjectAPI(typeRegistry, openmct) {
|
|||||||
this.interceptorRegistry = new InterceptorRegistry();
|
this.interceptorRegistry = new InterceptorRegistry();
|
||||||
|
|
||||||
this.SYNCHRONIZED_OBJECT_TYPES = ['notebook', 'plan'];
|
this.SYNCHRONIZED_OBJECT_TYPES = ['notebook', 'plan'];
|
||||||
|
|
||||||
|
this.errors = {
|
||||||
|
Conflict: ConflictError
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -181,8 +187,17 @@ ObjectAPI.prototype.get = function (identifier, abortSignal) {
|
|||||||
|
|
||||||
let objectPromise = provider.get(identifier, abortSignal).then(result => {
|
let objectPromise = provider.get(identifier, abortSignal).then(result => {
|
||||||
delete this.cache[keystring];
|
delete this.cache[keystring];
|
||||||
|
|
||||||
result = this.applyGetInterceptors(identifier, result);
|
result = this.applyGetInterceptors(identifier, result);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}).catch((result) => {
|
||||||
|
console.warn(`Failed to retrieve ${keystring}:`, result);
|
||||||
|
|
||||||
|
delete this.cache[keystring];
|
||||||
|
|
||||||
|
result = this.applyGetInterceptors(identifier);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -285,6 +300,7 @@ ObjectAPI.prototype.isPersistable = function (idOrKeyString) {
|
|||||||
ObjectAPI.prototype.save = function (domainObject) {
|
ObjectAPI.prototype.save = function (domainObject) {
|
||||||
let provider = this.getProvider(domainObject.identifier);
|
let provider = this.getProvider(domainObject.identifier);
|
||||||
let savedResolve;
|
let savedResolve;
|
||||||
|
let savedReject;
|
||||||
let result;
|
let result;
|
||||||
|
|
||||||
if (!this.isPersistable(domainObject.identifier)) {
|
if (!this.isPersistable(domainObject.identifier)) {
|
||||||
@ -294,14 +310,18 @@ ObjectAPI.prototype.save = function (domainObject) {
|
|||||||
} else {
|
} else {
|
||||||
const persistedTime = Date.now();
|
const persistedTime = Date.now();
|
||||||
if (domainObject.persisted === undefined) {
|
if (domainObject.persisted === undefined) {
|
||||||
result = new Promise((resolve) => {
|
result = new Promise((resolve, reject) => {
|
||||||
savedResolve = resolve;
|
savedResolve = resolve;
|
||||||
|
savedReject = reject;
|
||||||
});
|
});
|
||||||
domainObject.persisted = persistedTime;
|
domainObject.persisted = persistedTime;
|
||||||
provider.create(domainObject).then((response) => {
|
provider.create(domainObject)
|
||||||
this.mutate(domainObject, 'persisted', persistedTime);
|
.then((response) => {
|
||||||
savedResolve(response);
|
this.mutate(domainObject, 'persisted', persistedTime);
|
||||||
});
|
savedResolve(response);
|
||||||
|
}).catch((error) => {
|
||||||
|
savedReject(error);
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
domainObject.persisted = persistedTime;
|
domainObject.persisted = persistedTime;
|
||||||
this.mutate(domainObject, 'persisted', persistedTime);
|
this.mutate(domainObject, 'persisted', persistedTime);
|
||||||
|
@ -483,6 +483,10 @@ define([
|
|||||||
* @returns {Object<String, {TelemetryValueFormatter}>}
|
* @returns {Object<String, {TelemetryValueFormatter}>}
|
||||||
*/
|
*/
|
||||||
TelemetryAPI.prototype.getFormatMap = function (metadata) {
|
TelemetryAPI.prototype.getFormatMap = function (metadata) {
|
||||||
|
if (!metadata) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
if (!this.formatMapCache.has(metadata)) {
|
if (!this.formatMapCache.has(metadata)) {
|
||||||
const formatMap = metadata.values().reduce(function (map, valueMetadata) {
|
const formatMap = metadata.values().reduce(function (map, valueMetadata) {
|
||||||
map[valueMetadata.key] = this.getValueFormatter(valueMetadata);
|
map[valueMetadata.key] = this.getValueFormatter(valueMetadata);
|
||||||
|
@ -130,8 +130,13 @@ export class TelemetryCollection extends EventEmitter {
|
|||||||
this.options.onPartialResponse = this._processNewTelemetry.bind(this);
|
this.options.onPartialResponse = this._processNewTelemetry.bind(this);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
if (this.requestAbort) {
|
||||||
|
this.requestAbort.abort();
|
||||||
|
}
|
||||||
|
|
||||||
this.requestAbort = new AbortController();
|
this.requestAbort = new AbortController();
|
||||||
this.options.signal = this.requestAbort.signal;
|
this.options.signal = this.requestAbort.signal;
|
||||||
|
this.emit('requestStarted');
|
||||||
historicalData = await this.historicalProvider.request(this.domainObject, this.options);
|
historicalData = await this.historicalProvider.request(this.domainObject, this.options);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.name !== 'AbortError') {
|
if (error.name !== 'AbortError') {
|
||||||
@ -140,6 +145,7 @@ export class TelemetryCollection extends EventEmitter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.emit('requestEnded');
|
||||||
this.requestAbort = undefined;
|
this.requestAbort = undefined;
|
||||||
|
|
||||||
this._processNewTelemetry(historicalData);
|
this._processNewTelemetry(historicalData);
|
||||||
|
@ -41,7 +41,6 @@ const DEFAULTS = [
|
|||||||
'platform/forms',
|
'platform/forms',
|
||||||
'platform/identity',
|
'platform/identity',
|
||||||
'platform/persistence/aggregator',
|
'platform/persistence/aggregator',
|
||||||
'platform/persistence/queue',
|
|
||||||
'platform/policy',
|
'platform/policy',
|
||||||
'platform/entanglement',
|
'platform/entanglement',
|
||||||
'platform/search',
|
'platform/search',
|
||||||
|
@ -32,7 +32,7 @@ describe('the plugin', function () {
|
|||||||
let openmct;
|
let openmct;
|
||||||
let composition;
|
let composition;
|
||||||
|
|
||||||
beforeEach((done) => {
|
beforeEach(() => {
|
||||||
|
|
||||||
openmct = createOpenMct();
|
openmct = createOpenMct();
|
||||||
|
|
||||||
@ -47,11 +47,6 @@ describe('the plugin', function () {
|
|||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
openmct.on('start', done);
|
|
||||||
openmct.startHeadless();
|
|
||||||
|
|
||||||
composition = openmct.composition.get({identifier});
|
|
||||||
|
|
||||||
spyOn(couchPlugin.couchProvider, 'getObjectsByFilter').and.returnValue(Promise.resolve([
|
spyOn(couchPlugin.couchProvider, 'getObjectsByFilter').and.returnValue(Promise.resolve([
|
||||||
{
|
{
|
||||||
identifier: {
|
identifier: {
|
||||||
@ -66,6 +61,19 @@ describe('the plugin', function () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
]));
|
]));
|
||||||
|
|
||||||
|
spyOn(couchPlugin.couchProvider, "get").and.callFake((id) => {
|
||||||
|
return Promise.resolve({
|
||||||
|
identifier: id
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
openmct.once('start', resolve);
|
||||||
|
openmct.startHeadless();
|
||||||
|
}).then(() => {
|
||||||
|
composition = openmct.composition.get({identifier});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
|
@ -96,11 +96,11 @@ export default {
|
|||||||
|
|
||||||
this.timestampKey = this.openmct.time.timeSystem().key;
|
this.timestampKey = this.openmct.time.timeSystem().key;
|
||||||
|
|
||||||
this.valueMetadata = this
|
this.valueMetadata = this.metadata ? this
|
||||||
.metadata
|
.metadata
|
||||||
.valuesForHints(['range'])[0];
|
.valuesForHints(['range'])[0] : undefined;
|
||||||
|
|
||||||
this.valueKey = this.valueMetadata.key;
|
this.valueKey = this.valueMetadata ? this.valueMetadata.key : undefined;
|
||||||
|
|
||||||
this.unsubscribe = this.openmct
|
this.unsubscribe = this.openmct
|
||||||
.telemetry
|
.telemetry
|
||||||
@ -151,7 +151,10 @@ export default {
|
|||||||
size: 1,
|
size: 1,
|
||||||
strategy: 'latest'
|
strategy: 'latest'
|
||||||
})
|
})
|
||||||
.then((array) => this.updateValues(array[array.length - 1]));
|
.then((array) => this.updateValues(array[array.length - 1]))
|
||||||
|
.catch((error) => {
|
||||||
|
console.warn('Error fetching data', error);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
updateBounds(bounds, isTick) {
|
updateBounds(bounds, isTick) {
|
||||||
this.bounds = bounds;
|
this.bounds = bounds;
|
||||||
|
@ -73,8 +73,9 @@ export default {
|
|||||||
hasUnits() {
|
hasUnits() {
|
||||||
let itemsWithUnits = this.items.filter((item) => {
|
let itemsWithUnits = this.items.filter((item) => {
|
||||||
let metadata = this.openmct.telemetry.getMetadata(item.domainObject);
|
let metadata = this.openmct.telemetry.getMetadata(item.domainObject);
|
||||||
|
const valueMetadatas = metadata ? metadata.valueMetadatas : [];
|
||||||
|
|
||||||
return this.metadataHasUnits(metadata.valueMetadatas);
|
return this.metadataHasUnits(valueMetadatas);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,49 +0,0 @@
|
|||||||
/*****************************************************************************
|
|
||||||
* 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 { BAR_GRAPH_KEY } from '../charts/barGraph/BarGraphConstants';
|
|
||||||
import BarGraphViewProvider from '../charts/barGraph/BarGraphViewProvider';
|
|
||||||
import BarGraphInspectorViewProvider from '../charts/barGraph/inspector/BarGraphInspectorViewProvider';
|
|
||||||
import BarGraphCompositionPolicy from '../charts/barGraph/BarGraphCompositionPolicy';
|
|
||||||
|
|
||||||
export default function () {
|
|
||||||
return function install(openmct) {
|
|
||||||
openmct.types.addType(BAR_GRAPH_KEY, {
|
|
||||||
key: BAR_GRAPH_KEY,
|
|
||||||
name: "Bar Graph",
|
|
||||||
cssClass: "icon-bar-chart",
|
|
||||||
description: "View data as a bar graph. Can be added to Display Layouts.",
|
|
||||||
creatable: true,
|
|
||||||
initialize: function (domainObject) {
|
|
||||||
domainObject.composition = [];
|
|
||||||
domainObject.configuration = {
|
|
||||||
barStyles: {}
|
|
||||||
};
|
|
||||||
},
|
|
||||||
priority: 891
|
|
||||||
});
|
|
||||||
|
|
||||||
openmct.objectViews.addProvider(new BarGraphViewProvider(openmct));
|
|
||||||
openmct.inspectorViews.addProvider(new BarGraphInspectorViewProvider(openmct));
|
|
||||||
openmct.composition.addPolicy(new BarGraphCompositionPolicy(openmct).allow);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -1,151 +0,0 @@
|
|||||||
/*****************************************************************************
|
|
||||||
* 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 {createOpenMct, resetApplicationState} from "utils/testing";
|
|
||||||
import { BAR_GRAPH_VIEW, BAR_GRAPH_KEY } from '../charts/barGraph/BarGraphConstants';
|
|
||||||
import BarGraphPlugin from './plugin';
|
|
||||||
|
|
||||||
describe("the plugin", function () {
|
|
||||||
let element;
|
|
||||||
let child;
|
|
||||||
let openmct;
|
|
||||||
let telemetryPromise;
|
|
||||||
let telemetryPromiseResolve;
|
|
||||||
let mockObjectPath;
|
|
||||||
|
|
||||||
beforeEach((done) => {
|
|
||||||
mockObjectPath = [
|
|
||||||
{
|
|
||||||
name: 'mock folder',
|
|
||||||
type: 'fake-folder',
|
|
||||||
identifier: {
|
|
||||||
key: 'mock-folder',
|
|
||||||
namespace: ''
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'mock parent folder',
|
|
||||||
type: 'time-strip',
|
|
||||||
identifier: {
|
|
||||||
key: 'mock-parent-folder',
|
|
||||||
namespace: ''
|
|
||||||
}
|
|
||||||
}
|
|
||||||
];
|
|
||||||
const testTelemetry = [
|
|
||||||
{
|
|
||||||
'utc': 1,
|
|
||||||
'some-key': 'some-value 1',
|
|
||||||
'some-other-key': 'some-other-value 1'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'utc': 2,
|
|
||||||
'some-key': 'some-value 2',
|
|
||||||
'some-other-key': 'some-other-value 2'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'utc': 3,
|
|
||||||
'some-key': 'some-value 3',
|
|
||||||
'some-other-key': 'some-other-value 3'
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
openmct = createOpenMct();
|
|
||||||
|
|
||||||
telemetryPromise = new Promise((resolve) => {
|
|
||||||
telemetryPromiseResolve = resolve;
|
|
||||||
});
|
|
||||||
|
|
||||||
spyOn(openmct.telemetry, 'request').and.callFake(() => {
|
|
||||||
telemetryPromiseResolve(testTelemetry);
|
|
||||||
|
|
||||||
return telemetryPromise;
|
|
||||||
});
|
|
||||||
|
|
||||||
openmct.install(new BarGraphPlugin());
|
|
||||||
|
|
||||||
element = document.createElement("div");
|
|
||||||
element.style.width = "640px";
|
|
||||||
element.style.height = "480px";
|
|
||||||
child = document.createElement("div");
|
|
||||||
child.style.width = "640px";
|
|
||||||
child.style.height = "480px";
|
|
||||||
element.appendChild(child);
|
|
||||||
document.body.appendChild(element);
|
|
||||||
|
|
||||||
spyOn(window, 'ResizeObserver').and.returnValue({
|
|
||||||
observe() {},
|
|
||||||
disconnect() {}
|
|
||||||
});
|
|
||||||
|
|
||||||
openmct.time.timeSystem("utc", {
|
|
||||||
start: 0,
|
|
||||||
end: 4
|
|
||||||
});
|
|
||||||
|
|
||||||
openmct.types.addType("test-object", {
|
|
||||||
creatable: true
|
|
||||||
});
|
|
||||||
|
|
||||||
openmct.on("start", done);
|
|
||||||
openmct.startHeadless();
|
|
||||||
});
|
|
||||||
|
|
||||||
afterEach((done) => {
|
|
||||||
openmct.time.timeSystem('utc', {
|
|
||||||
start: 0,
|
|
||||||
end: 1
|
|
||||||
});
|
|
||||||
resetApplicationState(openmct).then(done).catch(done);
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("the bar graph", () => {
|
|
||||||
const mockObject = {
|
|
||||||
name: 'A bar graph',
|
|
||||||
key: BAR_GRAPH_KEY,
|
|
||||||
creatable: true
|
|
||||||
};
|
|
||||||
|
|
||||||
it('defines a bar graph type with the correct key', () => {
|
|
||||||
const objectDef = openmct.types.get(BAR_GRAPH_KEY).definition;
|
|
||||||
expect(objectDef.key).toEqual(mockObject.key);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('is creatable', () => {
|
|
||||||
const objectDef = openmct.types.get(BAR_GRAPH_KEY).definition;
|
|
||||||
expect(objectDef.creatable).toEqual(mockObject.creatable);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("the bar graph view", () => {
|
|
||||||
it("provides view for objects with telemetry", () => {
|
|
||||||
const testObject = {
|
|
||||||
id: "test-object",
|
|
||||||
type: BAR_GRAPH_KEY
|
|
||||||
};
|
|
||||||
|
|
||||||
const applicableViews = openmct.objectViews.get(testObject, mockObjectPath);
|
|
||||||
let plotView = applicableViews.find((viewProvider) => viewProvider.key === BAR_GRAPH_VIEW);
|
|
||||||
expect(plotView).toBeDefined();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
@ -98,6 +98,8 @@ describe('the plugin', function () {
|
|||||||
|
|
||||||
conditionSetDefinition.initialize(mockConditionSetDomainObject);
|
conditionSetDefinition.initialize(mockConditionSetDomainObject);
|
||||||
|
|
||||||
|
spyOn(openmct.objects, "save").and.returnValue(Promise.resolve(true));
|
||||||
|
|
||||||
openmct.on('start', done);
|
openmct.on('start', done);
|
||||||
openmct.startHeadless();
|
openmct.startHeadless();
|
||||||
});
|
});
|
||||||
|
@ -101,7 +101,7 @@ export default {
|
|||||||
addChildren(domainObject) {
|
addChildren(domainObject) {
|
||||||
let keyString = this.openmct.objects.makeKeyString(domainObject.identifier);
|
let keyString = this.openmct.objects.makeKeyString(domainObject.identifier);
|
||||||
let metadata = this.openmct.telemetry.getMetadata(domainObject);
|
let metadata = this.openmct.telemetry.getMetadata(domainObject);
|
||||||
let metadataWithFilters = metadata.valueMetadatas.filter(value => value.filters);
|
let metadataWithFilters = metadata ? metadata.valueMetadatas.filter(value => value.filters) : [];
|
||||||
let hasFiltersWithKeyString = this.persistedFilters[keyString] !== undefined;
|
let hasFiltersWithKeyString = this.persistedFilters[keyString] !== undefined;
|
||||||
let mutateFilters = false;
|
let mutateFilters = false;
|
||||||
let childObject = {
|
let childObject = {
|
||||||
|
@ -159,7 +159,7 @@ export default {
|
|||||||
let image = { ...datum };
|
let image = { ...datum };
|
||||||
image.formattedTime = this.formatTime(datum);
|
image.formattedTime = this.formatTime(datum);
|
||||||
image.url = this.formatImageUrl(datum);
|
image.url = this.formatImageUrl(datum);
|
||||||
image.time = datum[this.timeKey];
|
image.time = this.parseTime(image.formattedTime);
|
||||||
image.imageDownloadName = this.getImageDownloadName(datum);
|
image.imageDownloadName = this.getImageDownloadName(datum);
|
||||||
|
|
||||||
return image;
|
return image;
|
||||||
|
@ -180,9 +180,13 @@ export default {
|
|||||||
this.openmct.notifications.alert(message);
|
this.openmct.notifications.alert(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
const relativeHash = hash.slice(hash.indexOf('#'));
|
if (this.openmct.editor.isEditing()) {
|
||||||
const url = new URL(relativeHash, `${location.protocol}//${location.host}${location.pathname}`);
|
this.previewEmbed();
|
||||||
this.openmct.router.navigate(url.hash);
|
} else {
|
||||||
|
const relativeHash = hash.slice(hash.indexOf('#'));
|
||||||
|
const url = new URL(relativeHash, `${location.protocol}//${location.host}${location.pathname}`);
|
||||||
|
this.openmct.router.navigate(url.hash);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
formatTime(unixTime, timeFormat) {
|
formatTime(unixTime, timeFormat) {
|
||||||
return Moment.utc(unixTime).format(timeFormat);
|
return Moment.utc(unixTime).format(timeFormat);
|
||||||
|
72
src/plugins/notebook/monkeyPatchObjectAPIForNotebooks.js
Normal file
72
src/plugins/notebook/monkeyPatchObjectAPIForNotebooks.js
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
import {NOTEBOOK_TYPE} from './notebook-constants';
|
||||||
|
|
||||||
|
export default function (openmct) {
|
||||||
|
const apiSave = openmct.objects.save.bind(openmct.objects);
|
||||||
|
|
||||||
|
openmct.objects.save = async (domainObject) => {
|
||||||
|
if (domainObject.type !== NOTEBOOK_TYPE) {
|
||||||
|
return apiSave(domainObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
const localMutable = openmct.objects._toMutable(domainObject);
|
||||||
|
let result;
|
||||||
|
|
||||||
|
try {
|
||||||
|
result = await apiSave(localMutable);
|
||||||
|
} catch (error) {
|
||||||
|
if (error instanceof openmct.objects.errors.Conflict) {
|
||||||
|
result = resolveConflicts(localMutable, openmct);
|
||||||
|
} else {
|
||||||
|
result = Promise.reject(error);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
openmct.objects.destroyMutable(localMutable);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function resolveConflicts(localMutable, openmct) {
|
||||||
|
return openmct.objects.getMutable(localMutable.identifier).then((remoteMutable) => {
|
||||||
|
const localEntries = localMutable.configuration.entries;
|
||||||
|
remoteMutable.$refresh(remoteMutable);
|
||||||
|
applyLocalEntries(remoteMutable, localEntries);
|
||||||
|
|
||||||
|
openmct.objects.destroyMutable(remoteMutable);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function applyLocalEntries(mutable, entries) {
|
||||||
|
Object.entries(entries).forEach(([sectionKey, pagesInSection]) => {
|
||||||
|
Object.entries(pagesInSection).forEach(([pageKey, localEntries]) => {
|
||||||
|
const remoteEntries = mutable.configuration.entries[sectionKey][pageKey];
|
||||||
|
const mergedEntries = [].concat(remoteEntries);
|
||||||
|
let shouldMutate = false;
|
||||||
|
|
||||||
|
const locallyAddedEntries = _.differenceBy(localEntries, remoteEntries, 'id');
|
||||||
|
const locallyModifiedEntries = _.differenceWith(localEntries, remoteEntries, (localEntry, remoteEntry) => {
|
||||||
|
return localEntry.id === remoteEntry.id && localEntry.text === remoteEntry.text;
|
||||||
|
});
|
||||||
|
|
||||||
|
locallyAddedEntries.forEach((localEntry) => {
|
||||||
|
mergedEntries.push(localEntry);
|
||||||
|
shouldMutate = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
locallyModifiedEntries.forEach((locallyModifiedEntry) => {
|
||||||
|
let mergedEntry = mergedEntries.find(entry => entry.id === locallyModifiedEntry.id);
|
||||||
|
if (mergedEntry !== undefined) {
|
||||||
|
mergedEntry.text = locallyModifiedEntry.text;
|
||||||
|
shouldMutate = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (shouldMutate) {
|
||||||
|
mutable.$set(`configuration.entries.${sectionKey}.${pageKey}`, mergedEntries);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
@ -2,6 +2,7 @@ import CopyToNotebookAction from './actions/CopyToNotebookAction';
|
|||||||
import Notebook from './components/Notebook.vue';
|
import Notebook from './components/Notebook.vue';
|
||||||
import NotebookSnapshotIndicator from './components/NotebookSnapshotIndicator.vue';
|
import NotebookSnapshotIndicator from './components/NotebookSnapshotIndicator.vue';
|
||||||
import SnapshotContainer from './snapshot-container';
|
import SnapshotContainer from './snapshot-container';
|
||||||
|
import monkeyPatchObjectAPIForNotebooks from './monkeyPatchObjectAPIForNotebooks.js';
|
||||||
|
|
||||||
import { notebookImageMigration } from '../notebook/utils/notebook-migration';
|
import { notebookImageMigration } from '../notebook/utils/notebook-migration';
|
||||||
import { NOTEBOOK_TYPE } from './notebook-constants';
|
import { NOTEBOOK_TYPE } from './notebook-constants';
|
||||||
@ -165,5 +166,7 @@ export default function NotebookPlugin() {
|
|||||||
return domainObject;
|
return domainObject;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
monkeyPatchObjectAPIForNotebooks(openmct);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -154,6 +154,8 @@ describe("Notebook plugin:", () => {
|
|||||||
testObjectProvider.get.and.returnValue(Promise.resolve(notebookViewObject));
|
testObjectProvider.get.and.returnValue(Promise.resolve(notebookViewObject));
|
||||||
openmct.objects.addProvider('test-namespace', testObjectProvider);
|
openmct.objects.addProvider('test-namespace', testObjectProvider);
|
||||||
testObjectProvider.observe.and.returnValue(() => {});
|
testObjectProvider.observe.and.returnValue(() => {});
|
||||||
|
testObjectProvider.create.and.returnValue(Promise.resolve(true));
|
||||||
|
testObjectProvider.update.and.returnValue(Promise.resolve(true));
|
||||||
|
|
||||||
return openmct.objects.getMutable(notebookViewObject.identifier).then((mutableObject) => {
|
return openmct.objects.getMutable(notebookViewObject.identifier).then((mutableObject) => {
|
||||||
mutableNotebookObject = mutableObject;
|
mutableNotebookObject = mutableObject;
|
||||||
|
@ -125,7 +125,7 @@ export function addNotebookEntry(openmct, domainObject, notebookStorage, embed =
|
|||||||
const newEntries = addEntryIntoPage(notebookStorage, entries, entry);
|
const newEntries = addEntryIntoPage(notebookStorage, entries, entry);
|
||||||
|
|
||||||
addDefaultClass(domainObject, openmct);
|
addDefaultClass(domainObject, openmct);
|
||||||
openmct.objects.mutate(domainObject, 'configuration.entries', newEntries);
|
domainObject.configuration.entries = newEntries;
|
||||||
|
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
@ -15,12 +15,16 @@
|
|||||||
|
|
||||||
port.onmessage = async function (event) {
|
port.onmessage = async function (event) {
|
||||||
if (event.data.request === 'close') {
|
if (event.data.request === 'close') {
|
||||||
|
console.log('Closing connection');
|
||||||
connections.splice(event.data.connectionId - 1, 1);
|
connections.splice(event.data.connectionId - 1, 1);
|
||||||
if (connections.length <= 0) {
|
if (connections.length <= 0) {
|
||||||
// abort any outstanding requests if there's nobody listening to it.
|
// abort any outstanding requests if there's nobody listening to it.
|
||||||
controller.abort();
|
controller.abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log('Closed.');
|
||||||
|
connected = false;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -29,68 +33,9 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
connected = true;
|
do {
|
||||||
|
await self.listenForChanges(event.data.url, event.data.body, port);
|
||||||
let url = event.data.url;
|
} while (connected);
|
||||||
let body = event.data.body;
|
|
||||||
let error = false;
|
|
||||||
// feed=continuous maintains an indefinitely open connection with a keep-alive of HEARTBEAT milliseconds until this client closes the connection
|
|
||||||
// style=main_only returns only the current winning revision of the document
|
|
||||||
|
|
||||||
const response = await fetch(url, {
|
|
||||||
method: 'POST',
|
|
||||||
headers: {
|
|
||||||
"Content-Type": 'application/json'
|
|
||||||
},
|
|
||||||
signal,
|
|
||||||
body
|
|
||||||
});
|
|
||||||
|
|
||||||
let reader;
|
|
||||||
|
|
||||||
if (response.body === undefined) {
|
|
||||||
error = true;
|
|
||||||
} else {
|
|
||||||
reader = response.body.getReader();
|
|
||||||
}
|
|
||||||
|
|
||||||
while (!error) {
|
|
||||||
const {done, value} = await reader.read();
|
|
||||||
//done is true when we lose connection with the provider
|
|
||||||
if (done) {
|
|
||||||
error = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (value) {
|
|
||||||
let chunk = new Uint8Array(value.length);
|
|
||||||
chunk.set(value, 0);
|
|
||||||
const decodedChunk = new TextDecoder("utf-8").decode(chunk).split('\n');
|
|
||||||
if (decodedChunk.length && decodedChunk[decodedChunk.length - 1] === '') {
|
|
||||||
decodedChunk.forEach((doc, index) => {
|
|
||||||
try {
|
|
||||||
if (doc) {
|
|
||||||
const objectChanges = JSON.parse(doc);
|
|
||||||
connections.forEach(function (connection) {
|
|
||||||
connection.postMessage({
|
|
||||||
objectChanges
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} catch (decodeError) {
|
|
||||||
//do nothing;
|
|
||||||
console.log(decodeError);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (error) {
|
|
||||||
port.postMessage({
|
|
||||||
error
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -103,4 +48,64 @@
|
|||||||
console.log('Error on feed');
|
console.log('Error on feed');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
self.listenForChanges = async function (url, body, port) {
|
||||||
|
connected = true;
|
||||||
|
let error = false;
|
||||||
|
// feed=continuous maintains an indefinitely open connection with a keep-alive of HEARTBEAT milliseconds until this client closes the connection
|
||||||
|
// style=main_only returns only the current winning revision of the document
|
||||||
|
|
||||||
|
console.log('Opening changes feed connection.');
|
||||||
|
const response = await fetch(url, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
"Content-Type": 'application/json'
|
||||||
|
},
|
||||||
|
signal,
|
||||||
|
body
|
||||||
|
});
|
||||||
|
|
||||||
|
let reader;
|
||||||
|
|
||||||
|
if (response.body === undefined) {
|
||||||
|
error = true;
|
||||||
|
} else {
|
||||||
|
reader = response.body.getReader();
|
||||||
|
}
|
||||||
|
|
||||||
|
while (!error) {
|
||||||
|
const {done, value} = await reader.read();
|
||||||
|
//done is true when we lose connection with the provider
|
||||||
|
if (done) {
|
||||||
|
error = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (value) {
|
||||||
|
let chunk = new Uint8Array(value.length);
|
||||||
|
chunk.set(value, 0);
|
||||||
|
const decodedChunk = new TextDecoder("utf-8").decode(chunk).split('\n');
|
||||||
|
console.log('Received chunk');
|
||||||
|
if (decodedChunk.length && decodedChunk[decodedChunk.length - 1] === '') {
|
||||||
|
decodedChunk.forEach((doc, index) => {
|
||||||
|
try {
|
||||||
|
if (doc) {
|
||||||
|
const objectChanges = JSON.parse(doc);
|
||||||
|
connections.forEach(function (connection) {
|
||||||
|
connection.postMessage({
|
||||||
|
objectChanges
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (decodeError) {
|
||||||
|
//do nothing;
|
||||||
|
console.log(decodeError);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('Done reading changes feed');
|
||||||
|
};
|
||||||
|
|
||||||
}());
|
}());
|
||||||
|
@ -29,7 +29,7 @@ const ID = "_id";
|
|||||||
const HEARTBEAT = 50000;
|
const HEARTBEAT = 50000;
|
||||||
const ALL_DOCS = "_all_docs?include_docs=true";
|
const ALL_DOCS = "_all_docs?include_docs=true";
|
||||||
|
|
||||||
export default class CouchObjectProvider {
|
class CouchObjectProvider {
|
||||||
constructor(openmct, options, namespace) {
|
constructor(openmct, options, namespace) {
|
||||||
options = this._normalize(options);
|
options = this._normalize(options);
|
||||||
this.openmct = openmct;
|
this.openmct = openmct;
|
||||||
@ -74,13 +74,6 @@ export default class CouchObjectProvider {
|
|||||||
if (event.data.type === 'connection') {
|
if (event.data.type === 'connection') {
|
||||||
this.changesFeedSharedWorkerConnectionId = event.data.connectionId;
|
this.changesFeedSharedWorkerConnectionId = event.data.connectionId;
|
||||||
} else {
|
} else {
|
||||||
const error = event.data.error;
|
|
||||||
if (error && Object.keys(this.observers).length > 0) {
|
|
||||||
this.observeObjectChanges();
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let objectChanges = event.data.objectChanges;
|
let objectChanges = event.data.objectChanges;
|
||||||
objectChanges.identifier = {
|
objectChanges.identifier = {
|
||||||
namespace: this.namespace,
|
namespace: this.namespace,
|
||||||
@ -126,11 +119,12 @@ export default class CouchObjectProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return fetch(this.url + '/' + subPath, fetchOptions)
|
return fetch(this.url + '/' + subPath, fetchOptions)
|
||||||
.then(response => response.json())
|
.then((response) => {
|
||||||
.then(function (response) {
|
if (response.status === CouchObjectProvider.HTTP_CONFLICT) {
|
||||||
return response;
|
throw new this.openmct.objects.errors.Conflict(`Conflict persisting ${fetchOptions.body.name}`);
|
||||||
}, function () {
|
}
|
||||||
return undefined;
|
|
||||||
|
return response.json();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -561,12 +555,18 @@ export default class CouchObjectProvider {
|
|||||||
let intermediateResponse = this.getIntermediateResponse();
|
let intermediateResponse = this.getIntermediateResponse();
|
||||||
const key = model.identifier.key;
|
const key = model.identifier.key;
|
||||||
this.enqueueObject(key, model, intermediateResponse);
|
this.enqueueObject(key, model, intermediateResponse);
|
||||||
this.objectQueue[key].pending = true;
|
if (!this.objectQueue[key].pending) {
|
||||||
const queued = this.objectQueue[key].dequeue();
|
this.objectQueue[key].pending = true;
|
||||||
let document = new CouchDocument(key, queued.model);
|
const queued = this.objectQueue[key].dequeue();
|
||||||
this.request(key, "PUT", document).then((response) => {
|
let document = new CouchDocument(key, queued.model);
|
||||||
this.checkResponse(response, queued.intermediateResponse, key);
|
this.request(key, "PUT", document).then((response) => {
|
||||||
});
|
console.log('create check response', key);
|
||||||
|
this.checkResponse(response, queued.intermediateResponse, key);
|
||||||
|
}).catch(error => {
|
||||||
|
queued.intermediateResponse.reject(error);
|
||||||
|
this.objectQueue[key].pending = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return intermediateResponse.promise;
|
return intermediateResponse.promise;
|
||||||
}
|
}
|
||||||
@ -581,6 +581,9 @@ export default class CouchObjectProvider {
|
|||||||
let document = new CouchDocument(key, queued.model, this.objectQueue[key].rev);
|
let document = new CouchDocument(key, queued.model, this.objectQueue[key].rev);
|
||||||
this.request(key, "PUT", document).then((response) => {
|
this.request(key, "PUT", document).then((response) => {
|
||||||
this.checkResponse(response, queued.intermediateResponse, key);
|
this.checkResponse(response, queued.intermediateResponse, key);
|
||||||
|
}).catch((error) => {
|
||||||
|
queued.intermediateResponse.reject(error);
|
||||||
|
this.objectQueue[key].pending = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -594,3 +597,7 @@ export default class CouchObjectProvider {
|
|||||||
return intermediateResponse.promise;
|
return intermediateResponse.promise;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CouchObjectProvider.HTTP_CONFLICT = 409;
|
||||||
|
|
||||||
|
export default CouchObjectProvider;
|
||||||
|
@ -21,67 +21,57 @@
|
|||||||
-->
|
-->
|
||||||
<template>
|
<template>
|
||||||
<div class="u-contents">
|
<div class="u-contents">
|
||||||
<ul v-if="canEdit"
|
<div v-if="canEdit"
|
||||||
class="l-inspector-part"
|
class="grid-row"
|
||||||
>
|
>
|
||||||
<h2 v-if="heading"
|
<div class="grid-cell label"
|
||||||
:title="heading"
|
:title="editTitle"
|
||||||
>{{ heading }}</h2>
|
>{{ shortLabel }}</div>
|
||||||
<li class="grid-row">
|
<div class="grid-cell value">
|
||||||
<div class="grid-cell label"
|
<div class="c-click-swatch c-click-swatch--menu"
|
||||||
:title="editTitle"
|
@click="toggleSwatch()"
|
||||||
>{{ shortLabel }}</div>
|
>
|
||||||
<div class="grid-cell value">
|
<span class="c-color-swatch"
|
||||||
<div class="c-click-swatch c-click-swatch--menu"
|
:style="{ background: currentColor }"
|
||||||
@click="toggleSwatch()"
|
|
||||||
>
|
>
|
||||||
<span class="c-color-swatch"
|
</span>
|
||||||
:style="{ background: currentColor }"
|
</div>
|
||||||
|
<div class="c-palette c-palette--color">
|
||||||
|
<div v-show="swatchActive"
|
||||||
|
class="c-palette__items"
|
||||||
|
>
|
||||||
|
<div v-for="group in colorPaletteGroups"
|
||||||
|
:key="group.id"
|
||||||
|
class="u-contents"
|
||||||
>
|
>
|
||||||
</span>
|
<div v-for="color in group"
|
||||||
</div>
|
:key="color.id"
|
||||||
<div class="c-palette c-palette--color">
|
class="c-palette__item"
|
||||||
<div v-show="swatchActive"
|
:class="{ 'selected': currentColor === color.hexString }"
|
||||||
class="c-palette__items"
|
:style="{ background: color.hexString }"
|
||||||
>
|
@click="setColor(color)"
|
||||||
<div v-for="group in colorPaletteGroups"
|
|
||||||
:key="group.id"
|
|
||||||
class="u-contents"
|
|
||||||
>
|
>
|
||||||
<div v-for="color in group"
|
|
||||||
:key="color.id"
|
|
||||||
class="c-palette__item"
|
|
||||||
:class="{ 'selected': currentColor === color.hexString }"
|
|
||||||
:style="{ background: color.hexString }"
|
|
||||||
@click="setColor(color)"
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</div>
|
||||||
</ul>
|
</div>
|
||||||
<ul v-else
|
<div v-else
|
||||||
class="l-inspector-part"
|
class="grid-row"
|
||||||
>
|
>
|
||||||
<h2 v-if="heading"
|
<div class="grid-cell label"
|
||||||
:title="heading"
|
:title="viewTitle"
|
||||||
>{{ heading }}</h2>
|
>{{ shortLabel }}</div>
|
||||||
<li class="grid-row">
|
<div class="grid-cell value">
|
||||||
<div class="grid-cell label"
|
<span class="c-color-swatch"
|
||||||
:title="viewTitle"
|
:style="{
|
||||||
>{{ shortLabel }}</div>
|
'background': currentColor
|
||||||
<div class="grid-cell value">
|
}"
|
||||||
<span class="c-color-swatch"
|
>
|
||||||
:style="{
|
</span>
|
||||||
'background': currentColor
|
</div>
|
||||||
}"
|
</div>
|
||||||
>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -114,12 +104,6 @@ export default {
|
|||||||
default() {
|
default() {
|
||||||
return 'Color';
|
return 'Color';
|
||||||
}
|
}
|
||||||
},
|
|
||||||
heading: {
|
|
||||||
type: String,
|
|
||||||
default() {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
|
@ -23,20 +23,24 @@
|
|||||||
import { BAR_GRAPH_KEY } from './BarGraphConstants';
|
import { BAR_GRAPH_KEY } from './BarGraphConstants';
|
||||||
|
|
||||||
export default function BarGraphCompositionPolicy(openmct) {
|
export default function BarGraphCompositionPolicy(openmct) {
|
||||||
function hasRange(metadata) {
|
function hasAggregateDomainAndRange(metadata) {
|
||||||
const rangeValues = metadata.valuesForHints(['range']);
|
const rangeValues = metadata.valuesForHints(['range']);
|
||||||
|
|
||||||
return rangeValues.length > 0;
|
return rangeValues.length > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function hasBarGraphTelemetry(domainObject) {
|
function hasBarGraphTelemetry(domainObject) {
|
||||||
if (!openmct.telemetry.isTelemetryObject(domainObject)) {
|
if (!Object.prototype.hasOwnProperty.call(domainObject, 'telemetry')) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
let metadata = openmct.telemetry.getMetadata(domainObject);
|
let metadata = openmct.telemetry.getMetadata(domainObject);
|
||||||
|
|
||||||
return metadata.values().length > 0 && hasRange(metadata);
|
return metadata.values().length > 0 && hasAggregateDomainAndRange(metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
function hasNoChildren(parentObject) {
|
||||||
|
return parentObject.composition && parentObject.composition.length < 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
@ -1,3 +1,5 @@
|
|||||||
export const BAR_GRAPH_VIEW = 'bar-graph.view';
|
export const BAR_GRAPH_VIEW = 'bar-graph.view';
|
||||||
export const BAR_GRAPH_KEY = 'telemetry.plot.bar-graph';
|
export const BAR_GRAPH_KEY = 'telemetry.plot.bar-graph';
|
||||||
export const BAR_GRAPH_INSPECTOR_KEY = 'telemetry.plot.bar-graph.inspector';
|
export const BAR_GRAPH_INSPECTOR_KEY = 'telemetry.plot.bar-graph.inspector';
|
||||||
|
export const SUBSCRIBE = 'subscribe';
|
||||||
|
export const UNSUBSCRIBE = 'unsubscribe';
|
@ -12,7 +12,6 @@
|
|||||||
</div>
|
</div>
|
||||||
<div ref="plot"
|
<div ref="plot"
|
||||||
class="c-bar-chart"
|
class="c-bar-chart"
|
||||||
@plotly_relayout="zoom"
|
|
||||||
></div>
|
></div>
|
||||||
<div v-if="false"
|
<div v-if="false"
|
||||||
ref="localControl"
|
ref="localControl"
|
||||||
@ -29,7 +28,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import Plotly from 'plotly-basic';
|
import Plotly from 'plotly.js-basic-dist';
|
||||||
|
import { SUBSCRIBE, UNSUBSCRIBE } from './BarGraphConstants';
|
||||||
|
|
||||||
const MULTI_AXES_X_PADDING_PERCENT = {
|
const MULTI_AXES_X_PADDING_PERCENT = {
|
||||||
LEFT: 8,
|
LEFT: 8,
|
||||||
@ -79,6 +79,8 @@ export default {
|
|||||||
this.registerListeners();
|
this.registerListeners();
|
||||||
},
|
},
|
||||||
beforeDestroy() {
|
beforeDestroy() {
|
||||||
|
this.$refs.plot.removeAllListeners();
|
||||||
|
|
||||||
if (this.plotResizeObserver) {
|
if (this.plotResizeObserver) {
|
||||||
this.plotResizeObserver.unobserve(this.$refs.plotWrapper);
|
this.plotResizeObserver.unobserve(this.$refs.plotWrapper);
|
||||||
clearTimeout(this.resizeTimer);
|
clearTimeout(this.resizeTimer);
|
||||||
@ -201,6 +203,8 @@ export default {
|
|||||||
return yaxis;
|
return yaxis;
|
||||||
},
|
},
|
||||||
registerListeners() {
|
registerListeners() {
|
||||||
|
this.$refs.plot.on('plotly_relayout', this.zoom);
|
||||||
|
|
||||||
this.removeBarColorListener = this.openmct.objects.observe(
|
this.removeBarColorListener = this.openmct.objects.observe(
|
||||||
this.domainObject,
|
this.domainObject,
|
||||||
'configuration.barStyles',
|
'configuration.barStyles',
|
||||||
@ -222,7 +226,7 @@ export default {
|
|||||||
this.updatePlot();
|
this.updatePlot();
|
||||||
|
|
||||||
this.isZoomed = false;
|
this.isZoomed = false;
|
||||||
this.$emit('subscribe');
|
this.$emit(SUBSCRIBE);
|
||||||
},
|
},
|
||||||
barColorChanged() {
|
barColorChanged() {
|
||||||
const colors = [];
|
const colors = [];
|
||||||
@ -281,7 +285,7 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.isZoomed = true;
|
this.isZoomed = true;
|
||||||
this.$emit('unsubscribe');
|
this.$emit(UNSUBSCRIBE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
@ -25,13 +25,12 @@
|
|||||||
class="c-plot c-bar-chart-view"
|
class="c-plot c-bar-chart-view"
|
||||||
:data="trace"
|
:data="trace"
|
||||||
:plot-axis-title="plotAxisTitle"
|
:plot-axis-title="plotAxisTitle"
|
||||||
@subscribe="subscribeToAll"
|
|
||||||
@unsubscribe="removeAllSubscriptions"
|
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import ColorPalette from '../../plot/lib/ColorPalette';
|
import * as SPECTRAL_AGGREGATE from './BarGraphConstants';
|
||||||
|
import ColorPalette from '../lib/ColorPalette';
|
||||||
import BarGraph from './BarGraphPlot.vue';
|
import BarGraph from './BarGraphPlot.vue';
|
||||||
import Color from "@/plugins/plot/lib/Color";
|
import Color from "@/plugins/plot/lib/Color";
|
||||||
|
|
||||||
@ -41,16 +40,18 @@ export default {
|
|||||||
},
|
},
|
||||||
inject: ['openmct', 'domainObject'],
|
inject: ['openmct', 'domainObject'],
|
||||||
data() {
|
data() {
|
||||||
this.telemetryObjects = {};
|
|
||||||
this.telemetryObjectFormats = {};
|
|
||||||
this.subscriptions = [];
|
|
||||||
this.composition = {};
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
composition: {},
|
||||||
|
currentDomainObject: this.domainObject,
|
||||||
|
subscriptions: [],
|
||||||
|
telemetryObjects: {},
|
||||||
trace: []
|
trace: []
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
activeClock() {
|
||||||
|
return this.openmct.time.activeClock;
|
||||||
|
},
|
||||||
plotAxisTitle() {
|
plotAxisTitle() {
|
||||||
const { xAxisMetadata = {}, yAxisMetadata = {} } = this.trace[0] || {};
|
const { xAxisMetadata = {}, yAxisMetadata = {} } = this.trace[0] || {};
|
||||||
const xAxisUnit = xAxisMetadata.units ? `(${xAxisMetadata.units})` : '';
|
const xAxisUnit = xAxisMetadata.units ? `(${xAxisMetadata.units})` : '';
|
||||||
@ -67,11 +68,20 @@ export default {
|
|||||||
this.loadComposition();
|
this.loadComposition();
|
||||||
|
|
||||||
this.openmct.time.on('bounds', this.refreshData);
|
this.openmct.time.on('bounds', this.refreshData);
|
||||||
|
this.openmct.time.on('clock', this.clockChanged);
|
||||||
|
|
||||||
|
this.$refs.barGraph.$on(SPECTRAL_AGGREGATE.SUBSCRIBE, this.subscribeToAll);
|
||||||
|
this.$refs.barGraph.$on(SPECTRAL_AGGREGATE.UNSUBSCRIBE, this.removeAllSubscriptions);
|
||||||
|
|
||||||
|
this.unobserve = this.openmct.objects.observe(this.currentDomainObject, '*', this.updateDomainObject);
|
||||||
},
|
},
|
||||||
beforeDestroy() {
|
beforeDestroy() {
|
||||||
|
this.$refs.barGraph.$off();
|
||||||
this.openmct.time.off('bounds', this.refreshData);
|
this.openmct.time.off('bounds', this.refreshData);
|
||||||
|
this.openmct.time.off('clock', this.clockChanged);
|
||||||
|
|
||||||
this.removeAllSubscriptions();
|
this.removeAllSubscriptions();
|
||||||
|
this.unobserve();
|
||||||
|
|
||||||
if (!this.composition) {
|
if (!this.composition) {
|
||||||
return;
|
return;
|
||||||
@ -84,16 +94,21 @@ export default {
|
|||||||
addTelemetryObject(telemetryObject) {
|
addTelemetryObject(telemetryObject) {
|
||||||
const key = this.openmct.objects.makeKeyString(telemetryObject.identifier);
|
const key = this.openmct.objects.makeKeyString(telemetryObject.identifier);
|
||||||
|
|
||||||
|
if (!this.domainObject.configuration.barStyles) {
|
||||||
|
this.domainObject.configuration.barStyles = {};
|
||||||
|
}
|
||||||
|
|
||||||
// check to see if we've set a bar color
|
// check to see if we've set a bar color
|
||||||
if (!this.domainObject.configuration.barStyles[key] || !this.domainObject.configuration.barStyles[key].color) {
|
if (!this.domainObject.configuration.barStyles[key] || !this.domainObject.configuration.barStyles[key].color) {
|
||||||
const color = this.colorPalette.getNextColor().asHexString();
|
const color = this.colorPalette.getNextColor().asHexString();
|
||||||
|
this.domainObject.configuration.barStyles[key] = {
|
||||||
|
name: telemetryObject.name,
|
||||||
|
color
|
||||||
|
};
|
||||||
this.openmct.objects.mutate(
|
this.openmct.objects.mutate(
|
||||||
this.domainObject,
|
this.domainObject,
|
||||||
`configuration.barStyles[${key}]`,
|
`configuration.barStyles[${key}]`,
|
||||||
{
|
this.domainObject.configuration.barStyles[key]
|
||||||
name: telemetryObject.name,
|
|
||||||
color
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
let color = this.domainObject.configuration.barStyles[key].color;
|
let color = this.domainObject.configuration.barStyles[key].color;
|
||||||
@ -105,9 +120,6 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.telemetryObjects[key] = telemetryObject;
|
this.telemetryObjects[key] = telemetryObject;
|
||||||
const metadata = this.openmct.telemetry.getMetadata(telemetryObject);
|
|
||||||
const formats = this.openmct.telemetry.getFormatMap(metadata);
|
|
||||||
this.telemetryObjectFormats[key] = formats;
|
|
||||||
|
|
||||||
this.requestDataFor(telemetryObject);
|
this.requestDataFor(telemetryObject);
|
||||||
this.subscribeToObject(telemetryObject);
|
this.subscribeToObject(telemetryObject);
|
||||||
@ -132,8 +144,16 @@ export default {
|
|||||||
|
|
||||||
this.trace = isInTrace ? newTrace : newTrace.concat([trace]);
|
this.trace = isInTrace ? newTrace : newTrace.concat([trace]);
|
||||||
},
|
},
|
||||||
|
clockChanged() {
|
||||||
|
this.removeAllSubscriptions();
|
||||||
|
this.subscribeToAll();
|
||||||
|
},
|
||||||
getAxisMetadata(telemetryObject) {
|
getAxisMetadata(telemetryObject) {
|
||||||
const metadata = this.openmct.telemetry.getMetadata(telemetryObject);
|
const metadata = this.openmct.telemetry.getMetadata(telemetryObject);
|
||||||
|
if (!metadata) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
const yAxisMetadata = metadata.valuesForHints(['range'])[0];
|
const yAxisMetadata = metadata.valuesForHints(['range'])[0];
|
||||||
//Exclude 'name' and 'time' based metadata specifically, from the x-Axis values by using range hints only
|
//Exclude 'name' and 'time' based metadata specifically, from the x-Axis values by using range hints only
|
||||||
const xAxisMetadata = metadata.valuesForHints(['range']);
|
const xAxisMetadata = metadata.valuesForHints(['range']);
|
||||||
@ -143,19 +163,21 @@ export default {
|
|||||||
yAxisMetadata
|
yAxisMetadata
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
getOptions() {
|
getOptions(telemetryObject) {
|
||||||
const { start, end } = this.openmct.time.bounds();
|
const { start, end } = this.openmct.time.bounds();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
end,
|
end,
|
||||||
start
|
start,
|
||||||
|
startTime: null,
|
||||||
|
spectra: true
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
loadComposition() {
|
loadComposition() {
|
||||||
this.composition = this.openmct.composition.get(this.domainObject);
|
this.composition = this.openmct.composition.get(this.currentDomainObject);
|
||||||
|
|
||||||
if (!this.composition) {
|
if (!this.composition) {
|
||||||
this.addTelemetryObject(this.domainObject);
|
this.addTelemetryObject(this.currentDomainObject);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -184,7 +206,6 @@ export default {
|
|||||||
removeTelemetryObject(identifier) {
|
removeTelemetryObject(identifier) {
|
||||||
const key = this.openmct.objects.makeKeyString(identifier);
|
const key = this.openmct.objects.makeKeyString(identifier);
|
||||||
delete this.telemetryObjects[key];
|
delete this.telemetryObjects[key];
|
||||||
delete this.this.telemetryObjectFormats[key];
|
|
||||||
if (this.domainObject.configuration.barStyles[key]) {
|
if (this.domainObject.configuration.barStyles[key]) {
|
||||||
delete this.domainObject.configuration.barStyles[key];
|
delete this.domainObject.configuration.barStyles[key];
|
||||||
}
|
}
|
||||||
@ -193,17 +214,13 @@ export default {
|
|||||||
|
|
||||||
this.trace = this.trace.filter(t => t.key !== key);
|
this.trace = this.trace.filter(t => t.key !== key);
|
||||||
},
|
},
|
||||||
addDataToGraph(telemetryObject, data, axisMetadata) {
|
processData(telemetryObject, data, axisMetadata) {
|
||||||
const key = this.openmct.objects.makeKeyString(telemetryObject.identifier);
|
const key = this.openmct.objects.makeKeyString(telemetryObject.identifier);
|
||||||
|
|
||||||
if (data.message) {
|
if (data.message) {
|
||||||
this.openmct.notifications.alert(data.message);
|
this.openmct.notifications.alert(data.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.isDataInTimeRange(data)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let xValues = [];
|
let xValues = [];
|
||||||
let yValues = [];
|
let yValues = [];
|
||||||
|
|
||||||
@ -211,10 +228,10 @@ export default {
|
|||||||
axisMetadata.xAxisMetadata.forEach((metadata) => {
|
axisMetadata.xAxisMetadata.forEach((metadata) => {
|
||||||
xValues.push(metadata.name);
|
xValues.push(metadata.name);
|
||||||
if (data[metadata.key]) {
|
if (data[metadata.key]) {
|
||||||
const formattedValue = this.format(key, metadata.key, data);
|
//TODO: Format the data?
|
||||||
yValues.push(formattedValue);
|
yValues.push(data[metadata.key]);
|
||||||
} else {
|
} else {
|
||||||
yValues.push(null);
|
yValues.push('');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -235,24 +252,16 @@ export default {
|
|||||||
|
|
||||||
this.addTrace(trace, key);
|
this.addTrace(trace, key);
|
||||||
},
|
},
|
||||||
isDataInTimeRange(data) {
|
|
||||||
const timeSystemKey = this.openmct.time.timeSystem().key;
|
|
||||||
const currentTimestamp = data[timeSystemKey];
|
|
||||||
|
|
||||||
return currentTimestamp && this.openmct.time.bounds().end >= currentTimestamp;
|
|
||||||
},
|
|
||||||
format(telemetryObjectKey, metadataKey, data) {
|
|
||||||
const formats = this.telemetryObjectFormats[telemetryObjectKey];
|
|
||||||
|
|
||||||
return formats[metadataKey].format(data);
|
|
||||||
},
|
|
||||||
requestDataFor(telemetryObject) {
|
requestDataFor(telemetryObject) {
|
||||||
const axisMetadata = this.getAxisMetadata(telemetryObject);
|
const axisMetadata = this.getAxisMetadata(telemetryObject);
|
||||||
this.openmct.telemetry.request(telemetryObject)
|
this.openmct.telemetry.request(telemetryObject, this.getOptions(telemetryObject))
|
||||||
.then(data => {
|
.then(data => {
|
||||||
data.forEach((datum) => {
|
data.forEach((datum) => {
|
||||||
this.addDataToGraph(telemetryObject, datum, axisMetadata);
|
this.processData(telemetryObject, datum, axisMetadata);
|
||||||
});
|
});
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.warn(`Error fetching data`, error);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
subscribeToObject(telemetryObject) {
|
subscribeToObject(telemetryObject) {
|
||||||
@ -260,10 +269,10 @@ export default {
|
|||||||
|
|
||||||
this.removeSubscription(key);
|
this.removeSubscription(key);
|
||||||
|
|
||||||
const options = this.getOptions();
|
const options = this.getOptions(telemetryObject);
|
||||||
const axisMetadata = this.getAxisMetadata(telemetryObject);
|
const axisMetadata = this.getAxisMetadata(telemetryObject);
|
||||||
const unsubscribe = this.openmct.telemetry.subscribe(telemetryObject,
|
const unsubscribe = this.openmct.telemetry.subscribe(telemetryObject,
|
||||||
data => this.addDataToGraph(telemetryObject, data, axisMetadata)
|
data => this.processData(telemetryObject, data, axisMetadata)
|
||||||
, options);
|
, options);
|
||||||
|
|
||||||
this.subscriptions.push({
|
this.subscriptions.push({
|
||||||
@ -274,6 +283,9 @@ export default {
|
|||||||
subscribeToAll() {
|
subscribeToAll() {
|
||||||
const telemetryObjects = Object.values(this.telemetryObjects);
|
const telemetryObjects = Object.values(this.telemetryObjects);
|
||||||
telemetryObjects.forEach(this.subscribeToObject);
|
telemetryObjects.forEach(this.subscribeToObject);
|
||||||
|
},
|
||||||
|
updateDomainObject(newDomainObject) {
|
||||||
|
this.currentDomainObject = newDomainObject;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
@ -33,9 +33,9 @@
|
|||||||
</li>
|
</li>
|
||||||
<ColorSwatch v-if="expanded"
|
<ColorSwatch v-if="expanded"
|
||||||
:current-color="currentColor"
|
:current-color="currentColor"
|
||||||
title="Manually set the color for this bar graph."
|
title="Manually set the color for this bar graph series."
|
||||||
edit-title="Manually set the color for this bar graph"
|
edit-title="Manually set the color for this bar graph series"
|
||||||
view-title="The color for this bar graph."
|
view-title="The color for this bar graph series."
|
||||||
short-label="Color"
|
short-label="Color"
|
||||||
class="grid-properties"
|
class="grid-properties"
|
||||||
@colorSet="setColor"
|
@colorSet="setColor"
|
||||||
@ -44,7 +44,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import ColorSwatch from '../../../plot/ColorSwatch.vue';
|
import ColorSwatch from '../../ColorSwatch.vue';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
@ -20,15 +20,13 @@
|
|||||||
at runtime from the About dialog for additional information.
|
at runtime from the About dialog for additional information.
|
||||||
-->
|
-->
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<ul class="c-tree">
|
||||||
<ul class="c-tree">
|
<h2 title="Display properties for this object">Bar Graph Series</h2>
|
||||||
<li v-for="series in domainObject.composition"
|
<bar-graph-options v-for="series in domainObject.composition"
|
||||||
:key="series.key"
|
:key="series.key"
|
||||||
>
|
:item="series"
|
||||||
<bar-graph-options :item="series" />
|
/>
|
||||||
</li>
|
</ul>
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
@ -82,12 +82,17 @@ export default class PlotSeries extends Model {
|
|||||||
.openmct
|
.openmct
|
||||||
.telemetry
|
.telemetry
|
||||||
.getMetadata(options.domainObject);
|
.getMetadata(options.domainObject);
|
||||||
|
|
||||||
this.formats = options
|
this.formats = options
|
||||||
.openmct
|
.openmct
|
||||||
.telemetry
|
.telemetry
|
||||||
.getFormatMap(this.metadata);
|
.getFormatMap(this.metadata);
|
||||||
|
|
||||||
const range = this.metadata.valuesForHints(['range'])[0];
|
//if the object is missing or doesn't have metadata for some reason
|
||||||
|
let range = {};
|
||||||
|
if (this.metadata) {
|
||||||
|
range = this.metadata.valuesForHints(['range'])[0];
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
name: options.domainObject.name,
|
name: options.domainObject.name,
|
||||||
@ -191,7 +196,10 @@ export default class PlotSeries extends Model {
|
|||||||
.uniq(true, point => [this.getXVal(point), this.getYVal(point)].join())
|
.uniq(true, point => [this.getXVal(point), this.getYVal(point)].join())
|
||||||
.value();
|
.value();
|
||||||
this.reset(newPoints);
|
this.reset(newPoints);
|
||||||
}.bind(this));
|
}.bind(this))
|
||||||
|
.catch((error) => {
|
||||||
|
console.warn('Error fetching data', error);
|
||||||
|
});
|
||||||
/* eslint-enable you-dont-need-lodash-underscore/concat */
|
/* eslint-enable you-dont-need-lodash-underscore/concat */
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@ -199,7 +207,9 @@ export default class PlotSeries extends Model {
|
|||||||
*/
|
*/
|
||||||
onXKeyChange(xKey) {
|
onXKeyChange(xKey) {
|
||||||
const format = this.formats[xKey];
|
const format = this.formats[xKey];
|
||||||
this.getXVal = format.parse.bind(format);
|
if (format) {
|
||||||
|
this.getXVal = format.parse.bind(format);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Update y formatter on change, default to stepAfter interpolation if
|
* Update y formatter on change, default to stepAfter interpolation if
|
||||||
|
@ -184,7 +184,7 @@ export default class YAxisModel extends Model {
|
|||||||
this.set('values', yMetadata.values);
|
this.set('values', yMetadata.values);
|
||||||
if (!label) {
|
if (!label) {
|
||||||
const labelName = series.map(function (s) {
|
const labelName = series.map(function (s) {
|
||||||
return s.metadata.value(s.get('yKey')).name;
|
return s.metadata ? s.metadata.value(s.get('yKey')).name : '';
|
||||||
}).reduce(function (a, b) {
|
}).reduce(function (a, b) {
|
||||||
if (a === undefined) {
|
if (a === undefined) {
|
||||||
return b;
|
return b;
|
||||||
@ -204,7 +204,7 @@ export default class YAxisModel extends Model {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const labelUnits = series.map(function (s) {
|
const labelUnits = series.map(function (s) {
|
||||||
return s.metadata.value(s.get('yKey')).units;
|
return s.metadata ? s.metadata.value(s.get('yKey')).units : '';
|
||||||
}).reduce(function (a, b) {
|
}).reduce(function (a, b) {
|
||||||
if (a === undefined) {
|
if (a === undefined) {
|
||||||
return b;
|
return b;
|
||||||
|
@ -19,12 +19,18 @@
|
|||||||
* this source code distribution or the Licensing information page available
|
* this source code distribution or the Licensing information page available
|
||||||
* at runtime from the About dialog for additional information.
|
* at runtime from the About dialog for additional information.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
import { BAR_GRAPH_KEY } from './barGraph/BarGraphConstants';
|
||||||
import PlotViewProvider from './PlotViewProvider';
|
import PlotViewProvider from './PlotViewProvider';
|
||||||
|
import SpectralPlotViewProvider from './spectralPlot/SpectralPlotViewProvider';
|
||||||
|
import BarGraphViewProvider from './barGraph/BarGraphViewProvider';
|
||||||
import OverlayPlotViewProvider from './overlayPlot/OverlayPlotViewProvider';
|
import OverlayPlotViewProvider from './overlayPlot/OverlayPlotViewProvider';
|
||||||
import StackedPlotViewProvider from './stackedPlot/StackedPlotViewProvider';
|
import StackedPlotViewProvider from './stackedPlot/StackedPlotViewProvider';
|
||||||
import PlotsInspectorViewProvider from './inspector/PlotsInspectorViewProvider';
|
import PlotsInspectorViewProvider from './inspector/PlotsInspectorViewProvider';
|
||||||
|
import BarGraphInspectorViewProvider from './barGraph/inspector/BarGraphInspectorViewProvider';
|
||||||
import OverlayPlotCompositionPolicy from './overlayPlot/OverlayPlotCompositionPolicy';
|
import OverlayPlotCompositionPolicy from './overlayPlot/OverlayPlotCompositionPolicy';
|
||||||
import StackedPlotCompositionPolicy from './stackedPlot/StackedPlotCompositionPolicy';
|
import StackedPlotCompositionPolicy from './stackedPlot/StackedPlotCompositionPolicy';
|
||||||
|
import SpectralPlotCompositionPolicy from './spectralPlot/SpectralPlotCompositionPolicy';
|
||||||
|
import BarGraphCompositionPolicy from './barGraph/BarGraphCompositionPolicy';
|
||||||
|
|
||||||
export default function () {
|
export default function () {
|
||||||
return function install(openmct) {
|
return function install(openmct) {
|
||||||
@ -58,15 +64,48 @@ export default function () {
|
|||||||
},
|
},
|
||||||
priority: 890
|
priority: 890
|
||||||
});
|
});
|
||||||
|
openmct.types.addType('telemetry.plot.spectral', {
|
||||||
|
key: "telemetry.plot.spectral",
|
||||||
|
name: "Spectral Plot",
|
||||||
|
cssClass: "icon-plot-stacked",
|
||||||
|
description: "View Spectra on Y Axes with non-time domain on the X axis. Can be added to Display Layouts.",
|
||||||
|
//Temporarily disabling spectral plots
|
||||||
|
creatable: false,
|
||||||
|
initialize: function (domainObject) {
|
||||||
|
domainObject.composition = [];
|
||||||
|
domainObject.configuration = {};
|
||||||
|
},
|
||||||
|
priority: 890
|
||||||
|
});
|
||||||
|
|
||||||
|
openmct.types.addType(BAR_GRAPH_KEY, {
|
||||||
|
key: BAR_GRAPH_KEY,
|
||||||
|
name: "Bar Graph",
|
||||||
|
cssClass: "icon-bar-chart",
|
||||||
|
description: "View data as a bar graph. Can be added to Display Layouts.",
|
||||||
|
creatable: true,
|
||||||
|
initialize: function (domainObject) {
|
||||||
|
domainObject.composition = [];
|
||||||
|
domainObject.configuration = {
|
||||||
|
plotType: 'bar'
|
||||||
|
};
|
||||||
|
},
|
||||||
|
priority: 891
|
||||||
|
});
|
||||||
|
|
||||||
openmct.objectViews.addProvider(new StackedPlotViewProvider(openmct));
|
openmct.objectViews.addProvider(new StackedPlotViewProvider(openmct));
|
||||||
openmct.objectViews.addProvider(new OverlayPlotViewProvider(openmct));
|
openmct.objectViews.addProvider(new OverlayPlotViewProvider(openmct));
|
||||||
openmct.objectViews.addProvider(new PlotViewProvider(openmct));
|
openmct.objectViews.addProvider(new PlotViewProvider(openmct));
|
||||||
|
openmct.objectViews.addProvider(new SpectralPlotViewProvider(openmct));
|
||||||
|
openmct.objectViews.addProvider(new BarGraphViewProvider(openmct));
|
||||||
|
|
||||||
openmct.inspectorViews.addProvider(new PlotsInspectorViewProvider(openmct));
|
openmct.inspectorViews.addProvider(new PlotsInspectorViewProvider(openmct));
|
||||||
|
openmct.inspectorViews.addProvider(new BarGraphInspectorViewProvider(openmct));
|
||||||
|
|
||||||
openmct.composition.addPolicy(new OverlayPlotCompositionPolicy(openmct).allow);
|
openmct.composition.addPolicy(new OverlayPlotCompositionPolicy(openmct).allow);
|
||||||
openmct.composition.addPolicy(new StackedPlotCompositionPolicy(openmct).allow);
|
openmct.composition.addPolicy(new StackedPlotCompositionPolicy(openmct).allow);
|
||||||
|
openmct.composition.addPolicy(new SpectralPlotCompositionPolicy(openmct).allow);
|
||||||
|
openmct.composition.addPolicy(new BarGraphCompositionPolicy(openmct).allow);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,10 +24,12 @@ import {createMouseEvent, createOpenMct, resetApplicationState, spyOnBuiltins} f
|
|||||||
import PlotVuePlugin from "./plugin";
|
import PlotVuePlugin from "./plugin";
|
||||||
import Vue from "vue";
|
import Vue from "vue";
|
||||||
import StackedPlot from "./stackedPlot/StackedPlot.vue";
|
import StackedPlot from "./stackedPlot/StackedPlot.vue";
|
||||||
|
// import SpectralPlot from "./spectralPlot/SpectralPlot.vue";
|
||||||
import configStore from "./configuration/ConfigStore";
|
import configStore from "./configuration/ConfigStore";
|
||||||
import EventEmitter from "EventEmitter";
|
import EventEmitter from "EventEmitter";
|
||||||
import PlotOptions from "./inspector/PlotOptions.vue";
|
import PlotOptions from "./inspector/PlotOptions.vue";
|
||||||
import PlotConfigurationModel from "./configuration/PlotConfigurationModel";
|
import PlotConfigurationModel from "./configuration/PlotConfigurationModel";
|
||||||
|
import { BAR_GRAPH_VIEW, BAR_GRAPH_KEY } from './barGraph/BarGraphConstants';
|
||||||
|
|
||||||
describe("the plugin", function () {
|
describe("the plugin", function () {
|
||||||
let element;
|
let element;
|
||||||
@ -312,6 +314,38 @@ describe("the plugin", function () {
|
|||||||
let plotView = applicableViews.find((viewProvider) => viewProvider.key === "plot-stacked");
|
let plotView = applicableViews.find((viewProvider) => viewProvider.key === "plot-stacked");
|
||||||
expect(plotView).toBeDefined();
|
expect(plotView).toBeDefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("provides a spectral plot view for objects with telemetry", () => {
|
||||||
|
const testTelemetryObject = {
|
||||||
|
id: "test-object",
|
||||||
|
type: "telemetry.plot.spectral",
|
||||||
|
telemetry: {
|
||||||
|
values: [{
|
||||||
|
key: "a-very-fine-key"
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const applicableViews = openmct.objectViews.get(testTelemetryObject, mockObjectPath);
|
||||||
|
let plotView = applicableViews.find((viewProvider) => viewProvider.key === "plot-spectral");
|
||||||
|
expect(plotView).toBeDefined();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("provides a spectral aggregate plot view for objects with telemetry", () => {
|
||||||
|
const testTelemetryObject = {
|
||||||
|
id: "test-object",
|
||||||
|
type: BAR_GRAPH_KEY,
|
||||||
|
telemetry: {
|
||||||
|
values: [{
|
||||||
|
key: "lots-of-aggregate-telemetry"
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const applicableViews = openmct.objectViews.get(testTelemetryObject, mockObjectPath);
|
||||||
|
let plotView = applicableViews.find((viewProvider) => viewProvider.key === BAR_GRAPH_VIEW);
|
||||||
|
expect(plotView).toBeDefined();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("The single plot view", () => {
|
describe("The single plot view", () => {
|
||||||
@ -462,6 +496,146 @@ describe("the plugin", function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/*
|
||||||
|
* disabling this until we develop the plot view
|
||||||
|
describe("The spectral plot view", () => {
|
||||||
|
let testTelemetryObject;
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
let testTelemetryObject2;
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
let config;
|
||||||
|
let spectralPlotObject;
|
||||||
|
let component;
|
||||||
|
let mockComposition;
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
let plotViewComponentObject;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
const getFunc = openmct.$injector.get;
|
||||||
|
spyOn(openmct.$injector, "get")
|
||||||
|
.withArgs("exportImageService").and.returnValue({
|
||||||
|
exportPNG: () => {},
|
||||||
|
exportJPG: () => {}
|
||||||
|
})
|
||||||
|
.and.callFake(getFunc);
|
||||||
|
|
||||||
|
spectralPlotObject = {
|
||||||
|
identifier: {
|
||||||
|
namespace: "",
|
||||||
|
key: "test-spectral-plot"
|
||||||
|
},
|
||||||
|
type: "telemetry.plot.spectral",
|
||||||
|
name: "Test Spectral Plot"
|
||||||
|
};
|
||||||
|
|
||||||
|
testTelemetryObject = {
|
||||||
|
identifier: {
|
||||||
|
namespace: "",
|
||||||
|
key: "test-object"
|
||||||
|
},
|
||||||
|
type: "test-object",
|
||||||
|
name: "Test Object",
|
||||||
|
telemetry: {
|
||||||
|
values: [{
|
||||||
|
key: "utc",
|
||||||
|
format: "utc",
|
||||||
|
name: "Time",
|
||||||
|
hints: {
|
||||||
|
domain: 1
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
key: "some-key",
|
||||||
|
name: "Some attribute",
|
||||||
|
hints: {
|
||||||
|
range: 1
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
key: "some-other-key",
|
||||||
|
name: "Another attribute",
|
||||||
|
hints: {
|
||||||
|
range: 2
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
testTelemetryObject2 = {
|
||||||
|
identifier: {
|
||||||
|
namespace: "",
|
||||||
|
key: "test-object2"
|
||||||
|
},
|
||||||
|
type: "test-object",
|
||||||
|
name: "Test Object2",
|
||||||
|
telemetry: {
|
||||||
|
values: [{
|
||||||
|
key: "utc",
|
||||||
|
format: "utc",
|
||||||
|
name: "Time",
|
||||||
|
hints: {
|
||||||
|
domain: 1
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
key: "wavelength",
|
||||||
|
name: "Wavelength",
|
||||||
|
hints: {
|
||||||
|
range: 1
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
key: "some-other-key2",
|
||||||
|
name: "Another attribute2",
|
||||||
|
hints: {
|
||||||
|
range: 2
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
mockComposition = new EventEmitter();
|
||||||
|
mockComposition.load = () => {
|
||||||
|
mockComposition.emit('add', testTelemetryObject);
|
||||||
|
|
||||||
|
return [testTelemetryObject];
|
||||||
|
};
|
||||||
|
|
||||||
|
spyOn(openmct.composition, 'get').and.returnValue(mockComposition);
|
||||||
|
|
||||||
|
let viewContainer = document.createElement("div");
|
||||||
|
child.append(viewContainer);
|
||||||
|
component = new Vue({
|
||||||
|
el: viewContainer,
|
||||||
|
components: {
|
||||||
|
SpectralPlot
|
||||||
|
},
|
||||||
|
provide: {
|
||||||
|
openmct: openmct,
|
||||||
|
domainObject: spectralPlotObject,
|
||||||
|
composition: openmct.composition.get(spectralPlotObject)
|
||||||
|
},
|
||||||
|
template: "<spectral-plot></spectral-plot>"
|
||||||
|
});
|
||||||
|
|
||||||
|
cleanupFirst.push(() => {
|
||||||
|
component.$destroy();
|
||||||
|
component = undefined;
|
||||||
|
});
|
||||||
|
|
||||||
|
return telemetryPromise
|
||||||
|
.then(Vue.nextTick())
|
||||||
|
.then(() => {
|
||||||
|
plotViewComponentObject = component.$root.$children[0];
|
||||||
|
const configId = openmct.objects.makeKeyString(testTelemetryObject.identifier);
|
||||||
|
config = configStore.get(configId);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("Renders a collapsed legend for every telemetry", () => {
|
||||||
|
let legend = element.querySelectorAll(".plot-wrapper-collapsed-legend .plot-series-name");
|
||||||
|
expect(legend.length).toBe(1);
|
||||||
|
expect(legend[0].innerHTML).toEqual("Test Object");
|
||||||
|
});
|
||||||
|
|
||||||
|
}); */
|
||||||
|
|
||||||
describe("The stacked plot view", () => {
|
describe("The stacked plot view", () => {
|
||||||
let testTelemetryObject;
|
let testTelemetryObject;
|
||||||
let testTelemetryObject2;
|
let testTelemetryObject2;
|
||||||
@ -991,4 +1165,39 @@ describe("the plugin", function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("the spectral plot", () => {
|
||||||
|
const mockObject = {
|
||||||
|
name: 'A Very Nice Spectral Plot',
|
||||||
|
key: 'telemetry.plot.spectral',
|
||||||
|
creatable: true
|
||||||
|
};
|
||||||
|
|
||||||
|
it('defines a spectral plot object type with the correct key', () => {
|
||||||
|
const objectDef = openmct.types.get('telemetry.plot.spectral').definition;
|
||||||
|
expect(objectDef.key).toEqual(mockObject.key);
|
||||||
|
});
|
||||||
|
|
||||||
|
xit('is creatable', () => {
|
||||||
|
const objectDef = openmct.types.get('telemetry.plot.spectral').definition;
|
||||||
|
expect(objectDef.creatable).toEqual(mockObject.creatable);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("the aggregate spectral plot", () => {
|
||||||
|
const mockObject = {
|
||||||
|
name: 'An Even Nicer Aggregate Spectral Plot',
|
||||||
|
key: BAR_GRAPH_KEY,
|
||||||
|
creatable: true
|
||||||
|
};
|
||||||
|
|
||||||
|
it('defines a spectral plot object type with the correct key', () => {
|
||||||
|
const objectDef = openmct.types.get(BAR_GRAPH_KEY).definition;
|
||||||
|
expect(objectDef.key).toEqual(mockObject.key);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('is creatable', () => {
|
||||||
|
const objectDef = openmct.types.get(BAR_GRAPH_KEY).definition;
|
||||||
|
expect(objectDef.creatable).toEqual(mockObject.creatable);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -36,7 +36,6 @@ define([
|
|||||||
'./URLIndicatorPlugin/URLIndicatorPlugin',
|
'./URLIndicatorPlugin/URLIndicatorPlugin',
|
||||||
'./telemetryMean/plugin',
|
'./telemetryMean/plugin',
|
||||||
'./plot/plugin',
|
'./plot/plugin',
|
||||||
'./charts/plugin',
|
|
||||||
'./telemetryTable/plugin',
|
'./telemetryTable/plugin',
|
||||||
'./staticRootPlugin/plugin',
|
'./staticRootPlugin/plugin',
|
||||||
'./notebook/plugin',
|
'./notebook/plugin',
|
||||||
@ -88,7 +87,6 @@ define([
|
|||||||
URLIndicatorPlugin,
|
URLIndicatorPlugin,
|
||||||
TelemetryMean,
|
TelemetryMean,
|
||||||
PlotPlugin,
|
PlotPlugin,
|
||||||
ChartPlugin,
|
|
||||||
TelemetryTablePlugin,
|
TelemetryTablePlugin,
|
||||||
StaticRootPlugin,
|
StaticRootPlugin,
|
||||||
Notebook,
|
Notebook,
|
||||||
@ -191,7 +189,6 @@ define([
|
|||||||
plugins.ExampleImagery = ExampleImagery;
|
plugins.ExampleImagery = ExampleImagery;
|
||||||
plugins.ImageryPlugin = ImageryPlugin;
|
plugins.ImageryPlugin = ImageryPlugin;
|
||||||
plugins.Plot = PlotPlugin.default;
|
plugins.Plot = PlotPlugin.default;
|
||||||
plugins.Chart = ChartPlugin.default;
|
|
||||||
plugins.TelemetryTable = TelemetryTablePlugin;
|
plugins.TelemetryTable = TelemetryTablePlugin;
|
||||||
|
|
||||||
plugins.SummaryWidget = SummaryWidget;
|
plugins.SummaryWidget = SummaryWidget;
|
||||||
|
@ -60,18 +60,17 @@ define([
|
|||||||
this.addTelemetryObject = this.addTelemetryObject.bind(this);
|
this.addTelemetryObject = this.addTelemetryObject.bind(this);
|
||||||
this.removeTelemetryObject = this.removeTelemetryObject.bind(this);
|
this.removeTelemetryObject = this.removeTelemetryObject.bind(this);
|
||||||
this.removeTelemetryCollection = this.removeTelemetryCollection.bind(this);
|
this.removeTelemetryCollection = this.removeTelemetryCollection.bind(this);
|
||||||
|
this.incrementOutstandingRequests = this.incrementOutstandingRequests.bind(this);
|
||||||
|
this.decrementOutstandingRequests = this.decrementOutstandingRequests.bind(this);
|
||||||
this.resetRowsFromAllData = this.resetRowsFromAllData.bind(this);
|
this.resetRowsFromAllData = this.resetRowsFromAllData.bind(this);
|
||||||
this.isTelemetryObject = this.isTelemetryObject.bind(this);
|
this.isTelemetryObject = this.isTelemetryObject.bind(this);
|
||||||
this.refreshData = this.refreshData.bind(this);
|
|
||||||
this.updateFilters = this.updateFilters.bind(this);
|
this.updateFilters = this.updateFilters.bind(this);
|
||||||
|
this.clearData = this.clearData.bind(this);
|
||||||
this.buildOptionsFromConfiguration = this.buildOptionsFromConfiguration.bind(this);
|
this.buildOptionsFromConfiguration = this.buildOptionsFromConfiguration.bind(this);
|
||||||
|
|
||||||
this.filterObserver = undefined;
|
this.filterObserver = undefined;
|
||||||
|
|
||||||
this.createTableRowCollections();
|
this.createTableRowCollections();
|
||||||
|
|
||||||
openmct.time.on('bounds', this.refreshData);
|
|
||||||
openmct.time.on('timeSystem', this.refreshData);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -141,8 +140,6 @@ define([
|
|||||||
let columnMap = this.getColumnMapForObject(keyString);
|
let columnMap = this.getColumnMapForObject(keyString);
|
||||||
let limitEvaluator = this.openmct.telemetry.limitEvaluator(telemetryObject);
|
let limitEvaluator = this.openmct.telemetry.limitEvaluator(telemetryObject);
|
||||||
|
|
||||||
this.incrementOutstandingRequests();
|
|
||||||
|
|
||||||
const telemetryProcessor = this.getTelemetryProcessor(keyString, columnMap, limitEvaluator);
|
const telemetryProcessor = this.getTelemetryProcessor(keyString, columnMap, limitEvaluator);
|
||||||
const telemetryRemover = this.getTelemetryRemover();
|
const telemetryRemover = this.getTelemetryRemover();
|
||||||
|
|
||||||
@ -151,13 +148,13 @@ define([
|
|||||||
this.telemetryCollections[keyString] = this.openmct.telemetry
|
this.telemetryCollections[keyString] = this.openmct.telemetry
|
||||||
.requestCollection(telemetryObject, requestOptions);
|
.requestCollection(telemetryObject, requestOptions);
|
||||||
|
|
||||||
|
this.telemetryCollections[keyString].on('requestStarted', this.incrementOutstandingRequests);
|
||||||
|
this.telemetryCollections[keyString].on('requestEnded', this.decrementOutstandingRequests);
|
||||||
this.telemetryCollections[keyString].on('remove', telemetryRemover);
|
this.telemetryCollections[keyString].on('remove', telemetryRemover);
|
||||||
this.telemetryCollections[keyString].on('add', telemetryProcessor);
|
this.telemetryCollections[keyString].on('add', telemetryProcessor);
|
||||||
this.telemetryCollections[keyString].on('clear', this.tableRows.clear);
|
this.telemetryCollections[keyString].on('clear', this.clearData);
|
||||||
this.telemetryCollections[keyString].load();
|
this.telemetryCollections[keyString].load();
|
||||||
|
|
||||||
this.decrementOutstandingRequests();
|
|
||||||
|
|
||||||
this.telemetryObjects[keyString] = {
|
this.telemetryObjects[keyString] = {
|
||||||
telemetryObject,
|
telemetryObject,
|
||||||
keyString,
|
keyString,
|
||||||
@ -268,17 +265,6 @@ define([
|
|||||||
this.emit('object-removed', objectIdentifier);
|
this.emit('object-removed', objectIdentifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
refreshData(bounds, isTick) {
|
|
||||||
if (!isTick && this.tableRows.outstandingRequests === 0) {
|
|
||||||
this.tableRows.clear();
|
|
||||||
this.tableRows.sortBy({
|
|
||||||
key: this.openmct.time.timeSystem().key,
|
|
||||||
direction: 'asc'
|
|
||||||
});
|
|
||||||
this.tableRows.resubscribe();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
clearData() {
|
clearData() {
|
||||||
this.tableRows.clear();
|
this.tableRows.clear();
|
||||||
this.emit('refresh');
|
this.emit('refresh');
|
||||||
@ -378,9 +364,6 @@ define([
|
|||||||
let keystrings = Object.keys(this.telemetryCollections);
|
let keystrings = Object.keys(this.telemetryCollections);
|
||||||
keystrings.forEach(this.removeTelemetryCollection);
|
keystrings.forEach(this.removeTelemetryCollection);
|
||||||
|
|
||||||
this.openmct.time.off('bounds', this.refreshData);
|
|
||||||
this.openmct.time.off('timeSystem', this.refreshData);
|
|
||||||
|
|
||||||
if (this.filterObserver) {
|
if (this.filterObserver) {
|
||||||
this.filterObserver();
|
this.filterObserver();
|
||||||
}
|
}
|
||||||
|
@ -131,7 +131,8 @@ export default {
|
|||||||
objects.forEach(object => this.addColumnsForObject(object, false));
|
objects.forEach(object => this.addColumnsForObject(object, false));
|
||||||
},
|
},
|
||||||
addColumnsForObject(telemetryObject) {
|
addColumnsForObject(telemetryObject) {
|
||||||
let metadataValues = this.openmct.telemetry.getMetadata(telemetryObject).values();
|
const metadata = this.openmct.telemetry.getMetadata(telemetryObject);
|
||||||
|
let metadataValues = metadata ? metadata.values() : [];
|
||||||
metadataValues.forEach(metadatum => {
|
metadataValues.forEach(metadatum => {
|
||||||
let column = new TelemetryTableColumn(this.openmct, metadatum);
|
let column = new TelemetryTableColumn(this.openmct, metadatum);
|
||||||
this.tableConfiguration.addSingleColumnForObject(telemetryObject, column);
|
this.tableConfiguration.addSingleColumnForObject(telemetryObject, column);
|
||||||
|
@ -105,7 +105,8 @@ export default {
|
|||||||
composition.load().then((domainObjects) => {
|
composition.load().then((domainObjects) => {
|
||||||
domainObjects.forEach(telemetryObject => {
|
domainObjects.forEach(telemetryObject => {
|
||||||
let keyString = this.openmct.objects.makeKeyString(telemetryObject.identifier);
|
let keyString = this.openmct.objects.makeKeyString(telemetryObject.identifier);
|
||||||
let metadataValues = this.openmct.telemetry.getMetadata(telemetryObject).values();
|
const metadata = this.openmct.telemetry.getMetadata(telemetryObject);
|
||||||
|
let metadataValues = metadata ? metadata.values() : [];
|
||||||
let filters = this.filteredTelemetry[keyString];
|
let filters = this.filteredTelemetry[keyString];
|
||||||
|
|
||||||
if (filters !== undefined) {
|
if (filters !== undefined) {
|
||||||
|
@ -125,7 +125,6 @@
|
|||||||
<div
|
<div
|
||||||
class="c-table c-telemetry-table c-table--filterable c-table--sortable has-control-bar u-style-receiver js-style-receiver"
|
class="c-table c-telemetry-table c-table--filterable c-table--sortable has-control-bar u-style-receiver js-style-receiver"
|
||||||
:class="{
|
:class="{
|
||||||
'loading': loading,
|
|
||||||
'is-paused' : paused
|
'is-paused' : paused
|
||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
@ -362,7 +361,7 @@ export default {
|
|||||||
autoScroll: true,
|
autoScroll: true,
|
||||||
sortOptions: {},
|
sortOptions: {},
|
||||||
filters: {},
|
filters: {},
|
||||||
loading: true,
|
loading: false,
|
||||||
scrollable: undefined,
|
scrollable: undefined,
|
||||||
tableEl: undefined,
|
tableEl: undefined,
|
||||||
headersHolderEl: undefined,
|
headersHolderEl: undefined,
|
||||||
@ -422,6 +421,14 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
|
loading: {
|
||||||
|
handler(isLoading) {
|
||||||
|
if (this.viewActionsCollection) {
|
||||||
|
let action = isLoading ? 'disable' : 'enable';
|
||||||
|
this.viewActionsCollection[action](['export-csv-all']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
markedRows: {
|
markedRows: {
|
||||||
handler(newVal, oldVal) {
|
handler(newVal, oldVal) {
|
||||||
this.$emit('marked-rows-updated', newVal, oldVal);
|
this.$emit('marked-rows-updated', newVal, oldVal);
|
||||||
@ -1020,6 +1027,12 @@ export default {
|
|||||||
this.viewActionsCollection.disable(['export-csv-marked', 'unmark-all-rows']);
|
this.viewActionsCollection.disable(['export-csv-marked', 'unmark-all-rows']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.loading) {
|
||||||
|
this.viewActionsCollection.disable(['export-csv-all']);
|
||||||
|
} else {
|
||||||
|
this.viewActionsCollection.enable(['export-csv-all']);
|
||||||
|
}
|
||||||
|
|
||||||
if (this.paused) {
|
if (this.paused) {
|
||||||
this.viewActionsCollection.hide(['pause-data']);
|
this.viewActionsCollection.hide(['pause-data']);
|
||||||
this.viewActionsCollection.show(['play-data']);
|
this.viewActionsCollection.show(['play-data']);
|
||||||
|
@ -151,29 +151,22 @@ export default {
|
|||||||
this.stopFollowingTimeContext();
|
this.stopFollowingTimeContext();
|
||||||
this.timeContext = this.openmct.time.getContextForView([this.domainObject]);
|
this.timeContext = this.openmct.time.getContextForView([this.domainObject]);
|
||||||
this.timeContext.on('timeContext', this.setTimeContext);
|
this.timeContext.on('timeContext', this.setTimeContext);
|
||||||
this.timeContext.on('clock', this.setViewFromClock);
|
this.timeContext.on('clock', this.setTimeOptions);
|
||||||
},
|
},
|
||||||
stopFollowingTimeContext() {
|
stopFollowingTimeContext() {
|
||||||
if (this.timeContext) {
|
if (this.timeContext) {
|
||||||
this.timeContext.off('timeContext', this.setTimeContext);
|
this.timeContext.off('timeContext', this.setTimeContext);
|
||||||
this.timeContext.off('clock', this.setViewFromClock);
|
this.timeContext.off('clock', this.setTimeOptions);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
setViewFromClock(clock) {
|
setTimeOptions(clock) {
|
||||||
if (!this.timeOptions.mode) {
|
this.timeOptions.clockOffsets = this.timeOptions.clockOffsets || this.timeContext.clockOffsets();
|
||||||
this.setTimeOptions(clock);
|
this.timeOptions.fixedOffsets = this.timeOptions.fixedOffsets || this.timeContext.bounds();
|
||||||
}
|
|
||||||
},
|
|
||||||
setTimeOptions() {
|
|
||||||
if (!this.timeOptions || !this.timeOptions.mode) {
|
|
||||||
this.mode = this.timeContext.clock() === undefined ? { key: 'fixed' } : { key: Object.create(this.timeContext.clock()).key};
|
|
||||||
this.timeOptions = {
|
|
||||||
clockOffsets: this.timeContext.clockOffsets(),
|
|
||||||
fixedOffsets: this.timeContext.bounds()
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
this.registerIndependentTimeOffsets();
|
if (!this.timeOptions.mode) {
|
||||||
|
this.mode = this.timeContext.clock() === undefined ? {key: 'fixed'} : {key: Object.create(this.timeContext.clock()).key};
|
||||||
|
this.registerIndependentTimeOffsets();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
saveFixedOffsets(offsets) {
|
saveFixedOffsets(offsets) {
|
||||||
const newOptions = Object.assign({}, this.timeOptions, {
|
const newOptions = Object.assign({}, this.timeOptions, {
|
||||||
|
@ -20,7 +20,8 @@
|
|||||||
* at runtime from the About dialog for additional information.
|
* at runtime from the About dialog for additional information.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
<template>
|
<template>
|
||||||
<div ref="modeMenuButton"
|
<div v-if="modes.length > 1"
|
||||||
|
ref="modeMenuButton"
|
||||||
class="c-ctrl-wrapper c-ctrl-wrapper--menus-up"
|
class="c-ctrl-wrapper c-ctrl-wrapper--menus-up"
|
||||||
>
|
>
|
||||||
<div class="c-menu-button c-ctrl-wrapper c-ctrl-wrapper--menus-left">
|
<div class="c-menu-button c-ctrl-wrapper c-ctrl-wrapper--menus-left">
|
||||||
|
@ -88,7 +88,7 @@ export default {
|
|||||||
this.mutablePromise.then(() => {
|
this.mutablePromise.then(() => {
|
||||||
this.openmct.objects.destroyMutable(this.domainObject);
|
this.openmct.objects.destroyMutable(this.domainObject);
|
||||||
});
|
});
|
||||||
} else {
|
} else if (this.domainObject.isMutable) {
|
||||||
this.openmct.objects.destroyMutable(this.domainObject);
|
this.openmct.objects.destroyMutable(this.domainObject);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -160,7 +160,9 @@ export default {
|
|||||||
this.status = this.openmct.status.get(this.domainObject.identifier);
|
this.status = this.openmct.status.get(this.domainObject.identifier);
|
||||||
this.removeStatusListener = this.openmct.status.observe(this.domainObject.identifier, this.setStatus);
|
this.removeStatusListener = this.openmct.status.observe(this.domainObject.identifier, this.setStatus);
|
||||||
const provider = this.openmct.objectViews.get(this.domainObject, this.objectPath)[0];
|
const provider = this.openmct.objectViews.get(this.domainObject, this.objectPath)[0];
|
||||||
this.$refs.objectView.show(this.domainObject, provider.key, false, this.objectPath);
|
if (provider) {
|
||||||
|
this.$refs.objectView.show(this.domainObject, provider.key, false, this.objectPath);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
beforeDestroy() {
|
beforeDestroy() {
|
||||||
this.removeStatusListener();
|
this.removeStatusListener();
|
||||||
@ -193,8 +195,10 @@ export default {
|
|||||||
},
|
},
|
||||||
showMenuItems(event) {
|
showMenuItems(event) {
|
||||||
const sortedActions = this.openmct.actions._groupAndSortActions(this.menuActionItems);
|
const sortedActions = this.openmct.actions._groupAndSortActions(this.menuActionItems);
|
||||||
const menuItems = this.openmct.menus.actionsToMenuItems(sortedActions, this.actionCollection.objectPath, this.actionCollection.view);
|
if (sortedActions.length) {
|
||||||
this.openmct.menus.showMenu(event.x, event.y, menuItems);
|
const menuItems = this.openmct.menus.actionsToMenuItems(sortedActions, this.actionCollection.objectPath, this.actionCollection.view);
|
||||||
|
this.openmct.menus.showMenu(event.x, event.y, menuItems);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
setStatus(status) {
|
setStatus(status) {
|
||||||
this.status = status;
|
this.status = status;
|
||||||
|
@ -49,6 +49,7 @@ describe("the inspector", () => {
|
|||||||
|
|
||||||
beforeEach((done) => {
|
beforeEach((done) => {
|
||||||
openmct = createOpenMct();
|
openmct = createOpenMct();
|
||||||
|
spyOn(openmct.objects, 'save').and.returnValue(Promise.resolve(true));
|
||||||
openmct.on('start', done);
|
openmct.on('start', done);
|
||||||
openmct.startHeadless();
|
openmct.startHeadless();
|
||||||
});
|
});
|
||||||
@ -77,12 +78,12 @@ describe("the inspector", () => {
|
|||||||
expect(savedStylesViewComponent.$children[0].$children.length).toBe(0);
|
expect(savedStylesViewComponent.$children[0].$children.length).toBe(0);
|
||||||
stylesViewComponent.$children[0].saveStyle(mockStyle);
|
stylesViewComponent.$children[0].saveStyle(mockStyle);
|
||||||
|
|
||||||
stylesViewComponent.$nextTick().then(() => {
|
return stylesViewComponent.$nextTick().then(() => {
|
||||||
expect(savedStylesViewComponent.$children[0].$children.length).toBe(1);
|
expect(savedStylesViewComponent.$children[0].$children.length).toBe(1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should allow a saved style to be applied", () => {
|
xit("should allow a saved style to be applied", () => {
|
||||||
spyOn(openmct.editor, 'isEditing').and.returnValue(true);
|
spyOn(openmct.editor, 'isEditing').and.returnValue(true);
|
||||||
|
|
||||||
selection = mockTelemetryTableSelection;
|
selection = mockTelemetryTableSelection;
|
||||||
@ -91,12 +92,12 @@ describe("the inspector", () => {
|
|||||||
|
|
||||||
stylesViewComponent.$children[0].saveStyle(mockStyle);
|
stylesViewComponent.$children[0].saveStyle(mockStyle);
|
||||||
|
|
||||||
stylesViewComponent.$nextTick().then(() => {
|
return stylesViewComponent.$nextTick().then(() => {
|
||||||
const styleSelectorComponent = savedStylesViewComponent.$children[0].$children[0];
|
const styleSelectorComponent = savedStylesViewComponent.$children[0].$children[0];
|
||||||
|
|
||||||
styleSelectorComponent.selectStyle();
|
styleSelectorComponent.selectStyle();
|
||||||
|
|
||||||
savedStylesViewComponent.$nextTick().then(() => {
|
return savedStylesViewComponent.$nextTick().then(() => {
|
||||||
const styleEditorComponentIndex = stylesViewComponent.$children[0].$children.length - 1;
|
const styleEditorComponentIndex = stylesViewComponent.$children[0].$children.length - 1;
|
||||||
const styleEditorComponent = stylesViewComponent.$children[0].$children[styleEditorComponentIndex];
|
const styleEditorComponent = stylesViewComponent.$children[0].$children[styleEditorComponentIndex];
|
||||||
const styles = styleEditorComponent.$children.filter(component => component.options.value === mockStyle.color);
|
const styles = styleEditorComponent.$children.filter(component => component.options.value === mockStyle.color);
|
||||||
@ -147,7 +148,7 @@ describe("the inspector", () => {
|
|||||||
stylesViewComponent = createViewComponent(StylesView, selection, openmct);
|
stylesViewComponent = createViewComponent(StylesView, selection, openmct);
|
||||||
savedStylesViewComponent = createViewComponent(SavedStylesView, selection, openmct);
|
savedStylesViewComponent = createViewComponent(SavedStylesView, selection, openmct);
|
||||||
|
|
||||||
stylesViewComponent.$nextTick().then(() => {
|
return stylesViewComponent.$nextTick().then(() => {
|
||||||
const styleEditorComponentIndex = stylesViewComponent.$children[0].$children.length - 1;
|
const styleEditorComponentIndex = stylesViewComponent.$children[0].$children.length - 1;
|
||||||
const styleEditorComponent = stylesViewComponent.$children[0].$children[styleEditorComponentIndex];
|
const styleEditorComponent = stylesViewComponent.$children[0].$children[styleEditorComponentIndex];
|
||||||
const saveStyleButtonIndex = styleEditorComponent.$children.length - 1;
|
const saveStyleButtonIndex = styleEditorComponent.$children.length - 1;
|
||||||
@ -168,7 +169,7 @@ describe("the inspector", () => {
|
|||||||
stylesViewComponent = createViewComponent(StylesView, selection, openmct);
|
stylesViewComponent = createViewComponent(StylesView, selection, openmct);
|
||||||
savedStylesViewComponent = createViewComponent(SavedStylesView, selection, openmct);
|
savedStylesViewComponent = createViewComponent(SavedStylesView, selection, openmct);
|
||||||
|
|
||||||
stylesViewComponent.$nextTick().then(() => {
|
return stylesViewComponent.$nextTick().then(() => {
|
||||||
const styleEditorComponentIndex = stylesViewComponent.$children[0].$children.length - 1;
|
const styleEditorComponentIndex = stylesViewComponent.$children[0].$children.length - 1;
|
||||||
const styleEditorComponent = stylesViewComponent.$children[0].$children[styleEditorComponentIndex];
|
const styleEditorComponent = stylesViewComponent.$children[0].$children[styleEditorComponentIndex];
|
||||||
const saveStyleButtonIndex = styleEditorComponent.$children.length - 1;
|
const saveStyleButtonIndex = styleEditorComponent.$children.length - 1;
|
||||||
@ -185,7 +186,7 @@ describe("the inspector", () => {
|
|||||||
stylesViewComponent = createViewComponent(StylesView, selection, openmct);
|
stylesViewComponent = createViewComponent(StylesView, selection, openmct);
|
||||||
savedStylesViewComponent = createViewComponent(SavedStylesView, selection, openmct);
|
savedStylesViewComponent = createViewComponent(SavedStylesView, selection, openmct);
|
||||||
|
|
||||||
stylesViewComponent.$nextTick().then(() => {
|
return stylesViewComponent.$nextTick().then(() => {
|
||||||
const styleEditorComponentIndex = stylesViewComponent.$children[0].$children.length - 1;
|
const styleEditorComponentIndex = stylesViewComponent.$children[0].$children.length - 1;
|
||||||
const styleEditorComponent = stylesViewComponent.$children[0].$children[styleEditorComponentIndex];
|
const styleEditorComponent = stylesViewComponent.$children[0].$children[styleEditorComponentIndex];
|
||||||
const saveStyleButtonIndex = styleEditorComponent.$children.length - 1;
|
const saveStyleButtonIndex = styleEditorComponent.$children.length - 1;
|
||||||
|
@ -42,8 +42,6 @@ const webpackConfig = {
|
|||||||
"csv": "comma-separated-values",
|
"csv": "comma-separated-values",
|
||||||
"EventEmitter": "eventemitter3",
|
"EventEmitter": "eventemitter3",
|
||||||
"bourbon": "bourbon.scss",
|
"bourbon": "bourbon.scss",
|
||||||
"plotly-basic": "plotly.js-basic-dist",
|
|
||||||
"plotly-gl2d": "plotly.js-gl2d-dist",
|
|
||||||
"vue": vueFile,
|
"vue": vueFile,
|
||||||
"d3-scale": path.join(__dirname, "node_modules/d3-scale/build/d3-scale.min.js"),
|
"d3-scale": path.join(__dirname, "node_modules/d3-scale/build/d3-scale.min.js"),
|
||||||
"printj": path.join(__dirname, "node_modules/printj/dist/printj.min.js"),
|
"printj": path.join(__dirname, "node_modules/printj/dist/printj.min.js"),
|
||||||
|
Reference in New Issue
Block a user