Skip to content

Commit 45d5b07

Browse files
filenames fix
1 parent 07d7f8f commit 45d5b07

16 files changed

+1743
-0
lines changed
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
/*****************************************************************************
2+
* Open MCT, Copyright (c) 2014-2017, United States Government
3+
* as represented by the Administrator of the National Aeronautics and Space
4+
* Administration. All rights reserved.
5+
*
6+
* Open MCT is licensed under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
* http://www.apache.org/licenses/LICENSE-2.0.
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
* License for the specific language governing permissions and limitations
15+
* under the License.
16+
*
17+
* Open MCT includes source code licensed under additional open source
18+
* licenses. See the Open Source Licenses file (LICENSES.md) included with
19+
* this source code distribution or the Licensing information page available
20+
* at runtime from the About dialog for additional information.
21+
*****************************************************************************/
22+
23+
/**
24+
* Module defining viewSnapshot (Originally NewWindowAction). Created by vwoeltje on 11/18/14.
25+
*/
26+
define(
27+
["painterro"],
28+
function () {
29+
30+
var ANNOTATION_STRUCT = {
31+
title: "Annotate Snapshot",
32+
template: "annotate-snapshot",
33+
options: [{
34+
name: "OK",
35+
key: "ok",
36+
description:"save annotation"
37+
},
38+
{
39+
name: "Cancel",
40+
key: "cancel",
41+
description:"cancel editing"
42+
}]
43+
};
44+
45+
function AnnotateSnapshot(dialogService,dndService,$rootScope,context) {
46+
context = context || {};
47+
48+
// Choose the object to be opened into a new tab
49+
this.domainObject = context.selectedObject || context.domainObject;
50+
this.dialogService = dialogService;
51+
this.dndService = dndService;
52+
this.$rootScope = $rootScope;
53+
}
54+
55+
56+
57+
58+
AnnotateSnapshot.prototype.perform = function ($event,snapshot,embedId,entryId,$scope) {
59+
60+
var DOMAIN_OBJECT = this.domainObject;
61+
var ROOTSCOPE = this.$rootScope;
62+
63+
this.dialogService.getUserChoice(ANNOTATION_STRUCT)
64+
.then(saveNotes);
65+
66+
var painterro;
67+
68+
var tracker = function(){
69+
$(document.body).find('.l-dialog .outer-holder').addClass('annotation-dialog');
70+
painterro = Painterro({
71+
id: 'snap-annotation',
72+
backgroundFillColor: '#eee',
73+
hiddenTools:['save', 'open', 'close','eraser'],
74+
saveHandler: function (image, done) {
75+
if(entryId && embedId){
76+
var elementPos = DOMAIN_OBJECT.model.entries.map(function(x) {return x.createdOn; }).indexOf(entryId)
77+
var entryEmbeds = DOMAIN_OBJECT.model.entries[elementPos].embeds;
78+
var embedPos = entryEmbeds.map(function(x) {return x.id; }).indexOf(embedId);
79+
$scope.saveSnap(image.asBlob(),embedPos,elementPos);
80+
}else{
81+
ROOTSCOPE.snapshot = {'src':image.asDataURL('image/png'),
82+
'modified':Date.now()};
83+
}
84+
85+
done(true);
86+
}
87+
}).show(snapshot);
88+
89+
}
90+
91+
ANNOTATION_STRUCT.model = {'tracker':tracker};
92+
93+
94+
95+
function saveNotes(param){
96+
if(param=='ok'){
97+
painterro.save();
98+
}else{
99+
ROOTSCOPE.snapshot = "annotationCancelled";
100+
}
101+
}
102+
103+
};
104+
105+
return AnnotateSnapshot;
106+
}
107+
);
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*****************************************************************************
2+
* Open MCT, Copyright (c) 2014-2017, United States Government
3+
* as represented by the Administrator of the National Aeronautics and Space
4+
* Administration. All rights reserved.
5+
*
6+
* Open MCT is licensed under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
* http://www.apache.org/licenses/LICENSE-2.0.
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
* License for the specific language governing permissions and limitations
15+
* under the License.
16+
*
17+
* Open MCT includes source code licensed under additional open source
18+
* licenses. See the Open Source Licenses file (LICENSES.md) included with
19+
* this source code distribution or the Licensing information page available
20+
* at runtime from the About dialog for additional information.
21+
*****************************************************************************/
22+
23+
define(
24+
[],
25+
function () {
26+
27+
var SNAPSHOT_TEMPLATE = '<mct-representation key="\'draggedEntry\'"'+
28+
'parameters="{entry:entryId,embed:embedId}"'+
29+
'class="t-rep-frame holder"'+
30+
'mct-object="selObj">'+
31+
'</mct-representation>';
32+
33+
function CreateSnapshot($compile,context) {
34+
context = context || {};
35+
this.domainObject = context.selectedObject || context.domainObject;
36+
this.context = context;
37+
this.$compile = $compile;
38+
}
39+
40+
41+
CreateSnapshot.prototype.perform = function ($event,snapshot,embedId,entryId,$scope) {
42+
var compile = this.$compile;
43+
var model = this.domainObject.model;
44+
var elementPos = model.entries.map(function(x) {return x.createdOn; }).indexOf(entryId)
45+
var entryEmbeds = model.entries[elementPos].embeds;
46+
var embedPos = entryEmbeds.map(function(x) {return x.id; }).indexOf(embedId);
47+
var embedType = entryEmbeds[embedPos].type;
48+
49+
$scope.getDomainObj(embedType).then(function(resp){
50+
if(entryId >= 0 && embedId >= 0){
51+
$scope.selObj = resp[embedType];
52+
$scope.entryId = elementPos;
53+
$scope.embedId = embedPos;
54+
var element = compile(SNAPSHOT_TEMPLATE)($scope);
55+
}
56+
});
57+
};
58+
59+
return CreateSnapshot;
60+
}
61+
);
Lines changed: 195 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
1+
/*****************************************************************************
2+
* Open MCT, Copyright (c) 2014-2017, United States Government
3+
* as represented by the Administrator of the National Aeronautics and Space
4+
* Administration. All rights reserved.
5+
*
6+
* Open MCT is licensed under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
* http://www.apache.org/licenses/LICENSE-2.0.
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
* License for the specific language governing permissions and limitations
15+
* under the License.
16+
*
17+
* Open MCT includes source code licensed under additional open source
18+
* licenses. See the Open Source Licenses file (LICENSES.md) included with
19+
* this source code distribution or the Licensing information page available
20+
* at runtime from the About dialog for additional information.
21+
*****************************************************************************/
22+
define(
23+
[],
24+
function () {
25+
26+
var SNAPSHOT_TEMPLATE = '<mct-representation key="\'draggedEntry\'"'+
27+
'class="t-rep-frame holder"'+
28+
'mct-object="selObj">'+
29+
'</mct-representation>';
30+
31+
var NEW_TASK_FORM = {
32+
name: "Create a Notebook Entry",
33+
hint: "Please select one Notebook",
34+
sections: [{
35+
rows: [{
36+
name: 'Entry',
37+
key: 'entry',
38+
control: 'textarea',
39+
required: true,
40+
"cssClass": "l-textarea-sm"
41+
},
42+
{
43+
name: 'Embed Type',
44+
key: 'withSnapshot',
45+
control: 'snapshot-select',
46+
"options": [
47+
{
48+
"name": "Link and Snapshot",
49+
"value": true
50+
},
51+
{
52+
"name": "Link only",
53+
"value": false
54+
}
55+
]
56+
},
57+
{
58+
name: 'Embed',
59+
key: 'embedObject',
60+
control: 'embed-control'
61+
},
62+
{
63+
name: 'Save in Notebook',
64+
key: 'saveNotebook',
65+
control: 'locator',
66+
validate: validateLocation
67+
}]
68+
}]
69+
};
70+
71+
function NewEntryContextual($compile,$rootScope,dialogService,notificationService,linkService,context) {
72+
context = context || {};
73+
this.domainObject = context.selectedObject || context.domainObject;
74+
this.dialogService = dialogService;
75+
this.notificationService = notificationService;
76+
this.linkService = linkService;
77+
this.$rootScope = $rootScope;
78+
this.$compile = $compile;
79+
}
80+
81+
function validateLocation(newParentObj) {
82+
return newParentObj.model.type == 'notebook';
83+
}
84+
85+
86+
NewEntryContextual.prototype.perform = function () {
87+
88+
var self = this;
89+
var domainObj = this.domainObject;
90+
var notification = this.notificationService;
91+
var linkService = this.linkService;
92+
var dialogService = this.dialogService;
93+
var rootScope = this.$rootScope;
94+
rootScope.newEntryText = '';
95+
// Create the overlay element and add it to the document's body
96+
this.$rootScope.selObj = domainObj;
97+
this.$rootScope.selValue = "";
98+
var newScope = rootScope.$new();
99+
newScope.selObj = domainObj;
100+
newScope.selValue = "";
101+
var element = this.$compile(SNAPSHOT_TEMPLATE)(newScope);
102+
//newScope.$destroy();
103+
104+
this.$rootScope.$watch("snapshot", setSnapshot);
105+
106+
function setSnapshot(value){
107+
if(value === "annotationCancelled"){
108+
rootScope.snapshot = rootScope.lastValue;
109+
rootScope.lastValue = '';
110+
}else if(value && value !== rootScope.lastValue){
111+
var overlayModel = {
112+
title: NEW_TASK_FORM.name,
113+
message: NEW_TASK_FORM.message,
114+
structure: NEW_TASK_FORM,
115+
value: {'entry': rootScope.newEntryText || ""}
116+
};
117+
118+
// Provide result from the model
119+
function resultGetter() {
120+
return overlayModel.value;
121+
}
122+
123+
rootScope.currentDialog = overlayModel;
124+
125+
dialogService.getDialogResponse(
126+
"overlay-dialog",
127+
overlayModel,
128+
resultGetter
129+
).then(addNewEntry);
130+
131+
rootScope.lastValue = value;
132+
}
133+
}
134+
135+
function addNewEntry(options){
136+
options.selectedModel = options.embedObject.getModel();
137+
options.cssClass= options.embedObject.getCapability('type').typeDef.cssClass;
138+
if(self.$rootScope.snapshot){
139+
options.snapshot= self.$rootScope.snapshot;
140+
self.$rootScope.snapshot = undefined;
141+
}else{
142+
options.snapshot = undefined;
143+
}
144+
145+
if(!options.withSnapshot){
146+
options.snapshot = '';
147+
}
148+
149+
createSnap(options);
150+
}
151+
152+
function createSnap(options){
153+
options.saveNotebook.useCapability('mutation', function(model) {
154+
var entries = model.entries;
155+
var lastEntry= entries[entries.length-1];
156+
if(lastEntry==undefined || lastEntry.text || lastEntry.embeds){
157+
model.entries.push({
158+
'createdOn':Date.now(),
159+
'text': options.entry,
160+
'embeds':[{'type':options.embedObject.getId(),
161+
'id':''+Date.now(),
162+
'cssClass':options.cssClass,
163+
'name':options.selectedModel.name,
164+
'snapshot':options.snapshot
165+
}]
166+
});
167+
}else{
168+
model.entries[entries.length-1] = {
169+
'createdOn':Date.now(),
170+
'text': options.entry,
171+
'embeds':[{'type':options.embedObject.getId(),
172+
'id':''+Date.now(),
173+
'cssClass':options.cssClass,
174+
'name':options.selectedModel.name,
175+
'snapshot':options.snapshot
176+
}]
177+
};
178+
}
179+
});
180+
181+
notification.info({
182+
title: "Notebook Entry created"
183+
});
184+
}
185+
};
186+
187+
NewEntryContextual.appliesTo = function (context) {
188+
var domainObject = context.domainObject;
189+
return domainObject && domainObject.hasCapability("notebook") &&
190+
domainObject.getCapability("notebook").isNotebook();
191+
};
192+
193+
return NewEntryContextual;
194+
}
195+
);

0 commit comments

Comments
 (0)