Compare commits

...

8 Commits

Author SHA1 Message Date
Pete Richards
2254bd8204 [plot] set minimum marquee size
Users must draw a marquee box with diagonal size of atleast 7.5
pixels.  This prevents clicks from being translated to zooms on
the plot.  Because startMarquee triggers a plot history update.
endMarquee must remove the plot history update when preventing
marqueeZoom.  This has a side effect of causing a requery for
data, but is a simple enough solution for now.

Fixes #2002.
2018-05-04 12:00:09 -07:00
Pete Richards
c8a097d798 [Telemetry] handle string enumeration value
Don't treat all strings as properly formatted enumeration values.

Instead, check any input value against known enumerations and if
one matches, return it.  Otherwise, return input.

Fixes #2018
2018-05-04 11:59:02 -07:00
Pete Richards
97baa15176 State generator realtime uses strings
Change the state generator's realtime data to return string values
instead of number values.  This exercises an edge case where
enumerations could be a string instead of a number.  Exposes #2018.
2018-05-04 11:58:55 -07:00
Pete Richards
fca69b69df [Plot] improve y-axis label handling
First, change the y-Axis label retrieval to retrieve the proper
value from the plot confoguration so that it uses the persisted
value, Fixes #2024

Secondly, when removing a series, if there are no series left in
the plot and a custom y-axis label has not been specified, then
clear the y-axis label.  Fixes #2014.
2018-05-04 11:58:20 -07:00
Pete Richards
968242d63b [Plot] Properly update yAxis on key change.
yAxis should update after the key for a series changes.

Fixes #2025.
2018-05-04 11:56:47 -07:00
Pete Richards
e2f3728a6e removed unused file 2018-05-04 11:56:39 -07:00
Pete Richards
5d44ff9b9f don't allow plot or table view of summary widget 2018-05-04 11:56:04 -07:00
Pete Richards
642b4c7d6f sprintf support
commit 21ec3928d0b474e2f87d1bcb5c0ce9939901a627
Author: Pete Richards <peter.l.richards@nasa.gov>
Date:   Fri Sep 22 17:50:16 2017 -0700

    Basic sprintf support
2018-04-25 10:36:32 -07:00
11 changed files with 166 additions and 190 deletions

View File

@@ -30,6 +30,8 @@ define([
{
key: "sin",
name: "Sine",
format: 'printf',
sprintf: '%0.2f',
hints: {
range: 1
}
@@ -37,6 +39,8 @@ define([
{
key: "cos",
name: "Cosine",
format: 'printf',
sprintf: '%0.2f',
hints: {
range: 2
}

View File

@@ -47,7 +47,9 @@ define([
var interval = setInterval(function () {
var now = Date.now();
callback(pointForTimestamp(now, duration, domainObject.name));
var datum = pointForTimestamp(now, duration, domainObject.name);
datum.value += "";
callback(datum);
}, duration);
return function () {

View File

@@ -49,7 +49,8 @@ requirejs.config({
"d3-format": "node_modules/d3-format/build/d3-format.min",
"d3-interpolate": "node_modules/d3-interpolate/build/d3-interpolate.min",
"d3-time": "node_modules/d3-time/build/d3-time.min",
"d3-time-format": "node_modules/d3-time-format/build/d3-time-format.min"
"d3-time-format": "node_modules/d3-time-format/build/d3-time-format.min",
"printj": "node_modules/printj/dist/printj.min"
},
"shim": {
"angular": {

View File

@@ -49,6 +49,7 @@
"mkdirp": "^0.5.1",
"moment": "^2.11.1",
"node-bourbon": "^4.2.3",
"printj": "^1.1.0",
"requirejs": "2.1.x",
"split": "^1.0.0",
"v8-compile-cache": "^1.1.0"

View File

@@ -21,9 +21,11 @@
*****************************************************************************/
define([
'lodash'
'lodash',
'printj'
], function (
_
_,
printj
) {
// TODO: needs reference to formatService;
@@ -57,8 +59,8 @@ define([
return vm;
}, {byValue: {}, byString: {}});
this.formatter.format = function (value) {
if (typeof value === "number") {
return this.enumerations.byValue[value] || value;
if (this.enumerations.byValue.hasOwnProperty(value)) {
return this.enumerations.byValue[value];
}
return value;
}.bind(this);
@@ -71,6 +73,12 @@ define([
return Number(string);
}.bind(this);
}
if (valueMetadata.sprintf) {
this.formatter = numberFormatter;
this.formatter.format = function (value) {
return printj.sprintf(valueMetadata.sprintf, value);
}
}
}
TelemetryValueFormatter.prototype.parse = function (datum) {

View File

@@ -146,10 +146,14 @@ define([
this.updateStats(seriesStats);
}
}, this);
this.listenTo(series, 'change:yKey', function () {
this.updateFromSeries(this.seriesCollection);
}, this);
},
untrackSeries: function (series) {
this.stopListening(series);
this.resetStats();
this.updateFromSeries(this.seriesCollection);
},
toggleAutoscale: function (autoscale) {
if (autoscale) {
@@ -162,8 +166,13 @@ define([
* Update yAxis format, values, and label from known series.
*/
updateFromSeries: function (series) {
var plotModel = this.plot.get('domainObject');
var label = _.get(plotModel, 'configuration.yAxis.label');
var sampleSeries = series.first();
if (!sampleSeries) {
if (!label) {
this.unset('label');
}
return;
}
@@ -172,9 +181,6 @@ define([
var yFormat = sampleSeries.formats[yKey];
this.set('format', yFormat.format.bind(yFormat));
this.set('values', yMetadata.values);
var plotModel = this.plot.get('domainObject');
var label = _.get(plotModel, 'configuration.xAxis.label');
if (!label) {
var labelUnits = series.map(function (s) {
return s.metadata.value(s.get('yKey')).units;

View File

@@ -1,177 +0,0 @@
/*****************************************************************************
* Open MCT, Copyright (c) 2014-2018, 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 () {
/**
* A class for encapsulating structure and behaviour of the plot
* options form
* @memberOf platform/features/plot
* @param topic
* @constructor
*/
function PlotOptionsForm() {
/*
Defined below are the form structures for the plot options.
*/
this.xAxisForm = {
name: 'x-axis',
sections: [{
name: 'x-axis',
rows: [
{
name: 'Domain',
control: 'select',
key: 'key',
options: [
{
name: 'SCET',
value: 'scet'
},
{
name: 'ERT',
value: 'ert'
},
{
name: 'SCLK',
value: 'sclk'
},
{
name: 'LST',
value: 'lst'
}
]
}
]
}]};
this.yAxisForm = {
name: 'y-axis',
sections: [{
// Will need to be repeated for each y-axis, with a
// distinct name for each. Ideally the name of the axis
// itself.
name: 'y-axis',
rows: [
{
name: 'Range',
control: 'select',
key: 'key',
options: [
{
name: 'Autoselect',
value: 'auto'
},
{
name: 'EU',
value: 'eu'
},
{
name: 'DN',
value: 'dn'
},
{
name: 'Status',
value: 'enum'
}
]
},
{
name: 'Autoscale',
control: 'checkbox',
key: 'autoscale'
},
{
name: 'Min',
control: 'textfield',
key: 'min',
pattern: '[0-9]',
inputsize: 'sm'
},
{
name: 'Max',
control: 'textfield',
key: 'max',
pattern: '[0-9]',
inputsize: 'sm'
}
]
}]
};
this.plotSeriesForm = {
name: 'Series Options',
sections: [
{
rows: [
{
name: 'Color',
control: 'color',
key: 'color'
}]
},
{
rows: [
{
name: 'Markers',
control: 'checkbox',
key: 'markers',
layout: 'control-first'
}
]
},
{
rows: [
{
name: 'No Line',
control: 'radio',
key: 'interpolate',
value: 'none',
layout: 'control-first'
},
{
name: 'Step Line',
control: 'radio',
key: 'interpolate',
value: 'stepAfter',
layout: 'control-first'
},
{
name: 'Linear Line',
control: 'radio',
key: 'interpolate',
value: 'linear',
layout: 'control-first'
}
]
}
]
};
}
return PlotOptionsForm;
});

View File

@@ -220,6 +220,7 @@ define([
return;
}
this.marquee.end = this.positionOverPlot;
this.marquee.endPixels = this.positionOverElement;
};
MCTPlotController.prototype.startMarquee = function ($event) {
@@ -227,6 +228,8 @@ define([
if (this.positionOverPlot) {
this.freeze();
this.marquee = {
startPixels: this.positionOverElement,
endPixels: this.positionOverElement,
start: this.positionOverPlot,
end: this.positionOverPlot,
color: [1, 1, 1, 0.5]
@@ -237,8 +240,14 @@ define([
};
MCTPlotController.prototype.endMarquee = function () {
if (this.marquee.start.x !== this.marquee.end.x &&
this.marquee.start.y !== this.marquee.end.y) {
var startPixels = this.marquee.startPixels;
var endPixels = this.marquee.endPixels;
var marqueeDistance = Math.sqrt(
Math.pow(startPixels.x - endPixels.x, 2) +
Math.pow(startPixels.y - endPixels.y, 2)
);
// Don't zoom if mouse moved less than 7.5 pixels.
if (marqueeDistance > 7.5) {
this.$scope.xAxis.set('displayRange', {
min: Math.min(this.marquee.start.x, this.marquee.end.x),
max: Math.max(this.marquee.start.x, this.marquee.end.x)
@@ -248,6 +257,10 @@ define([
max: Math.max(this.marquee.start.y, this.marquee.end.y)
});
this.$scope.$emit('user:viewport:change:end');
} else {
// A history entry is created by startMarquee, need to remove
// if marquee zoom doesn't occur.
this.back();
}
this.$scope.rectangles = [];
this.marquee = undefined;

View File

@@ -0,0 +1,45 @@
/*****************************************************************************
* Open MCT, Copyright (c) 2014-2017, 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 (
) {
/**
* Policy determining which views can apply to summary widget. Disables
* any view other than normal summary widget view.
*/
function SummaryWidgetViewPolicy() {
}
SummaryWidgetViewPolicy.prototype.allow = function (view, domainObject) {
if (domainObject.getModel().type === 'summary-widget') {
return view.key === 'summary-widget-viewer';
}
return true;
};
return SummaryWidgetViewPolicy;
});

View File

@@ -2,12 +2,14 @@ define([
'./SummaryWidgetsCompositionPolicy',
'./src/telemetry/SummaryWidgetMetadataProvider',
'./src/telemetry/SummaryWidgetTelemetryProvider',
'./src/views/SummaryWidgetViewProvider'
'./src/views/SummaryWidgetViewProvider',
'./SummaryWidgetViewPolicy'
], function (
SummaryWidgetsCompositionPolicy,
SummaryWidgetMetadataProvider,
SummaryWidgetTelemetryProvider,
SummaryWidgetViewProvider
SummaryWidgetViewProvider,
SummaryWidgetViewPolicy
) {
function plugin() {
@@ -87,6 +89,11 @@ define([
openmct.legacyExtension('policies', {category: 'composition',
implementation: SummaryWidgetsCompositionPolicy, depends: ['openmct']
});
openmct.legacyExtension('policies', {
category: 'view',
implementation: SummaryWidgetViewPolicy,
depends: ['openmct']
});
openmct.telemetry.addProvider(new SummaryWidgetMetadataProvider(openmct));
openmct.telemetry.addProvider(new SummaryWidgetTelemetryProvider(openmct));
openmct.objectViews.addProvider(new SummaryWidgetViewProvider(openmct));

View File

@@ -0,0 +1,66 @@
/*****************************************************************************
* Open MCT, Copyright (c) 2014-2017, 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([
'../SummaryWidgetViewPolicy'
], function (
SummaryWidgetViewPolicy
) {
describe('SummaryWidgetViewPolicy', function () {
var policy;
var domainObject;
var view;
beforeEach(function () {
policy = new SummaryWidgetViewPolicy();
domainObject = jasmine.createSpyObj('domainObject', [
'getModel'
]);
domainObject.getModel.andReturn({});
view = {};
});
it('returns true for other object types', function () {
domainObject.getModel.andReturn({
type: 'random'
});
expect(policy.allow(view, domainObject)).toBe(true);
});
it('allows summary widget view for summary widgets', function () {
domainObject.getModel.andReturn({
type: 'summary-widget'
});
view.key = 'summary-widget-viewer';
expect(policy.allow(view, domainObject)).toBe(true);
});
it('disallows other views for summary widgets', function () {
domainObject.getModel.andReturn({
type: 'summary-widget'
});
view.key = 'other view';
expect(policy.allow(view, domainObject)).toBe(false);
});
});
});