From 248f160e738ba411aeb02836318063f21d5a3ca9 Mon Sep 17 00:00:00 2001 From: Deep Tailor Date: Tue, 12 Mar 2019 12:20:03 -0700 Subject: [PATCH] Filters Inspector View (#2296) * Added telemetry filters to the API * Support multiple inspector views * Renamed InspectorView.vue to InspectorViews.vue * first cut of filter inspector plugin * abstract for better readability * third times the charm * working persist checkbox selections * fix typo * working persisted filters from inspector * add prop validations for FitlerValue and FilterObject * enable filter inspector view for overlay and stacked plots * remove object from persisted filter when object is removed from composition * update filterValue to filterField for clarity * Added filter code to tables * add filter support to Telemetry Tables * fix errors when old domainObject does not have configuration property * working filters on overlay plots * make requested changes * Add filters as 'options' object on subscribe * Significant mods to Filtering - Styling; - Added Browse view in Inspector; - Added .c-checkbox-list class; - "PLOT SERIES" header changed to "PLOT SERIES OPTIONS" for clarity; * make filter update pass updated filters to telemetry adapter * Tolerate undefined configuration * Conditionally destroy filters listener * use @change event instead of @blur' --- .../generator/GeneratorMetadataProvider.js | 9 +- index.html | 1 + src/api/telemetry/TelemetryAPI.js | 4 +- src/api/telemetry/TelemetryMetadataManager.js | 4 + .../filters/components/FilterField.vue | 113 ++++++++++++++++++ .../filters/components/FilterObject.vue | 93 ++++++++++++++ .../filters/components/FiltersView.vue | 85 +++++++++++++ .../filters/filtersInspectorViewProvider.js | 73 +++++++++++ src/plugins/filters/plugin.js | 33 +++++ src/plugins/plot/plugin.js | 3 +- .../res/templates/plot-options-browse.html | 2 +- .../plot/res/templates/plot-options-edit.html | 2 +- .../configuration/PlotConfigurationModel.js | 13 ++ .../plot/src/configuration/PlotSeries.js | 21 +++- .../src/configuration/SeriesCollection.js | 4 +- .../plot/src/telemetry/PlotController.js | 17 +++ src/plugins/plugins.js | 3 + .../TableConfigurationViewProvider.js | 3 +- src/plugins/telemetryTable/TelemetryTable.js | 34 +++++- .../components/table-configuration.vue | 32 ++--- src/styles-new/_controls.scss | 12 ++ src/ui/inspector/Inspector.vue | 13 +- src/ui/inspector/InspectorView.vue | 37 ------ src/ui/inspector/InspectorViews.vue | 40 +++++++ src/ui/registries/InspectorViewRegistry.js | 8 +- 25 files changed, 585 insertions(+), 74 deletions(-) create mode 100644 src/plugins/filters/components/FilterField.vue create mode 100644 src/plugins/filters/components/FilterObject.vue create mode 100644 src/plugins/filters/components/FiltersView.vue create mode 100644 src/plugins/filters/filtersInspectorViewProvider.js create mode 100644 src/plugins/filters/plugin.js delete mode 100644 src/ui/inspector/InspectorView.vue create mode 100644 src/ui/inspector/InspectorViews.vue diff --git a/example/generator/GeneratorMetadataProvider.js b/example/generator/GeneratorMetadataProvider.js index 1668d72d4c..fecf996ffe 100644 --- a/example/generator/GeneratorMetadataProvider.js +++ b/example/generator/GeneratorMetadataProvider.js @@ -33,12 +33,19 @@ define([ formatString: '%0.2f', hints: { range: 1 - } + }, + filters: [ + { + comparator: 'equals', + possibleValues: [1,2,3,4] + } + ] }, { key: "cos", name: "Cosine", formatString: '%0.2f', + filters: ['equals'], hints: { range: 2 } diff --git a/index.html b/index.html index bb4babbf54..7a43151700 100644 --- a/index.html +++ b/index.html @@ -81,6 +81,7 @@ openmct.install(openmct.plugins.Tabs()); openmct.install(openmct.plugins.FlexibleLayout()); openmct.install(openmct.plugins.LADTable()); + openmct.install(openmct.plugins.Filters(['table', 'telemetry.plot.overlay'])); openmct.install(openmct.plugins.ObjectMigration()); openmct.start(); diff --git a/src/api/telemetry/TelemetryAPI.js b/src/api/telemetry/TelemetryAPI.js index 2c833ccbd8..d32b57d361 100644 --- a/src/api/telemetry/TelemetryAPI.js +++ b/src/api/telemetry/TelemetryAPI.js @@ -297,7 +297,7 @@ define([ * @returns {Function} a function which may be called to terminate * the subscription */ - TelemetryAPI.prototype.subscribe = function (domainObject, callback) { + TelemetryAPI.prototype.subscribe = function (domainObject, callback, options) { var provider = this.findSubscriptionProvider(domainObject); if (!this.subscribeCache) { @@ -316,7 +316,7 @@ define([ subscriber.callbacks.forEach(function (cb) { cb(value); }); - }); + }, options); } else { subscriber.unsubscribe = function () {}; } diff --git a/src/api/telemetry/TelemetryMetadataManager.js b/src/api/telemetry/TelemetryMetadataManager.js index 8ab1d7441d..df3fbc6320 100644 --- a/src/api/telemetry/TelemetryMetadataManager.js +++ b/src/api/telemetry/TelemetryMetadataManager.js @@ -124,6 +124,10 @@ define([ return sortedMetadata; }; + TelemetryMetadataManager.prototype.getFilterableValues = function () { + return this.valueMetadatas.filter(metadatum => metadatum.filters && metadatum.filters.length > 0); + } + TelemetryMetadataManager.prototype.getDefaultDisplayValue = function () { let valueMetadata = this.valuesForHints(['range'])[0]; diff --git a/src/plugins/filters/components/FilterField.vue b/src/plugins/filters/components/FilterField.vue new file mode 100644 index 0000000000..e2a4d5d1ab --- /dev/null +++ b/src/plugins/filters/components/FilterField.vue @@ -0,0 +1,113 @@ + + + + + + diff --git a/src/plugins/filters/components/FilterObject.vue b/src/plugins/filters/components/FilterObject.vue new file mode 100644 index 0000000000..5d3eb281fb --- /dev/null +++ b/src/plugins/filters/components/FilterObject.vue @@ -0,0 +1,93 @@ + + + + + diff --git a/src/plugins/filters/components/FiltersView.vue b/src/plugins/filters/components/FiltersView.vue new file mode 100644 index 0000000000..26df30bbe5 --- /dev/null +++ b/src/plugins/filters/components/FiltersView.vue @@ -0,0 +1,85 @@ + + + + + diff --git a/src/plugins/filters/filtersInspectorViewProvider.js b/src/plugins/filters/filtersInspectorViewProvider.js new file mode 100644 index 0000000000..80e00c7aff --- /dev/null +++ b/src/plugins/filters/filtersInspectorViewProvider.js @@ -0,0 +1,73 @@ +/***************************************************************************** + * 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([ + './components/FiltersView.vue', + 'vue' +], function ( + FiltersView, + Vue +) { + + function FiltersInspectorViewProvider(openmct, supportedObjectTypesArray) { + return { + key: 'filters-inspector', + name: 'Filters Inspector View', + canView: function (selection) { + if (selection.length === 0) { + return false; + } + let object = selection[0].context.item; + + return object && supportedObjectTypesArray.some(type => object.type === type); + }, + view: function (selection) { + let component; + let providedObject = selection[0].context.item; + + return { + show: function (element) { + component = new Vue({ + provide: { + openmct, + providedObject + }, + components: { + FiltersView: FiltersView.default + }, + template: '', + el: element + }); + }, + destroy: function () { + component.$destroy(); + component = undefined; + } + } + }, + priority: function () { + return 1; + } + } + } + return FiltersInspectorViewProvider; +}); diff --git a/src/plugins/filters/plugin.js b/src/plugins/filters/plugin.js new file mode 100644 index 0000000000..ff55026d02 --- /dev/null +++ b/src/plugins/filters/plugin.js @@ -0,0 +1,33 @@ +/***************************************************************************** + * 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([ + './filtersInspectorViewProvider' +], function ( + FiltersInspectorViewProvider +) { + return function plugin(supportedObjectTypesArray) { + return function install(openmct) { + openmct.inspectorViews.addProvider(new FiltersInspectorViewProvider(openmct, supportedObjectTypesArray)); + }; + }; +}); diff --git a/src/plugins/plot/plugin.js b/src/plugins/plot/plugin.js index 426f4fe343..9ad9a9b4f8 100644 --- a/src/plugins/plot/plugin.js +++ b/src/plugins/plot/plugin.js @@ -250,7 +250,8 @@ define([ {"has": "telemetry"} ], "model": { - "composition": [] + "composition": [], + "configuration": {} }, "properties": [], "priority": 890 diff --git a/src/plugins/plot/res/templates/plot-options-browse.html b/src/plugins/plot/res/templates/plot-options-browse.html index e05fe60d75..f0783f300c 100644 --- a/src/plugins/plot/res/templates/plot-options-browse.html +++ b/src/plugins/plot/res/templates/plot-options-browse.html @@ -21,7 +21,7 @@ -->