Blame view

js/app/views/APISImagesUI.js 5 KB
16035364   Benjamin Renard   First commit
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
/**
  * Project      :  AMDA-NG
  * Name         : APISImagesUI.js
  * @plugin 	  amdaUI.APISImagesUI
  * @extends 	  Ext.panel.Panel
  * @brief		 APIS view
  * @author Benjamin
  * @version $Id: APISImagesUI.js 1664 2013-07-03 11:37:37Z benjamin $
  ********************************************************************************
  *    FT Id     :   Date   : Name - Description
  *******************************************************************************
  *  :          
  */

Ext.define('amdaUI.APISImagesUI', {
    extend: 'amdaUI.AstroImagesUI',
    alias: 'widget.panelAPIS',
	
	getPreviewUrl : function(image)
	{
		return image.get('preview_url');
	},
	
	getImageLink : function(image)
	{
		return image.get('image_url');
	},
	
b7796276   Benjamin Renard   Migration to supp...
29
	getImageToSendUrl : function(image)
16035364   Benjamin Renard   First commit
30
	{
b7796276   Benjamin Renard   Migration to supp...
31
32
33
		if (image.get('fits_url'))
			return image.get('fits_url');
		return image.get('image_url');
16035364   Benjamin Renard   First commit
34
35
36
37
38
39
40
	},
	
	getAcknowledgement : function()
	{
		return '<br/><a target="_blank"  href="http://lesia.obspm.fr/apis/">APIS database by Laurent Lamy - Lesia-Observatoire de Paris</a>';
	},
	
b7796276   Benjamin Renard   Migration to supp...
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
	getAdditionalRequestConfig : function(panelId)
	{
		return  {
            xtype: 'checkboxgroup',
            fieldLabel: 'Datasets selection',
            labelAlign: 'top',
            columns: 2,
            flex: 1,
            vertical: true,
            id: panelId+'-checkgroup-datasetid',
            items: [
                { boxLabel: 'Original Data', inputValue: 'original_data', checked: true },
                { boxLabel: 'Processed Data', inputValue: 'processed_data', checked: true },
                { boxLabel: 'Cylindric Proj.', inputValue: 'cylindric_proj', checked: true },
                { boxLabel: 'Polar Proj. North', inputValue: 'polar_proj_north', checked: true },
                { boxLabel: 'Polar Proj. South', inputValue: 'polar_proj_south', checked: true }
            ]
        };
	},
	
	getTargetList : function()
	{
		return [
    	        ["saturn",  "Saturn"],
    	        ["jupiter", "Jupiter"],
    	        ["uranus", "Uranus"],
    	        ["europa", "Europa"],
    	        ["ganymede", "Ganymede"],
    	        ["io", "Io"],
    	        ["titan", "Titan"]];
	},
	
16035364   Benjamin Renard   First commit
73
	onFinishGetImages : function(result, e)
b7796276   Benjamin Renard   Migration to supp...
74
	{
16035364   Benjamin Renard   First commit
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
		var t = e.getTransaction();
		
		if (e.status && result) 
		{	
		  if (result.success)
		  {
			var imgs = new Array();
			
			var crtStartTime = 0.0;
			var crtFolder;
			Ext.each(result.result,function(folder)
					{	
						var rec = {
								name  : folder.date,
								start : folder.date,
								images : new Array()
						};
						imgs.push(rec);
						
						Ext.each(folder.images, function(image)
								{
b7796276   Benjamin Renard   Migration to supp...
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
									var additional_text = '';
									switch (image.dataset_id)
									{
									case 'cylindric_proj' :
										additional_text = 'Cylindric Proj.';
										break;
									case 'original_data' :
										additional_text = 'Original data';
										break;
									case 'polar_proj_north' :
										additional_text = 'Polar Proj. North'; 
										break;
									case 'polar_proj_south' :
										additional_text = 'Polar Proj. South'; 
										break;
									case 'processed_data' :
										additional_text = 'Processed data'; 
										break;
									}
16035364   Benjamin Renard   First commit
115
116
117
118
119
120
121
122
123
124
125
126
									
									rec.images.push({
										name        : image.name,
										target      : image.target_name,
										ra          : image.ra,
										dec         : image.dec,
										ref         : image.reference,
										start       : image.time_min,
										stop        : image.time_max,
										exposure    : image.time_exp_max,
										instrument  : image.instrument_name,
										preview_url : image.preview_url,
b7796276   Benjamin Renard   Migration to supp...
127
128
129
										fits_url    : image.native_access_url,
										image_url   : image.access_url,
										additional_text : additional_text
16035364   Benjamin Renard   First commit
130
131
132
133
									});
								});
					});
			this.createTree(imgs);
b7796276   Benjamin Renard   Migration to supp...
134
135
136
			
			if (result.warning)
				myDesktopApp.warningMsg(result.warning);
16035364   Benjamin Renard   First commit
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
		  }
		  else
		  {
			  //ERROR
			  if (result.message)
				  Ext.Msg.show({title:'Error', msg: result.message, icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK});
			  else
				  Ext.Msg.show({title:'Error', msg: 'Unknown error', icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK});
		  }
		}
		else
		{
		  // FAILURE
	      Ext.Msg.show({title:'Error System', msg: e.message, icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK});
		}
	},
	
	refreshTree : function(o)
	{
		var startTime = this.timeSelector.getStartTime();
        var stopTime = this.timeSelector.getStopTime();     
b7796276   Benjamin Renard   Migration to supp...
158
159
160
        var target = this.getTargetCombo().getValue();
        
        var datasetsGroup = this.queryById(this.id+'-checkgroup-datasetid');
16035364   Benjamin Renard   First commit
161

b7796276   Benjamin Renard   Migration to supp...
162
163
164
165
166
167
        var datasets = [];
        
        Ext.each(datasetsGroup.getChecked(), function (check, index) {
        	datasets.push(check.inputValue);
        });
        
16035364   Benjamin Renard   First commit
168
169
170
        var obj = {
        		startTime : startTime,
        		stopTime  : stopTime,
b7796276   Benjamin Renard   Migration to supp...
171
172
        		target    : target,
        		datasets  : datasets
16035364   Benjamin Renard   First commit
173
174
175
176
177
178
179
        };
        
        this.getImageTreePanel().setLoading(true);

        AmdaAction.getAPISImagesUrl(obj,this.onFinishGetImages,this);
	}
});