Code issues fixes:

NotificationLaunchIndicator deleted.
Inappropriate modifications to domain object models fixed.
Implemented $destroy listener on entryDnd directive.
Naming conventions fixed.
Unnecessary changes made to platform handled.
Painterro dependency handled
gulp verify fix.
This commit is contained in:
Cristian Franco
2017-12-27 00:26:27 -05:00
parent 499655def2
commit 3f9bad1805
31 changed files with 650 additions and 3883 deletions

View File

@@ -1,65 +1,72 @@
define([
"openmct",
"./src/controllers/notebookController",
"./src/controllers/newEntryController",
"./src/controllers/selectSnapshotController",
"./src/controllers/NotebookController",
"./src/controllers/NewEntryController",
"./src/controllers/SelectSnapshotController",
"./src/controllers/LayoutNotebookController",
"./src/directives/MCTSnapshot",
"./src/directives/entryDnd",
"./src/actions/viewSnapshot",
"./src/actions/annotateSnapshot",
"./src/actions/removeEmbed",
"./src/actions/createSnapshot",
"./src/actions/removeSnapshot",
"./src/actions/newEntryContextual",
"./src/capabilities/notebookCapability",
"./src/indicators/notificationIndicator"
"./src/directives/MCTModalNotebook",
"./src/directives/EntryDnd",
"./src/actions/ViewSnapshot",
"./src/actions/AnnotateSnapshot",
"./src/actions/RemoveEmbed",
"./src/actions/CreateSnapshot",
"./src/actions/RemoveSnapshot",
"./src/actions/NewEntryContextual",
"./src/capabilities/NotebookCapability",
"./src/policies/CompositionPolicy",
"./src/policies/ViewPolicy",
], function (
openmct,
notebookController,
newEntryController,
selectSnapshotController,
NotebookController,
NewEntryController,
SelectSnapshotController,
LayoutNotebookController,
MCTSnapshot,
MCTModalNotebook,
MCTEntryDnd,
viewSnapshotAction,
ViewSnapshotAction,
AnnotateSnapshotAction,
removeEmbedAction,
createSnapshotAction,
removeSnapshotAction,
RemoveEmbedAction,
CreateSnapshotAction,
RemoveSnapshotAction,
newEntryAction,
NotebookCapability,
NotificationLaunchIndicator
CompositionPolicy,
ViewPolicy
) {
openmct.legacyRegistry.register("example/notebook", {
"name": "Notebook Plugin",
"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":[
{ "createdOn": 1507512539258,
"text": "Quis qui dolupti atempe non preicias qui dolorro",
"embeds":[]
},
{ "createdOn": 1507570153599,
"text": "Rehek rerspis nis dem re verae remporrunti sintis vendi comnimi ntiusapic teceseque."
},
{ "createdOn": 1507595098278,
"text": "Rehek rerspis nis dem re verae remporrunti sintis vendi comnimi ntiusapic teceseque."
}
],
"composition":[],
"entryTypes":[]
}
}
],
"views": [
"types":[
{
"key": "notebook",
"name": "Notebook",
"cssClass": "icon-notebook",
"description": "Create and save timestamped notes with embedded object snapshots.",
"features": ["creation"],
"model": {
"entries":[
{ "createdOn": 1507512539258,
"text": "Quis qui dolupti atempe non preicias qui dolorro",
"embeds":[]
},
{ "createdOn": 1507570153599,
"text": "Rehek rerspis nis dem re verae remporrunti sintis vendi comnimi ntiusapic teceseque."
},
{ "createdOn": 1507595098278,
"text": "Rehek rerspis nis dem re verae remporrunti sintis vendi comnimi ntiusapic teceseque."
}
],
"composition":[],
"entryTypes":[]
}
}
],
"views": [
{
"key": "notebook.view",
"type": "notebook",
@@ -75,11 +82,42 @@ define([
"drop"
]
},
],
"controllers": [
{
"key": "layoutNotebook",
"name": "Display Layout",
"cssClass": "icon-layout",
"type": "layout",
"templateUrl": "templates/layoutNotebook.html",
"editable": true,
"uses": [],
"toolbar": {
"sections": [
{
"items": [
{
"method": "showFrame",
"cssClass": "icon-frame-show",
"control": "button",
"title": "Show frame",
"description": "Show frame"
},
{
"method": "hideFrame",
"cssClass": "icon-frame-hide",
"control": "button",
"title": "Hide frame",
"description": "Hide frame"
}
]
}
]
}
}
],
"controllers": [
{
"key": "notebookController",
"implementation": notebookController,
"key": "NotebookController",
"implementation": NotebookController,
"depends": [ "$scope",
"dialogService",
"popupService",
@@ -93,24 +131,33 @@ define([
]
},
{
"key": "newEntryController",
"implementation": newEntryController,
"key": "NewEntryController",
"implementation": NewEntryController,
"depends": [ "$scope",
"$rootScope"
]
},
{
"key": "selectSnapshotController",
"implementation": selectSnapshotController,
"implementation": SelectSnapshotController,
"depends": [ "$scope",
"$rootScope"
]
},
{
"key": "LayoutNotebookController",
"implementation": LayoutNotebookController,
"depends": [ "$scope"]
}
],
],
"representations": [
{
"key": "draggedEntry",
"templateUrl": "templates/entry.html"
},
{
"key": "frameLayoutNotebook",
"templateUrl": "templates/frameLayoutNotebook.html"
}
],
"templates": [
@@ -145,12 +192,19 @@ define([
"typeService",
"notificationService"
]
},
{
"key": "mctModalNotebook",
"implementation": MCTModalNotebook,
"depends": [
"$document"
]
}
],
"actions": [
{
"key": "view-snapshot",
"implementation": viewSnapshotAction,
"implementation": ViewSnapshotAction,
"name": "View Snapshot",
"description": "View the large image in a modal",
"category": "embed",
@@ -174,7 +228,7 @@ define([
{
"key": "remove-embed",
"implementation": removeEmbedAction,
"implementation": RemoveEmbedAction,
"name": "Remove...",
"cssClass": "icon-trash labeled",
"description": "Remove this embed",
@@ -188,7 +242,7 @@ define([
},
{
"key": "remove-snapshot",
"implementation": removeSnapshotAction,
"implementation": RemoveSnapshotAction,
"name": "Remove Snapshot",
"cssClass": "icon-trash labeled",
"description": "Remove Snapshot of the embed",
@@ -199,7 +253,7 @@ define([
},
{
"key": "create-snapshot",
"implementation": createSnapshotAction,
"implementation": CreateSnapshotAction,
"name": "Create Snapshot",
"description": "Create a snapshot for the embed",
"category": "embed-no-snap",
@@ -228,10 +282,16 @@ define([
"priority": "preferred"
}
],
"indicators": [
"licenses": [
{
"implementation": NotificationLaunchIndicator,
"priority": "fallback"
"name": "painterro",
"version": "4.1.0",
"author": "Mike Bostock",
"description": "D3 (or D3.js) is a JavaScript library for visualizing data using web standards. D3 helps you bring data to life using SVG, Canvas and HTML. D3 combines powerful visualization and interaction techniques with a data-driven approach to DOM manipulation, giving you the full capabilities of modern browsers and the freedom to design the right visual interface for your data.",
"website": "https://d3js.org/",
"copyright": "Copyright 2010-2016 Mike Bostock",
"license": "BSD-3-Clause",
"link": "https://github.com/d3/d3/blob/master/LICENSE"
}
],
"capabilities": [
@@ -245,6 +305,17 @@ define([
]
}
],
"policies": [
{
"category": "composition",
"implementation": CompositionPolicy,
"message": "Objects of this type cannot contain objects of that type."
},
{
"category": "view",
"implementation": ViewPolicy
}
],
"controls": [
{
"key": "embed-control",
@@ -255,7 +326,7 @@ define([
"templateUrl": "templates/controls/snapSelect.html"
}
],
"stylesheets": [
"stylesheets": [
{
"stylesheetUrl": "css/notebook.css",
"theme": "espresso"

File diff suppressed because one or more lines are too long

View File

@@ -21,7 +21,7 @@
-->
<div class='form-control'>
<ng-form name="mctControl">
<div class='fields' ng-controller="newEntryController">
<div class='fields' ng-controller="NewEntryController">
<div class="l-flex-row new-display-embed">
<div class="l-flex-row embed">
<div ng-if="snapToggle" class="l-flex-row">

View File

@@ -0,0 +1,54 @@
<!--
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 frame-template t-frame-inner abs t-object-type-{{ representation.selected.key }}">
<div class="abs object-browse-bar l-flex-row">
<div class="left flex-elem l-flex-row grows">
<mct-representation
key="'object-header-frame'"
mct-object="domainObject"
class="l-flex-row flex-elem object-header grows">
</mct-representation>
</div>
<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>
<a class="s-button icon-notebook t-btn-view-large"
title="New Notebook Entry"
ng-if="parameters"
ng-click="ngModel()">
</a>
<a class="s-button icon-expand t-btn-view-large"
title="View large"
mct-modal-notebook>
</a>
</div>
</div>
<div class="abs object-holder">
<mct-representation
key="representation.selected.key"
mct-object="representation.selected.key && domainObject">
</mct-representation>
</div>
</div>

View File

@@ -0,0 +1,84 @@
<!--
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="abs l-layout"
ng-controller="LayoutController as controller"
ng-click="controller.clearSelection()">
<!-- Background grid -->
<div class="l-grid-holder" ng-click="controller.clearSelection()">
<div class="l-grid l-grid-x"
ng-if="!controller.getGridSize()[0] < 3"
ng-style="{ 'background-size': controller.getGridSize() [0] + 'px 100%' }"></div>
<div class="l-grid l-grid-y"
ng-if="!controller.getGridSize()[1] < 3"
ng-style="{ 'background-size': '100% ' + controller.getGridSize() [1] + 'px' }"></div>
</div>
<div class='abs frame t-frame-outer child-frame panel s-selectable s-moveable s-hover-border'
ng-class="{ 'no-frame': !controller.hasFrame(childObject), 's-selected':controller.selected(childObject) }"
ng-repeat="childObject in composition"
ng-click="controller.select($event, childObject.getId())"
ng-style="controller.getFrameStyle(childObject.getId())">
<div ng-controller="LayoutNotebookController as controller">
<mct-representation key="'frameLayoutNotebook'"
class="t-rep-frame holder contents abs"
parameters = "hasNotebookAction"
ng-model="newNotebook"
mct-object="childObject">
</mct-representation>
</div>
<!-- Drag handles -->
<span class="abs t-edit-handle-holder s-hover-border" ng-if="controller.selected(childObject)">
<span class="edit-handle edit-move"
mct-drag-down="controller.startDrag(childObject.getId(), [1,1], [0,0])"
mct-drag="controller.continueDrag(delta)"
mct-drag-up="controller.endDrag()">
</span>
<span class="edit-corner edit-resize-nw"
mct-drag-down="controller.startDrag(childObject.getId(), [1,1], [-1,-1])"
mct-drag="controller.continueDrag(delta)"
mct-drag-up="controller.endDrag()">
</span>
<span class="edit-corner edit-resize-ne"
mct-drag-down="controller.startDrag(childObject.getId(), [0,1], [1,-1])"
mct-drag="controller.continueDrag(delta)"
mct-drag-up="controller.endDrag()">
</span>
<span class="edit-corner edit-resize-sw"
mct-drag-down="controller.startDrag(childObject.getId(), [1,0], [-1,1])"
mct-drag="controller.continueDrag(delta)"
mct-drag-up="controller.endDrag()">
</span>
<span class="edit-corner edit-resize-se"
mct-drag-down="controller.startDrag(childObject.getId(), [0,0], [1,1])"
mct-drag="controller.continueDrag(delta)"
mct-drag-up="controller.endDrag()">
</span>
</span>
</div>
</div>

View File

@@ -1,4 +1,4 @@
<div ng-controller="notebookController as controller" class="mct-notebook">
<div ng-controller="NotebookController as controller" class="mct-notebook">
<!-- Reuse of native styles the more as I can -->
<div class="notebook-head l-flex-row flex-elem grows">

View File

@@ -24,7 +24,7 @@
* Module defining viewSnapshot (Originally NewWindowAction). Created by vwoeltje on 11/18/14.
*/
define(
['../../lib/painterro'],
["painterro"],
function () {
var ANNOTATION_STRUCT = {
@@ -42,7 +42,7 @@ define(
}]
};
function annotateSnapshot(dialogService,dndService,$rootScope,context) {
function AnnotateSnapshot(dialogService,dndService,$rootScope,context) {
context = context || {};
// Choose the object to be opened into a new tab
@@ -55,15 +55,14 @@ define(
annotateSnapshot.prototype.perform = function ($event,snapshot,embedId,entryId,$scope) {
AnnotateSnapshot.prototype.perform = function ($event,snapshot,embedId,entryId,$scope) {
var domainObject = this.domainObject;
var DOMAIN_OBJECT = this.domainObject;
var ROOTSCOPE = this.$rootScope;
this.dialogService.getUserChoice(ANNOTATION_STRUCT)
.then(saveNotes);
var rootscope = this.$rootScope;
var painterro;
var tracker = function(){
@@ -74,12 +73,12 @@ define(
hiddenTools:['save', 'open', 'close','eraser'],
saveHandler: function (image, done) {
if(entryId && embedId){
var elementPos = domainObject.model.entries.map(function(x) {return x.createdOn; }).indexOf(entryId)
var entryEmbeds = domainObject.model.entries[elementPos].embeds;
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);
$scope.saveSnap(image.asBlob(),embedPos,elementPos);
}else{
rootscope.snapshot = {'src':image.asDataURL('image/png'),
ROOTSCOPE.snapshot = {'src':image.asDataURL('image/png'),
'modified':Date.now()};
}
@@ -97,12 +96,12 @@ define(
if(param=='ok'){
painterro.save();
}else{
rootscope.snapshot = "annotationCancelled";
ROOTSCOPE.snapshot = "annotationCancelled";
}
}
};
return annotateSnapshot;
return AnnotateSnapshot;
}
);

View File

@@ -30,7 +30,7 @@ define(
'mct-object="selObj">'+
'</mct-representation>';
function createSnapshot($compile,context) {
function CreateSnapshot($compile,context) {
context = context || {};
this.domainObject = context.selectedObject || context.domainObject;
this.context = context;
@@ -38,7 +38,7 @@ define(
}
createSnapshot.prototype.perform = function ($event,snapshot,embedId,entryId,$scope) {
CreateSnapshot.prototype.perform = function ($event,snapshot,embedId,entryId,$scope) {
var compile = this.$compile;
var model = this.domainObject.model;
var elementPos = model.entries.map(function(x) {return x.createdOn; }).indexOf(entryId)
@@ -56,6 +56,6 @@ define(
});
};
return createSnapshot;
return CreateSnapshot;
}
);

View File

@@ -68,7 +68,7 @@ define(
}]
};
function newEntryContextual($compile,$rootScope,dialogService,notificationService,linkService,context) {
function NewEntryContextual($compile,$rootScope,dialogService,notificationService,linkService,context) {
context = context || {};
this.domainObject = context.selectedObject || context.domainObject;
this.dialogService = dialogService;
@@ -83,7 +83,7 @@ define(
}
newEntryContextual.prototype.perform = function () {
NewEntryContextual.prototype.perform = function () {
var self = this;
var domainObj = this.domainObject;
@@ -184,12 +184,12 @@ define(
}
};
newEntryContextual.appliesTo = function (context) {
NewEntryContextual.appliesTo = function (context) {
var domainObject = context.domainObject;
return domainObject && domainObject.hasCapability("notebook") &&
domainObject.getCapability("notebook").isNotebook();
};
return newEntryContextual;
return NewEntryContextual;
}
);

View File

@@ -24,7 +24,7 @@ define(
[],
function () {
function removeEmbed(dialogService,context) {
function RemoveEmbed(dialogService,context) {
context = context || {};
this.domainObject = context.selectedObject || context.domainObject;
@@ -32,8 +32,8 @@ define(
}
removeEmbed.prototype.perform = function ($event,snapshot,embedId,entryId) {
var domainObj = this.domainObject;
RemoveEmbed.prototype.perform = function ($event,snapshot,embedId,entryId) {
var DOMAIN_OBJ = this.domainObject;
errorDialog = this.dialogService.showBlockingMessage({
severity: "error",
title: "This action will permanently delete this Embed. Do you want to continue?",
@@ -53,17 +53,16 @@ define(
});
function remove(){
domainObj.useCapability('mutation', function(model) {
DOMAIN_OBJ.useCapability('mutation', function(model) {
var elementPos = model.entries.map(function(x) {return x.createdOn; }).indexOf(entryId)
var entryEmbeds = model.entries[elementPos].embeds;
var embedPos = entryEmbeds.map(function(x) {return x.id; }).indexOf(embedId);
model.entries[elementPos].embeds.splice(embedPos,1);
});
}
};
return removeEmbed;
return RemoveEmbed;
}
);

View File

@@ -24,7 +24,7 @@ define(
[],
function () {
function removeSnapshot(dialogService,context) {
function RemoveSnapshot(dialogService,context) {
context = context || {};
this.domainObject = context.selectedObject || context.domainObject;
@@ -33,9 +33,9 @@ define(
removeSnapshot.prototype.perform = function ($event,snapshot,embedId,entryId) {
RemoveSnapshot.prototype.perform = function ($event,snapshot,embedId,entryId) {
var domainObj = this.domainObject;
var DOMAIN_OBJ = this.domainObject;
errorDialog = this.dialogService.showBlockingMessage({
severity: "error",
title: "This action will permanently delete this Snapshot. Do you want to continue?",
@@ -55,7 +55,7 @@ define(
});
function remove(){
domainObj.useCapability('mutation', function(model) {
DOMAIN_OBJ.useCapability('mutation', function(model) {
var elementPos = model.entries.map(function(x) {return x.createdOn; }).indexOf(entryId)
var entryEmbeds = model.entries[elementPos].embeds;
var embedPos = entryEmbeds.map(function(x) {return x.id; }).indexOf(embedId);
@@ -65,6 +65,6 @@ define(
};
return removeSnapshot;
return RemoveSnapshot;
}
);

View File

@@ -21,7 +21,7 @@
*****************************************************************************/
/**
* Module defining viewSnapshot (Originally NewWindowAction). Created by vwoeltje on 11/18/14.
* Module defining ViewSnapshot
*/
define(
[],
@@ -40,7 +40,7 @@ define(
' </div>';
function viewSnapshot($compile,context) {
function ViewSnapshot($compile,context) {
context = context || {};
this.$compile = $compile;
@@ -125,7 +125,7 @@ define(
}
viewSnapshot.prototype.perform = function($event,snapshot,embedId,entryId,$scope,embed) {
ViewSnapshot.prototype.perform = function($event,snapshot,embedId,entryId,$scope,embed) {
var isOpen = false;
// Create the overlay element and add it to the document's body
@@ -155,6 +155,6 @@ define(
toggleOverlay();
};
return viewSnapshot;
return ViewSnapshot;
}
);

View File

@@ -30,7 +30,7 @@ define(
*
* @constructor
*/
function noteBookCapability(typeService, domainObject) {
function NotebookCapability(typeService, domainObject) {
this.domainObject = domainObject;
this.typeService = typeService;
return this;
@@ -41,10 +41,10 @@ define(
*
* @returns {Boolean}
*/
noteBookCapability.prototype.isNotebook = function () {
return this.typeService.getType('notebook');;
NotebookCapability.prototype.isNotebook = function () {
return this.typeService.getType('notebook');
};
return noteBookCapability;
return NotebookCapability;
}
);

View File

@@ -0,0 +1,54 @@
/*****************************************************************************
* 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.
*****************************************************************************/
/**
* This bundle implements object types and associated views for
* display-building.
*/
define(
[],
function () {
/**
* The LayoutNotebookController is responsible for supporting the
* notebook feature creation on theLayout view.
**/
function LayoutNotebookController($scope) {
$scope.hasNotebookAction = undefined;
$scope.newNotebook = undefined;
var actions = $scope.domainObject.getCapability('action');
var notebookAction = actions.getActions({'key': 'notebook-new-entry'});
if (notebookAction.length > 0) {
$scope.hasNotebookAction = true;
$scope.newNotebook = function () {
notebookAction[0].perform();
};
}
}
return LayoutNotebookController;
}
);

View File

@@ -21,12 +21,12 @@
*****************************************************************************/
/**
* Module defining newEntryController. */
* Module defining NewEntryController. */
define(
[],
function () {
function newEntryController($scope,$rootScope) {
function NewEntryController($scope,$rootScope) {
$scope.snapshot = undefined;
$scope.snapToggle = true;
@@ -61,6 +61,6 @@ define(
}
}
return newEntryController;
return NewEntryController;
}
);

View File

@@ -27,7 +27,7 @@ define(
function () {
function notebookController(
function NotebookController(
$scope,
dialogService,
popupService,
@@ -42,13 +42,7 @@ define(
var showAll = true,
showCompleted;
var self = this;
$scope.entriesEl = $(document.body).find('.entries-list');
$scope.time = now();
$scope.AS = actionService;
$scope.sortEntries = '-createdOn';
$scope.showTime = "0";
$scope.editEntry = false;
@@ -59,7 +53,7 @@ define(
/*--seconds in an hour--*/
$scope.hourSecs = 60 * 60 * 1000;
SECONDS_IN_AN_HOUR = 60 * 60 * 1000;
this.scope = $scope;
@@ -74,7 +68,7 @@ define(
$scope.hoursFilter = function(hours,entryTime){
if(+hours){
return entryTime > (now() - $scope.hourSecs*(+hours));
return entryTime > (now() - SECONDS_IN_AN_HOUR *(+hours));
}else{
return true;
}
@@ -91,11 +85,15 @@ define(
var entries = $scope.domainObject.model.entries;
var lastEntry= entries[entries.length-1];
if(lastEntry==undefined || lastEntry.text || lastEntry.embeds){
$scope.domainObject.model.entries.push({'createdOn':now()});
$scope.domainObject.useCapability('mutation', function(model) {
model.entries.push({'createdOn':now()});
});
}else{
$scope.domainObject.model.entries[entries.length-1].createdOn = now();
}
$scope.domainObject.useCapability('mutation', function(model) {});
$scope.domainObject.useCapability('mutation', function(model) {
model.entries[entries.length-1].createdOn = now();
});
}
$scope.entrySearch = '';
};
@@ -112,11 +110,13 @@ define(
errorDialog.dismiss();
var elementPos = $scope.domainObject.model.entries.map(function(x) {return x.createdOn; }).indexOf(+delId.replace('entry_',''));
if(elementPos != -1){
$scope.domainObject.model.entries.splice(elementPos,1);
$scope.domainObject.useCapability('mutation', function(model) {
model.entries.splice(elementPos,1);
});
}else{
console.log('delete error');
}
$scope.domainObject.useCapability('mutation', function(model) {});
}
},{
label: "Cancel",
@@ -136,11 +136,12 @@ define(
$scope.textBlur = function($event,entryId){
if($event.target && $event.target.value !== ""){
var elementPos = $scope.domainObject.model.entries.map(function(x) {return x.createdOn}).indexOf(+(entryId));
$scope.domainObject.model.entries[elementPos].text = $event.target.value;
if($scope.currentEntryValue !== $event.target.value){
$scope.domainObject.model.entries[elementPos].createdOn = now();
}
$scope.domainObject.useCapability('mutation', function(model) {});
$scope.domainObject.useCapability('mutation', function(model) {
model.entries[elementPos].text = $event.target.value;
if($scope.currentEntryValue !== $event.target.value){
model.entries[elementPos].createdOn = now();
}
});
}
}
@@ -334,5 +335,5 @@ define(
$scope.$on('$destroy', function () {});
}
return notebookController;
return NotebookController;
});

View File

@@ -21,12 +21,12 @@
*****************************************************************************/
/**
* Module defining selectSnapshot. */
* Module defining SelectSnapshotController. */
define(
[],
function () {
function selectSnapshot($scope,$rootScope) {
function SelectSnapshotController($scope,$rootScope) {
$scope.selectModel = true;
@@ -39,6 +39,6 @@ define(
}
return selectSnapshot;
return SelectSnapshotController;
}
);

View File

@@ -0,0 +1,165 @@
/*****************************************************************************
* 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 (
$
) {
var OVERLAY_TEMPLATE = '' +
' <div class="abs blocker"></div>' +
' <div class="abs outer-holder">' +
' <a class="close icon-x-in-circle"></a>' +
' <div class="abs inner-holder l-flex-col">' +
' <div class="t-contents flex-elem holder grows"></div>' +
' <div class="bottom-bar flex-elem holder">' +
' <a class="t-done s-button major">Done</a>' +
' </div>' +
' </div>' +
' </div>';
var NEW_NOTEBOOK_TEMPLATE = '<a class="s-button icon-notebook new-notebook-entry" title="New Notebook Entry">' +
'<span class="title-label">New Notebook Entry</span>' +
'</a>';
/**
* MCT Trigger Modal is intended for use in only one location: inside the
* object-header to allow views in a layout to be popped out in a modal.
* Users can close the modal and go back to normal, and everything generally
* just works fine.
*
* This code is sensitive to how our html is constructed-- particularly with
* how it locates the the container of an element in a layout. However, it
* should be able to handle slight relocations so long as it is always a
* descendent of a `.frame` element.
*/
function MCTModalNotebook($document) {
var document = $document[0];
function link($scope, $element) {
var frame = $element.parent();
for (var i = 0; i < 10; i++) {
if (frame.hasClass('frame')) {
break;
}
frame = frame.parent();
}
if (!frame.hasClass('frame')) {
$element.remove();
return;
}
frame = frame[0];
var layoutContainer = frame.parentElement,
isOpen = false,
toggleOverlay,
overlay,
closeButton,
doneButton,
notebookButton,
blocker,
overlayContainer,
notebookButtonEl;
function openOverlay() {
// Remove frame classes from being applied in a non-frame context
$(frame).removeClass('frame frame-template');
overlay = document.createElement('div');
$(overlay).addClass('abs overlay l-large-view');
overlay.innerHTML = OVERLAY_TEMPLATE;
overlayContainer = overlay.querySelector('.t-contents');
closeButton = overlay.querySelector('a.close');
closeButton.addEventListener('click', toggleOverlay);
doneButton = overlay.querySelector('a.t-done');
doneButton.addEventListener('click', toggleOverlay);
blocker = overlay.querySelector('.abs.blocker');
blocker.addEventListener('click', toggleOverlay);
document.body.appendChild(overlay);
layoutContainer.removeChild(frame);
overlayContainer.appendChild(frame);
//verify if there is a new notebook entry action
var actions = $scope.domainObject.getCapability('action');
var notebookAction = actions.getActions({'key': 'notebook-new-entry'});
if (notebookAction.length > 0) {
notebookButtonEl = document.createElement('div');
$(notebookButtonEl).addClass('notebook-button-container');
notebookButtonEl.innerHTML = NEW_NOTEBOOK_TEMPLATE;
notebookButton = frame.querySelector('.object-browse-bar .left');
notebookButton.appendChild(notebookButtonEl);
$(frame.querySelector('.object-holder')).addClass('container-notebook');
notebookButton.addEventListener('click', function () {
notebookAction[0].perform();
});
}
}
function closeOverlay() {
$(frame).addClass('frame frame-template');
overlayContainer.removeChild(frame);
layoutContainer.appendChild(frame);
document.body.removeChild(overlay);
closeButton.removeEventListener('click', toggleOverlay);
closeButton = undefined;
doneButton.removeEventListener('click', toggleOverlay);
doneButton = undefined;
blocker.removeEventListener('click', toggleOverlay);
blocker = undefined;
overlayContainer = undefined;
overlay = undefined;
if (notebookButton) {
notebookButton.removeChild(notebookButtonEl);
}
}
toggleOverlay = function () {
if (!isOpen) {
openOverlay();
isOpen = true;
} else {
closeOverlay();
isOpen = false;
}
};
$element.on('click', toggleOverlay);
$scope.$on('$destroy', function () {
$element.off('click', toggleOverlay);
});
}
return {
restrict: 'A',
link: link
};
}
return MCTModalNotebook;
});

View File

@@ -30,10 +30,9 @@ define([
'mct-object="selObj">'+
'</mct-representation>';
function entryDnd($rootScope,$compile,dndService,typeService,notificationService) {
function EntryDnd($rootScope,$compile,dndService,typeService,notificationService) {
function link($scope, $element) {
var domainObj = $scope.domainObject;
function drop(e) {
var event = (e || {}).originalEvent || e,
@@ -46,20 +45,23 @@ define([
$scope.clearSearch();
if($element[0].id == 'newEntry'){
entryId = domainObj.model.entries.length;
entryId = $scope.domainObject.model.entries.length;
embedId = 0;
var lastEntry= domainObj.model.entries[entryId-1];
var lastEntry= $scope.domainObject.model.entries[entryId-1];
if(lastEntry==undefined || lastEntry.text || lastEntry.embeds){
domainObj.model.entries.push({'createdOn':+Date.now(),
'embeds':[{'type':selectedObject.getId(),
$scope.domainObject.useCapability('mutation', function(model) {
model.entries.push({'createdOn':+Date.now(),
'embeds':[{'type':selectedObject.getId(),
'id':''+Date.now(),
'cssClass':cssClass,
'name':selectedModel.name,
'snapshot':''
}]
});
});
}else{
domainObj.model.entries[entryId-1] =
$scope.domainObject.useCapability('mutation', function(model) {
model.entries[entryId-1] =
{'createdOn':+Date.now(),
'embeds':[{'type':selectedObject.getId(),
'id':''+Date.now(),
@@ -68,6 +70,7 @@ define([
'snapshot':''
}]
};
});
}
$scope.scrollToTop();
@@ -77,22 +80,23 @@ define([
}else{
entryId = domainObj.model.entries.map(function(x) {
entryId = $scope.domainObject.model.entries.map(function(x) {
return x.createdOn;
}).indexOf(+($element[0].id.replace('entry_','')));
if(!domainObj.model.entries[entryId].embeds){
domainObj.model.entries[entryId].embeds = [];
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':''
});
});
domainObj.model.entries[entryId].embeds.push({'type':selectedObject.getId(),
'id':''+Date.now(),
'cssClass':cssClass,
'name':selectedModel.name,
'snapshot':''
});
embedId = domainObj.model.entries[entryId].embeds.length-1;
embedId = $scope.domainObject.model.entries[entryId].embeds.length-1;
if (selectedObject) {
e.preventDefault();
@@ -125,7 +129,8 @@ define([
$scope.$on('$destroy', function () {
$element.off('dragover', dragover);
$element.off('drop', drop);
});
}
@@ -135,6 +140,6 @@ define([
};
}
return entryDnd;
return EntryDnd;
});

View File

@@ -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.
*****************************************************************************/
/**
* This bundle implements "containment" rules, which determine which objects
* can be contained within a notebook.
*/
define(
[],
function () {
function CompositionPolicy() {
}
CompositionPolicy.prototype.allow = function (parent, child) {
var parentDef = parent.getCapability('type').getName();
if(parentDef === 'Notebook' && child.getCapability('status').list().length){
return false;
}
return true;
};
return CompositionPolicy;
}
);

View File

@@ -19,36 +19,22 @@
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
/*global define,window*/
define(
[],
function () {
"use strict";
/**
* A tool for manually invoking notifications. When included this
* indicator will allow for notifications of different types to be
* launched for demonstration and testing purposes.
* @constructor
*/
function NotificationIndicator() {
function ViewPolicy() {
}
NotificationIndicator.template = 'notificationTemplate';
ViewPolicy.prototype.allow = function (view, domainObject) {
if(view.key === 'layout'){
return false;
}
NotificationIndicator.prototype.getGlyphClass = function () {
return 'ok';
};
NotificationIndicator.prototype.getText = function () {
return "Launch notification";
};
NotificationIndicator.prototype.getDescription = function () {
return "Launch notification";
return true;
};
return NotificationIndicator;
return ViewPolicy;
}
);

View File

@@ -48,7 +48,8 @@ requirejs.config({
"d3-format": "node_modules/d3-format/build/d3-format.min",
"d3-interpolate": "node_modules/d3-interpolate/build/d3-interpolate.min",
"d3-time": "node_modules/d3-time/build/d3-time.min",
"d3-time-format": "node_modules/d3-time-format/build/d3-time-format.min"
"d3-time-format": "node_modules/d3-time-format/build/d3-time-format.min",
"painterro": "node_modules/@cristian77/painterro/build/painterro.min"
},
"shim": {
"angular": {
@@ -66,6 +67,9 @@ requirejs.config({
"moment-duration-format": {
"deps": ["moment"]
},
"painterro": {
"exports": "painterro"
},
"screenfull": {
"exports": "screenfull"
},

View File

@@ -1,8 +1,9 @@
{
"name": "openmct",
"version": "0.12.1-SNAPSHOT",
"description": "The Open MCT core platform",
"description": "The Open MCT core platform -- notebook",
"dependencies": {
"@cristian77/painterro": "^0.2.48",
"d3-array": "^1.0.2",
"d3-axis": "^1.0.4",
"d3-collection": "^1.0.2",
@@ -14,6 +15,7 @@
"d3-time": "^1.0.4",
"d3-time-format": "^2.0.3",
"express": "^4.13.1",
"jasmine-core": "^2.5.2",
"minimist": "^1.1.1",
"request": "^2.69.0"
},

View File

@@ -44,7 +44,7 @@
ng-model="treeModel"
class="holder flex-elem grows vscroll tree-holder"
ng-hide="treeModel.search">
</mct-representation>
</mct-representation>
</div>
</div>

View File

@@ -64,7 +64,7 @@ define(
"composition",
parent,
domainObject
) && parent.model.type !== 'notebook';
);
}
sections.push({

View File

@@ -78,7 +78,7 @@
// Make icon lighten when hovering over search bar
&:hover:before {
/*color: pullForward($colorInputIcon, 10%);*/
color: pullForward($colorInputIcon, 10%);
}
.clear-input {
@@ -94,7 +94,7 @@
}
&:hover {
/*color: pullForward($colorInputIcon, 10%);*/
color: pullForward($colorInputIcon, 10%);
}
}
@@ -105,7 +105,7 @@
right: $iconEdgeM;
text-align: right;
&:hover {
/*color: pullForward($colorInputIcon, 10%);*/
color: pullForward($colorInputIcon, 10%);
}
}

View File

@@ -34,11 +34,6 @@
ng-model="representation"
mct-object="domainObject">
</mct-representation>
<a class="s-button icon-notebook t-btn-view-large"
title="New Notebook Entry"
ng-if="parameters"
ng-click="ngModel()">
</a>
<a class="s-button icon-expand t-btn-view-large"
title="View large"
mct-trigger-modal>

View File

@@ -42,8 +42,6 @@
<mct-representation key="'frame'"
class="t-rep-frame holder contents abs"
parameters = "hasNotebookAction"
ng-model="newNotebook"
mct-object="childObject">
</mct-representation>
<!-- Drag handles -->

View File

@@ -50,10 +50,6 @@ define(
var self = this,
callbackCount = 0;
$scope.hasNotebookAction = undefined;
$scope.newNotebook = undefined;
// Update grid size when it changed
function updateGridSize(layoutGrid) {
var oldSize = self.gridSize;
@@ -173,17 +169,6 @@ define(
// Update composed objects on screen, and position panes
$scope.$watchCollection("model.composition", refreshComposition);
var actions = $scope.domainObject.getCapability('action');
var notebookAction = actions.getActions({'key':'notebook-new-entry'});
if(notebookAction.length > 0){
$scope.hasNotebookAction = true;
$scope.newNotebook = function(){
notebookAction[0].perform();
}
}
// Position panes where they are dropped
$scope.$on("mctDrop", handleDrop);
}

View File

@@ -38,10 +38,6 @@ define([
' </div>' +
' </div>';
var NEW_NOTEBOOK_TEMPLATE = '<a class="s-button icon-notebook new-notebook-entry" title="New Notebook Entry">'+
'<span class="title-label">New Notebook Entry</span>'+
'</a>';
/**
* MCT Trigger Modal is intended for use in only one location: inside the
* object-header to allow views in a layout to be popped out in a modal.
@@ -77,12 +73,10 @@ define([
overlay,
closeButton,
doneButton,
notebookButton,
blocker,
overlayContainer,
notebookButtonEl;
overlayContainer;
function openOverlay() {
function openOverlay() {
// Remove frame classes from being applied in a non-frame context
$(frame).removeClass('frame frame-template');
@@ -99,22 +93,6 @@ define([
document.body.appendChild(overlay);
layoutContainer.removeChild(frame);
overlayContainer.appendChild(frame);
//verify if there is a new notebook entry action
var actions = $scope.domainObject.getCapability('action');
var notebookAction = actions.getActions({'key':'notebook-new-entry'});
if(notebookAction.length > 0){
notebookButtonEl = document.createElement('div');
$(notebookButtonEl).addClass('notebook-button-container');
notebookButtonEl.innerHTML = NEW_NOTEBOOK_TEMPLATE;
notebookButton = frame.querySelector('.object-browse-bar .left');
notebookButton.appendChild(notebookButtonEl);
$(frame.querySelector('.object-holder')).addClass('container-notebook');
notebookButton.addEventListener('click', function(){
notebookAction[0].perform();
});
}
}
function closeOverlay() {
@@ -130,12 +108,6 @@ define([
blocker = undefined;
overlayContainer = undefined;
overlay = undefined;
if(notebookButton){
notebookButton.removeChild(notebookButtonEl);
}
}
toggleOverlay = function () {

View File

@@ -75,7 +75,8 @@ requirejs.config({
"d3-format": "node_modules/d3-format/build/d3-format.min",
"d3-interpolate": "node_modules/d3-interpolate/build/d3-interpolate.min",
"d3-time": "node_modules/d3-time/build/d3-time.min",
"d3-time-format": "node_modules/d3-time-format/build/d3-time-format.min"
"d3-time-format": "node_modules/d3-time-format/build/d3-time-format.min",
"painterro": "node_modules/@cristian77/painterro/build/painterro.min"
},
"shim": {