Blame view

js/app/AmdaApp.js 22.5 KB
b185823c   Nathanael Jourdane   Use IntervalUI mo...
1
/**
16035364   Benjamin Renard   First commit
2
3
 * Project  : AMDA-NG4
 * Name     : AmdaApp.js
b185823c   Nathanael Jourdane   Use IntervalUI mo...
4
 * @class   amdaApp.AmdaApp
16035364   Benjamin Renard   First commit
5
6
7
 * @extends Ext.ux.desktop.App
 * @brief   Main class defining Amda Desktop and its Modules
 * @author  Ext JS Library 4.0 Copyright(c) 2006-2011 Sencha Inc. licensing@sencha.com
16035364   Benjamin Renard   First commit
8
9
 */

b185823c   Nathanael Jourdane   Use IntervalUI mo...
10

16035364   Benjamin Renard   First commit
11
12
13
Ext.define('amdaApp.AmdaApp', {
    extend: 'Ext.ux.desktop.App',

b185823c   Nathanael Jourdane   Use IntervalUI mo...
14
    requires: [
16035364   Benjamin Renard   First commit
15
16
17
18
19
20
       'Ext.window.MessageBox',
       'Ext.ux.desktop.ShortcutModel',
       'amdaUI.SampToolBarUI',
       'amdaDesktop.DynamicModule',
       'MyDesktop.Settings'
    ],
b185823c   Nathanael Jourdane   Use IntervalUI mo...
21

16035364   Benjamin Renard   First commit
22
    dynamicModules: {
5cfea1f2   elena   vizu draft
23
24
25
26
27
28
	visu : {
    		id          : 'visu-win',
    		icon        : 'icon-visu_catalog',
    		title       : 'Visualization',
    		source      : 'amdaDesktop.VisuModule',
    		useLauncher : true
b185823c   Nathanael Jourdane   Use IntervalUI mo...
29
    	},
d18b535d   elena   catalog draft + c...
30
31
32
33
34
35
36
	statistics : {
    		id          : 'statistics-win',
    		icon        : 'icon-statistics',
    		title       : 'Statistics',
    		source      : 'amdaDesktop.StatisticsModule',
    		useLauncher : true
    	},
f792a3de   elena   catalog ihm
37
38
39
	catalog : {
    		id          : 'catalog-win',
    		icon        : 'icon-catalog',
d18b535d   elena   catalog draft + c...
40
    		title       : 'Manage catalogs',
f792a3de   elena   catalog ihm
41
42
43
    		source      : 'amdaDesktop.CatalogModule',
    		useLauncher : true
    	},
16035364   Benjamin Renard   First commit
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
    	param : {
    		id          : 'param-win',
    		icon        : 'icon-parameters',
    		title       : 'Create/modify parameters',
    		source      : 'amdaDesktop.ParameterModule',
    		useLauncher : true
    	},
    	tt : {
    		id          : 'timetab-win',
    		icon        : 'icon-manage-tt',
    		title       : 'Manage Time Tables',
    		source      : 'amdaDesktop.TimeTableModule',
    		useLauncher : true
    	},
    	tt_op : {
    		id          : 'ttsOpe-win',
    		icon        : 'icon-tts',
    		title       : 'Operations on Time Tables',
    		source      : 'amdaDesktop.TimeTableOperationModule',
    		useLauncher : true
    	},
    	plot : {
18d4a11e   Benjamin Renard   Save and load plo...
66
            id          : 'plot-win',
5cfea1f2   elena   vizu draft
67
    	    icon         : 'icon-plot',
16035364   Benjamin Renard   First commit
68
    	    title       : 'Plot Manager',
18d4a11e   Benjamin Renard   Save and load plo...
69
    	    source      : 'amdaDesktop.PlotModule',
16035364   Benjamin Renard   First commit
70
71
72
    	    useLauncher : true
    	},
    	search : {
f792a3de   elena   catalog ihm
73
	    id          : 'search-win',
16035364   Benjamin Renard   First commit
74
75
76
77
78
79
    	    icon        : 'icon-search',
    	    title       : 'Data Mining',
    	    source      : 'amdaDesktop.SearchModule',
    	    useLauncher : true
    	},
    	download : {
f792a3de   elena   catalog ihm
80
	    id          : 'down-win',
16035364   Benjamin Renard   First commit
81
82
    	    icon        : 'icon-download',
    	    title       : 'Download data',
f792a3de   elena   catalog ihm
83
	    source      : 'amdaDesktop.DownloadModule',
16035364   Benjamin Renard   First commit
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
    	    useLauncher : true
    	},
    	upload : {
    		id          : 'up-win',
    		icon        : 'icon-mydata',
    		title       : 'Upload data',
    		source      : 'amdaDesktop.UploadModule',
    		useLauncher : true
    	},
    	interop : {
    		id          : 'interop-win',
    		icon        : 'icon-interop',
    		title       : 'Interoperability',
    		source      : 'amdaDesktop.InteropModule',
    		useLauncher : true
    	},
b185823c   Nathanael Jourdane   Use IntervalUI mo...
100
101
		epntap : {
			id          : 'epntap-win',
d53e0fe6   Nathanael Jourdane   Move EPN-TAP modu...
102
			icon        : 'icon-interop',
b185823c   Nathanael Jourdane   Use IntervalUI mo...
103
104
			title       : 'EPN-TAP data',
			source      : 'amdaDesktop.EpnTapModule',
d53e0fe6   Nathanael Jourdane   Move EPN-TAP modu...
105
			useLauncher : false
b185823c   Nathanael Jourdane   Use IntervalUI mo...
106
		},
16035364   Benjamin Renard   First commit
107
108
109
110
111
112
    	info : {
    		id          : 'info-win',
    		icon        : 'icon-information',
    		title       : 'About AMDA',
    		source      : 'amdaDesktop.AboutModule',
    		useLauncher : false
b185823c   Nathanael Jourdane   Use IntervalUI mo...
113
    	},
16035364   Benjamin Renard   First commit
114
    	explorer : {
b185823c   Nathanael Jourdane   Use IntervalUI mo...
115
    		id          : 'explorer-win',
16035364   Benjamin Renard   First commit
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
    	    icon        : 'icon-elements',
    	    title       : 'Workspace Explorer',
    	    source      : 'amdaDesktop.ExplorerModule',
    	    useLauncher : false
    	},
    	my_data : {
    		id          : 'mydata-win',
    	    icon        : 'icon-mydata',
    	    title       : 'Define parameter',
    	    source      : 'amdaDesktop.MyDataModule',
    	    useLauncher : false
    	},
    	help : {
    		id          : 'help-win',
    		icon        : 'icon-help',
    		title       : 'Help',
    		source      : 'amdaDesktop.HelpModule',
    	    useLauncher : false
    	},
    	feedback : {
    		id          : 'feed-win',
    		icon        : 'icon-feedback',
    		title       : 'Feedback',
    		source      : 'amdaDesktop.FeedbackModule',
    	    useLauncher : false
    	},
    	filters : {
    		id          : 'filters-win',
    		icon        : 'icon-filter',
    		title       : 'Filters',
    		source      : 'amdaDesktop.FiltersModule',
    	    useLauncher : false
    	},
16035364   Benjamin Renard   First commit
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
    	result : {
    		id          : 'result-win',
    		contentId   : 'resultUI',
    		icon        : 'icon-results',
    		title       : 'Results',
    		source      : 'amdaDesktop.ResultModule',
    	    useLauncher : false
    	},
    	astro : {
    		id          : 'astroimages-win',
    		icon        : 'icon-interop',
    		title       : 'Astronomical Images',
    		source      : 'amdaDesktop.AstroImagesModule',
    	    useLauncher : false
    	}
    },
b185823c   Nathanael Jourdane   Use IntervalUI mo...
165
166

// IDs of Modules working with  parameters; used in Alias Node
16035364   Benjamin Renard   First commit
167
    paramModulesID : ['plot-win', 'param-win', 'search-win', 'down-win'],
b185823c   Nathanael Jourdane   Use IntervalUI mo...
168

16035364   Benjamin Renard   First commit
169
170
// Important system constants
    MAX_UPLOADED_FILE_SIZE : 30000000, // 30MB
b185823c   Nathanael Jourdane   Use IntervalUI mo...
171

16035364   Benjamin Renard   First commit
172
173
174
175
    listeners : {
		scope : this,
		beforeunload : function ()
		{
aa94fd24   elena   Merge with last svn
176

16035364   Benjamin Renard   First commit
177
178
179
180
181
			var interopModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.interop.id);
			if (interopModule)
				interopModule.forceSampDisconnect();
			return true;
		},
b185823c   Nathanael Jourdane   Use IntervalUI mo...
182
		ready : function ()
16035364   Benjamin Renard   First commit
183
184
                {
				  //AKKA - Clean user WS
aa94fd24   elena   Merge with last svn
185
186
	          AmdaAction.cleanUserWS(function(res,e){},this);
		}
16035364   Benjamin Renard   First commit
187
        },
b185823c   Nathanael Jourdane   Use IntervalUI mo...
188

16035364   Benjamin Renard   First commit
189
190
191
192
193
    init: function() {
        // custom logic before getXYZ methods get called...

        this.callParent();

b185823c   Nathanael Jourdane   Use IntervalUI mo...
194
        // now ready...
16035364   Benjamin Renard   First commit
195
196
197
198
199
200
201
202
203
204
205
206
207
208
        //override createWindow method of desktop
        Ext.override(Ext.ux.desktop.Desktop, {
            createWindow: function (config, cls) {
                var me = this;
                var win = this.callParent([config,cls]);
                win.on({
                    boxready: function (w) {
                        w.dd.xTickSize = me.xTickSize;
                        w.dd.yTickSize = me.yTickSize;

                        if (w.resizer) {
                            w.resizer.widthIncrement = me.xTickSize;
                            w.resizer.heightIncrement = me.yTickSize;
                        }
b185823c   Nathanael Jourdane   Use IntervalUI mo...
209

16035364   Benjamin Renard   First commit
210
211
                        if (w.y < 0)
                            w.el.setY(0);
b185823c   Nathanael Jourdane   Use IntervalUI mo...
212

16035364   Benjamin Renard   First commit
213
214
                        if (w.x + w.width > me.el.getWidth())
                            w.el.setX(me.el.getWidth()-w.width);
b185823c   Nathanael Jourdane   Use IntervalUI mo...
215

16035364   Benjamin Renard   First commit
216
217
                        if (w.y + w.height > me.el.getHeight())
                            w.el.setY((me.el.getHeight()-w.height > 0) ? me.el.getHeight()-w.height : 0);
b185823c   Nathanael Jourdane   Use IntervalUI mo...
218

16035364   Benjamin Renard   First commit
219
220
221
222
223
224
225
226
                    },
                    single: true
                });
                return win;
            }
        });

    },
b185823c   Nathanael Jourdane   Use IntervalUI mo...
227
//create InfoBox
16035364   Benjamin Renard   First commit
228
229
230
231
      infoMsg : function(msg) {
	  Ext.Msg.show({
	      title: 'AMDA Info',
	      cls: 'infoMsg',
b185823c   Nathanael Jourdane   Use IntervalUI mo...
232
	      msg: msg,
16035364   Benjamin Renard   First commit
233
234
235
236
237
238
239
	      modal: false,
	      autoScroll: true,
	      resizable: true,
	      icon: Ext.Msg.INFO,
	      buttons: Ext.Msg.OK
	  });
	},
b185823c   Nathanael Jourdane   Use IntervalUI mo...
240
241

//create WarningBox
16035364   Benjamin Renard   First commit
242
243
244
      warningMsg : function(msg) {
	  Ext.Msg.show({
	      title: 'Attention',
b185823c   Nathanael Jourdane   Use IntervalUI mo...
245
	      msg: msg,
16035364   Benjamin Renard   First commit
246
247
248
249
	      icon: Ext.Msg.WARNING,
	      buttons: Ext.Msg.OK
	  });
	},
b185823c   Nathanael Jourdane   Use IntervalUI mo...
250
251

//create ErrorBox
16035364   Benjamin Renard   First commit
252
253
254
      errorMsg : function(msg) {
	  Ext.Msg.show({
	      title: 'Failure',
b185823c   Nathanael Jourdane   Use IntervalUI mo...
255
	      msg: msg,
16035364   Benjamin Renard   First commit
256
257
258
	      icon: Ext.Msg.ERROR,
	      buttons: Ext.Msg.OK
	  });
b185823c   Nathanael Jourdane   Use IntervalUI mo...
259
260
	},

16035364   Benjamin Renard   First commit
261
262
    getModules : function(){
    	var allModules = [];
b185823c   Nathanael Jourdane   Use IntervalUI mo...
263

16035364   Benjamin Renard   First commit
264
265
266
267
    	//Add dynamic modules
    	Ext.Object.each(this.dynamicModules, function(key, def) {
    		allModules.push(new amdaDesktop.DynamicModule(def.id, def.icon, def.title, def.source, def.useLauncher));
    	});
b185823c   Nathanael Jourdane   Use IntervalUI mo...
268

16035364   Benjamin Renard   First commit
269
270
271
272
273
274
275
276
277
278
279
        return allModules;
    },

    getDesktopConfig: function () {
        var me = this, ret = me.callParent();

        var desktopId = 'AmdaDesktop';
        var wallpaper = Ext.state.Manager.getProvider().get(desktopId+'_wallpaper');
        if (!wallpaper)
        	wallpaper = 'js/resources/images/desktop/wallpapers/Cdpp2.jpg';
        return Ext.apply(ret, {
aa94fd24   elena   Merge with last svn
280
            id       : desktopId,
16035364   Benjamin Renard   First commit
281
282
283
284
285
286
            contextMenuItems: [
                { text: 'Change Settings', handler: me.onSettings, scope: me }
            ],

            shortcuts: Ext.create('Ext.data.Store', {
                model: 'Ext.ux.desktop.ShortcutModel',
b185823c   Nathanael Jourdane   Use IntervalUI mo...
287
288
289
                data: [
                   { name: 'Help',  iconCls: 'help', module: 'help-win' },
                   { name: 'Create/Modify parameter',  iconCls: 'edit', module: 'param-win' },
18d4a11e   Benjamin Renard   Save and load plo...
290
                   { name: 'Plot data',  iconCls: 'plot', module: 'plot-win'},
16035364   Benjamin Renard   First commit
291
                   { name: 'Data mining',  iconCls: 'search', module: 'search-win'},
12c10cdb   Nathanael Jourdane   Get the list of s...
292
                   { name: 'Statistics',  iconCls: 'statistics', module: 'statistics-win'},
16035364   Benjamin Renard   First commit
293
294
                   { name: 'Download data',  iconCls: 'download_manager', module: 'down-win'},
                   { name: 'Upload data',  iconCls: 'mydata', module: 'up-win'},
aa94fd24   elena   Merge with last svn
295
296
                   { name: 'Manage TimeTables',    iconCls: 'timeTable', module: 'timetab-win' },
                   { name: 'TimeTables operations',   iconCls: 'operations', module: 'ttsOpe-win' },
d18b535d   elena   catalog draft + c...
297
                   { name: 'Manage catalogs',  iconCls: 'catalog', module: 'catalog-win'},
5cfea1f2   elena   vizu draft
298
                   { name: 'Visualize catalogs',  iconCls: 'visu_catalog', module: 'visu-win'},
9b951b58   Nathanael Jourdane   Move EPN-TAP modu...
299
                   { name: 'Interoperability',   iconCls: 'interop', module: 'interop-win' }
16035364   Benjamin Renard   First commit
300
301
302
303
304
305
306
307
308
309
310
               ]
            }),

            wallpaper: wallpaper,
            wallpaperStretch: false
        });
    },

    // config for the start menu
    getStartConfig : function() {
        var me = this, ret = me.callParent();
16035364   Benjamin Renard   First commit
311
        return Ext.apply(ret, {
b185823c   Nathanael Jourdane   Use IntervalUI mo...
312
            title: sessionID,
16035364   Benjamin Renard   First commit
313
314
315
316
317
318
319
320
321
322
323
            iconCls: 'icon-user',
            height: 270,
            toolConfig: {
                width: 130,
                items: [
                    {
                        text:'Settings',
                        iconCls:'settings',
                        handler: me.onSettings,
                        scope: me
                    },
b185823c   Nathanael Jourdane   Use IntervalUI mo...
324
                    '-',
16035364   Benjamin Renard   First commit
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
     /*               {
                        text : 'Manage Workspaces',
                        iconCls : 'icon-manage-ws',
                        id : 'mngws-win-tool',
                        scope : this,
                        disabled: true,
                        handler : function(obj, e) {
                            e.stopEvent();
                            var moduleId = obj.el.id;
                            var module = this.getModule(moduleId.replace('-tool', ''));
                            if (module) {
                                module.createWindow();
                            }
                        }
                    }, {
                        text : 'Manage Resources',
                        iconCls : 'icon-manage-resrc',
                        id : 'resrc-win-tool',
                        disabled : true,
                        handler : function(obj, e) {
                            e.stopEvent();
                            var moduleId = obj.el.id;
                            var module = this.getModule(moduleId.replace('-tool', ''));
                            if (module) {
                                module.createWindow();
                            }
                        },
                        scope : this
                    },
    */
                    {
                        text : 'Profile',
                        iconCls : 'icon-user',
                        id : 'profile-win-tool',
                        handler : function(obj, e) {
                            e.stopEvent();
                            AmdaAction.getUserInfo(this.onGetUserInfo,this);
                        },
                        scope : this
                    },{
                        text : 'Feedback',
                        iconCls : 'icon-feedback',
                        id : 'feed-win-tool',
                        handler : function(obj, e) {
                            e.stopEvent();
                            var moduleId = obj.el.id;
                            this.getLoadedModule(moduleId.replace('-tool', ''), true, function(module) {
                            	module.createWindow();
                            });
b185823c   Nathanael Jourdane   Use IntervalUI mo...
374

16035364   Benjamin Renard   First commit
375
                        },
b185823c   Nathanael Jourdane   Use IntervalUI mo...
376
                        scope : this
16035364   Benjamin Renard   First commit
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
                    }, {
                        text : 'Help',
                        iconCls : 'icon-help',
                        id : 'help-win-tool',
                        scope : this,
                        handler : function(obj, e) {
                            e.stopEvent();
                            var moduleId = obj.el.id;
                            this.getLoadedModule(moduleId.replace('-tool', ''), true, function(module) {
                            	module.createWindow();
                            });
                        }
                    }, {
                        text : 'About AMDA',
                        iconCls : 'icon-information',
                        id : 'info-win-tool',
                        scope : this,
                        handler : function(obj, e) {
                            e.stopEvent();
                            var moduleId = obj.el.id;
                            this.getLoadedModule(moduleId.replace('-tool', ''), true, function(module) {
                            	module.createWindow();
                            });
                        }
                    }, '-', {
                        text : 'Workspaces',
                        iconCls : 'icon-ws',
                        disabled: true,
                        scope : this
                    }, '-', {
                        text : 'Logout',
                        iconCls : 'logout',
b185823c   Nathanael Jourdane   Use IntervalUI mo...
409
                        scope : this,
16035364   Benjamin Renard   First commit
410
411
412
413
414
415
                        handler : me.onLogout
                    }
                ]
            }
        });
    },
b185823c   Nathanael Jourdane   Use IntervalUI mo...
416

16035364   Benjamin Renard   First commit
417
418
419
    getModuleDefinition: function(id) {
    	return this.getModule(id);
    },
b185823c   Nathanael Jourdane   Use IntervalUI mo...
420

16035364   Benjamin Renard   First commit
421
422
423
424
425
    getLoadedModule: function(id, forceLoad, onReady) {
    	var moduleDef = this.getModuleDefinition(id);
    	if (!moduleDef)
    		return null;
    	if (!moduleDef.isReady())
b185823c   Nathanael Jourdane   Use IntervalUI mo...
426
    	{
16035364   Benjamin Renard   First commit
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
    		if (forceLoad)
    		{
    			//loadMask.show();
    			moduleDef.get(function (module) {
    				//loadMask.hide();
    				if (onReady)
    					onReady(module);
    			});
    		}
    		return null;
    	}
    	if (onReady)
			onReady(moduleDef.get());
    	return moduleDef.get();
    },
b185823c   Nathanael Jourdane   Use IntervalUI mo...
442

16035364   Benjamin Renard   First commit
443
444
    getTaskbarConfig: function () {
        var ret = this.callParent();
16035364   Benjamin Renard   First commit
445
446
447
448
        return Ext.apply(ret, {
            quickStart: [],
            trayItems: [
                {
b185823c   Nathanael Jourdane   Use IntervalUI mo...
449
                	name: this.dynamicModules.feedback.title, iconCls: 'icon-feedback',
16035364   Benjamin Renard   First commit
450
451
452
453
454
455
456
457
458
459
460
461
                	tooltip: { text: this.dynamicModules.feedback.title, align: 'bl-tl' },
                	overflowText: this.dynamicModules.feedback.title,
                	iconCls: this.dynamicModules.feedback.icon,
                	scope: this,
                	handler : function(obj, e) {
                		e.stopEvent();
                		this.getLoadedModule(this.dynamicModules.feedback.id, true, function(module) {
                        	module.createWindow();
                        });
                	}
                },
                {
b185823c   Nathanael Jourdane   Use IntervalUI mo...
462
                    name: this.dynamicModules.info.title, iconCls: 'icon-information',
16035364   Benjamin Renard   First commit
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
                	tooltip: { text: this.dynamicModules.info.title, align: 'bl-tl' },
                	overflowText: this.dynamicModules.info.title,
                	iconCls: this.dynamicModules.info.icon,
                	scope: this,
                	handler : function(obj, e) {
                		e.stopEvent();
                		this.getLoadedModule(this.dynamicModules.info.id, true, function(module) {
                        	module.createWindow();
                        });
                    }
                },
                {
                    name: 'Logout', iconCls : 'logout',
                    tooltip: { text: 'Logout', align: 'bl-tl' },
                    overflowText: 'Logout',
b185823c   Nathanael Jourdane   Use IntervalUI mo...
478
                    scope : this,
16035364   Benjamin Renard   First commit
479
480
481
482
483
484
485
486
487
                    handler : this.onLogout
                },
                '-',
                { xtype: 'trayclock', flex: 1 }
            ]
        });
    },

    onLogout: function (obj,e) {
b185823c   Nathanael Jourdane   Use IntervalUI mo...
488
489
490
491
    	e.stopEvent();
    //	var interopModule = this.getModule(amdaDesktop.InteropModule.id);
    	if (isGuest) {
           this.guestLogout();
16035364   Benjamin Renard   First commit
492
493
494
        }
        else {
            this.saveSessionState();
b185823c   Nathanael Jourdane   Use IntervalUI mo...
495
        }
16035364   Benjamin Renard   First commit
496
    },
b185823c   Nathanael Jourdane   Use IntervalUI mo...
497

16035364   Benjamin Renard   First commit
498
499
    onGetUserInfo : function (result, e){
    	var t = e.getTransaction();
b185823c   Nathanael Jourdane   Use IntervalUI mo...
500
501
		if (e.status)
		{
16035364   Benjamin Renard   First commit
502
503
			if (result && result.success)
			{
b185823c   Nathanael Jourdane   Use IntervalUI mo...
504
				// SUCCESS
16035364   Benjamin Renard   First commit
505
506
507
508
509
510
511
				var msg = '<b>Login :</b> '+result['login']+'<br/>';
				msg += ('<b>Last Name :</b> '+result['name']+'<br/>');
				msg += ('<b>First Name :</b> '+result['first_name']+'<br/>');
				msg += ('<b>Groups :</b> '+result['group']+'<br/>');
				msg += ('<b>Email :</b> '+result['email']+'<br/>');
				msg += ('<b>Registration date :</b> '+result['date']+'<br/>');
				msg += ('<b>Receive Newsletter :</b> '+(result['news'] == "1"?"true":"false")+'<br/>');
b185823c   Nathanael Jourdane   Use IntervalUI mo...
512

16035364   Benjamin Renard   First commit
513
514
515
516
517
518
519
520
521
522
523
524
				this.infoMsg(msg);
			}
			else
			{
				//ERROR
				this.errorMsg('Cannot get user info');
			}
		}
		else
		{
			// FAILURE
			this.errorMsg('Cannot get user info : '+e.message);
b185823c   Nathanael Jourdane   Use IntervalUI mo...
525
		}
16035364   Benjamin Renard   First commit
526
	},
b185823c   Nathanael Jourdane   Use IntervalUI mo...
527
528


16035364   Benjamin Renard   First commit
529
530
531
    guestLogout: function()
    {
        Ext.Msg.show({
b185823c   Nathanael Jourdane   Use IntervalUI mo...
532
                        title : 'Logout',
16035364   Benjamin Renard   First commit
533
534
                        msg   :'Your guest workspace is to be deleted. Continue logout ?',
                        buttons : Ext.Msg.YESNO,
b185823c   Nathanael Jourdane   Use IntervalUI mo...
535
                        iconCls : 'logout',
16035364   Benjamin Renard   First commit
536
537
538
539
540
                        fn : function(btn) {
                          if (btn == 'yes')
                          {
                            AmdaAction.logout(true, function(){
                                sessionID = '';
b185823c   Nathanael Jourdane   Use IntervalUI mo...
541
542
543
                                window.location.href ='index.html';
                            });
                          }
16035364   Benjamin Renard   First commit
544
                        }
b185823c   Nathanael Jourdane   Use IntervalUI mo...
545
                    });
16035364   Benjamin Renard   First commit
546
    },
b185823c   Nathanael Jourdane   Use IntervalUI mo...
547

16035364   Benjamin Renard   First commit
548
549
550
551
552
    forceLogout: function()
    {
      //  myDesktopApp.warningMsg('Your guest session is finished');
        AmdaAction.logout(true, function(){
                                sessionID = '';
b185823c   Nathanael Jourdane   Use IntervalUI mo...
553
554
                                window.location.href ='index.html';
                            });
16035364   Benjamin Renard   First commit
555
    },
b185823c   Nathanael Jourdane   Use IntervalUI mo...
556

16035364   Benjamin Renard   First commit
557
558
559
560
    saveSessionState : function()
    {
        var me = this;
        Ext.Msg.show({
b185823c   Nathanael Jourdane   Use IntervalUI mo...
561
                        title : 'Logout',
16035364   Benjamin Renard   First commit
562
563
                        msg   :'Do you want to keep current windows sizes and locations<br/> for the next sessions?',
                        buttons : Ext.Msg.YESNOCANCEL,
b185823c   Nathanael Jourdane   Use IntervalUI mo...
564
                        iconCls : 'logout',
16035364   Benjamin Renard   First commit
565
566
567
568
569
570
571
572
573
574
575
576
577
578
                        fn : function(btn) {
	                  if (btn == 'yes')
	                  {
                            //set wallpaper
                            Ext.state.Manager.getProvider().set(me.desktop.id+'_wallpaper',me.desktop.getWallpaper());
                            //
                            Ext.state.Manager.getProvider().on({
                                    scope : this,
                                    aftersave : function(provider)
                                    {
                                            sessionID = '';
                                            window.location.href ='index.html';
                                    }
                            });
b185823c   Nathanael Jourdane   Use IntervalUI mo...
579
580
                            Ext.state.Manager.getProvider().saveState();
                            AmdaAction.logout();
16035364   Benjamin Renard   First commit
581
582
583
584
585
586
587
588
589
590
591
	                  }
	                  else if (btn == 'no')
	                  {
                              Ext.state.Manager.getProvider().on({
                                    scope : this,
                                    aftersave : function(provider)
                                    {
                                            sessionID = '';
                                            window.location.href ='index.html';
                                    }
                            });
b185823c   Nathanael Jourdane   Use IntervalUI mo...
592
593
594
                            Ext.state.Manager.getProvider().set(me.desktop.id+'_wallpaper',me.desktop.getWallpaper());
                            Ext.state.Manager.getProvider().saveLastTime();
                            AmdaAction.logout();
16035364   Benjamin Renard   First commit
595
596
597
598
599
600
601
602
603
604
605
	                  }
                        }
    			});
    },

    onSettings: function () {
        var dlg = new MyDesktop.Settings({
            desktop: this.desktop
        });
        dlg.show();
    },
b185823c   Nathanael Jourdane   Use IntervalUI mo...
606

16035364   Benjamin Renard   First commit
607
608
609
610
611
612
613
    /**
     * initialization at the start of AMDA-NG webApplication
     */
    initProject : function() {
        moduleIds = new Ext.util.MixedCollection();
        // Adding Workspace Explorer Id
        moduleIds.add(this.dynamicModules.explorer.id);
b185823c   Nathanael Jourdane   Use IntervalUI mo...
614

16035364   Benjamin Renard   First commit
615
616
617
618
619
        moduleIds.each(function(item) {
            this.getLoadedModule(item, true, function (module) {
            	module.createWindow();
            });
        }, this);
b185823c   Nathanael Jourdane   Use IntervalUI mo...
620

aa94fd24   elena   Merge with last svn
621
        if (freeSpace < diskQuota / 20) {
b185823c   Nathanael Jourdane   Use IntervalUI mo...
622
            myDesktopApp.warningMsg('Think of cleaning up your work space.<br/>Only ' +
aa94fd24   elena   Merge with last svn
623
624
625
            Math.round(freeSpace/1024/1024)+ 'MB of '+Math.round(diskQuota/1024/1024) +
            'MB rests');
        }
b185823c   Nathanael Jourdane   Use IntervalUI mo...
626

aa94fd24   elena   Merge with last svn
627
        if (isFirstVisit && !isGuest) {
b185823c   Nathanael Jourdane   Use IntervalUI mo...
628
            if (isSpecialInfo) {
aa94fd24   elena   Merge with last svn
629
630
631
632
                myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.info.id, true, function(module) {
			module.createWindow(isSpecialInfo, 'Welcome to AMDA', true);
		});
            } else {
b185823c   Nathanael Jourdane   Use IntervalUI mo...
633

aa94fd24   elena   Merge with last svn
634
635
636
637
                myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.help.id, true, function(module) {
			module.createWindow();
		});
            }
b185823c   Nathanael Jourdane   Use IntervalUI mo...
638
        }
aa94fd24   elena   Merge with last svn
639
640
        else {
            if (isSpecialInfo && !isNewInfo) {
b185823c   Nathanael Jourdane   Use IntervalUI mo...
641
		myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.info.id, true, function(module) {
aa94fd24   elena   Merge with last svn
642
643
644
645
                	module.createWindow(isSpecialInfo, 'Welcome to AMDA', true);
               	});
            }
        }
b185823c   Nathanael Jourdane   Use IntervalUI mo...
646

aa94fd24   elena   Merge with last svn
647
648
         if (isNewInfo) {
            myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.info.id, true, function(module) {
b185823c   Nathanael Jourdane   Use IntervalUI mo...
649
		//  module.createWindow('releaseNotes.' + AMDAVERSION, 'New Release V'+ AMDAVERSION);
aa94fd24   elena   Merge with last svn
650
651
652
		module.createWindow(news, 'Amda Latest News');
	    });
        }
b185823c   Nathanael Jourdane   Use IntervalUI mo...
653

aa94fd24   elena   Merge with last svn
654
655
656
657
658
        if (isGuest) {
            myDesktopApp.warningMsg("Welcome to Guest Session<br/>Guest session lasts for "+
                                    guestSessionDuration/3600+" h maximum<br/>"+
                                    "For extended use time and functionalities (saved sessions)<br/> please register at amda@irap.omp.eu");
            Ext.Function.defer(myDesktopApp.warningMsg,(guestSessionDuration-300)*1000, this, ["Your session will be closed in 5 min!"]);
b185823c   Nathanael Jourdane   Use IntervalUI mo...
659
            Ext.Function.defer(myDesktopApp.forceLogout, guestSessionDuration*1000);
16035364   Benjamin Renard   First commit
660
        }
aa94fd24   elena   Merge with last svn
661

b185823c   Nathanael Jourdane   Use IntervalUI mo...
662
663


16035364   Benjamin Renard   First commit
664
665
666
667
668
669
        this.desktop.taskbar.tray.width = 130;
        this.desktop.taskbar.insert(4,new amdaUI.SampToolBarUI({id : 'samptb', onSwitchConnect : function ()
      	  {
        	myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.interop.id, true, function(module) {
        		module.switchSampConnect();
        	});
b185823c   Nathanael Jourdane   Use IntervalUI mo...
670

16035364   Benjamin Renard   First commit
671
672
673
    	  }}));
    }
});