Blame view

js/app/models/LocalParamNode.js 8.12 KB
10200969   Roipoussiere   Remove whitespace...
1
/**
16035364   Benjamin Renard   First commit
2
3
4
5
6
 * Project  : AMDA-NG4
 * Name     : LocalParamNode.js
 * @class   amdaModel.LocalParamNode
 * @extends amdaModel.InteractiveNode
 * @brief   Basic Model of Node corresponding to a amda  parameter
10200969   Roipoussiere   Remove whitespace...
7
8
 * @author
 * @version $Id: LocalParamNode.js 2800 2015-02-27 16:23:06Z elena $
16035364   Benjamin Renard   First commit
9
10
 */

10200969   Roipoussiere   Remove whitespace...
11
Ext.define('amdaModel.LocalParamNode',
16035364   Benjamin Renard   First commit
12
{
eec153c1   Elena.Budnik   formattage, netto...
13
14
15
16
17
18
	extend: 'amdaModel.InteractiveNode',

	statics:
	{
		nodeType: 'localParam'
	},
10200969   Roipoussiere   Remove whitespace...
19
20

	fields:
eec153c1   Elena.Budnik   formattage, netto...
21
22
	[
		{name: 'alias', type:'string', persist: false},
10200969   Roipoussiere   Remove whitespace...
23
		{name: 'isParameter', type: 'boolean', persist: false},
eec153c1   Elena.Budnik   formattage, netto...
24
25
26
27
28
29
		{name: 'notyet', type: 'boolean', defaultValue: false, persist: false},
		{name: 'needsArgs', type: 'boolean', 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},
10200969   Roipoussiere   Remove whitespace...
30
		{name: 'timeRestriction', type: 'boolean', persist: false},
eec153c1   Elena.Budnik   formattage, netto...
31
		{name: 'rank', type: 'integer', persist: false, defaultValue: null}
10200969   Roipoussiere   Remove whitespace...
32
	],
16035364   Benjamin Renard   First commit
33

eec153c1   Elena.Budnik   formattage, netto...
34
	constructor : function(config)
10200969   Roipoussiere   Remove whitespace...
35
	{
eec153c1   Elena.Budnik   formattage, netto...
36
37
38
39
40
		this.callParent(arguments);

		this.set('allowDrop', true);
		this.set('moduleId',myDesktopApp.dynamicModules.param.id);
		this.set('objectDataModel',amdaModel.Parameter.$className);
10200969   Roipoussiere   Remove whitespace...
41

eec153c1   Elena.Budnik   formattage, netto...
42
		// if future missions or 'depending on mission'
10200969   Roipoussiere   Remove whitespace...
43
44
		if (this.get('globalStart')) {
		var now = Ext.Date.format(new Date(), 'Y/m/d');
eec153c1   Elena.Budnik   formattage, netto...
45
46
47
		if ( this.get('globalStart') > now )
			this.set('cls','predicted');
		}
a0f13ed1   Elena.Budnik   small format + ti...
48
49
50
51
52
53
54
55
56
57
58
59
60
// 		// time restriction on parameters
// 		if (this.get('timeRestriction')) {
// 		//      this.set('cls','predicted');
// 			var id = this.get('id');
// 			var bracketPos =  id.indexOf("(");
// 			if (bracketPos > 0) {
// 				id = Ext.String.insert(id, '_restr', bracketPos);
// 			}
// 			else {
// 				id += '_restr';
// 			}
// 			this.set('id', id);
// 		}
10200969   Roipoussiere   Remove whitespace...
61
62

		if (this.get('rank')) {
eec153c1   Elena.Budnik   formattage, netto...
63
64
65
			var rank = this.get('rank');
			if (rank == 1) this.set('iconCls', 'icon-mercury');
			if (rank == 2) this.set('iconCls', 'icon-venus');
085aaa36   Elena.Budnik   add uranus neptun...
66
			if (rank == 5 || rank == 6) this.set('iconCls', 'icon-earth');
eec153c1   Elena.Budnik   formattage, netto...
67
			if (rank == 7) this.set('iconCls', 'icon-mars');
10200969   Roipoussiere   Remove whitespace...
68
			if (rank == 8) this.set('iconCls', 'icon-jupiter');
eec153c1   Elena.Budnik   formattage, netto...
69
			if (rank == 9) this.set('iconCls', 'icon-saturn');
085aaa36   Elena.Budnik   add uranus neptun...
70
71
			if (rank == 10) this.set('iconCls', 'icon-uranus'); 
			if (rank == 11) this.set('iconCls', 'icon-neptune');   
10200969   Roipoussiere   Remove whitespace...
72
			if (rank == 93) this.set('iconCls', 'icon-comet');
085aaa36   Elena.Budnik   add uranus neptun...
73
			if (rank == 3 || rank == 4) this.set('iconCls', 'icon-sw');
eec153c1   Elena.Budnik   formattage, netto...
74
75
			if (rank >= 99) this.set('iconCls', 'icon-solarsystem');
		}
10200969   Roipoussiere   Remove whitespace...
76
77
78
79
80
81
82
83
84

		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'))
eec153c1   Elena.Budnik   formattage, netto...
85
86
87
				this.set('iconCls', 'icon-spectra');
		}
	},
16035364   Benjamin Renard   First commit
88

10200969   Roipoussiere   Remove whitespace...
89
	allMenuItems : function()
eec153c1   Elena.Budnik   formattage, netto...
90
91
92
93
94
95
96
97
98
99
100
	{
		var menuItems =
		[{
			fnId : 'root-collapseAll',
			text : 'Close All',
			hidden : true
		}, {
			fnId : 'dire-collapseAll',
			text : 'Close All',
			hidden : true
		}, {
30cd92df   Roipoussiere   Fix merge conflicts
101
102
103
104
			fnId : 'miss-collapseAll',
			text : 'Close All',
			hidden : true
		}, {
eec153c1   Elena.Budnik   formattage, netto...
105
106
107
108
109
110
111
112
113
114
			fnId : 'para-plotParam',
			text : 'Plot Parameter',
			hidden : true
		}, {
			fnId : 'para-downParam',
			text : 'Download Parameter',
			hidden : true
		},{
			fnId : 'leaf-createAlias',
			text : 'Create/Edit Alias',
10200969   Roipoussiere   Remove whitespace...
115
116
			hidden : true
		},{
eec153c1   Elena.Budnik   formattage, netto...
117
118
119
120
121
122
123
124
125
126
127
			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
30cd92df   Roipoussiere   Fix merge conflicts
128
129
130
131
		}, {
			fnId : 'miss-epnTap',
			text : 'Display EPN-TAP services',
			hidden : true
eec153c1   Elena.Budnik   formattage, netto...
132
		}];
16035364   Benjamin Renard   First commit
133

eec153c1   Elena.Budnik   formattage, netto...
134
135
		return menuItems;
	},
10200969   Roipoussiere   Remove whitespace...
136
137

	onMenuItemClick : function(menu,item,event)
eec153c1   Elena.Budnik   formattage, netto...
138
	{
10200969   Roipoussiere   Remove whitespace...
139
		switch (item.fnId)
eec153c1   Elena.Budnik   formattage, netto...
140
141
142
143
144
145
		{
			case 'root-collapseAll':
			case 'dire-collapseAll':
				if(this && !this.isLeaf()) {
					this.collapse(true);
				}
10200969   Roipoussiere   Remove whitespace...
146
				break;
eec153c1   Elena.Budnik   formattage, netto...
147
			case 'leaf-plotParam':
10200969   Roipoussiere   Remove whitespace...
148
149
			case 'para-plotParam':
					this.createPlot(this);
eec153c1   Elena.Budnik   formattage, netto...
150
151
				break;
			case 'leaf-downParam':
10200969   Roipoussiere   Remove whitespace...
152
153
			case 'para-downParam':
					this.createDownload(this);
eec153c1   Elena.Budnik   formattage, netto...
154
155
156
				break;
			case 'leaf-createDerivedParam':
				if (!this.get('notyet'))
10200969   Roipoussiere   Remove whitespace...
157
158
159
					this.createLeaf(this);
				else
					myDesktopApp.warningMsg("Sorry! access to this parameter is restricted");
eec153c1   Elena.Budnik   formattage, netto...
160
				break;
10200969   Roipoussiere   Remove whitespace...
161
			case 'leaf-createAlias':
eec153c1   Elena.Budnik   formattage, netto...
162
				if (!this.get('notyet'))
10200969   Roipoussiere   Remove whitespace...
163
					this.createAlias(this);
eec153c1   Elena.Budnik   formattage, netto...
164
165
				else
					myDesktopApp.warningMsg("Sorry! access to this parameter is restricted");
10200969   Roipoussiere   Remove whitespace...
166

eec153c1   Elena.Budnik   formattage, netto...
167
				break;
d2d8b461   Nathanael Jourdane   Display epntap co...
168
			case 'miss-epnTap':
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
169
				this.displayEpnTap();
30cd92df   Roipoussiere   Fix merge conflicts
170
				break;
eec153c1   Elena.Budnik   formattage, netto...
171
172
173
174
			default:
				break;
		}
	},
10200969   Roipoussiere   Remove whitespace...
175
176
177

	createLeaf: function(node)
	{
eec153c1   Elena.Budnik   formattage, netto...
178
179
180
		// instanciate a Parameter object with the current data in his buidchain
		var param =  Ext.create(this.get('objectDataModel'));//, { buildchain: node.get('alias') ? "#"+node.get('alias') : node.get('id') });
		// instanciate a DerivedParamNode with this param object
10200969   Roipoussiere   Remove whitespace...
181
		var newNode = Ext.create(amdaModel.DerivedParamNode.$className, {leaf : true, object : param});
16035364   Benjamin Renard   First commit
182

eec153c1   Elena.Budnik   formattage, netto...
183
184
		// edit newNode into Parameter Module with node as contextNode
		newNode.editInModule();
10200969   Roipoussiere   Remove whitespace...
185

eec153c1   Elena.Budnik   formattage, netto...
186
187
188
189
190
		var module = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.param.id, true, function(module) {
			var paramName;
			var components = null;
			if (node.get('alias')!= "" )
				paramName = "#"+node.get('alias');
10200969   Roipoussiere   Remove whitespace...
191
			else
eec153c1   Elena.Budnik   formattage, netto...
192
				paramName = node.get('id');
9fad5834   Elena.Budnik   redmine #4795
193
194
195
196
197
198
199
200
201
202
// 			var component_info = node.get('component_info');
// 			if (component_info && component_info.parentId) {
// 				//It's a component
// 				paramName = component_info.parentId;
// 				components = [];
// 				if (component_info.index1)
// 					components['index1'] = component_info.index1;
// 				if (component_info.index2)
// 					components['index2'] = component_info.index2;
// 			}
10200969   Roipoussiere   Remove whitespace...
203
204
205

			module.addParam(paramName,true,node.get('needsArgs'),components);
		});
eec153c1   Elena.Budnik   formattage, netto...
206
207
	},

10200969   Roipoussiere   Remove whitespace...
208
	createAlias: function(node)
eec153c1   Elena.Budnik   formattage, netto...
209
	{
10200969   Roipoussiere   Remove whitespace...
210
		var win = myDesktopApp.desktop.getWindow('alias-win');
eec153c1   Elena.Budnik   formattage, netto...
211
212
213
214
215
216
217
218
219
220
221
222
223
		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,
10200969   Roipoussiere   Remove whitespace...
224
					items :
eec153c1   Elena.Budnik   formattage, netto...
225
226
227
					[{
						xtype : 'alias',
						region : 'center',
10200969   Roipoussiere   Remove whitespace...
228
						margins :
eec153c1   Elena.Budnik   formattage, netto...
229
230
231
232
233
						{
							top: 0,
							right: 5,
							bottom: 5,
							left: 5
10200969   Roipoussiere   Remove whitespace...
234
						},
eec153c1   Elena.Budnik   formattage, netto...
235
236
237
						paramNode : node,
						id : 'aliasUI'
					}]
10200969   Roipoussiere   Remove whitespace...
238
				});
eec153c1   Elena.Budnik   formattage, netto...
239
			}
10200969   Roipoussiere   Remove whitespace...
240
			else
eec153c1   Elena.Budnik   formattage, netto...
241
242
243
			{
				//Set data into Alias Widget
				win.items.items[0].paramNode = node;
10200969   Roipoussiere   Remove whitespace...
244
245
246
				win.items.items[0].setAlias(node);
			}
			win.show();
eec153c1   Elena.Budnik   formattage, netto...
247
		}
10200969   Roipoussiere   Remove whitespace...
248
		else
eec153c1   Elena.Budnik   formattage, netto...
249
250
		{
			var message = 'Sorry, parameter ' + node.get('id') + ' cannot have alias';
10200969   Roipoussiere   Remove whitespace...
251
			Ext.Msg.alert('Impossible Create Alias', message);
eec153c1   Elena.Budnik   formattage, netto...
252
253
254
			if (win) win.close();
		}
	},
10200969   Roipoussiere   Remove whitespace...
255

eec153c1   Elena.Budnik   formattage, netto...
256
257
258
	isParameter : function()
	{
		return this.get('isParameter');
30cd92df   Roipoussiere   Fix merge conflicts
259
	},
a048eff4   Nathanael Jourdane   Add EPN-TAP to Am...
260

b96f55a5   Nathanael Jourdane   Fill more precise...
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
286
287
288
289
290
291
292
293
294
  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})
    })
  }
16035364   Benjamin Renard   First commit
295
});