Blame view

js/app/views/PlotUI.js 8.46 KB
16035364   Benjamin Renard   First commit
1
2
3
4
5
/**
 * Project   : AMDA-NG
 * Name      : PlotUI.js
 * @class   amdaUI.PlotUI
 * @extends Ext.container.Container
18d4a11e   Benjamin Renard   Save and load plo...
6
7
8
 * @brief   New Plot Module UI definition (View)
 * @author  Benjamin Renard
 * @version $Id: PlotUI.js benjamin $
16035364   Benjamin Renard   First commit
9
10
11
12
 */


Ext.define('amdaUI.PlotUI', {
18d4a11e   Benjamin Renard   Save and load plo...
13
14
	extend: 'Ext.container.Container',
	alias: 'widget.newPanelPlot',
16035364   Benjamin Renard   First commit
15
	
18d4a11e   Benjamin Renard   Save and load plo...
16
17
18
19
20
21
22
23
24
25
26
	requires: [
	           'amdaModel.DownloadNode',
	           'amdaModel.Download',
	           'amdaUI.TimeSelectorUI',
	           'amdaPlotComp.PlotTabPanel',
	           'amdaPlotComp.PlotOutputForm',
	           'amdaPlotComp.PlotElementPanel'
    ],
	
	formPanel: null,
	
27b2a53e   Benjamin Renard   Link tab plot to ...
27
28
	multiPlotIntervalPanel : null,
	
18d4a11e   Benjamin Renard   Save and load plo...
29
30
31
32
33
34
35
36
37
38
39
	plotOutput: null,
	
	plotTabs : null,
	
	plotElement : null,
	
	constructor: function(config) {
		this.init(config);	    
		this.callParent(arguments);
		if (this.object)
			this.setObject(this.object);
16035364   Benjamin Renard   First commit
40
41
	},
	
18d4a11e   Benjamin Renard   Save and load plo...
42
43
44
45
46
	setObject : function(object) {
		this.object = object;
		this.plotOutput.setObject(this.object);
		this.plotTabs.setRequestObject(this.object);
		this.timeSelector.intervalSel.setInterval(this.object.get('startDate'), this.object.get('stopDate'));
e27eecbd   Benjamin Renard   Save and load TT ...
47
		this.addTTs(this.object.get('timeTables'));
16035364   Benjamin Renard   First commit
48
	},
18d4a11e   Benjamin Renard   Save and load plo...
49
	
a971060f   Benjamin Renard   Fix some bugs
50
51
52
53
54
	saveProcess : function() {
		var plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id);
    	if (!plotModule)
    		return;
    	
e27eecbd   Benjamin Renard   Save and load TT ...
55
56
    	this.updateObject();
    	
a971060f   Benjamin Renard   Fix some bugs
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
    	if ((this.object.get('id') != '') && (plotModule.linkedNode.get('text') == this.object.get('name')))
			//update existing request
			plotModule.linkedNode.update();
    	else
    	{
    		var me = this;
    		//Request Name validation
    		plotModule.linkedNode.isValidName(this.object.get('name'), function (res) {
    			if (!res)
    			{
    				myDesktopApp.errorMsg('Error during object validation');
    				return;
    			}
			  
    			if (!res.valid)
    			{
    				if (res.error)
    					myDesktopApp.errorMsg(res.error);
    				else
    					myDesktopApp.errorMsg('Invalid object name');
    				return;
    			}
			 
    			//Save
    			if (me.object.get('id') != '')
    			{
    				//Duplicate request
    				plotModule.createLinkedNode();
    				plotModule.linkedNode.set('object',me.object);
    			}
    			else
    			{
    				//Create new request
    			}
    			plotModule.linkedNode.create();
    		});
    	}
	},
16035364   Benjamin Renard   First commit
95
    
18d4a11e   Benjamin Renard   Save and load plo...
96
97
98
99
100
    resetProcess : function(){
    	var plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id);			
		plotModule.createLinkedNode();
		plotModule.createObject();					  
		this.setObject(plotModule.linkedNode.get('object'));
16035364   Benjamin Renard   First commit
101
    },
16035364   Benjamin Renard   First commit
102
	
18d4a11e   Benjamin Renard   Save and load plo...
103
    getDataProcess : function(){
27504b3e   Elena.Budnik   redmine 5080
104
105
106
107
108
109
110
		this.updateObject(); 
		// plot was not called - form only		
		if (this.object.get('last-plotted-tab') == 0)
		{			
			this.object.set('last-plotted-tab', this.plotTabs.getSelectedTabId());
		}
    	var downObject = amdaModel.DownloadNode.decodeObject(this.object);		
18d4a11e   Benjamin Renard   Save and load plo...
111
112
    	amdaModel.DownloadNode.set('object',Ext.create('amdaModel.Download',downObject));		 
    	amdaModel.DownloadNode.editInModule(); 
16035364   Benjamin Renard   First commit
113
    },
18d4a11e   Benjamin Renard   Save and load plo...
114
115
116
117
    
    addParameter : function(node){
    	var crtTree = this.plotTabs.getTreeFromPlotTab(this.plotTabs.getActiveTab());
    	crtTree.dropRecord(node,null,'append');
16035364   Benjamin Renard   First commit
118
119
    },
    
18d4a11e   Benjamin Renard   Save and load plo...
120
	/**
16035364   Benjamin Renard   First commit
121
122
123
     * plot method called by 'Do Plot' button to launch the plot process
     */
    doPlot : function(){
a971060f   Benjamin Renard   Fix some bugs
124
    	this.updateObject();
87658ba0   Benjamin Renard   TT Navigation in ...
125
    	this.object.set('last-plotted-tab', this.plotTabs.getSelectedTabId());
18d4a11e   Benjamin Renard   Save and load plo...
126
127
128
129
    	var plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id);
    	if (plotModule)
    		plotModule.linkedNode.execute();
    },  
16035364   Benjamin Renard   First commit
130
	
18d4a11e   Benjamin Renard   Save and load plo...
131
132
133
134
135
	/**
	 * Check if changes were made before closing window 
	 * @return false
	 */	
	fclose : function() {
a971060f   Benjamin Renard   Fix some bugs
136
137
		var module = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id);
		if (module)
18d4a11e   Benjamin Renard   Save and load plo...
138
			module.closeInteractiveSession();
18d4a11e   Benjamin Renard   Save and load plo...
139
		
a971060f   Benjamin Renard   Fix some bugs
140
		return this.object.isDirty();
18d4a11e   Benjamin Renard   Save and load plo...
141
	},
16035364   Benjamin Renard   First commit
142
	
a971060f   Benjamin Renard   Fix some bugs
143
144
145
146
147
148
149
150
151
152
153
154
155
    /**
     * update this.object from form
     */
    updateObject : function(){
    	var timeSource = this.timeSelector.getActiveTimeSource();
    	var multiPlotForm = this.multiPlotIntervalPanel.getForm();
    	multiPlotForm.updateRecord(this.object);
    	this.object.set('timesrc', timeSource);
    	if (timeSource === amdaModel.AmdaTimeObject.inputTimeSrc[0])
        	this.object.set('timeTables',this.timeSelector.TTGrid.getStore().data.items);
    	this.plotTabs.updateTimeObject();
    },
	
a0f13ed1   Elena.Budnik   small format + ti...
156
	addTT : function(newTTName,newTTid,timeSelectorId) {
c94de8e9   Benjamin Renard   Fix Multi plot ti...
157
158
159
		var crtTimeSelector = Ext.getCmp(timeSelectorId);
		if (crtTimeSelector)
			crtTimeSelector.addTT(newTTName,newTTid);
18d4a11e   Benjamin Renard   Save and load plo...
160
	},
e27eecbd   Benjamin Renard   Save and load TT ...
161
162
163
164
165
	
	addTTs : function(TTarray) {
		// set TTTab	    
		this.timeSelector.setTTTab(TTarray);
	},
16035364   Benjamin Renard   First commit
166

a0f13ed1   Elena.Budnik   small format + ti...
167
168
169
170
171
172
173
174
	/**
	* Set Start-Stop from parameter info (Local & MyData)
	*/ 
	setTimeFromData : function(obj) {                                                               
		if (!obj.start || !obj.stop)
			return;
		var dateStart = new Date(obj.start.replace(/[T|Z]/g,' ').replace(/\-/g,'\/')); 
		var dateStop = new Date(obj.stop.replace(/[T|Z]/g,' ').replace(/\-/g,'\/')); 
2e8be1ae   Elena.Budnik   Set Start-Stop fr...
175

a0f13ed1   Elena.Budnik   small format + ti...
176
177
178
179
180
181
182
183
		for (var i = 0; i < this.plotTabs.items.getCount(); ++i) {
			var plotTab = this.plotTabs.items.getAt(i).items.getAt(0);  
			plotTab.items.getAt(1).intervalSel.setInterval(dateStart, dateStop);
			//TBD  plotTab.updateTimeObject();		 
		}
		
		this.timeSelector.intervalSel.setInterval(dateStart, dateStop);        
	},
18d4a11e   Benjamin Renard   Save and load plo...
184
	
27b2a53e   Benjamin Renard   Link tab plot to ...
185
186
187
188
    updateLinkedToMultiPlotMode : function(isLinkedToMultiPlotMode) {
		this.multiPlotIntervalPanel.setVisible(isLinkedToMultiPlotMode);
	},
    
18d4a11e   Benjamin Renard   Save and load plo...
189
	init : function(config) {
c94de8e9   Benjamin Renard   Fix Multi plot ti...
190
		this.timeSelector = new amdaUI.TimeSelectorUI( { id: 'multiPlotTimeSelector' + config.id, title : 'MultiPlot Time Selection'} );
18d4a11e   Benjamin Renard   Save and load plo...
191
192
193
194
		
		this.plotOutput = new amdaPlotComp.PlotOutputForm({flex: 2});
		
		this.plotElement = new amdaPlotComp.PlotElementPanel({flex: 3});
16035364   Benjamin Renard   First commit
195

c94de8e9   Benjamin Renard   Fix Multi plot ti...
196
		this.plotTabs = new amdaPlotComp.PlotTabPanel({flex: 3, plotElementPanel : this.plotElement, plotUI : this});
18d4a11e   Benjamin Renard   Save and load plo...
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
		
		this.optionsPanel = new Ext.form.Panel({
			layout: {
			    type: 'vbox',
			    pack: 'start',
			    align: 'stretch'
			},
			bodyStyle: { background : '#dfe8f6' },  
			defaults: {
				border: false
			},
			items: [
			        this.plotElement,
			        this.plotOutput
			]
		});
		
27b2a53e   Benjamin Renard   Link tab plot to ...
214
		this.multiPlotIntervalPanel = new Ext.form.Panel({
c94de8e9   Benjamin Renard   Fix Multi plot ti...
215
			flex: 2,
27b2a53e   Benjamin Renard   Link tab plot to ...
216
217
218
219
220
221
222
223
224
225
226
			layout: 'fit',
			bodyStyle: { background : '#dfe8f6' },
			visible : false,
			defaults: {
				border: false
			},
			items : [
			         this.timeSelector
			]
		});
		
18d4a11e   Benjamin Renard   Save and load plo...
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
		this.formPanel = new Ext.form.Panel({
			region: 'center',
			layout: {
			    type: 'hbox',
			    pack: 'start',
			    align: 'stretch'
			},
			bodyStyle: { background : '#dfe8f6' },  
			defaults: {
				border: false
			},
			items: [
			        {
						xtype : 'panel',
						layout: {
						    type: 'vbox',
						    pack: 'start',
						    align: 'stretch'
						},
						bodyStyle: { background : '#dfe8f6' },
						defaults: {
							border: false
						},
						flex: 1,
						items: [
	        				this.plotTabs,
27b2a53e   Benjamin Renard   Link tab plot to ...
253
	        				this.multiPlotIntervalPanel
18d4a11e   Benjamin Renard   Save and load plo...
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
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
	        			]
					},
			        {
			        	xtype : 'panel',
			        	layout: 'fit',
			        	bodyStyle: { background : '#dfe8f6' },  
			        	defaults: {
							border: false
						},
			        	flex: 1,
			        	items: [
			        	        this.optionsPanel
			            ]
			        }
			],
			fbar: [
			       {
			    	   xtype: 'button',
			    	   text: 'Plot',
			    	   scope: this,
			    	   handler: function(button) {
			    		   this.doPlot();
			    	   }
			       },
			       ' ',
			       {
			    	   xtype: 'button',
			    	   text: 'Get Data',
			    	   scope: this,
			    	   handler: function(button) {
			    		   this.getDataProcess();
			    	   }
			       },
			       ' ',
			       {
			    	   xtype: 'button',
			    	   text: 'Reset',
			    	   scope: this,
			    	   handler: function(button) {
			    		   this.resetProcess();
			    	   }
			       },
			       '->',
			       {
			    	   xtype: 'button',
			    	   text: 'Save Request',
			    	   scope: this,
			    	   handler: function(button) {
			    		   this.saveProcess();
			    	   }
			       }
			]
		});
		
		var myConf = {
				layout: 'border',
				items: [
				        this.formPanel,
				        {
				        	xtype: 'panel', 
				        	region: 'south',
				        	title: 'Information',
				        	collapsible: true,
				        	height: 100,
				        	autoHide: false,
				        	bodyStyle: 'padding:5px',
				        	iconCls: 'icon-information',
				        	loader: {
				        		autoLoad: true,
				        		url: helpDir+'plotHOWTO'
				        	}
				        }
	            ]
		};
		Ext.apply (this , Ext.apply (arguments, myConf));
	}
8f85fbfa   Benjamin Renard   Remove deprecated...
330
});