Optionally provide list of object types to show as views rather than telemetry in Display Layouts (#2339)

* Optionally provide list of object types to show as views rather than alpha numerics to display layouts

* Only make table view available for objects that have telemetry to show
This commit is contained in:
Andrew Henry 2019-03-28 22:21:27 -07:00 committed by Deep Tailor
parent 57efef3160
commit bc5e300ba9
5 changed files with 25 additions and 10 deletions

View File

@ -54,6 +54,9 @@
openmct.install(openmct.plugins.AutoflowView({ openmct.install(openmct.plugins.AutoflowView({
type: "telemetry.panel" type: "telemetry.panel"
})); }));
openmct.install(openmct.plugins.DisplayLayout({
showAsView: ['summary-widget', 'example.imagery']
}));
openmct.install(openmct.plugins.Conductor({ openmct.install(openmct.plugins.Conductor({
menuOptions: [ menuOptions: [
{ {

View File

@ -248,7 +248,6 @@ define([
this.legacyRegistry = defaultRegistry; this.legacyRegistry = defaultRegistry;
this.install(this.plugins.Plot()); this.install(this.plugins.Plot());
this.install(this.plugins.TelemetryTable()); this.install(this.plugins.TelemetryTable());
this.install(this.plugins.DisplayLayout());
this.install(PreviewPlugin.default()); this.install(PreviewPlugin.default());
this.install(LegacyIndicatorsPlugin()); this.install(LegacyIndicatorsPlugin());
this.install(LicensesPlugin.default()); this.install(LicensesPlugin.default());
@ -257,7 +256,6 @@ define([
if (typeof BUILD_CONSTANTS !== 'undefined') { if (typeof BUILD_CONSTANTS !== 'undefined') {
this.install(buildInfoPlugin(BUILD_CONSTANTS)); this.install(buildInfoPlugin(BUILD_CONSTANTS));
} }
} }
MCT.prototype = Object.create(EventEmitter.prototype); MCT.prototype = Object.create(EventEmitter.prototype);
@ -328,6 +326,12 @@ define([
* MCT; if undefined, MCT will be run in the body of the document * MCT; if undefined, MCT will be run in the body of the document
*/ */
MCT.prototype.start = function (domElement) { MCT.prototype.start = function (domElement) {
if (!this.plugins.DisplayLayout._installed) {
this.install(this.plugins.DisplayLayout({
showAsView: ['summary-widget']
}));
}
if (!domElement) { if (!domElement) {
domElement = document.body; domElement = document.body;
} }

View File

@ -152,7 +152,7 @@
return this.internalDomainObject.configuration.items; return this.internalDomainObject.configuration.items;
} }
}, },
inject: ['openmct'], inject: ['openmct', 'options'],
props: ['domainObject'], props: ['domainObject'],
components: ITEM_TYPE_VIEW_MAP, components: ITEM_TYPE_VIEW_MAP,
methods: { methods: {
@ -283,9 +283,8 @@
} }
}, },
isTelemetry(domainObject) { isTelemetry(domainObject) {
if (this.openmct.telemetry.isTelemetryObject(domainObject) if (this.openmct.telemetry.isTelemetryObject(domainObject) &&
&& domainObject.type !== 'summary-widget' !this.options.showAsView.includes(domainObject.type)) {
&& domainObject.type !== 'example.imagery') {
return true; return true;
} else { } else {
return false; return false;

View File

@ -25,8 +25,7 @@ import Vue from 'vue'
import objectUtils from '../../api/objects/object-utils.js' import objectUtils from '../../api/objects/object-utils.js'
import DisplayLayoutType from './DisplayLayoutType.js' import DisplayLayoutType from './DisplayLayoutType.js'
import DisplayLayoutToolbar from './DisplayLayoutToolbar.js' import DisplayLayoutToolbar from './DisplayLayoutToolbar.js'
export default function DisplayLayoutPlugin(options) {
export default function () {
return function (openmct) { return function (openmct) {
openmct.objectViews.addProvider({ openmct.objectViews.addProvider({
key: 'layout.view', key: 'layout.view',
@ -47,7 +46,8 @@ export default function () {
template: '<layout ref="displayLayout" :domain-object="domainObject"></layout>', template: '<layout ref="displayLayout" :domain-object="domainObject"></layout>',
provide: { provide: {
openmct, openmct,
objectUtils objectUtils,
options
}, },
el: container, el: container,
data () { data () {
@ -83,5 +83,6 @@ export default function () {
return true; return true;
} }
}); });
DisplayLayoutPlugin._installed = true;
} }
} }

View File

@ -32,12 +32,20 @@ define([
Vue Vue
) { ) {
function TelemetryTableViewProvider(openmct) { function TelemetryTableViewProvider(openmct) {
function hasTelemetry(domainObject) {
if (!domainObject.hasOwnProperty('telemetry')) {
return false;
}
let metadata = openmct.telemetry.getMetadata(domainObject);
return metadata.values().length > 0;
}
return { return {
key: 'table', key: 'table',
name: 'Telemetry Table', name: 'Telemetry Table',
cssClass: 'icon-tabular-realtime', cssClass: 'icon-tabular-realtime',
canView(domainObject) { canView(domainObject) {
return domainObject.type === 'table' || domainObject.hasOwnProperty('telemetry'); return domainObject.type === 'table' ||
hasTelemetry(domainObject)
}, },
canEdit(domainObject) { canEdit(domainObject) {
return domainObject.type === 'table'; return domainObject.type === 'table';