LocalParamNode.js
7.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
/**
* Project : AMDA-NG4
* Name : LocalParamNode.js
* @class amdaModel.LocalParamNode
* @extends amdaModel.InteractiveNode
* @brief Basic Model of Node corresponding to a amda parameter
* @author
* @version $Id: LocalParamNode.js 2800 2015-02-27 16:23:06Z elena $
*/
Ext.define('amdaModel.LocalParamNode',
{
extend: 'amdaModel.InteractiveNode',
statics: {
nodeType: 'localParam'
},
fields: [
{name: 'alias', type:'string', persist: false},
{name: 'isParameter', type: 'boolean', persist: false},
{name: 'notyet', type: 'boolean', defaultValue: false, persist: false},
{name: 'isSpectra', type: 'boolean', defaultValue: false, persist: false},
{name: 'isStack', type: 'boolean', defaultValue: true, persist: false},
{name: 'globalStart', type: 'string', persist: false},
{name: 'globalStop', type: 'string', persist: false},
{name: 'timeRestriction', type: 'boolean', persist: false},
{name: 'rank', type: 'integer', persist: false, defaultValue: null}
],
icons : {'1' : 'icon-mercury','2' : 'icon-venus','3' : 'icon-sw','4' : 'icon-sw','5' : 'icon-earth','6' : 'icon-earth',
'7' : 'icon-mars','8' : 'icon-jupiter','9' : 'icon-saturn','10' : 'icon-uranus','11' : 'icon-neptune',
'93' :'icon-comet', '99' :'icon-solarsystem', '999' :'icon-solarsystem'
},
constructor : function(config)
{
this.callParent(arguments);
this.set('allowDrop', true);
this.set('moduleId',myDesktopApp.dynamicModules.param.id);
this.set('objectDataModel',amdaModel.Parameter.$className);
// if future missions or 'depending on mission'
if (this.get('globalStart')) {
var now = Ext.Date.format(new Date(), 'Y/m/d');
if ( this.get('globalStart') > now )
this.set('cls','predicted');
}
// // time restriction on parameters
// if (this.get('timeRestriction')) {
// TBD
// }
if (this.get('rank')) {
var rank = this.get('rank');
this.set('iconCls', this.icons[rank]);
}
if (this.get('isParameter')) {
if (this.get('leaf'))
this.set('iconCls', 'icon-scalar');
else
this.set('iconCls', 'icon-vector');
if (this.get('isStack') || this.get('isSpectra'))
this.set('iconCls', 'icon-spectra');
}
},
allMenuItems : function()
{
var menuItems =
[{
fnId : 'root-collapseAll',
text : 'Close All',
hidden : true
}, {
fnId : 'dire-collapseAll',
text : 'Close All',
hidden : true
}, {
fnId : 'miss-collapseAll',
text : 'Close All',
hidden : true
}, {
fnId : 'para-plotParam',
text : 'Plot Parameter',
hidden : true
}, {
fnId : 'para-downParam',
text : 'Download Parameter',
hidden : true
},{
fnId : 'para-createDerivedParam',
text : 'Create Derived Parameter',
hidden : true
}, {
fnId : 'leaf-createAlias',
text : 'Create/Edit Alias',
hidden : true
},{
fnId : 'leaf-createDerivedParam',
text : 'Create Derived Parameter',
hidden : true
},{
fnId : 'leaf-plotParam',
text : 'Plot Parameter',
hidden : true
}, {
fnId : 'leaf-downParam',
text : 'Download Parameter',
hidden : true
}, {
fnId : 'miss-epnTap',
text : 'Display EPN-TAP services',
hidden : true
}];
return menuItems;
},
onMenuItemClick : function(menu,item,event)
{
switch (item.fnId)
{
case 'root-collapseAll':
case 'dire-collapseAll':
case 'miss-collapseAll':
if(this && !this.isLeaf()) {
this.collapse(true);
}
break;
case 'leaf-plotParam':
case 'para-plotParam':
this.createPlot(this);
break;
case 'leaf-downParam':
case 'para-downParam':
if (!this.get('disable')) {
if (this.get('notyet')) {
myDesktopApp.warningMsg("Sorry! this parameter is PlotOnly");
}
else {
this.createDownload(this);
}
}
break;
case 'para-createDerivedParam':
case 'leaf-createDerivedParam':
if (!this.get('disable')) {
if (this.get('notyet')) {
myDesktopApp.warningMsg("Sorry! this parameter is PlotOnly");
}
else {
this.createLeaf(this);
}
}
break;
case 'leaf-createAlias':
if (!this.get('disable')) {
if (this.get('notyet')) {
myDesktopApp.warningMsg("Sorry! this parameter is PlotOnly");
}
else {
this.createAlias(this);
}
}
break;
case 'miss-epnTap':
this.displayEpnTap();
break;
default:
break;
}
},
createLeaf: function(node)
{
myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.param.id, true, function(module) {
if (!myDesktopApp.desktop.getWindow(myDesktopApp.dynamicModules.param.id)) {
var param = Ext.create(node.get('objectDataModel'));
var newNode = Ext.create(amdaModel.DerivedParamNode.$className, {leaf : true, object : param});
// edit newNode into Parameter Module with node as contextNode
newNode.editInModule();
}
var paramName;
var components = null;
if (node.get('alias')!= "" )
paramName = "#"+node.get('alias');
else
paramName = node.get('id');
module.addParam(paramName,node.get('leaf'),node.get('needsArgs'),components);
});
},
createAlias: function(node)
{
var win = myDesktopApp.desktop.getWindow('alias-win');
if (!node.get('needsArgs') && node.get('leaf'))
{
if(!win)
{
var win = myDesktopApp.desktop.createWindow(
{
border: false,
id : 'alias-win',
title : 'Create Alias',
width : 400,
height : 200,
layout : 'border',
maximizable : false,
items :
[{
xtype : 'alias',
region : 'center',
margins :
{
top: 0,
right: 5,
bottom: 5,
left: 5
},
paramNode : node,
id : 'aliasUI'
}]
});
}
else
{
//Set data into Alias Widget
win.items.items[0].paramNode = node;
win.items.items[0].setAlias(node);
}
win.show();
}
else
{
var message = 'Sorry, parameter ' + node.get('id') + ' cannot have alias';
Ext.Msg.alert('Impossible Create Alias', message);
if (win) win.close();
}
},
isParameter : function()
{
return this.get('isParameter');
},
displayEpnTap: function () {
const missions = {
'Giotto': '1P',
'ICE': '21P',
'Rosetta': '67P',
'Voyager': 'Jupiter, Io, Thébé, Métis Adrastée, Europe, ' +
'Saturn, Atlas, Prométhée, Pandore, Téthys, Japet, Encelade, Uranus, Mirandaneptune, Triton',
'Pioneer': 'Earth, Moon, Venus, Jupiter, Callisto, Ganymede, Io, Europa, Amalthea, Saturn, Iapetus, Phoebe, ' +
'Hyperion, Epimetheus, Atlas, Dione, Mimas, Janus, Tethys, Enceladus, Calypso, Rhea, Titan',
'Ulysses': 'Sun',
'Solar_Probe_Plus': 'Sun',
'Solar_Orbiter': 'Sun',
'Ephemerides': 'Mercury, Venus, Earth, Mars, Jupiter, Saturn, Uranus, Neptune, Deimos, Phobos, 67P'
}
const icons = {
'icon-mercury': 'Mercury',
'icon-venus': 'Venus',
'icon-earth': 'Earth',
'icon-mars': 'Mars',
'icon-jupiter': 'Jupiter',
'icon-saturn': 'Saturn',
'icon-sw': 'Earth, Sun'
}
const targetName = this.get('id') in missions ? missions[this.get('id')]
: this.get('iconCls') in icons ? icons[this.get('iconCls')]
: ''
const start = this.get('globalStart') ? this.get('globalStart') : ''
const stop = this.get('globalStop') ? this.get('globalStop') : ''
const filter = {'productType': 'all', 'targetName': targetName, 'start': start, 'stop': stop}
myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.interop.id, true, function (module) {
module.createWindow({'activeTab': 2, 'epntapFilter': filter})
})
}
});