Compare commits
	
		
			1 Commits
		
	
	
		
			tab-keep-a
			...
			alpha-enum
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|   | 9fef060501 | 
| @@ -55,7 +55,7 @@ | ||||
|     "node-bourbon": "^4.2.3", | ||||
|     "node-sass": "^4.9.2", | ||||
|     "painterro": "^0.2.65", | ||||
|     "printj": "^1.1.0", | ||||
|     "printj": "^1.2.1", | ||||
|     "raw-loader": "^0.5.1", | ||||
|     "request": "^2.69.0", | ||||
|     "split": "^1.0.0", | ||||
|   | ||||
							
								
								
									
										77
									
								
								src/plugins/displayLayout/AlphanumericFormatViewProvider.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										77
									
								
								src/plugins/displayLayout/AlphanumericFormatViewProvider.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,77 @@ | ||||
| /***************************************************************************** | ||||
|  * 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/AlphanumericFormatView.vue', | ||||
|     'vue' | ||||
| ], function (AlphanumericFormatView, Vue) { | ||||
|  | ||||
|     function AlphanumericFormatViewProvider(openmct, options) { | ||||
|         function isTelemetryObject(selectionPath) { | ||||
|             let selectedObject = selectionPath[0].context.item; | ||||
|             let parentObject = selectionPath[1].context.item; | ||||
|             return parentObject &&  | ||||
|                 parentObject.type === 'layout' && | ||||
|                 selectedObject && | ||||
|                 openmct.telemetry.isTelemetryObject(selectedObject) && | ||||
|                 !options.showAsView.includes(selectedObject.type) | ||||
|         } | ||||
|  | ||||
|         return { | ||||
|             key: 'alphanumeric-format', | ||||
|             name: 'Alphanumeric Format', | ||||
|             canView: function (selection) { | ||||
|                 if (selection.length === 0 || selection[0].length === 1) { | ||||
|                     return false; | ||||
|                 } | ||||
|  | ||||
|                 return selection.every(isTelemetryObject); | ||||
|             }, | ||||
|             view: function (selection) { | ||||
|                 let component; | ||||
|                 return { | ||||
|                     show: function (element) { | ||||
|                         component = new Vue({ | ||||
|                             provide: { | ||||
|                                 openmct | ||||
|                             }, | ||||
|                             components: { | ||||
|                                 AlphanumericFormatView: AlphanumericFormatView.default | ||||
|                             }, | ||||
|                             template: '<alphanumeric-format-view></alphanumeric-format-view>', | ||||
|                             el: element | ||||
|                         }); | ||||
|                     }, | ||||
|                     destroy: function () { | ||||
|                         component.$destroy(); | ||||
|                         component = undefined; | ||||
|                     } | ||||
|                 } | ||||
|             }, | ||||
|             priority: function () { | ||||
|                 return 1; | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     return AlphanumericFormatViewProvider; | ||||
| }); | ||||
| @@ -0,0 +1,80 @@ | ||||
| /***************************************************************************** | ||||
|  * 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. | ||||
|  *****************************************************************************/ | ||||
|  | ||||
| <template> | ||||
|     <div class="c-properties" v-if="isEditing"> | ||||
|         <div class="c-properties__header">Alphanumeric Format</div> | ||||
|         <ul class="c-properties__section" v-if="!multiSelect"> | ||||
|             <li class="c-properties__row"> | ||||
|                 <div class="c-properties__label" title="Printf formatting for the selected telemetry"> | ||||
|                     <label for="telemetryPrintfFormat">Format</label> | ||||
|                 </div> | ||||
|                 <div class="c-properties__value"> | ||||
|                     <input id="telemetryPrintfFormat" type="text" @change="formatTelemetry" :value="telemetryFormat"> | ||||
|                 </div> | ||||
|             </li> | ||||
|         </ul> | ||||
|         <div class="c-properties__row--span-all" v-if="multiSelect">No format to display for multiple items</div> | ||||
|     </div> | ||||
| </template> | ||||
|  | ||||
| <script> | ||||
|     export default { | ||||
|         inject: ['openmct'], | ||||
|         data() { | ||||
|             let selectionPath = this.openmct.selection.get()[0]; | ||||
|             return { | ||||
|                 isEditing: this.openmct.editor.isEditing(), | ||||
|                 telemetryFormat: selectionPath[0].context.layoutItem.format, | ||||
|                 multiSelect: false | ||||
|             } | ||||
|         }, | ||||
|         methods: { | ||||
|             toggleEdit(isEditing) { | ||||
|                 this.isEditing = isEditing; | ||||
|             }, | ||||
|             formatTelemetry(event) { | ||||
|                 let selectionPath = this.openmct.selection.get()[0]; | ||||
|                 let newFormat = event.currentTarget.value; | ||||
|                 selectionPath[0].context.updateTelemetryFormat(newFormat); | ||||
|                 this.telemetryFormat = newFormat; | ||||
|             }, | ||||
|             handleSelection(selection) { | ||||
|                 if (selection.length === 0 || selection[0].length === 0) { | ||||
|                     return; | ||||
|                 } | ||||
|  | ||||
|                 this.multiSelect = selection.length > 1 ? true : false; | ||||
|             } | ||||
|         }, | ||||
|         mounted() { | ||||
|             this.openmct.editor.on('isEditing', this.toggleEdit); | ||||
|             this.openmct.selection.on('change', this.handleSelection); | ||||
|             this.handleSelection(this.openmct.selection.get()); | ||||
|         }, | ||||
|         destroyed() { | ||||
|             this.openmct.editor.off('isEditing', this.toggleEdit); | ||||
|             this.openmct.selection.off('change', this.handleSelection); | ||||
|         } | ||||
|     } | ||||
|  | ||||
| </script> | ||||
| @@ -48,7 +48,8 @@ | ||||
|                    :multiSelect="selectedLayoutItems.length > 1" | ||||
|                    @move="move" | ||||
|                    @endMove="endMove" | ||||
|                    @endLineResize='endLineResize'> | ||||
|                    @endLineResize='endLineResize' | ||||
|                    @formatChanged='updateTelemetryFormat'> | ||||
|         </component> | ||||
|         <edit-marquee v-if='showMarquee' | ||||
|                       :gridSize="gridSize" | ||||
| @@ -557,6 +558,11 @@ | ||||
|                     this.layoutItems.splice(itemIndex, 1); | ||||
|                     this.layoutItems.splice(newIndex, 0, items[itemIndex]); | ||||
|                 } | ||||
|             }, | ||||
|             updateTelemetryFormat(item, format) { | ||||
|                 let index = this.layoutItems.indexOf(item); | ||||
|                 item.format = format; | ||||
|                 this.mutate(`configuration.items[${index}]`, item); | ||||
|             } | ||||
|         }, | ||||
|         mounted() { | ||||
|   | ||||
| @@ -79,6 +79,7 @@ | ||||
|  | ||||
|  <script> | ||||
|     import LayoutFrame from './LayoutFrame.vue' | ||||
|     import printj from 'printj' | ||||
|  | ||||
|     const DEFAULT_TELEMETRY_DIMENSIONS = [10, 5], | ||||
|           DEFAULT_POSITION = [1, 1]; | ||||
| @@ -143,6 +144,10 @@ | ||||
|                     return; | ||||
|                 } | ||||
|  | ||||
|                 if (this.item.format) { | ||||
|                     return printj.sprintf(this.item.format, this.datum[this.valueMetadata.key]); | ||||
|                 } | ||||
|  | ||||
|                 return this.valueFormatter && this.valueFormatter.format(this.datum); | ||||
|             }, | ||||
|             telemetryClass() { | ||||
| @@ -168,6 +173,9 @@ | ||||
|                 } | ||||
|  | ||||
|                 this.context.index = newIndex; | ||||
|             }, | ||||
|             item(newItem) { | ||||
|                 this.context.layoutItem = newItem; | ||||
|             } | ||||
|         }, | ||||
|         methods: { | ||||
| @@ -194,6 +202,7 @@ | ||||
|                 }.bind(this)); | ||||
|             }, | ||||
|             updateView(datum) { | ||||
|                 // TODO: normalize datum | ||||
|                 this.datum = datum; | ||||
|             }, | ||||
|             removeSubscription() { | ||||
| @@ -219,10 +228,14 @@ | ||||
|                 this.context = { | ||||
|                     item: domainObject, | ||||
|                     layoutItem: this.item, | ||||
|                     index: this.index | ||||
|                     index: this.index, | ||||
|                     updateTelemetryFormat: this.updateTelemetryFormat | ||||
|                 }; | ||||
|                 this.removeSelectable = this.openmct.selection.selectable( | ||||
|                     this.$el, this.context, this.initSelect); | ||||
|             }, | ||||
|             updateTelemetryFormat(format) { | ||||
|                 this.$emit('formatChanged', this.item, format); | ||||
|             } | ||||
|         }, | ||||
|         mounted() { | ||||
|   | ||||
| @@ -25,6 +25,8 @@ import Vue from 'vue' | ||||
| import objectUtils from '../../api/objects/object-utils.js' | ||||
| import DisplayLayoutType from './DisplayLayoutType.js' | ||||
| import DisplayLayoutToolbar from './DisplayLayoutToolbar.js' | ||||
| import AlphaNumericFormatViewProvider from './AlphaNumericFormatViewProvider.js' | ||||
|  | ||||
| export default function DisplayLayoutPlugin(options) { | ||||
|     return function (openmct) { | ||||
|         openmct.objectViews.addProvider({ | ||||
| @@ -76,7 +78,8 @@ export default function DisplayLayoutPlugin(options) { | ||||
|             } | ||||
|         }); | ||||
|         openmct.types.addType('layout', DisplayLayoutType()); | ||||
|         openmct.toolbars.addProvider(new DisplayLayoutToolbar(openmct)); | ||||
|         openmct.toolbars.addProvider(new DisplayLayoutToolbar(openmct, options)); | ||||
|         openmct.inspectorViews.addProvider(new AlphaNumericFormatViewProvider(openmct, options)); | ||||
|         openmct.composition.addPolicy((parent, child) => { | ||||
|             if (parent.type === 'layout' && child.type === 'folder') { | ||||
|                 return false; | ||||
|   | ||||
| @@ -25,10 +25,6 @@ import _ from 'lodash'; | ||||
|         }, | ||||
|         methods: { | ||||
|             updateSelection(selection) { | ||||
|                 if (_.isEqual(this.selection, selection)) { | ||||
|                     return; | ||||
|                 } | ||||
|  | ||||
|                 this.selection = selection; | ||||
|  | ||||
|                 if (this.selectedViews) { | ||||
| @@ -38,10 +34,6 @@ import _ from 'lodash'; | ||||
|                     this.$el.innerHTML = ''; | ||||
|                 } | ||||
|  | ||||
|                 if (selection.length > 1) { | ||||
|                     return; | ||||
|                 } | ||||
|  | ||||
|                 this.selectedViews = this.openmct.inspectorViews.get(selection); | ||||
|                 this.selectedViews.forEach(selectedView => { | ||||
|                     let viewContainer = document.createElement('div'); | ||||
|   | ||||
| @@ -35,6 +35,7 @@ const webpackConfig = { | ||||
|             "bourbon": "bourbon.scss", | ||||
|             "vue": path.join(__dirname, "node_modules/vue/dist/vue.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"), | ||||
|             "styles": path.join(__dirname, "src/styles-new") | ||||
|         } | ||||
|     }, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user