Compare commits
	
		
			13 Commits
		
	
	
		
			gauge-fixe
			...
			notebook-v
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|   | d663788e77 | ||
|   | 100c9af72d | ||
|   | ccc5969b28 | ||
|   | 748b4bf4d1 | ||
|   | 755f0ac126 | ||
|   | 0173c3cfab | ||
|   | 9ca6ef428e | ||
|   | 5842bbc821 | ||
|   | a2f499abf6 | ||
|   | 634aaefb48 | ||
|   | 80368b38b5 | ||
|   | 17c60d1d4d | ||
|   | 5bca13aeff | 
| @@ -70,6 +70,7 @@ | ||||
|                 })); | ||||
|                 openmct.install(openmct.plugins.SummaryWidget()); | ||||
|                 openmct.install(openmct.plugins.Notebook()); | ||||
|                 openmct.install(openmct.plugins.NotebookV2()); | ||||
|                 openmct.time.clock('local', {start: -THIRTY_MINUTES, end: 0}); | ||||
|                 openmct.time.timeSystem('utc'); | ||||
|                 openmct.start(); | ||||
|   | ||||
| @@ -48,247 +48,247 @@ define([ | ||||
|         "description": "Create and save timestamped notes with embedded object snapshots.", | ||||
|         "extensions": | ||||
|         { | ||||
|             "types": [ | ||||
|             { | ||||
|                 "key": "notebook", | ||||
|                 "name": "Notebook", | ||||
|                 "cssClass": "icon-notebook", | ||||
|                 "description": "Create and save timestamped notes with embedded object snapshots.", | ||||
|                 "features": ["creation"], | ||||
|                 "model": { | ||||
|                       "entries": [], | ||||
|                       "composition": [], | ||||
|                       "entryTypes": [], | ||||
|                       "defaultSort": "-createdOn" | ||||
|                   }, | ||||
|                 "properties": [ | ||||
|                     { | ||||
|                         "key": "defaultSort", | ||||
|                         "name": "Default Sort", | ||||
|                         "control": "select", | ||||
|                         "options": [ | ||||
|                                 { | ||||
|                                     "name": "Newest First", | ||||
|                                     "value": "-createdOn" | ||||
|                                 }, | ||||
|                                 { | ||||
|                                     "name": "Oldest First", | ||||
|                                     "value": "createdOn" | ||||
|                                 } | ||||
|                             ], | ||||
|                         "cssClass": "l-inline" | ||||
|                     } | ||||
|                 ] | ||||
|             } | ||||
|           ], | ||||
|             "views": [ | ||||
|             { | ||||
|                 "key": "notebook.view", | ||||
|                 "type": "notebook", | ||||
|                 "cssClass": "icon-notebook", | ||||
|                 "name": "notebook", | ||||
|                 "template": notebookTemplate, | ||||
|                 "editable": false, | ||||
|                 "uses": [ | ||||
|                       "composition", | ||||
|                       "action" | ||||
|                   ], | ||||
|                 "gestures": [ | ||||
|                     "drop" | ||||
|                 ] | ||||
|             } | ||||
|           ], | ||||
|             "controllers": [ | ||||
|              { | ||||
|                  "key": "NotebookController", | ||||
|                  "implementation": NotebookController, | ||||
|                  "depends": [ | ||||
|                                 "$scope", | ||||
|                                 "dialogService", | ||||
|                                 "popupService", | ||||
|                                 "agentService", | ||||
|                                 "objectService", | ||||
|                                 "navigationService", | ||||
|                                 "now", | ||||
|                                 "actionService", | ||||
|                                 "$timeout", | ||||
|                                 "$element", | ||||
|                                 "$sce" | ||||
|                             ] | ||||
|              }, | ||||
|              { | ||||
|                  "key": "NewEntryController", | ||||
|                  "implementation": NewEntryController, | ||||
|                  "depends": ["$scope", | ||||
|                               "$rootScope" | ||||
|                              ] | ||||
|              }, | ||||
|              { | ||||
|                  "key": "selectSnapshotController", | ||||
|                  "implementation": SelectSnapshotController, | ||||
|                  "depends": ["$scope", | ||||
|                               "$rootScope" | ||||
|                              ] | ||||
|              }, | ||||
|              { | ||||
|                  "key": "LayoutNotebookController", | ||||
|                  "implementation": LayoutNotebookController, | ||||
|                  "depends": ["$scope"] | ||||
|              } | ||||
|            ], | ||||
|             "representations": [ | ||||
|                 { | ||||
|                     "key": "draggedEntry", | ||||
|                     "template": entryTemplate | ||||
|                 }, | ||||
|                 { | ||||
|                     "key": "frameLayoutNotebook", | ||||
|                     "template": frameTemplate | ||||
|                 } | ||||
|             ], | ||||
|             "templates": [ | ||||
|                 { | ||||
|                     "key": "annotate-snapshot", | ||||
|                     "template": annotationTemplate | ||||
|                 }, | ||||
|                 { | ||||
|                     "key": "notificationTemplate", | ||||
|                     "template": notificationsTemplate | ||||
|                 } | ||||
|             ], | ||||
|             "directives": [ | ||||
|                 { | ||||
|                     "key": "mctSnapshot", | ||||
|                     "implementation": MCTSnapshot, | ||||
|                     "depends": [ | ||||
|                         "$rootScope", | ||||
|                         "$document", | ||||
|                         "exportImageService", | ||||
|                         "dialogService", | ||||
|                         "notificationService" | ||||
|                     ] | ||||
|                 }, | ||||
|                 { | ||||
|                     "key": "mctEntryDnd", | ||||
|                     "implementation": MCTEntryDnd, | ||||
|                     "depends": [ | ||||
|                         "$rootScope", | ||||
|                         "$compile", | ||||
|                         "dndService", | ||||
|                         "typeService", | ||||
|                         "notificationService" | ||||
|                     ] | ||||
|                 } | ||||
|             ], | ||||
|             "actions": [ | ||||
|                 { | ||||
|                     "key": "view-snapshot", | ||||
|                     "implementation": ViewSnapshotAction, | ||||
|                     "name": "View Snapshot", | ||||
|                     "description": "View the large image in a modal", | ||||
|                     "category": "embed", | ||||
|                     "depends": [ | ||||
|                       "$compile" | ||||
|                     ] | ||||
|                 }, | ||||
|                 { | ||||
|                     "key": "annotate-snapshot", | ||||
|                     "implementation": AnnotateSnapshotAction, | ||||
|                     "name": "Annotate Snapshot", | ||||
|                     "cssClass": "icon-pencil labeled", | ||||
|                     "description": "Annotate embed's snapshot", | ||||
|                     "category": "embed", | ||||
|                     "depends": [ | ||||
|                       "dialogService", | ||||
|                       "dndService", | ||||
|                       "$rootScope" | ||||
|                     ] | ||||
|                 }, | ||||
|         //     "types": [ | ||||
|         //     { | ||||
|         //         "key": "notebook", | ||||
|         //         "name": "Notebook", | ||||
|         //         "cssClass": "icon-notebook", | ||||
|         //         "description": "Create and save timestamped notes with embedded object snapshots.", | ||||
|         //         "features": ["creation"], | ||||
|         //         "model": { | ||||
|         //               "entries": [], | ||||
|         //               "composition": [], | ||||
|         //               "entryTypes": [], | ||||
|         //               "defaultSort": "-createdOn" | ||||
|         //           }, | ||||
|         //         "properties": [ | ||||
|         //             { | ||||
|         //                 "key": "defaultSort", | ||||
|         //                 "name": "Default Sort", | ||||
|         //                 "control": "select", | ||||
|         //                 "options": [ | ||||
|         //                         { | ||||
|         //                             "name": "Newest First", | ||||
|         //                             "value": "-createdOn" | ||||
|         //                         }, | ||||
|         //                         { | ||||
|         //                             "name": "Oldest First", | ||||
|         //                             "value": "createdOn" | ||||
|         //                         } | ||||
|         //                     ], | ||||
|         //                 "cssClass": "l-inline" | ||||
|         //             } | ||||
|         //         ] | ||||
|         //     } | ||||
|         //   ], | ||||
|         //     "views": [ | ||||
|         //     { | ||||
|         //         "key": "notebook.view", | ||||
|         //         "type": "notebook", | ||||
|         //         "cssClass": "icon-notebook", | ||||
|         //         "name": "notebook", | ||||
|         //         "template": notebookTemplate, | ||||
|         //         "editable": false, | ||||
|         //         "uses": [ | ||||
|         //               "composition", | ||||
|         //               "action" | ||||
|         //           ], | ||||
|         //         "gestures": [ | ||||
|         //             "drop" | ||||
|         //         ] | ||||
|         //     } | ||||
|         //   ], | ||||
|         //     "controllers": [ | ||||
|         //      { | ||||
|         //          "key": "NotebookController", | ||||
|         //          "implementation": NotebookController, | ||||
|         //          "depends": [ | ||||
|         //                         "$scope", | ||||
|         //                         "dialogService", | ||||
|         //                         "popupService", | ||||
|         //                         "agentService", | ||||
|         //                         "objectService", | ||||
|         //                         "navigationService", | ||||
|         //                         "now", | ||||
|         //                         "actionService", | ||||
|         //                         "$timeout", | ||||
|         //                         "$element", | ||||
|         //                         "$sce" | ||||
|         //                     ] | ||||
|         //      }, | ||||
|         //      { | ||||
|         //          "key": "NewEntryController", | ||||
|         //          "implementation": NewEntryController, | ||||
|         //          "depends": ["$scope", | ||||
|         //                       "$rootScope" | ||||
|         //                      ] | ||||
|         //      }, | ||||
|         //      { | ||||
|         //          "key": "selectSnapshotController", | ||||
|         //          "implementation": SelectSnapshotController, | ||||
|         //          "depends": ["$scope", | ||||
|         //                       "$rootScope" | ||||
|         //                      ] | ||||
|         //      }, | ||||
|         //      { | ||||
|         //          "key": "LayoutNotebookController", | ||||
|         //          "implementation": LayoutNotebookController, | ||||
|         //          "depends": ["$scope"] | ||||
|         //      } | ||||
|         //    ], | ||||
|         //     "representations": [ | ||||
|         //         { | ||||
|         //             "key": "draggedEntry", | ||||
|         //             "template": entryTemplate | ||||
|         //         }, | ||||
|         //         { | ||||
|         //             "key": "frameLayoutNotebook", | ||||
|         //             "template": frameTemplate | ||||
|         //         } | ||||
|         //     ], | ||||
|         //     "templates": [ | ||||
|         //         { | ||||
|         //             "key": "annotate-snapshot", | ||||
|         //             "template": annotationTemplate | ||||
|         //         }, | ||||
|         //         { | ||||
|         //             "key": "notificationTemplate", | ||||
|         //             "template": notificationsTemplate | ||||
|         //         } | ||||
|         //     ], | ||||
|         //     "directives": [ | ||||
|         //         { | ||||
|         //             "key": "mctSnapshot", | ||||
|         //             "implementation": MCTSnapshot, | ||||
|         //             "depends": [ | ||||
|         //                 "$rootScope", | ||||
|         //                 "$document", | ||||
|         //                 "exportImageService", | ||||
|         //                 "dialogService", | ||||
|         //                 "notificationService" | ||||
|         //             ] | ||||
|         //         }, | ||||
|         //         { | ||||
|         //             "key": "mctEntryDnd", | ||||
|         //             "implementation": MCTEntryDnd, | ||||
|         //             "depends": [ | ||||
|         //                 "$rootScope", | ||||
|         //                 "$compile", | ||||
|         //                 "dndService", | ||||
|         //                 "typeService", | ||||
|         //                 "notificationService" | ||||
|         //             ] | ||||
|         //         } | ||||
|         //     ], | ||||
|         //     "actions": [ | ||||
|         //         { | ||||
|         //             "key": "view-snapshot", | ||||
|         //             "implementation": ViewSnapshotAction, | ||||
|         //             "name": "View Snapshot", | ||||
|         //             "description": "View the large image in a modal", | ||||
|         //             "category": "embed", | ||||
|         //             "depends": [ | ||||
|         //               "$compile" | ||||
|         //             ] | ||||
|         //         }, | ||||
|         //         { | ||||
|         //             "key": "annotate-snapshot", | ||||
|         //             "implementation": AnnotateSnapshotAction, | ||||
|         //             "name": "Annotate Snapshot", | ||||
|         //             "cssClass": "icon-pencil labeled", | ||||
|         //             "description": "Annotate embed's snapshot", | ||||
|         //             "category": "embed", | ||||
|         //             "depends": [ | ||||
|         //               "dialogService", | ||||
|         //               "dndService", | ||||
|         //               "$rootScope" | ||||
|         //             ] | ||||
|         //         }, | ||||
|  | ||||
|                 { | ||||
|                     "key": "remove-embed", | ||||
|                     "implementation": RemoveEmbedAction, | ||||
|                     "name": "Remove...", | ||||
|                     "cssClass": "icon-trash labeled", | ||||
|                     "description": "Remove this embed", | ||||
|                     "category": [ | ||||
|                         "embed", | ||||
|                         "embed-no-snap" | ||||
|                     ], | ||||
|                     "depends": [ | ||||
|                       "dialogService" | ||||
|                     ] | ||||
|                 }, | ||||
|                 { | ||||
|                     "key": "remove-snapshot", | ||||
|                     "implementation": RemoveSnapshotAction, | ||||
|                     "name": "Remove Snapshot", | ||||
|                     "cssClass": "icon-trash labeled", | ||||
|                     "description": "Remove Snapshot of the embed", | ||||
|                     "category": "embed", | ||||
|                     "depends": [ | ||||
|                       "dialogService" | ||||
|                     ] | ||||
|                 }, | ||||
|                 { | ||||
|                     "key": "notebook-new-entry", | ||||
|                     "implementation": newEntryAction, | ||||
|                     "name": "New Notebook Entry", | ||||
|                     "cssClass": "icon-notebook labeled", | ||||
|                     "description": "Add a new Notebook entry", | ||||
|                     "category": [ | ||||
|                          "view-control" | ||||
|                     ], | ||||
|                     "depends": [ | ||||
|                       "$compile", | ||||
|                       "$rootScope", | ||||
|                       "dialogService", | ||||
|                       "notificationService", | ||||
|                       "linkService" | ||||
|                     ], | ||||
|                     "priority": "preferred" | ||||
|                 } | ||||
|             ], | ||||
|             "licenses": [ | ||||
|                 { | ||||
|                     "name": "painterro", | ||||
|                     "version": "0.2.65", | ||||
|                     "author": "Ivan Borshchov", | ||||
|                     "description": "Painterro is JavaScript paint widget which allows editing images directly in a browser.", | ||||
|                     "website": "https://github.com/ivictbor/painterro", | ||||
|                     "copyright": "Copyright 2017 Ivan Borshchov", | ||||
|                     "license": "MIT", | ||||
|                     "link": "https://github.com/ivictbor/painterro/blob/master/LICENSE" | ||||
|                 } | ||||
|             ], | ||||
|             "capabilities": [ | ||||
|                 { | ||||
|                     "key": "notebook", | ||||
|                     "name": "Notebook Capability", | ||||
|                     "description": "Provides a capability for looking for a notebook domain object", | ||||
|                     "implementation": NotebookCapability, | ||||
|                     "depends": [ | ||||
|                         "typeService" | ||||
|                     ] | ||||
|                 } | ||||
|             ], | ||||
|             "policies": [ | ||||
|                 { | ||||
|                     "category": "composition", | ||||
|                     "implementation": CompositionPolicy, | ||||
|                     "message": "Objects of this type cannot contain objects of that type." | ||||
|                 } | ||||
|             ], | ||||
|             "controls": [ | ||||
|               { | ||||
|                   "key": "embed-control", | ||||
|                   "template": embedControlTemplate | ||||
|               }, | ||||
|                { | ||||
|                   "key": "snapshot-select", | ||||
|                   "template":  snapSelectTemplate | ||||
|               } | ||||
|             ], | ||||
|         //         { | ||||
|         //             "key": "remove-embed", | ||||
|         //             "implementation": RemoveEmbedAction, | ||||
|         //             "name": "Remove...", | ||||
|         //             "cssClass": "icon-trash labeled", | ||||
|         //             "description": "Remove this embed", | ||||
|         //             "category": [ | ||||
|         //                 "embed", | ||||
|         //                 "embed-no-snap" | ||||
|         //             ], | ||||
|         //             "depends": [ | ||||
|         //               "dialogService" | ||||
|         //             ] | ||||
|         //         }, | ||||
|         //         { | ||||
|         //             "key": "remove-snapshot", | ||||
|         //             "implementation": RemoveSnapshotAction, | ||||
|         //             "name": "Remove Snapshot", | ||||
|         //             "cssClass": "icon-trash labeled", | ||||
|         //             "description": "Remove Snapshot of the embed", | ||||
|         //             "category": "embed", | ||||
|         //             "depends": [ | ||||
|         //               "dialogService" | ||||
|         //             ] | ||||
|         //         }, | ||||
|         //         { | ||||
|         //             "key": "notebook-new-entry", | ||||
|         //             "implementation": newEntryAction, | ||||
|         //             "name": "New Notebook Entry", | ||||
|         //             "cssClass": "icon-notebook labeled", | ||||
|         //             "description": "Add a new Notebook entry", | ||||
|         //             "category": [ | ||||
|         //                  "view-control" | ||||
|         //             ], | ||||
|         //             "depends": [ | ||||
|         //               "$compile", | ||||
|         //               "$rootScope", | ||||
|         //               "dialogService", | ||||
|         //               "notificationService", | ||||
|         //               "linkService" | ||||
|         //             ], | ||||
|         //             "priority": "preferred" | ||||
|         //         } | ||||
|         //     ], | ||||
|         //     "licenses": [ | ||||
|         //         { | ||||
|         //             "name": "painterro", | ||||
|         //             "version": "0.2.65", | ||||
|         //             "author": "Ivan Borshchov", | ||||
|         //             "description": "Painterro is JavaScript paint widget which allows editing images directly in a browser.", | ||||
|         //             "website": "https://github.com/ivictbor/painterro", | ||||
|         //             "copyright": "Copyright 2017 Ivan Borshchov", | ||||
|         //             "license": "MIT", | ||||
|         //             "link": "https://github.com/ivictbor/painterro/blob/master/LICENSE" | ||||
|         //         } | ||||
|         //     ], | ||||
|         //     "capabilities": [ | ||||
|         //         { | ||||
|         //             "key": "notebook", | ||||
|         //             "name": "Notebook Capability", | ||||
|         //             "description": "Provides a capability for looking for a notebook domain object", | ||||
|         //             "implementation": NotebookCapability, | ||||
|         //             "depends": [ | ||||
|         //                 "typeService" | ||||
|         //             ] | ||||
|         //         } | ||||
|         //     ], | ||||
|         //     "policies": [ | ||||
|         //         { | ||||
|         //             "category": "composition", | ||||
|         //             "implementation": CompositionPolicy, | ||||
|         //             "message": "Objects of this type cannot contain objects of that type." | ||||
|         //         } | ||||
|         //     ], | ||||
|         //     "controls": [ | ||||
|         //       { | ||||
|         //           "key": "embed-control", | ||||
|         //           "template": embedControlTemplate | ||||
|         //       }, | ||||
|         //        { | ||||
|         //           "key": "snapshot-select", | ||||
|         //           "template":  snapSelectTemplate | ||||
|         //       } | ||||
|         //     ], | ||||
|             "stylesheets": [ | ||||
|                 { | ||||
|                     "stylesheetUrl": "css/notebook.css" | ||||
|   | ||||
| @@ -147,7 +147,7 @@ define( | ||||
|                 }); | ||||
|             }; | ||||
|  | ||||
|             $scope.textFocus = function ($event, entryId) { | ||||
|             $scope.textFocus = function ($event) { | ||||
|                 if ($event.srcElement) { | ||||
|                     $scope.currentEntryValue = $event.srcElement.innerText; | ||||
|                 } else { | ||||
|   | ||||
							
								
								
									
										215
									
								
								src/plugins/NotebookV2/plugin.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										215
									
								
								src/plugins/NotebookV2/plugin.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,215 @@ | ||||
| /***************************************************************************** | ||||
|  * 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([ | ||||
|     "./src/controllers/NotebookController", | ||||
|     "./src/controllers/NewEntryController", | ||||
|     "./src/controllers/SelectSnapshotController", | ||||
|     "./src/actions/NewEntryContextual", | ||||
|     "./src/actions/AnnotateSnapshot", | ||||
|     "./src/directives/MCTSnapshot", | ||||
|     "./src/directives/EntryDnd", | ||||
|     "text!./res/templates/controls/snapSelect.html", | ||||
|     "text!./res/templates/controls/embedControl.html", | ||||
|     "text!./res/templates/annotation.html", | ||||
|     "text!./res/templates/draggedEntry.html" | ||||
|  ], function ( | ||||
|     NotebookController, | ||||
|     NewEntryController, | ||||
|     SelectSnapshotController, | ||||
|     newEntryAction, | ||||
|     AnnotateSnapshotAction, | ||||
|     MCTSnapshotDirective, | ||||
|     EntryDndDirective, | ||||
|     snapSelectTemplate, | ||||
|     embedControlTemplate, | ||||
|     annotationTemplate, | ||||
|     draggedEntryTemplate | ||||
|  ) { | ||||
|     var installed  = false; | ||||
|  | ||||
|     function NotebookV2Plugin() { | ||||
|         return function install(openmct) { | ||||
|             if (installed) { | ||||
|                 return; | ||||
|             } | ||||
|  | ||||
|             installed = true; | ||||
|  | ||||
|             openmct.legacyRegistry.register('notebookV2', { | ||||
|                 name: 'Notebook Plugin', | ||||
|                 extensions: { | ||||
|                     types: [ | ||||
|                         { | ||||
|                             key: 'notebookV2', | ||||
|                             name: 'NotebookV2', | ||||
|                             cssClass: 'icon-notebook', | ||||
|                             description: 'Create and save timestamped notes with embedded object snapshots.', | ||||
|                             features: 'creation', | ||||
|                             model: { | ||||
|                                 entries: [], | ||||
|                                 composition: [], | ||||
|                                 entryTypes: [], | ||||
|                                 defaultSort: '-createdOn' | ||||
|                             }, | ||||
|                             properties: [ | ||||
|                                 { | ||||
|                                     key: 'defaultSort', | ||||
|                                     name: 'Default Sort', | ||||
|                                     control: 'select', | ||||
|                                     options: [ | ||||
|                                         { | ||||
|                                             name: 'Newest First', | ||||
|                                             value: "-createdOn", | ||||
|                                         }, | ||||
|                                         { | ||||
|                                             name: 'Oldest First', | ||||
|                                             value: "createdOn" | ||||
|                                         } | ||||
|                                     ], | ||||
|                                     cssClass: 'l-inline' | ||||
|                                 } | ||||
|                             ] | ||||
|                         } | ||||
|                     ], | ||||
|                     actions: [ | ||||
|                         { | ||||
|                             "key": "notebook-new-entry", | ||||
|                             "implementation": newEntryAction, | ||||
|                             "name": "New Notebook Entry", | ||||
|                             "cssClass": "icon-notebook labeled", | ||||
|                             "description": "Add a new Notebook entry", | ||||
|                             "category": [ | ||||
|                                 "view-control" | ||||
|                             ], | ||||
|                             "depends": [ | ||||
|                             "$compile", | ||||
|                             "$rootScope", | ||||
|                             "dialogService", | ||||
|                             "notificationService", | ||||
|                             "linkService" | ||||
|                             ], | ||||
|                             "priority": "preferred" | ||||
|                         }, | ||||
|                         { | ||||
|                             "key": "annotate-snapshot", | ||||
|                             "implementation": AnnotateSnapshotAction, | ||||
|                             "name": "Annotate Snapshot", | ||||
|                             "cssClass": "icon-pencil labeled", | ||||
|                             "description": "Annotate embed's snapshot", | ||||
|                             "category": "embed", | ||||
|                             "depends": [ | ||||
|                               "dialogService", | ||||
|                               "dndService", | ||||
|                               "$rootScope" | ||||
|                             ] | ||||
|                         } | ||||
|                     ], | ||||
|                     controllers: [ | ||||
|                         { | ||||
|                             "key": "NewEntryController", | ||||
|                             "implementation": NewEntryController, | ||||
|                             "depends": ["$scope", | ||||
|                                          "$rootScope" | ||||
|                                         ] | ||||
|                         }, | ||||
|                         { | ||||
|                             "key": "selectSnapshotController", | ||||
|                             "implementation": SelectSnapshotController, | ||||
|                             "depends": ["$scope", | ||||
|                                          "$rootScope" | ||||
|                                         ] | ||||
|                         } | ||||
|                     ], | ||||
|                     controls: [ | ||||
|                         { | ||||
|                             "key": "snapshot-select", | ||||
|                             "template":  snapSelectTemplate | ||||
|                         }, | ||||
|                         { | ||||
|                             "key": "embed-control", | ||||
|                             "template": embedControlTemplate | ||||
|                         } | ||||
|                     ], | ||||
|                     templates: [ | ||||
|                         { | ||||
|                             "key": "annotate-snapshot", | ||||
|                             "template": annotationTemplate | ||||
|                         } | ||||
|                     ], | ||||
|                     directives: [ | ||||
|                         { | ||||
|                             "key": "mctSnapshot", | ||||
|                             "implementation": MCTSnapshotDirective, | ||||
|                             "depends": [ | ||||
|                                 "$rootScope", | ||||
|                                 "$document", | ||||
|                                 "exportImageService", | ||||
|                                 "dialogService", | ||||
|                                 "notificationService" | ||||
|                             ] | ||||
|                         }, | ||||
|                         { | ||||
|                             "key": "mctEntryDnd", | ||||
|                             "implementation": EntryDndDirective, | ||||
|                             "depends": [ | ||||
|                                 "$rootScope", | ||||
|                                 "$compile", | ||||
|                                 "dndService", | ||||
|                                 "typeService", | ||||
|                                 "notificationService" | ||||
|                             ] | ||||
|                         } | ||||
|                     ], | ||||
|                     representations: [ | ||||
|                         { | ||||
|                             "key": "draggedEntry", | ||||
|                             "template": draggedEntryTemplate | ||||
|                         } | ||||
|                     ] | ||||
|                 } | ||||
|             }); | ||||
|  | ||||
|             openmct.legacyRegistry.enable('notebookV2'); | ||||
|  | ||||
|             openmct.objectViews.addProvider({ | ||||
|                 key: 'notebook-vue', | ||||
|                 name: 'Notebook View', | ||||
|                 cssClass: 'icon-notebook', | ||||
|                 canView: function (domainObject) { | ||||
|                     return domainObject.type === 'notebookV2'; | ||||
|                 }, | ||||
|                 view: function (domainObject) { | ||||
|                     var controller = new NotebookController (openmct, domainObject); | ||||
|  | ||||
|                     return { | ||||
|                         show: controller.show, | ||||
|                         destroy: controller.destroy | ||||
|                     }; | ||||
|                 } | ||||
|             }); | ||||
|         }; | ||||
|  | ||||
|     } | ||||
|  | ||||
|     return NotebookV2Plugin; | ||||
|  }); | ||||
							
								
								
									
										294
									
								
								src/plugins/NotebookV2/res/sass/_notebook-base.scss
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										294
									
								
								src/plugins/NotebookV2/res/sass/_notebook-base.scss
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,294 @@ | ||||
| /***************************************************************************** | ||||
|  * Open MCT, Copyright (c) 2014-2016, 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. | ||||
|  *****************************************************************************/ | ||||
| .w-notebook { | ||||
|     font-size: 0.8rem; | ||||
|     overflow: hidden; | ||||
|     position: absolute; | ||||
|     top: 0px; | ||||
|     right: 0px; | ||||
|     bottom: 0px; | ||||
|     left: 0px; | ||||
|     width: auto; | ||||
|     height: auto; | ||||
| } | ||||
|  | ||||
| .notebook-view-controls.l-flex-row { | ||||
|     > * { | ||||
|         // filter and sort selects | ||||
|         &:not(:first-child) { margin-left: $interiorMargin; } | ||||
|     } | ||||
| } | ||||
|  | ||||
| .l-notebook-drag-area { | ||||
|     padding: 10px; | ||||
|     font-style: italic; | ||||
|     cursor: pointer; | ||||
|     &:before { margin-right: 7px !important; } | ||||
|     .label { | ||||
|         @include ellipsize(); | ||||
|     } | ||||
| } | ||||
|  | ||||
| .frame { | ||||
|    .icon-notebook { | ||||
|         margin-right: 5px; | ||||
|     }  | ||||
| } | ||||
|  | ||||
| .overlay.l-dialog .title{ | ||||
|     white-space: normal; | ||||
| } | ||||
|  | ||||
| .w-notebook-entries { | ||||
|     padding-right: $interiorMarginSm; | ||||
|     position: relative; | ||||
|     overflow-x: hidden; | ||||
|     overflow-y: scroll; | ||||
|     .t-entries-list { | ||||
|     } | ||||
| } | ||||
|  | ||||
| .l-notebook-entry { | ||||
|     $p: $interiorMarginSm; | ||||
|     box-sizing: border-box; | ||||
|     margin-bottom: $p; | ||||
|     padding: $p $interiorMargin; | ||||
|  | ||||
|     .s-notebook-entry-time, | ||||
|     .s-notebook-entry-text, | ||||
|     .notebook-entry-delete { | ||||
|         padding-top: $p; | ||||
|         padding-bottom: $p; | ||||
|     } | ||||
|  | ||||
|     .s-notebook-entry-time { | ||||
|         border: 1px solid transparent; // Needed to maintain vertical alignment with s-notebook-entry-text | ||||
|     } | ||||
|  | ||||
|     .l-notebook-entry-content{ | ||||
|         .s-notebook-entry-text { | ||||
|             // Contenteditable div that holds text | ||||
|             min-height: 24px; // Needed in Firefox when field is blank | ||||
|             white-space: pre-wrap; | ||||
|         } | ||||
|         .entry-embeds{ | ||||
|             flex-wrap: wrap; | ||||
|         } | ||||
|         .snap-thumb { | ||||
|             cursor: pointer; | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| .l-entry-embed { | ||||
|     $m: $interiorMarginSm; | ||||
|     position: relative; | ||||
|     margin: $m $m 0 0; | ||||
|     padding: $interiorMarginSm; | ||||
|  | ||||
|     &.has-snapshot { | ||||
|         &:before { | ||||
|             position: absolute; | ||||
|             text-shadow: rgba(black, 0.7) 0 1px 5px; | ||||
|             z-index: 2; | ||||
|         } | ||||
|     } | ||||
|     .snap-thumb { | ||||
|         $d: 50px; | ||||
|         width: $d; | ||||
|         height: $d; | ||||
|         border-radius: 5px; | ||||
|         overflow: hidden; | ||||
|         img { | ||||
|             height: 100%; | ||||
|             width: 100%; | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     .embed-info { | ||||
|         margin-left: $interiorMargin; | ||||
|         .embed-title { | ||||
|             font-weight: bold; | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| .t-contents, | ||||
| .snap-annotation { | ||||
|     // Todo: don't write this to t-contents, add a l- class | ||||
|     overflow: hidden; | ||||
| } | ||||
|  | ||||
| .notebook-filters { | ||||
|     .select { | ||||
|         margin-left: $interiorMargin; | ||||
|     } | ||||
| } | ||||
|  | ||||
| .s-status-taking-snapshot, | ||||
| .overlay.snapshot { | ||||
|     // Handle overflow-y issues with tables and html2canvas | ||||
|     .l-sticky-headers .l-tabular-body { overflow: auto; } | ||||
| } | ||||
|  | ||||
|  | ||||
| /********************************************* MOBILE */ | ||||
| body.mobile { | ||||
|     // Hide the start entry area, and disable ability to edit or delete an entry in mobile context | ||||
|     .l-notebook-drag-area { | ||||
|         display: none; | ||||
|     } | ||||
|  | ||||
|     .l-notebook-entry { | ||||
|         pointer-events: none; | ||||
|     } | ||||
|  | ||||
|     &.phone.portrait { | ||||
|         .w-notebook-entry-time-and-content { | ||||
|             flex-direction: column !important; | ||||
|         } | ||||
|         .s-notebook-entry-time, | ||||
|         .notebook-entry-delete { | ||||
|             padding-top: 0; | ||||
|             padding-bottom: 0; | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| body.phone.portrait { | ||||
|     .l-notebook-head.l-flex-row { | ||||
|         flex-direction: column !important; | ||||
|         > * { | ||||
|             &:not(:first-child) { margin-top: $interiorMargin; } | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| /********************************************* PAINTERRO OVERRIDES */ | ||||
| .annotation-dialog .abs.editor { | ||||
|     border-radius: 0; | ||||
| } | ||||
|  | ||||
| #snap-annotation { | ||||
|     display: flex; | ||||
|     flex-direction: column; | ||||
|     position: absolute; | ||||
|     top: 0; right: 0; bottom: 0; left: 0; | ||||
| } | ||||
|  | ||||
| #snap-annotation-wrapper, | ||||
| #snap-annotation-bar { | ||||
|     position: relative; | ||||
|     top: auto; right: auto; bottom: auto; left: auto; | ||||
| } | ||||
|  | ||||
| #snap-annotation-wrapper { | ||||
|     order: 2; | ||||
|     flex: 10 0 auto; | ||||
| } | ||||
|  | ||||
| #snap-annotation-bar { | ||||
|     order: 1; | ||||
|     flex: 0 0 auto; | ||||
|     height: auto; | ||||
|     background-color: transparent !important; | ||||
|     margin-bottom: $interiorMargin; | ||||
|  | ||||
|     > div, | ||||
|     > div > span, | ||||
|     .ptro-icon-btn, | ||||
|     .ptro-named-btn, | ||||
|     .ptro-color-btn, | ||||
|     .ptro-bordered-btn, | ||||
|     .ptro-tool-ctl-name, | ||||
|     .ptro-color-btn, | ||||
|     .tool-controls, | ||||
|     .ptro-input { | ||||
|         // Lot of resets for crappy CSS in Painterro | ||||
|         &:first-child { | ||||
|             margin-left: 0 !important; | ||||
|         } | ||||
|         $h: $btnToolbarH; | ||||
|         display: inline-block; | ||||
|         font-family: inherit; | ||||
|         font-size: auto; | ||||
|         height: $h !important; | ||||
|         margin: 0 0 0 5px; | ||||
|         position: relative; | ||||
|         width: auto !important; | ||||
|         line-height: $h !important; | ||||
|         top: auto; | ||||
|         right: auto; | ||||
|         bottom: auto; | ||||
|         left: auto; | ||||
|         vertical-align: top; | ||||
|     } | ||||
|  | ||||
|     .ptro-tool-ctl-name { | ||||
|         border-radius: 0; | ||||
|         background: none; | ||||
|         top: auto; | ||||
|         font-family: inherit; | ||||
|         padding: 0; | ||||
|     } | ||||
|  | ||||
|     .ptro-color-btn { | ||||
|         width: $btnToolbarH !important; | ||||
|     } | ||||
|  | ||||
|     .ptro-icon-btn, | ||||
|     .ptro-named-btn { | ||||
|         // .s-button class is added via JS in AnnotateSnapshot.js | ||||
|         // TODO: redo this so that we don't need to use Zepto and JS | ||||
|         i { | ||||
|             font-size: 1.25em !important; | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     .tool-controls { | ||||
|         font-size: 0.8rem !important; | ||||
|     } | ||||
|  | ||||
|     .ptro-info, | ||||
|     .ptro-btn-color-checkers-bar, | ||||
|     *[title="Font name"], | ||||
|     *[title="Stroke color"], | ||||
|     *[title="Stroke width"], | ||||
|     *[data-id="fontName"], | ||||
|     *[data-id="fontStrokeSize"], | ||||
|     *[data-id="stroke"] { | ||||
|         display: none; | ||||
|     } | ||||
| } | ||||
|  | ||||
| /********************************************* NO IDEA WHAT THERE ARE APPLYING TO */ | ||||
| .context-available { | ||||
|     outline: none; | ||||
| } | ||||
|  | ||||
| .menu-element.menu-view{ | ||||
|     z-index: 999; | ||||
| } | ||||
|  | ||||
| .overlay.l-dialog .abs.editor { | ||||
|     padding-right: 0; | ||||
| } | ||||
							
								
								
									
										94
									
								
								src/plugins/NotebookV2/res/sass/_notebook-thematic.scss
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										94
									
								
								src/plugins/NotebookV2/res/sass/_notebook-thematic.scss
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,94 @@ | ||||
| /***************************************************************************** | ||||
|  * 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. | ||||
|  *****************************************************************************/ | ||||
|  | ||||
| .l-notebook-drag-area { | ||||
|     border: 1px dashed rgba($colorKey, 0.7); | ||||
|     border-radius: $controlCr; | ||||
|     color: rgba($colorBodyFg, 0.7); | ||||
|     &:hover { | ||||
|         background: rgba($colorKey, 0.2); | ||||
|         color: $colorBodyFg; | ||||
|     } | ||||
|     &.drag-active{ | ||||
|         border-color: $colorKey; | ||||
|     } | ||||
| } | ||||
|  | ||||
| .s-notebook-entry { | ||||
|     transition: background-color 500ms ease-out; | ||||
|     background-color: rgba($colorBodyFg, 0.1); | ||||
|     border-radius: $basicCr; | ||||
|  | ||||
|     &:hover { | ||||
|         transition: background-color 50ms ease-in; | ||||
|         background-color: rgba($colorBodyFg, 0.2); | ||||
|     } | ||||
|  | ||||
|     .s-notebook-entry-time { | ||||
|         color: rgba($colorBodyFg, 0.5); | ||||
|     } | ||||
| } | ||||
|  | ||||
| .l-entry-embed { | ||||
|     border-radius: $controlCr; | ||||
|     background-color: rgba($colorBodyFg, 0.1); | ||||
|     &.has-snapshot { | ||||
|         &:before { | ||||
|             color: $colorBodyFg; | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| .s-snapshot-datetime { | ||||
|     color: rgba($colorBodyFg, 0.4); | ||||
|     font-size: 0.8em; | ||||
| } | ||||
|  | ||||
| .snap-thumb { | ||||
|     border: 1px solid $colorInteriorBorder; | ||||
| } | ||||
|  | ||||
| .s-status-taking-snapshot, | ||||
| .overlay.snapshot { | ||||
|     // Applied to an object view when it's in the process of being snapshotted | ||||
|     background: $colorBodyBg; | ||||
| } | ||||
|  | ||||
| /********************************************* PAINTERRO OVERRIDES */ | ||||
| .ptro-wrapper { | ||||
|     background: rgba($colorBodyBg, 0.3) !important; | ||||
| } | ||||
|  | ||||
| #snap-annotation-bar { | ||||
|     .tool-controls { | ||||
|         color: $colorBodyFg !important; | ||||
|     } | ||||
| } | ||||
|  | ||||
| .s-button.ptro-color-active-control { | ||||
|     background: $colorBtnMajorBg  !important; | ||||
|     color: $colorBtnMajorFg !important; | ||||
|     &:hover { | ||||
|         background: $colorBtnMajorBgHov !important; | ||||
|         color: $colorBtnMajorFgHov !important; | ||||
|     } | ||||
| } | ||||
							
								
								
									
										30
									
								
								src/plugins/NotebookV2/res/sass/notebook-espresso.scss
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								src/plugins/NotebookV2/res/sass/notebook-espresso.scss
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,30 @@ | ||||
| /***************************************************************************** | ||||
|  * 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. | ||||
|  *****************************************************************************/ | ||||
| $output-bourbon-deprecation-warnings: false; | ||||
| @import "bourbon"; | ||||
|  | ||||
| @import "../../../../commonUI/general/res/sass/constants"; | ||||
| @import "../../../../commonUI/general/res/sass/mixins"; | ||||
| @import "../../../../commonUI/general/res/sass/glyphs"; | ||||
| @import "../../../../commonUI/themes/espresso/res/sass/constants"; | ||||
| @import "../../../../commonUI/themes/espresso/res/sass/mixins"; | ||||
| @import "notebook-thematic"; | ||||
							
								
								
									
										30
									
								
								src/plugins/NotebookV2/res/sass/notebook-snow.scss
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								src/plugins/NotebookV2/res/sass/notebook-snow.scss
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,30 @@ | ||||
| /***************************************************************************** | ||||
|  * 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. | ||||
|  *****************************************************************************/ | ||||
| $output-bourbon-deprecation-warnings: false; | ||||
| @import "bourbon"; | ||||
|  | ||||
| @import "../../../../commonUI/general/res/sass/constants"; | ||||
| @import "../../../../commonUI/general/res/sass/mixins"; | ||||
| @import "../../../../commonUI/general/res/sass/glyphs"; | ||||
| @import "../../../../commonUI/themes/snow/res/sass/constants"; | ||||
| @import "../../../../commonUI/themes/snow/res/sass/mixins"; | ||||
| @import "notebook-thematic"; | ||||
							
								
								
									
										28
									
								
								src/plugins/NotebookV2/res/sass/notebook.scss
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								src/plugins/NotebookV2/res/sass/notebook.scss
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,28 @@ | ||||
| /***************************************************************************** | ||||
|  * Open MCT, Copyright (c) 2014-2015, 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. | ||||
|  *****************************************************************************/ | ||||
| $output-bourbon-deprecation-warnings: false; | ||||
| @import "bourbon"; | ||||
| @import "../../../../commonUI/general/res/sass/constants"; | ||||
| @import "../../../../commonUI/general/res/sass/mixins"; | ||||
| @import "../../../../commonUI/general/res/sass/mobile/constants"; | ||||
| @import "../../../../commonUI/general/res/sass/mobile/mixins"; | ||||
| @import "notebook-base"; | ||||
							
								
								
									
										2
									
								
								src/plugins/NotebookV2/res/templates/annotation.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								src/plugins/NotebookV2/res/templates/annotation.html
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,2 @@ | ||||
| <div class="snap-annotation" id="snap-annotation" ng-controller="ngModel.controller"> | ||||
| </div> | ||||
| @@ -0,0 +1,51 @@ | ||||
| <!-- | ||||
|  Open MCT, Copyright (c) 2009-2016, 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. | ||||
| --> | ||||
| <!-- | ||||
| This element appears in the overlay dialog when initiating a new Notebook Entry from a view's Notebook button --> | ||||
| <div class='form-control'> | ||||
|     <ng-form name="mctControl"> | ||||
|         <div class='fields' ng-controller="NewEntryController"> | ||||
|             <div class="l-flex-row new-notebook-entry-embed l-entry-embed {{cssClass}}" | ||||
|                  ng-class="{ 'has-snapshot' : snapToggle }"> | ||||
|                 <div class="holder flex-elem snap-thumb" | ||||
|                     ng-if="snapToggle"> | ||||
|                     <img ng-src="{{snapshot.src}}" alt="{{snapshot.modified}}"> | ||||
|                 </div> | ||||
|  | ||||
|                 <div class="holder flex-elem embed-info"> | ||||
|                     <div class="embed-title">{{objectName}}</div> | ||||
|                     <div class="embed-date" | ||||
|                          ng-if="snapToggle">{{snapshot.modified| date:'yyyy-MM-dd HH:mm:ss'}}</div> | ||||
|                 </div> | ||||
|  | ||||
|                 <div class="holder flex-elem annotate-new" | ||||
|                      ng-if="snapToggle"> | ||||
|                     <a class="s-button flex-elem icon-pencil " | ||||
|                        title="Annotate this snapshot" | ||||
|                        ng-click="annotateSnapshot()"> | ||||
|                         <span class="title-label">Annotate</span> | ||||
|                     </a> | ||||
|                 </div> | ||||
|             </div> | ||||
|         </div> | ||||
|     </ng-form> | ||||
| </div> | ||||
| @@ -0,0 +1,29 @@ | ||||
| <!-- | ||||
|  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. | ||||
| --> | ||||
| <div class='form-control select' ng-controller="selectSnapshotController"> | ||||
|     <select | ||||
|             ng-model="selectModel" | ||||
|             ng-options="opt.value as opt.name for opt in options" | ||||
|             ng-required="ngRequired" | ||||
|             name="mctControl"> | ||||
|     </select> | ||||
| </div> | ||||
							
								
								
									
										38
									
								
								src/plugins/NotebookV2/res/templates/draggedEntry.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								src/plugins/NotebookV2/res/templates/draggedEntry.html
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,38 @@ | ||||
| <!-- | ||||
|  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. | ||||
| --> | ||||
| <div class="frame snap-frame frame-template t-frame-inner abs t-object-type-{{ representation.selected.key }}"> | ||||
|     <div class="abs object-browse-bar l-flex-row"> | ||||
|         <div class="btn-bar right l-flex-row flex-elem flex-justify-end flex-fixed"> | ||||
|             <mct-representation | ||||
|                     key="'switcher'" | ||||
|                     ng-model="representation" | ||||
|                     mct-object="domainObject"> | ||||
|             </mct-representation> | ||||
|         </div> | ||||
|     </div> | ||||
|     <div class="abs object-holder" data-entry = "{{parameters.entry}}" data-embed = "{{parameters.embed}}" mct-snapshot ng-if="representation.selected.key"> | ||||
|         <mct-representation | ||||
|                 key="representation.selected.key" | ||||
|                 mct-object="representation.selected.key && domainObject"> | ||||
|         </mct-representation> | ||||
|     </div> | ||||
| </div> | ||||
							
								
								
									
										36
									
								
								src/plugins/NotebookV2/res/templates/embed.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								src/plugins/NotebookV2/res/templates/embed.html
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,36 @@ | ||||
| <div | ||||
|     class="l-flex-row l-entry-embed" | ||||
|     v-bind:class="[embed.cssClass]"> | ||||
|  | ||||
|     <div | ||||
|         class="snap-thumb" | ||||
|         v-if="embed.snapshot" | ||||
|         v-on:click="openSnapshot"> | ||||
|         <img v-bind:src="embed.snapshot.src"> | ||||
|     </div> | ||||
|  | ||||
|     <div class="embed-info l-flex-col"> | ||||
|         <div class="embed-title object-header"> | ||||
|             <a v-on:click="navigate(embed.type)">{{embed.name}}</a> | ||||
|             <a class='context-available' v-on:click="toggleActionMenu"></a> | ||||
|         </div> | ||||
|  | ||||
|         <div class="hide-menu hidden"> | ||||
|             <div class="menu-element context-menu-wrapper mobile-disable-select"> | ||||
|                 <div class="menu context-menu"> | ||||
|                     <ul> | ||||
|                         <li v-for="(action) in actions"  | ||||
|                             v-bind:class="[action.cssClass]" | ||||
|                             v-on:click="action.perform(embed, entry)"> | ||||
|                             {{ action.name }} | ||||
|                         </li>  | ||||
|                     </ul> | ||||
|                 </div> | ||||
|             </div> | ||||
|         </div> | ||||
|  | ||||
|         <div class="embed-date" v-if="embed.snapshot"> | ||||
|                 {{formatTime(embed.createdOn, 'YYYY-MM-DD HH:mm:ss')}} | ||||
|         </div> | ||||
|     </div> | ||||
| </div> | ||||
							
								
								
									
										35
									
								
								src/plugins/NotebookV2/res/templates/entry.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								src/plugins/NotebookV2/res/templates/entry.html
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,35 @@ | ||||
| <li class="l-flex-row has-local-controls l-notebook-entry s-notebook-entry" | ||||
|     v-on:drop="dropOnEntry(entry.id)" | ||||
|     v-on:dragover="dragoverOnEntry" | ||||
|     > | ||||
|  | ||||
|     <div class="holder flex-elem l-flex-row grows w-notebook-entry-time-and-content"> | ||||
|         <div class="holder flex-elem s-notebook-entry-time"> | ||||
|             <span>{{formatTime(entry.createdOn, 'YYYY-MM-DD')}}</span> | ||||
|             <span>{{formatTime(entry.createdOn, 'HH:mm:ss')}}</span> | ||||
|         </div> | ||||
|  | ||||
|         <div class="holder flex-elem l-flex-col grows l-notebook-entry-content"> | ||||
|             <div class="flex-elem s-input-inline t-notebook-entry-input s-notebook-entry-text" | ||||
|                  contenteditable="true" | ||||
|                  ref="contenteditable" | ||||
|                  v-on:blur="textBlur($event, entry.id)" | ||||
|                  v-on:focus="textFocus($event, entry.id)" | ||||
|                  v-bind:key="entry.id" | ||||
|                  v-html="entry.text"> | ||||
|             </div> | ||||
|  | ||||
|             <div class="flex-elem entry-embeds l-flex-row"> | ||||
|                 <notebook-embed | ||||
|                     v-for="(embed, index) in entry.embeds" | ||||
|                     v-bind:embed="embed" | ||||
|                     v-bind:entry="entry" | ||||
|                 ></notebook-embed> | ||||
|             </div> | ||||
|         </div> | ||||
|  | ||||
|         <div class="holder flex-elem local-control local-controls-hidden notebook-entry-delete"> | ||||
|                 <a class="s-icon-button icon-trash" title="Delete Entry" v-on:click="deleteEntry"></a> | ||||
|         </div> | ||||
|     </div> | ||||
| </li> | ||||
							
								
								
									
										46
									
								
								src/plugins/NotebookV2/res/templates/notebook.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										46
									
								
								src/plugins/NotebookV2/res/templates/notebook.html
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,46 @@ | ||||
| <div class="mct-notebook w-notebook l-flex-col"> | ||||
|     <div class="l-notebook-head holder l-flex-row flex-elem"> | ||||
|         <div class="c-search flex-elem holder grows"> | ||||
|             <input class="c-search__search-input" | ||||
|                     type="text" tabindex="10000" | ||||
|                     v-model="entrySearch" | ||||
|                     v-on:keyup="search($event)"/> | ||||
|             <a class="c-search__clear-input clear-icon icon-x-in-circle" | ||||
|                 v-bind:class="[entrySearch ? 'show': '']" | ||||
|                 v-on:click="entrySearch = ''; search($event)"></a> | ||||
|         </div> | ||||
|  | ||||
|         <div class="notebook-view-controls l-flex-row flex-elem holder"> | ||||
|             <div class="select notebook-view-controls__filter-time"> | ||||
|                 <select v-model="showTime"> | ||||
|                     <option value="0" selected="selected">Show all</option> | ||||
|                     <option value="1">Last hour</option> | ||||
|                     <option value="8">Last 8 hours</option> | ||||
|                     <option value="24">Last 24 hours</option> | ||||
|                 </select> | ||||
|             </div> | ||||
|             <div class="select notebook-view-controls__sort"> | ||||
|                 <select v-model="sortEntries"> | ||||
|                     <option value="-createdOn" selected="selected">Newest first</option> | ||||
|                     <option value="createdOn">Oldest first</option> | ||||
|                 </select> | ||||
|             </div> | ||||
|         </div> | ||||
|     </div> | ||||
|  | ||||
|     <!--  drag area --> | ||||
|     <div class="holder flex-elem l-flex-row icon-plus labeled l-notebook-drag-area" v-on:click="newEntry($event)" | ||||
|     id="newEntry" mct-entry-dnd> | ||||
|     <span class="label">To start a new entry, click here or drag and drop any object</span> | ||||
|     </div> | ||||
|  | ||||
|     <!-- entries --> | ||||
|     <div class="holder flex-elem grows w-notebook-entries t-entries-list" ng-mouseover="handleActive()"> | ||||
|         <ul> | ||||
|            <notebook-entry | ||||
|                 v-for="entry in filterBySearch(entries, entrySearch)" | ||||
|                 v-bind:entry="entry" | ||||
|            ></notebook-entry> | ||||
|         </ul> | ||||
|     </div> | ||||
| </div> | ||||
							
								
								
									
										50
									
								
								src/plugins/NotebookV2/res/templates/viewSnapshot.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										50
									
								
								src/plugins/NotebookV2/res/templates/viewSnapshot.html
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,50 @@ | ||||
| <div class="abs overlay l-large-view"> | ||||
|     <div class="abs blocker" v-on:click="close"></div>  | ||||
|  | ||||
|     <div class="abs outer-holder"> | ||||
|  | ||||
|         <a  | ||||
|             class="close icon-x-in-circle" | ||||
|             v-on:click="close"> | ||||
|         </a> | ||||
|  | ||||
|         <div class="abs inner-holder l-flex-col">  | ||||
|             <div class="t-contents flex-elem holder grows"> | ||||
|  | ||||
|                 <div class="t-snapshot abs l-view-header"> | ||||
|                     <div class="abs object-browse-bar l-flex-row"> | ||||
|                         <div class="left flex-elem l-flex-row grows"> | ||||
|                             <div class="object-header flex-elem l-flex-row grows"> | ||||
|                                 <div class="type-icon flex-elem embed-icon holder" v-bind:class="embed.cssClass"></div> | ||||
|                                 <div class="title-label flex-elem holder flex-can-shrink">{{embed.name}}</div> | ||||
|                             </div> | ||||
|                         </div> | ||||
|                     </div> | ||||
|                 </div> | ||||
|  | ||||
|                 <div class="btn-bar right l-flex-row flex-elem flex-justify-end flex-fixed"> | ||||
|                     <div class="flex-elem holder flex-can-shrink s-snapshot-datetime"> | ||||
|                         SNAPSHOT {{formatTime(embed.createdOn, 'YYYY-MM-DD HH:mm:ss')}} | ||||
|                     </div> | ||||
|                     <a class="s-button icon-pencil" title="Annotate"> | ||||
|                         <span class="title-label">Annotate</span> | ||||
|                     </a> | ||||
|                 </div> | ||||
|  | ||||
|                 <div class="abs object-holder t-image-holder s-image-holder"> | ||||
|                     <div  | ||||
|                         class="image-main s-image-main" | ||||
|                         v-bind:style="{ backgroundImage: 'url(' + embed.snapshot.src + ')' }"> | ||||
|                     </div> | ||||
|                 </div> | ||||
|             </div> | ||||
|  | ||||
|             <div  | ||||
|                 class="bottom-bar flex-elem holder" | ||||
|                 v-on:click="close"> | ||||
|   | ||||
|                 <a class="t-done s-button major">Done</a>  | ||||
|             </div>  | ||||
|         </div>  | ||||
|     </div> | ||||
| </div> | ||||
							
								
								
									
										165
									
								
								src/plugins/NotebookV2/src/actions/AnnotateSnapshot.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										165
									
								
								src/plugins/NotebookV2/src/actions/AnnotateSnapshot.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,165 @@ | ||||
| /***************************************************************************** | ||||
|  * 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. | ||||
|  *****************************************************************************/ | ||||
|  | ||||
| /** | ||||
|  * Module defining viewSnapshot (Originally NewWindowAction). Created by vwoeltje on 11/18/14. | ||||
|  */ | ||||
| define( | ||||
|     ["painterro", "zepto"], | ||||
|     function (Painterro, $) { | ||||
|  | ||||
|         var annotationStruct = { | ||||
|             title: "Annotate Snapshot", | ||||
|             template: "annotate-snapshot", | ||||
|             options: [{ | ||||
|                 name: "OK", | ||||
|                 key: "ok", | ||||
|                 description: "save annotation" | ||||
|             }, | ||||
|             { | ||||
|                 name: "Cancel", | ||||
|                 key: "cancel", | ||||
|                 description: "cancel editing" | ||||
|             }] | ||||
|         }; | ||||
|  | ||||
|         function AnnotateSnapshot(dialogService, dndService, $rootScope, context) { | ||||
|             context = context || {}; | ||||
|  | ||||
|             // Choose the object to be opened into a new tab | ||||
|             this.domainObject = context.selectedObject || context.domainObject; | ||||
|             this.dialogService = dialogService; | ||||
|             this.dndService = dndService; | ||||
|             this.$rootScope = $rootScope; | ||||
|         } | ||||
|  | ||||
|         AnnotateSnapshot.prototype.perform = function ($event, snapshot, embedId, entryId) { | ||||
|  | ||||
|             var DOMAIN_OBJECT = this.domainObject; | ||||
|             var ROOTSCOPE = this.$rootScope; | ||||
|             var painterro; | ||||
|             var save = false; | ||||
|  | ||||
|             var controller = ['$scope', '$timeout', function PainterroController($scope, $timeout) { | ||||
|                 $(document.body).find('.l-dialog .outer-holder').addClass('annotation-dialog'); | ||||
|  | ||||
|                 // Timeout is necessary because Painterro uses document.getElementById, and mct-include | ||||
|                 // hasn't added the dialog to the DOM yet. | ||||
|                 $timeout(function () { | ||||
|                     painterro = Painterro({ | ||||
|                         id: 'snap-annotation', | ||||
|                         activeColor: '#ff0000', | ||||
|                         activeColorAlpha: 1.0, | ||||
|                         activeFillColor: '#fff', | ||||
|                         activeFillColorAlpha: 0.0, | ||||
|                         backgroundFillColor: '#000', | ||||
|                         backgroundFillColorAlpha: 0.0, | ||||
|                         defaultFontSize: 16, | ||||
|                         defaultLineWidth: 2, | ||||
|                         defaultTool: 'ellipse', | ||||
|                         hiddenTools: ['save', 'open', 'close', 'eraser', 'pixelize', 'rotate', 'settings', 'resize'], | ||||
|                         translation: { | ||||
|                             name: 'en', | ||||
|                             strings: { | ||||
|                                 lineColor: 'Line', | ||||
|                                 fillColor: 'Fill', | ||||
|                                 lineWidth: 'Size', | ||||
|                                 textColor: 'Color', | ||||
|                                 fontSize: 'Size', | ||||
|                                 fontStyle: 'Style' | ||||
|                             } | ||||
|                         }, | ||||
|                         saveHandler: function (image, done) { | ||||
|                             if (save) { | ||||
|                                 if (entryId && embedId) { | ||||
|                                     var elementPos = DOMAIN_OBJECT.model.entries.map(function (x) { | ||||
|                                         return x.createdOn; | ||||
|                                     }).indexOf(entryId); | ||||
|                                     var entryEmbeds = DOMAIN_OBJECT.model.entries[elementPos].embeds; | ||||
|                                     var embedPos = entryEmbeds.map(function (x) { | ||||
|                                         return x.id; | ||||
|                                     }).indexOf(embedId); | ||||
|  | ||||
|                                     saveSnap(image.asBlob(), embedPos, elementPos, DOMAIN_OBJECT); | ||||
|                                 }else { | ||||
|                                     ROOTSCOPE.snapshot = {'src': image.asDataURL('image/png'), | ||||
|                                                         'modified': Date.now()}; | ||||
|                                 } | ||||
|                             } | ||||
|                             done(true); | ||||
|                         } | ||||
|                     }).show(snapshot); | ||||
|  | ||||
|                     $(document.body).find('.ptro-icon-btn').addClass('s-button'); | ||||
|                     $(document.body).find('.ptro-input').addClass('s-button'); | ||||
|                 }); | ||||
|             }]; | ||||
|  | ||||
|             annotationStruct.model = {'controller': controller}; | ||||
|  | ||||
|             function saveNotes(param) { | ||||
|                 if (param === 'ok') { | ||||
|                     save = true; | ||||
|                 }else { | ||||
|                     save = false; | ||||
|                     ROOTSCOPE.snapshot = "annotationCancelled"; | ||||
|                 } | ||||
|                 painterro.save(); | ||||
|             } | ||||
|  | ||||
|             function rejectNotes() { | ||||
|                 save = false; | ||||
|                 ROOTSCOPE.snapshot = "annotationCancelled"; | ||||
|                 painterro.save(); | ||||
|             } | ||||
|  | ||||
|             function saveSnap(url, embedPos, entryPos, domainObject) { | ||||
|                 var snap = false; | ||||
|  | ||||
|                 if (embedPos !== -1 && entryPos !== -1) { | ||||
|                     var reader = new window.FileReader(); | ||||
|                     reader.readAsDataURL(url); | ||||
|                     reader.onloadend = function () { | ||||
|                         snap = reader.result; | ||||
|                         domainObject.useCapability('mutation', function (model) { | ||||
|                             if (model.entries[entryPos]) { | ||||
|                                 model.entries[entryPos].embeds[embedPos].snapshot = { | ||||
|                                     'src': snap, | ||||
|                                     'type': url.type, | ||||
|                                     'size': url.size, | ||||
|                                     'modified': Date.now() | ||||
|                                 }; | ||||
|                                 model.entries[entryPos].embeds[embedPos].id = Date.now(); | ||||
|                             } | ||||
|                         }); | ||||
|                     }; | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|             this.dialogService.getUserChoice(annotationStruct) | ||||
|             .then(saveNotes, rejectNotes); | ||||
|  | ||||
|         }; | ||||
|  | ||||
|         return AnnotateSnapshot; | ||||
|     } | ||||
| ); | ||||
							
								
								
									
										204
									
								
								src/plugins/NotebookV2/src/actions/NewEntryContextual.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										204
									
								
								src/plugins/NotebookV2/src/actions/NewEntryContextual.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,204 @@ | ||||
| /***************************************************************************** | ||||
|  * 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 () { | ||||
|  | ||||
|         var SNAPSHOT_TEMPLATE = '<mct-representation key="\'draggedEntry\'"' + | ||||
|                                     'class="t-rep-frame holder"' + | ||||
|                                     'mct-object="selObj">' + | ||||
|                                 '</mct-representation>'; | ||||
|  | ||||
|         var NEW_TASK_FORM = { | ||||
|             name: "Create a Notebook Entry", | ||||
|             hint: "Please select one Notebook", | ||||
|             sections: [{ | ||||
|                 rows: [{ | ||||
|                     name: 'Entry', | ||||
|                     key: 'entry', | ||||
|                     control: 'textarea', | ||||
|                     required: false, | ||||
|                     "cssClass": "l-textarea-sm" | ||||
|                 }, | ||||
|                 { | ||||
|                     name: 'Embed Type', | ||||
|                     key: 'withSnapshot', | ||||
|                     control: 'snapshot-select', | ||||
|                     "options": [ | ||||
|                         { | ||||
|                             "name": "Link and Snapshot", | ||||
|                             "value": true | ||||
|                         }, | ||||
|                         { | ||||
|                             "name": "Link only", | ||||
|                             "value": false | ||||
|                         } | ||||
|                     ] | ||||
|                 }, | ||||
|                 { | ||||
|                     name: 'Embed', | ||||
|                     key: 'embedObject', | ||||
|                     control: 'embed-control' | ||||
|                 }, | ||||
|                 { | ||||
|                     name: 'Save in Notebook', | ||||
|                     key: 'saveNotebook', | ||||
|                     control: 'locator', | ||||
|                     validate: validateLocation | ||||
|                 }] | ||||
|             }] | ||||
|         }; | ||||
|  | ||||
|         function NewEntryContextual($compile, $rootScope, dialogService, notificationService, linkService, context) { | ||||
|             context = context || {}; | ||||
|             this.domainObject = context.selectedObject || context.domainObject; | ||||
|             this.dialogService = dialogService; | ||||
|             this.notificationService = notificationService; | ||||
|             this.linkService = linkService; | ||||
|             this.$rootScope = $rootScope; | ||||
|             this.$compile = $compile; | ||||
|         } | ||||
|  | ||||
|         function validateLocation(newParentObj) { | ||||
|             return newParentObj.model.type === 'notebookV2'; | ||||
|         } | ||||
|  | ||||
|  | ||||
|         NewEntryContextual.prototype.perform = function () { | ||||
|             var self = this; | ||||
|             var domainObj = this.domainObject; | ||||
|             var notification = this.notificationService; | ||||
|             var dialogService = this.dialogService; | ||||
|             var rootScope = this.$rootScope; | ||||
|             rootScope.newEntryText = ''; | ||||
|             // // Create the overlay element and add it to the document's body | ||||
|             this.$rootScope.selObj = domainObj; | ||||
|             this.$rootScope.selValue = ""; | ||||
|             var newScope = rootScope.$new(); | ||||
|             newScope.selObj = domainObj; | ||||
|             newScope.selValue = ""; | ||||
|             this.$compile(SNAPSHOT_TEMPLATE)(newScope); | ||||
|  | ||||
|             this.$rootScope.$watch("snapshot", setSnapshot); | ||||
|  | ||||
|             function setSnapshot(value) { | ||||
|                 if (value === "annotationCancelled") { | ||||
|                     rootScope.snapshot = rootScope.lastValue; | ||||
|                     rootScope.lastValue = ''; | ||||
|  | ||||
|                 } else if (value && value !== rootScope.lastValue) { | ||||
|                     var overlayModel = { | ||||
|                         title: NEW_TASK_FORM.name, | ||||
|                         message: NEW_TASK_FORM.message, | ||||
|                         structure: NEW_TASK_FORM, | ||||
|                         value: {'entry': rootScope.newEntryText || ""} | ||||
|                     }; | ||||
|  | ||||
|                     rootScope.currentDialog = overlayModel; | ||||
|  | ||||
|                     dialogService.getDialogResponse( | ||||
|                         "overlay-dialog", | ||||
|                         overlayModel, | ||||
|                         function () { | ||||
|                             return overlayModel.value; | ||||
|                         } | ||||
|                     ).then(addNewEntry); | ||||
|  | ||||
|                     rootScope.lastValue = value; | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|             function addNewEntry(options) { | ||||
|                 options.selectedModel = options.embedObject.getModel(); | ||||
|                 options.cssClass = options.embedObject.getCapability('type').typeDef.cssClass; | ||||
|                 if (self.$rootScope.snapshot) { | ||||
|                     options.snapshot = self.$rootScope.snapshot; | ||||
|                     self.$rootScope.snapshot = undefined; | ||||
|                 }else { | ||||
|                     options.snapshot = undefined; | ||||
|                 } | ||||
|  | ||||
|                 if (!options.withSnapshot) { | ||||
|                     options.snapshot = ''; | ||||
|                 } | ||||
|  | ||||
|                 createSnap(options); | ||||
|             } | ||||
|  | ||||
|             function createSnap(options) { | ||||
|                 options.saveNotebook.useCapability('mutation', function (model) { | ||||
|                     var entries = model.entries; | ||||
|                     var lastEntry = entries[entries.length - 1]; | ||||
|                     var date = Date.now(); | ||||
|  | ||||
|                     if (lastEntry === undefined || lastEntry.text || lastEntry.embeds) { | ||||
|                         model.entries.push({ | ||||
|                             'id': date, | ||||
|                             'createdOn': date, | ||||
|                             'text': options.entry, | ||||
|                             'embeds': [{'type': options.embedObject.getId(), | ||||
|                                        'id': '' + date, | ||||
|                                        'cssClass': options.cssClass, | ||||
|                                        'name': options.selectedModel.name, | ||||
|                                        'snapshot': options.snapshot | ||||
|                                      }] | ||||
|                         }); | ||||
|                     }else { | ||||
|                         model.entries[entries.length - 1] = { | ||||
|                             'id': date, | ||||
|                             'createdOn': date, | ||||
|                             'text': options.entry, | ||||
|                             'embeds': [{'type': options.embedObject.getId(), | ||||
|                                        'id': '' + date, | ||||
|                                        'cssClass': options.cssClass, | ||||
|                                        'name': options.selectedModel.name, | ||||
|                                        'snapshot': options.snapshot | ||||
|                                      }] | ||||
|                         }; | ||||
|                     } | ||||
|                 }); | ||||
|  | ||||
|                 notification.info({ | ||||
|                     title: "Notebook Entry created" | ||||
|                 }); | ||||
|             } | ||||
|         }; | ||||
|  | ||||
|         NewEntryContextual.appliesTo = function (context) { | ||||
|             var domainObject = context.domainObject; | ||||
|  | ||||
|             if (domainObject) { | ||||
|                 if (domainObject.getModel().type === 'notebookV2') { | ||||
|                     // do not allow in context of a notebook | ||||
|                     return false; | ||||
|                 } else if (domainObject.getModel().type.includes('imagery')) { | ||||
|                     // do not allow in the context of an object with imagery | ||||
|                     // (because of cross domain issue with snapshot) | ||||
|                     return false; | ||||
|                 } | ||||
|             } | ||||
|             return true; | ||||
|         }; | ||||
|  | ||||
|         return NewEntryContextual; | ||||
|     } | ||||
| ); | ||||
							
								
								
									
										130
									
								
								src/plugins/NotebookV2/src/actions/snapshotAction.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										130
									
								
								src/plugins/NotebookV2/src/actions/snapshotAction.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,130 @@ | ||||
| /***************************************************************************** | ||||
|  * 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( | ||||
|     ['zepto'], | ||||
|     function ($) { | ||||
|  | ||||
|         function SnapshotAction (exportImageService, dialogService, context) { | ||||
|             this.exportImageService = exportImageService; | ||||
|             this.dialogService = dialogService; | ||||
|             this.domainObject = context.domainObject; | ||||
|         } | ||||
|  | ||||
|         SnapshotAction.prototype.perform = function () { | ||||
|             var elementToSnapshot =   | ||||
|                 $(document.body).find(".overlay .object-holder")[0] ||  | ||||
|                 $(document.body).find("[key='representation.selected.key']")[0]; | ||||
|  | ||||
|             $(elementToSnapshot).addClass("s-status-taking-snapshot"); | ||||
|  | ||||
|             this.exportImageService.exportPNGtoSRC(elementToSnapshot).then(function (blob) { | ||||
|                 $(elementToSnapshot).removeClass("s-status-taking-snapshot"); | ||||
|  | ||||
|                 if (blob) { | ||||
|                     var reader = new window.FileReader(); | ||||
|                     reader.readAsDataURL(blob); | ||||
|                     reader.onloadend = function () { | ||||
|                       this.saveSnapshot(reader.result, blob.type, blob.size);   | ||||
|                     }.bind(this);     | ||||
|                 } | ||||
|  | ||||
|             }.bind(this)); | ||||
|         }; | ||||
|  | ||||
|         SnapshotAction.prototype.saveSnapshot = function (imageURL, imageType, imageSize) { | ||||
|             var taskForm = this.generateTaskForm(), | ||||
|                 domainObject = this.domainObject, | ||||
|                 domainObjectId = domainObject.getId(), | ||||
|                 cssClass = domainObject.getCapability('type').typeDef.cssClass, | ||||
|                 name = domainObject.model.name; | ||||
|  | ||||
|             this.dialogService.getDialogResponse( | ||||
|                 'overlay-dialog', | ||||
|                 taskForm, | ||||
|                 function() { | ||||
|                     return taskForm.value; | ||||
|                 } | ||||
|             ).then(function (options) { | ||||
|                 var snapshotObject = { | ||||
|                     src: imageURL, | ||||
|                     type: imageType, | ||||
|                     size: imageSize | ||||
|                 }; | ||||
|  | ||||
|                 options.notebook.useCapability('mutation', function (model) { | ||||
|                     var date = Date.now(); | ||||
|  | ||||
|                     model.entries.push({ | ||||
|                         id: 'entry-' + date, | ||||
|                         createdOn: date, | ||||
|                         text: options.entry, | ||||
|                         embeds: [{ | ||||
|                             name: name, | ||||
|                             cssClass: cssClass, | ||||
|                             type: domainObjectId, | ||||
|                             id: 'embed-' + date, | ||||
|                             createdOn: date, | ||||
|                             snapshot: snapshotObject | ||||
|                         }] | ||||
|                     }); | ||||
|                 }); | ||||
|             }); | ||||
|         }; | ||||
|  | ||||
|         SnapshotAction.prototype.generateTaskForm = function () { | ||||
|             var taskForm = { | ||||
|                 name: "Create a Notebook Entry", | ||||
|                 hint: "Please select a Notebook", | ||||
|                 sections: [{ | ||||
|                     rows: [{ | ||||
|                         name: 'Entry', | ||||
|                         key: 'entry', | ||||
|                         control: 'textarea', | ||||
|                         required: false, | ||||
|                         "cssClass": "l-textarea-sm" | ||||
|                     }, | ||||
|                     { | ||||
|                         name: 'Save in Notebook', | ||||
|                         key: 'notebook', | ||||
|                         control: 'locator', | ||||
|                         validate: validateLocation | ||||
|                     }] | ||||
|                 }] | ||||
|             }; | ||||
|  | ||||
|             var overlayModel = { | ||||
|                 title: taskForm.name, | ||||
|                 message: 'AHAHAH', | ||||
|                 structure: taskForm, | ||||
|                 value: {'entry': ""} | ||||
|             }; | ||||
|      | ||||
|             function validateLocation (newParentObj) { | ||||
|                 return newParentObj.model.type === 'notebookV2'; | ||||
|             } | ||||
|  | ||||
|             return overlayModel; | ||||
|         }; | ||||
|  | ||||
|         return SnapshotAction; | ||||
|     } | ||||
| ); | ||||
							
								
								
									
										198
									
								
								src/plugins/NotebookV2/src/controllers/EmbedController.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										198
									
								
								src/plugins/NotebookV2/src/controllers/EmbedController.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,198 @@ | ||||
| /***************************************************************************** | ||||
|  * 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([ | ||||
|     'moment', | ||||
|     'zepto', | ||||
|     '../utils/SnapshotOverlay', | ||||
| ], | ||||
| function ( | ||||
|     Moment, | ||||
|     $, | ||||
|     SnapshotOverlay | ||||
| ) { | ||||
|     function EmbedController (openmct, domainObject) { | ||||
|         this.openmct = openmct; | ||||
|         this.domainObject = domainObject; | ||||
|         this.objectService = openmct.$injector.get('objectService'); | ||||
|         this.navigationService = openmct.$injector.get('navigationService'); | ||||
|         this.popupService = openmct.$injector.get('popupService'); | ||||
|         this.agentService = openmct.$injector.get('agentService'); | ||||
|         this.dialogService = openmct.$injector.get('dialogService'); | ||||
|          | ||||
|  | ||||
|         this.navigate = this.navigate.bind(this); | ||||
|         this.exposedData = this.exposedData.bind(this); | ||||
|         this.exposedMethods = this.exposedMethods.bind(this); | ||||
|         this.toggleActionMenu = this.toggleActionMenu.bind(this); | ||||
|     } | ||||
|  | ||||
|     EmbedController.prototype.navigate = function (embedType) { | ||||
|         this.objectService.getObjects([embedType]).then(function (objects) { | ||||
|             this.navigationService.setNavigation(objects[embedType]);    | ||||
|         }.bind(this)); | ||||
|     }; | ||||
|  | ||||
|     EmbedController.prototype.openSnapshot = function () { | ||||
|         if (!this.snapshotOverlay) { | ||||
|             this.snapShotOverlay = new SnapshotOverlay(this.embed, this.formatTime); | ||||
|         } else { | ||||
|             this.snapShotOverlay = undefined; | ||||
|         } | ||||
|     }; | ||||
|  | ||||
|     EmbedController.prototype.formatTime = function (unixTime, timeFormat) { | ||||
|         return Moment(unixTime).format(timeFormat); | ||||
|     }; | ||||
|  | ||||
|     EmbedController.prototype.findInArray = function (array, id) { | ||||
|         var foundId = -1; | ||||
|  | ||||
|         array.forEach(function (element, index) { | ||||
|             if (element.id === id) { | ||||
|                 foundId = index; | ||||
|                 return; | ||||
|             } | ||||
|         }); | ||||
|          | ||||
|         return foundId; | ||||
|     }; | ||||
|  | ||||
|     EmbedController.prototype.actionToMenuDecorator = function (action) { | ||||
|         return { | ||||
|             name: action.getMetadata().name, | ||||
|             cssClass: action.getMetadata().cssClass, | ||||
|             perform: action.perform | ||||
|         }; | ||||
|     }; | ||||
|  | ||||
|     EmbedController.prototype.populateActionMenu = function (objectService, actionService) { | ||||
|         return function () { | ||||
|             var self = this; | ||||
|  | ||||
|             objectService.getObjects([self.embed.type]).then(function (resp) { | ||||
|                 var domainObject = resp[self.embed.type], | ||||
|                     previewAction = actionService.getActions({key: 'mct-preview-action', domainObject: domainObject})[0]; | ||||
|                  | ||||
|                 self.actions.push(self.actionToMenuDecorator(previewAction)); | ||||
|             }); | ||||
|         }; | ||||
|     }; | ||||
|  | ||||
|     EmbedController.prototype.removeEmbedAction = function () { | ||||
|         var self = this; | ||||
|  | ||||
|         return { | ||||
|             name: 'Remove Embed', | ||||
|             cssClass: 'icon-trash', | ||||
|             perform: function (embed, entry) { | ||||
|                 var entryPosition = self.findInArray(self.domainObject.entries, entry.id), | ||||
|                     embedPosition = self.findInArray(entry.embeds, embed.id); | ||||
|                  | ||||
|                 var warningDialog = self.dialogService.showBlockingMessage({ | ||||
|                     severity: "error", | ||||
|                     title: "This action will permanently delete this embed. Do you wish to continue?", | ||||
|                     options: [{ | ||||
|                         label: "OK", | ||||
|                         callback: function () { | ||||
|                             entry.embeds.splice(embedPosition, 1); | ||||
|                             var dirString = 'entries[' + entryPosition + '].embeds'; | ||||
|  | ||||
|                             self.openmct.objects.mutate(self.domainObject, dirString, entry.embeds); | ||||
|  | ||||
|                             warningDialog.dismiss(); | ||||
|                         } | ||||
|                     },{ | ||||
|                         label: "Cancel", | ||||
|                         callback: function () { | ||||
|                             warningDialog.dismiss(); | ||||
|                         } | ||||
|                     }] | ||||
|                 }); | ||||
|             } | ||||
|         }; | ||||
|     }; | ||||
|  | ||||
|     EmbedController.prototype.toggleActionMenu = function (event) { | ||||
|         event.preventDefault(); | ||||
|  | ||||
|         var body = $(document.body), | ||||
|             container = $(event.target.parentElement.parentElement), | ||||
|             initiatingEvent = this.agentService.isMobile() ? | ||||
|                     'touchstart' : 'mousedown', | ||||
|             menu = container.find('.menu-element'), | ||||
|             dismissExistingMenu; | ||||
|          | ||||
|         // Remove the context menu | ||||
|         function dismiss() { | ||||
|             container.find('.hide-menu').append(menu); | ||||
|             body.off(initiatingEvent, dismiss); | ||||
|             menu.off(initiatingEvent, menuClickHandler); | ||||
|             dismissExistingMenu = undefined; | ||||
|         } | ||||
|          | ||||
|         function menuClickHandler(e) { | ||||
|             e.stopPropagation(); | ||||
|             window.setTimeout(dismiss, 300); | ||||
|         } | ||||
|  | ||||
|         // Dismiss any menu which was already showing | ||||
|         if (dismissExistingMenu) { | ||||
|             dismissExistingMenu(); | ||||
|         } | ||||
|  | ||||
|         // ...and record the presence of this menu. | ||||
|         dismissExistingMenu = dismiss; | ||||
|  | ||||
|         this.popupService.display(menu, [event.pageX,event.pageY], { | ||||
|             marginX: 0, | ||||
|             marginY: -50 | ||||
|         }); | ||||
|  | ||||
|         // Stop propagation so that clicks or touches on the menu do not close the menu | ||||
|         menu.on(initiatingEvent, menuClickHandler); | ||||
|  | ||||
|         body.on(initiatingEvent, dismiss); | ||||
|  | ||||
|     }; | ||||
|  | ||||
|     EmbedController.prototype.exposedData = function () { | ||||
|         return { | ||||
|             actions: [this.removeEmbedAction()], | ||||
|             showActionMenu: false | ||||
|         }; | ||||
|     }; | ||||
|  | ||||
|     EmbedController.prototype.exposedMethods = function () { | ||||
|         var self = this; | ||||
|  | ||||
|         return { | ||||
|             navigate: self.navigate, | ||||
|             openSnapshot: self.openSnapshot, | ||||
|             formatTime: self.formatTime, | ||||
|             toggleActionMenu: self.toggleActionMenu, | ||||
|             actionToMenuDecorator: self.actionToMenuDecorator | ||||
|         }; | ||||
|     }; | ||||
|  | ||||
|     return EmbedController; | ||||
| }); | ||||
							
								
								
									
										150
									
								
								src/plugins/NotebookV2/src/controllers/EntryController.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										150
									
								
								src/plugins/NotebookV2/src/controllers/EntryController.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,150 @@ | ||||
| /***************************************************************************** | ||||
|  * 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([ | ||||
|      'moment' | ||||
|  ], | ||||
|  function ( | ||||
|      Moment | ||||
|  ) { | ||||
|  | ||||
|     function EntryController (openmct, domainObject) { | ||||
|         this.openmct = openmct; | ||||
|         this.domainObject = domainObject; | ||||
|         this.dndService = this.openmct.$injector.get('dndService'); | ||||
|         this.dialogService = this.openmct.$injector.get('dialogService'); | ||||
|  | ||||
|         this.currentEntryValue = ''; | ||||
|  | ||||
|         this.exposedMethods = this.exposedMethods.bind(this); | ||||
|         this.exposedData = this.exposedData.bind(this); | ||||
|     } | ||||
|  | ||||
|     EntryController.prototype.entryPosById = function (entryId) { | ||||
|         var foundId = -1; | ||||
|  | ||||
|         this.domainObject.entries.forEach(function (element, index) { | ||||
|             if (element.id === entryId) { | ||||
|                 foundId = index; | ||||
|                 return; | ||||
|             } | ||||
|         }); | ||||
|          | ||||
|         return foundId; | ||||
|     }; | ||||
|  | ||||
|     EntryController.prototype.textFocus = function ($event) { | ||||
|         if ($event.target) { | ||||
|             this.currentEntryValue = $event.target.innerText; | ||||
|         } else { | ||||
|             $event.target.innerText = ''; | ||||
|         } | ||||
|     }; | ||||
|  | ||||
|     EntryController.prototype.textBlur = function ($event, entryId) { | ||||
|         if ($event.target) { | ||||
|             var entryPos = this.entryPosById(entryId); | ||||
|              | ||||
|             if (this.currentEntryValue !== $event.target.innerText) { | ||||
|                 this.openmct.objects.mutate(this.domainObject, 'entries[' + entryPos + '].text', $event.target.innerText); | ||||
|             } | ||||
|         } | ||||
|     }; | ||||
|  | ||||
|     EntryController.prototype.formatTime = function (unixTime, timeFormat) { | ||||
|         return Moment(unixTime).format(timeFormat); | ||||
|     }; | ||||
|  | ||||
|     EntryController.prototype.deleteEntry = function () { | ||||
|         var entryPos = this.entryPosById(this.entry.id), | ||||
|             domainObject = this.domainObject, | ||||
|             openmct = this.openmct; | ||||
|  | ||||
|         if (entryPos !== -1) { | ||||
|  | ||||
|             var errorDialog = this.dialogService.showBlockingMessage({ | ||||
|                 severity: "error", | ||||
|                 title: "This action will permanently delete this Notebook entry. Do you wish to continue?", | ||||
|                 options: [{ | ||||
|                     label: "OK", | ||||
|                     callback: function () { | ||||
|                         domainObject.entries.splice(entryPos, 1); | ||||
|                         openmct.objects.mutate(domainObject, 'entries', domainObject.entries); | ||||
|  | ||||
|                         errorDialog.dismiss(); | ||||
|                     } | ||||
|                 },{ | ||||
|                     label: "Cancel", | ||||
|                     callback: function () { | ||||
|                         errorDialog.dismiss(); | ||||
|                     } | ||||
|                 }] | ||||
|             }); | ||||
|         } | ||||
|     }; | ||||
|  | ||||
|     EntryController.prototype.dropOnEntry = function (entryId) { | ||||
|         var selectedObject = this.dndService.getData('mct-domain-object'), | ||||
|             selectedObjectId = selectedObject.getId(), | ||||
|             selectedModel = selectedObject.getModel(), | ||||
|             cssClass = selectedObject.getCapability('type').typeDef.cssClass, | ||||
|             entryPos = this.entryPosById(entryId), | ||||
|             currentEntryEmbeds = this.domainObject.entries[entryPos].embeds, | ||||
|             newEmbed = { | ||||
|                 type: selectedObjectId, | ||||
|                 id: '' + Date.now(), | ||||
|                 cssClass: cssClass, | ||||
|                 name: selectedModel.name, | ||||
|                 snapshot: '' | ||||
|             }; | ||||
|  | ||||
|         currentEntryEmbeds.push(newEmbed); | ||||
|         this.openmct.objects.mutate(this.domainObject, 'entries[' + entryPos + '].embeds', currentEntryEmbeds); | ||||
|     }; | ||||
|  | ||||
|     EntryController.prototype.dragoverOnEntry = function () { | ||||
|          | ||||
|     }; | ||||
|  | ||||
|     EntryController.prototype.exposedData = function () { | ||||
|         return { | ||||
|             openmct: this.openmct, | ||||
|             domainObject: this.domainObject, | ||||
|             dndService: this.dndService, | ||||
|             dialogService: this.dialogService, | ||||
|             currentEntryValue: this.currentEntryValue | ||||
|         }; | ||||
|     }; | ||||
|  | ||||
|     EntryController.prototype.exposedMethods = function () { | ||||
|         return { | ||||
|             entryPosById: this.entryPosById, | ||||
|             textFocus: this.textFocus, | ||||
|             textBlur: this.textBlur, | ||||
|             formatTime: this.formatTime, | ||||
|             deleteEntry: this.deleteEntry, | ||||
|             dropOnEntry: this.dropOnEntry, | ||||
|             dragoverOnEntry: this.dragoverOnEntry | ||||
|         }; | ||||
|     }; | ||||
|     return EntryController; | ||||
|  }); | ||||
							
								
								
									
										65
									
								
								src/plugins/NotebookV2/src/controllers/NewEntryController.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										65
									
								
								src/plugins/NotebookV2/src/controllers/NewEntryController.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,65 @@ | ||||
| /***************************************************************************** | ||||
|  * 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. | ||||
|  *****************************************************************************/ | ||||
|  | ||||
| /** | ||||
|  * Module defining NewEntryController. */ | ||||
| define( | ||||
|     [], | ||||
|     function () { | ||||
|  | ||||
|         function NewEntryController($scope,$rootScope) { | ||||
|  | ||||
|             $scope.snapshot = undefined; | ||||
|             $scope.snapToggle = true; | ||||
|             $scope.entryText = ''; | ||||
|             var annotateAction = $rootScope.selObj.getCapability('action').getActions({key: 'annotate-snapshot'})[0];                                                                 | ||||
|  | ||||
|             $scope.$parent.$parent.ngModel[$scope.$parent.$parent.field] = $rootScope.selObj; | ||||
|             $scope.objectName = $rootScope.selObj.getModel().name; | ||||
|             $scope.cssClass = $rootScope.selObj.getCapability('type').typeDef.cssClass; | ||||
|  | ||||
|             $scope.annotateSnapshot = function ($event) { | ||||
|                 if ($rootScope.currentDialog.value) { | ||||
|                     $rootScope.newEntryText = $scope.$parent.$parent.ngModel.entry; | ||||
|                     $rootScope.currentDialog.cancel(); | ||||
|                     annotateAction.perform($event, $rootScope.snapshot.src); | ||||
|                     $rootScope.currentDialog = undefined; | ||||
|                 } | ||||
|             }; | ||||
|  | ||||
|             function updateSnapshot(img) { | ||||
|                 $scope.snapshot = img; | ||||
|             } | ||||
|             // Update set of actions whenever the action capability | ||||
|             // changes or becomes available. | ||||
|             $rootScope.$watch("snapshot", updateSnapshot); | ||||
|  | ||||
|             $rootScope.$watch("selValue", toggleEmbed); | ||||
|  | ||||
|             function toggleEmbed(value) { | ||||
|                 $scope.snapToggle = value; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         return NewEntryController; | ||||
|     } | ||||
| ); | ||||
							
								
								
									
										174
									
								
								src/plugins/NotebookV2/src/controllers/NotebookController.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										174
									
								
								src/plugins/NotebookV2/src/controllers/NotebookController.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,174 @@ | ||||
| /***************************************************************************** | ||||
|  * 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([ | ||||
|      'vue', | ||||
|      './EntryController', | ||||
|      './EmbedController', | ||||
|      'text!../../res/templates/notebook.html', | ||||
|      'text!../../res/templates/entry.html', | ||||
|      'text!../../res/templates/embed.html' | ||||
|     ],  | ||||
|     function ( | ||||
|      Vue, | ||||
|      EntryController, | ||||
|      EmbedController, | ||||
|      NotebookTemplate, | ||||
|      EntryTemplate, | ||||
|      EmbedTemplate | ||||
|     ) { | ||||
|  | ||||
|     function NotebookController(openmct, domainObject) { | ||||
|         this.openmct = openmct; | ||||
|         this.domainObject = domainObject; | ||||
|         this.entrySearch = ''; | ||||
|         this.objectService = openmct.$injector.get('objectService'); | ||||
|         this.actionService = openmct.$injector.get('actionService'); | ||||
|  | ||||
|         this.show = this.show.bind(this); | ||||
|         this.destroy = this.destroy.bind(this); | ||||
|         this.newEntry = this.newEntry.bind(this); | ||||
|         this.entryPosById = this.entryPosById.bind(this); | ||||
|     } | ||||
|  | ||||
|     NotebookController.prototype.initializeVue = function (container){ | ||||
|         var self = this, | ||||
|             entryController = new EntryController(this.openmct, this.domainObject), | ||||
|             embedController = new EmbedController(this.openmct, this.domainObject); | ||||
|  | ||||
|         this.container = container; | ||||
|  | ||||
|         var notebookEmbed = { | ||||
|             props:['embed', 'entry'], | ||||
|             template: EmbedTemplate, | ||||
|             data: embedController.exposedData, | ||||
|             methods: embedController.exposedMethods(), | ||||
|             beforeMount: embedController.populateActionMenu(self.objectService, self.actionService) | ||||
|         }; | ||||
|  | ||||
|         var entryComponent = { | ||||
|             props:['entry'], | ||||
|             template: EntryTemplate, | ||||
|             components: { | ||||
|                 'notebook-embed': notebookEmbed | ||||
|             }, | ||||
|             data: entryController.exposedData, | ||||
|             methods: entryController.exposedMethods(), | ||||
|             mounted: self.focusOnEntry | ||||
|         }; | ||||
|  | ||||
|         var notebookVue = Vue.extend({ | ||||
|             template: NotebookTemplate, | ||||
|             components: { | ||||
|                 'notebook-entry': entryComponent | ||||
|             }, | ||||
|             data: function () { | ||||
|                 return { | ||||
|                     entrySearch: self.entrySearch, | ||||
|                     showTime: '0', | ||||
|                     sortEntries: '-createdOn', | ||||
|                     entries: self.domainObject.entries, | ||||
|                     currentEntryValue: '' | ||||
|                 }; | ||||
|             }, | ||||
|             methods: { | ||||
|                 search: function (event) { | ||||
|                     if (event.target.value) { | ||||
|                         this.entrySearch = event.target.value; | ||||
|                     } | ||||
|                 }, | ||||
|                 newEntry: self.newEntry, | ||||
|                 filterBySearch: self.filterBySearch | ||||
|             }  | ||||
|         }); | ||||
|  | ||||
|         this.NotebookVue =  new notebookVue(); | ||||
|         container.appendChild(this.NotebookVue.$mount().$el); | ||||
|     }; | ||||
|  | ||||
|     NotebookController.prototype.newEntry = function (event) { | ||||
|          | ||||
|         var entries = this.domainObject.entries, | ||||
|             lastEntryIndex = entries.length - 1, | ||||
|             lastEntry = entries[lastEntryIndex], | ||||
|             date = Date.now(); | ||||
|  | ||||
|         if (lastEntry === undefined || lastEntry.text || lastEntry.embeds.length) { | ||||
|             var createdEntry = {'id': 'entry-' + date, 'createdOn': date, 'embeds':[]}; | ||||
|              | ||||
|             entries.push(createdEntry); | ||||
|             this.openmct.objects.mutate(this.domainObject, 'entries', entries); | ||||
|         } else { | ||||
|             lastEntry.createdOn = date; | ||||
|  | ||||
|             this.openmct.objects.mutate(this.domainObject, 'entries[entries.length-1]', lastEntry); | ||||
|             this.focusOnEntry.bind(this.NotebookVue.$children[lastEntryIndex])(); | ||||
|         } | ||||
|  | ||||
|         this.entrySearch = ''; | ||||
|     }; | ||||
|  | ||||
|     NotebookController.prototype.entryPosById = function (entryId) { | ||||
|         var foundId = -1; | ||||
|  | ||||
|         this.domainObject.entries.forEach(function (element, index) { | ||||
|             if (element.id === entryId) { | ||||
|                 foundId = index; | ||||
|                 return; | ||||
|             } | ||||
|         }); | ||||
|          | ||||
|         return foundId; | ||||
|     }; | ||||
|  | ||||
|     NotebookController.prototype.focusOnEntry = function () { | ||||
|         if (!this.entry.text) { | ||||
|             this.$refs.contenteditable.focus(); | ||||
|         } | ||||
|     }; | ||||
|  | ||||
|     NotebookController.prototype.filterBySearch = function (entryArray, filterString) { | ||||
|         if (filterString) { | ||||
|             var lowerCaseFilterString = filterString.toLowerCase(); | ||||
|  | ||||
|             return entryArray.filter(function (entry) { | ||||
|                 if (entry.text) { | ||||
|                     return entry.text.toLowerCase().includes(lowerCaseFilterString); | ||||
|                 } else { | ||||
|                     return false; | ||||
|                 } | ||||
|             }); | ||||
|         } else { | ||||
|             return entryArray; | ||||
|         } | ||||
|     }; | ||||
|  | ||||
|     NotebookController.prototype.show = function (container) { | ||||
|         this.initializeVue(container); | ||||
|     }; | ||||
|  | ||||
|     NotebookController.prototype.destroy = function (container) { | ||||
|         this.NotebookVue.$destroy(true); | ||||
|     }; | ||||
|  | ||||
|     return NotebookController; | ||||
|  }); | ||||
| @@ -0,0 +1,44 @@ | ||||
| /***************************************************************************** | ||||
|  * 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. | ||||
|  *****************************************************************************/ | ||||
|  | ||||
| /** | ||||
|  * Module defining SelectSnapshotController. */ | ||||
| define( | ||||
|     [], | ||||
|     function () { | ||||
|  | ||||
|         function SelectSnapshotController($scope,$rootScope) { | ||||
|  | ||||
|             $scope.selectModel = true; | ||||
|  | ||||
|             function selectprint(value) { | ||||
|                 $rootScope.selValue = value; | ||||
|                 $scope.$parent.$parent.ngModel[$scope.$parent.$parent.field] = value; | ||||
|             } | ||||
|  | ||||
|             $scope.$watch("selectModel", selectprint); | ||||
|  | ||||
|         } | ||||
|  | ||||
|         return SelectSnapshotController; | ||||
|     } | ||||
| ); | ||||
							
								
								
									
										126
									
								
								src/plugins/NotebookV2/src/directives/EntryDnd.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										126
									
								
								src/plugins/NotebookV2/src/directives/EntryDnd.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,126 @@ | ||||
| /***************************************************************************** | ||||
|  * Open MCT, Copyright (c) 2014-2016, 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(['zepto'], function ($) { | ||||
|  | ||||
|     function EntryDnd($rootScope,$compile,dndService,typeService,notificationService) { | ||||
|  | ||||
|         function link($scope, $element) { | ||||
|  | ||||
|             function drop(e) { | ||||
|                 var selectedObject = dndService.getData('mct-domain-object'); | ||||
|                 var selectedModel = selectedObject.getModel(); | ||||
|                 var cssClass = selectedObject.getCapability('type').typeDef.cssClass; | ||||
|                 var entryId = -1; | ||||
|                 var embedId = -1; | ||||
|                 $scope.clearSearch(); | ||||
|                 if ($element[0].id === 'newEntry') { | ||||
|                     entryId = $scope.domainObject.model.entries.length; | ||||
|                     embedId = 0; | ||||
|                     var lastEntry = $scope.domainObject.model.entries[entryId - 1]; | ||||
|                     if (lastEntry === undefined || lastEntry.text || lastEntry.embeds) { | ||||
|                         $scope.domainObject.useCapability('mutation', function (model) { | ||||
|                             model.entries.push({'createdOn': +Date.now(), | ||||
|                                                 'id': +Date.now(), | ||||
|                                                 'embeds': [{'type': selectedObject.getId(), | ||||
|                                                        'id': '' + Date.now(), | ||||
|                                                        'cssClass': cssClass, | ||||
|                                                        'name': selectedModel.name, | ||||
|                                                        'snapshot': '' | ||||
|                                                      }] | ||||
|                                             }); | ||||
|                         }); | ||||
|                     }else { | ||||
|                         $scope.domainObject.useCapability('mutation', function (model) { | ||||
|                             model.entries[entryId - 1] = | ||||
|                                                     {'createdOn': +Date.now(), | ||||
|                                                      'embeds': [{'type': selectedObject.getId(), | ||||
|                                                                 'id': '' + Date.now(), | ||||
|                                                                 'cssClass': cssClass, | ||||
|                                                                 'name': selectedModel.name, | ||||
|                                                                 'snapshot': '' | ||||
|                                                                }] | ||||
|                                                     }; | ||||
|                         }); | ||||
|                     } | ||||
|  | ||||
|                     $scope.scrollToTop(); | ||||
|                     notificationService.info({ | ||||
|                         title: "Notebook Entry created" | ||||
|                     }); | ||||
|  | ||||
|                 }else { | ||||
|                     entryId = $scope.findEntryPositionById(Number($element[0].id.replace('entry_', ''))); | ||||
|  | ||||
|                     if (!$scope.domainObject.model.entries[entryId].embeds) { | ||||
|                         $scope.domainObject.model.entries[entryId].embeds = []; | ||||
|                     } | ||||
|  | ||||
|                     $scope.domainObject.useCapability('mutation', function (model) { | ||||
|                         model.entries[entryId].embeds.push({'type': selectedObject.getId(), | ||||
|                                                                           'id': '' + Date.now(), | ||||
|                                                                           'cssClass': cssClass, | ||||
|                                                                           'name': selectedModel.name, | ||||
|                                                                           'snapshot': '' | ||||
|                                                                         }); | ||||
|                     }); | ||||
|  | ||||
|                     embedId = $scope.domainObject.model.entries[entryId].embeds.length - 1; | ||||
|  | ||||
|                     if (selectedObject) { | ||||
|                         e.preventDefault(); | ||||
|  | ||||
|                     } | ||||
|                 } | ||||
|  | ||||
|                 if ($(e.currentTarget).hasClass('drag-active')) { | ||||
|                     $(e.currentTarget).removeClass('drag-active'); | ||||
|                 } | ||||
|  | ||||
|             } | ||||
|  | ||||
|             function dragover(e) { | ||||
|                 if (!$(e.currentTarget).hasClass('drag-active')) { | ||||
|                     $(e.currentTarget).addClass('drag-active'); | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|             // Listen for the drop itself | ||||
|             $element.on('dragover', dragover); | ||||
|             $element.on('drop', drop); | ||||
|  | ||||
|  | ||||
|             $scope.$on('$destroy', function () { | ||||
|                 $element.off('dragover', dragover); | ||||
|                 $element.off('drop', drop); | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|         return { | ||||
|             restrict: 'A', | ||||
|             link: link | ||||
|         }; | ||||
|     } | ||||
|  | ||||
|     return EntryDnd; | ||||
|  | ||||
| }); | ||||
							
								
								
									
										86
									
								
								src/plugins/NotebookV2/src/directives/MCTSnapshot.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										86
									
								
								src/plugins/NotebookV2/src/directives/MCTSnapshot.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,86 @@ | ||||
| /***************************************************************************** | ||||
|  * Open MCT, Copyright (c) 2014-2016, 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(['zepto'], function ($) { | ||||
|     function MCTSnapshot($rootScope, $document, exportImageService, dialogService, notificationService) { | ||||
|         var document = $document[0]; | ||||
|  | ||||
|         function link($scope, $element, $attrs) { | ||||
|             var objectElement = $(document.body).find(".overlay .object-holder")[0] || $(document.body).find("[key='representation.selected.key']")[0], | ||||
|                 takeSnapshot, | ||||
|                 makeImg, | ||||
|                 saveImg; | ||||
|  | ||||
|             $(objectElement).addClass("s-status-taking-snapshot"); | ||||
|  | ||||
|             saveImg = function (url, entryId, embedId) { | ||||
|                 $scope.$parent.$parent.$parent.saveSnap(url, embedId, entryId); | ||||
|             }; | ||||
|  | ||||
|             makeImg = function (el) { | ||||
|                 var scope = $scope; | ||||
|  | ||||
|                 exportImageService.exportPNGtoSRC(el).then(function (img) { | ||||
|  | ||||
|                     $(objectElement).removeClass("s-status-taking-snapshot"); | ||||
|  | ||||
|                     if (img) { | ||||
|                         if ($element[0].dataset.entry && $element[0].dataset.embed) { | ||||
|                             saveImg(img, +$element[0].dataset.entry, +$element[0].dataset.embed); | ||||
|                         } else { | ||||
|                             var reader = new window.FileReader(); | ||||
|                             reader.readAsDataURL(img); | ||||
|                             reader.onloadend = function () { | ||||
|                                 $($element[0]).attr("data-snapshot", reader.result); | ||||
|                                 $rootScope.snapshot = { | ||||
|                                     'src': reader.result, | ||||
|                                     'type': img.type, | ||||
|                                     'size': img.size, | ||||
|                                     'modified': Date.now() | ||||
|                                 }; | ||||
|                                 scope.$destroy(); | ||||
|                             }; | ||||
|                         } | ||||
|                     } | ||||
|                 }); | ||||
|             }; | ||||
|  | ||||
|             takeSnapshot = function () { | ||||
|                 makeImg(objectElement); | ||||
|             }; | ||||
|  | ||||
|             takeSnapshot(); | ||||
|  | ||||
|             $scope.$on('$destroy', function () { | ||||
|                 $element.remove(); | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|         return { | ||||
|             restrict: 'A', | ||||
|             link: link | ||||
|         }; | ||||
|     } | ||||
|  | ||||
|     return MCTSnapshot; | ||||
|  | ||||
| }); | ||||
							
								
								
									
										67
									
								
								src/plugins/NotebookV2/src/utils/SnapshotOverlay.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										67
									
								
								src/plugins/NotebookV2/src/utils/SnapshotOverlay.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,67 @@ | ||||
| /***************************************************************************** | ||||
|  * 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([ | ||||
|      'vue', | ||||
|      'text!../../res/templates/viewSnapshot.html' | ||||
|  ], function ( | ||||
|      Vue, | ||||
|      snapshotOverlayTemplate | ||||
|  ) { | ||||
|     function SnapshotOverlay (embedObject, formatTime) { | ||||
|         this.embedObject = embedObject; | ||||
|  | ||||
|         this.snapshotOverlayVue = new Vue({ | ||||
|             template: snapshotOverlayTemplate, | ||||
|             data: function () { | ||||
|                 return { | ||||
|                     embed: embedObject | ||||
|                 }; | ||||
|             }, | ||||
|             methods: { | ||||
|                 close: this.close.bind(this), | ||||
|                 formatTime: formatTime | ||||
|             } | ||||
|         }); | ||||
|          | ||||
|         this.open(); | ||||
|     } | ||||
|  | ||||
|     SnapshotOverlay.prototype.open = function () { | ||||
|          | ||||
|         this.overlay = document.createElement('div'); | ||||
|         this.overlay.id = 'snapshot'; | ||||
|  | ||||
|         document.body.appendChild(this.overlay); | ||||
|  | ||||
|         this.overlay.appendChild(this.snapshotOverlayVue.$mount().$el); | ||||
|     }; | ||||
|  | ||||
|     SnapshotOverlay.prototype.close = function (event) { | ||||
|         event.stopPropagation(); | ||||
|         this.snapshotOverlayVue.$destroy(); | ||||
|         this.overlay.parentNode.removeChild(this.overlay); | ||||
|     }; | ||||
|  | ||||
|     return SnapshotOverlay; | ||||
|  }); | ||||
| @@ -33,7 +33,8 @@ define([ | ||||
|     './URLIndicatorPlugin/URLIndicatorPlugin', | ||||
|     './telemetryMean/plugin', | ||||
|     './plot/plugin', | ||||
|     './staticRootPlugin/plugin' | ||||
|     './staticRootPlugin/plugin', | ||||
|     './NotebookV2/plugin' | ||||
| ], function ( | ||||
|     _, | ||||
|     UTCTimeSystem, | ||||
| @@ -47,7 +48,8 @@ define([ | ||||
|     URLIndicatorPlugin, | ||||
|     TelemetryMean, | ||||
|     PlotPlugin, | ||||
|     StaticRootPlugin | ||||
|     StaticRootPlugin, | ||||
|     NotebookV2 | ||||
| ) { | ||||
|     var bundleMap = { | ||||
|         CouchDB: 'platform/persistence/couch', | ||||
| @@ -140,6 +142,7 @@ define([ | ||||
|     plugins.SummaryWidget = SummaryWidget; | ||||
|     plugins.TelemetryMean = TelemetryMean; | ||||
|     plugins.URLIndicator = URLIndicatorPlugin; | ||||
|     plugins.NotebookV2 = NotebookV2; | ||||
|  | ||||
|     return plugins; | ||||
| }); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user