AboutModule.js 3.65 KB
/** 
 * Project  : AMDA-NG4
 * Name     : AboutModule.js
 * @class   amdaDesktop.AboutModule 
 * @extends amdaDesktop.AmdaModule
 * @brief   About Module controller definition
 * This Module describe new functionalities of AMDA-NG4
 * @author  CDA
 * @version $Id: AboutModule.js 2397 2014-06-03 10:21:28Z elena $
 */

Ext.define('amdaDesktop.AboutModule', 
{
	extend: 'amdaDesktop.AmdaModule',
	contentId : 'infoUI',
	file : 'releaseNotes.' + AMDAVERSION,

	createWindow : function(file, title, specialInfo)
	{             
		var desktop = myDesktopApp.getDesktop();            
		var win = desktop.getWindow(this.id);
		var theTitle = title ? title : this.title;
		
		if (!AMDAVERSION) this.file = 'about';
		
		var theFile = file ? file : this.file;
		if (!win) {	     
			win = desktop.createWindow({
				id: this.id,
				title: theTitle,
				file : theFile,
				width: 650,
				height: 570,
				autoScroll : true,
				minimizable: false,
				maximizable: false,
				bodyStyle: 'background:#ffffee; padding:15px 15px 15px 15px;',
				bodyCls : 'infoWindow',
				loader : {
							url : helpDir + theFile,
							loadMask : false,
							autoLoad : true // important			 
				},	            
				iconCls: this.icon,
				animCollapse:false,
				constrainHeader:true
			}); 
                
			if (specialInfo) {                    
					win.add({ xtype: 'toolbar',                               
								items: [  { 
									text: 'AMDA\'s ABCs',
									scope  : this,
									handler: function() {  
										myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.help.id, true, function (module) {
										module.createWindow();
										}); 
									}
								},'-',
								'->', '-', 
								{
									text: 'Stop showing this window on next login',
									scope  : this,
									handler: function() {                                              
										AmdaAction.deleteSpecialInfo(win.file);
										Ext.MessageBox.show({title:'Warning', 
											msg: 'OK. Close the window right now?',
											width: 300,   
											buttons: Ext.MessageBox.OKCANCEL, 
											fn : function(btn) {
												if (btn == 'cancel') return;
												win.close();
											},
											icon: Ext.MessageBox.WARNING,
											scope : this
									});  
								}
							}
						]});                      
			}
			
			if (isMigration && isOldWS) {
				win.on({
					show : function(){
					Ext.Msg.show({                            
						title:'Welcome on new AMDA',
						msg: 'It is your first visit of the new version of AMDA.<br/>'+
						'Do you want to copy here your workspace from the old AMDA ?',                           
						buttons: Ext.Msg.YESNO,
						icon: Ext.Msg.QUESTION,
						fn : function (btn) { 
							if (btn == 'yes') {
								loadMask.show();	
								AmdaAction.convertWS(function(res,e){ 
									var explorerModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.explorer.id);
									explorerModule.filtersStore.reload();
									loadMask.hide();
									
									if (res.success == true) {
											myDesktopApp.infoMsg('<b>Your Wokspace has been copied</b><br/><br/> ' + 
											'<b>Note : </b><br/><br> Plot Requests  have not been copied - too many modifs!<br/>' +
											'Derived params made from Remote params have not been copied<br/><br/>' +  res.msg);
									}
									else {
											myDesktopApp.errorMsg(res.error);
									}
								});
							}
						}  
					}); 
					} 
				});
			}
			win.show();
		}
		else if (win.file === theFile) {
				win.toFront();
		}
		else {	      
				win.loader.url = helpDir + theFile;
				win.loader.load();
				win.setTitle(theTitle);
				win.file = theFile;
				win.toFront();
		}
	}
});