/**
* Project : AMDA-NG4
* Name : AmdaApp.js
* @class amdaApp.AmdaApp
* @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
*/
Ext.define('amdaApp.AmdaApp', {
extend: 'Ext.ux.desktop.App',
requires: [
'Ext.window.MessageBox',
'Ext.ux.desktop.ShortcutModel',
'amdaUI.SampToolBarUI',
'amdaDesktop.DynamicModule',
'MyDesktop.Settings'
],
dynamicModules: {
visu : {
id : 'visu-win',
icon : 'icon-visu_catalog',
title : 'Visualization',
source : 'amdaDesktop.VisuModule',
useLauncher : true
},
statistics : {
id : 'statistics-win',
icon : 'icon-statistics',
title : 'Statistics',
source : 'amdaDesktop.StatisticsModule',
useLauncher : true
},
catalog : {
id : 'catalog-win',
icon : 'icon-catalog',
title : 'Manage catalogs',
source : 'amdaDesktop.CatalogModule',
useLauncher : true
},
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 : {
id : 'plot-win',
icon : 'icon-plot',
title : 'Plot Manager',
source : 'amdaDesktop.PlotModule',
useLauncher : true
},
search : {
id : 'search-win',
icon : 'icon-search',
title : 'Data Mining',
source : 'amdaDesktop.SearchModule',
useLauncher : true
},
download : {
id : 'down-win',
icon : 'icon-download',
title : 'Download data',
source : 'amdaDesktop.DownloadModule',
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
},
epntap : {
id : 'epntap-win',
icon : 'icon-interop',
title : 'EPN-TAP data',
source : 'amdaDesktop.EpnTapModule',
useLauncher : false
},
info : {
id : 'info-win',
icon : 'icon-information',
title : 'About AMDA',
source : 'amdaDesktop.AboutModule',
useLauncher : false
},
explorer : {
id : 'explorer-win',
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
},
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
}
},
// IDs of Modules working with parameters; used in Alias Node
//TODO stats-win
paramModulesID : ['plot-win', 'param-win', 'search-win', 'down-win'],
// Important system constants
MAX_UPLOADED_FILE_SIZE : max_uploaded_file_size, // in B, from my_config.php
listeners : {
scope : this,
beforeunload : function ()
{
var interopModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.interop.id);
if (interopModule)
interopModule.forceSampDisconnect();
return true;
},
ready : function ()
{
AmdaAction.cleanUserWS(function(res,e){},this);
}
},
init: function()
{
// custom logic before getXYZ methods get called...
this.callParent();
// TT duration management
Ext.state.Manager.getProvider().set('tt_duration', 3);
// Cat duration management
Ext.state.Manager.getProvider().set('cat_duration', 3);
// now ready...
//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;
}
if (w.y < 0)
w.el.setY(0);
if (w.x + w.width > me.el.getWidth())
w.el.setX(me.el.getWidth()-w.width);
if (w.y + w.height > me.el.getHeight())
w.el.setY((me.el.getHeight()-w.height > 0) ? me.el.getHeight()-w.height : 0);
},
single: true
});
return win;
}
});
},
//create InfoBox
infoMsg : function(msg) {
Ext.Msg.show({
title: 'AMDA Info',
cls: 'infoMsg',
msg: msg,
modal: false,
autoScroll: true,
resizable: true,
icon: Ext.Msg.INFO,
buttons: Ext.Msg.OK
});
},
//create InfoBox
infoMsgLong : function(msg) {
Ext.Msg.show({
title: 'AMDA Info',
cls: 'infoMsgLong',
msg: msg,
modal: false,
autoScroll: true,
resizable: true,
icon: Ext.Msg.INFO,
buttons: Ext.Msg.OK
});
},
//create WarningBox
warningMsg : function(msg) {
Ext.Msg.show({
title: 'Attention',
msg: msg,
icon: Ext.Msg.WARNING,
buttons: Ext.Msg.OK
});
},
//create ErrorBox
errorMsg : function(msg) {
Ext.Msg.show({
title: 'Failure',
msg: msg,
icon: Ext.Msg.ERROR,
buttons: Ext.Msg.OK
});
},
// add info icon; onCick AmdaHelp is shown
addAmdaInfo : function(help, style) {
if (style) {
help += '" style="' + style;
}
var html = '';
msg += (' Name : '+result['first_name']+' '+result['name']+'
');
msg += ('Groups : '+result['group']+'
');
msg += ('Email : '+result['email']+'
');
msg += ('Registration date : '+result['date']+'
');
msg += ('Disk space total / used / available : '+result['total']+' / '+result['used']+' / '+result['available']+' MB
');
this.infoMsg(msg);
}
else
{
//ERROR
this.errorMsg('Cannot get user info');
}
}
else
{
// FAILURE
this.errorMsg('Cannot get user info : '+e.message);
}
},
guestLogout: function() {
Ext.Msg.show({
title : 'Logout',
msg :'Your guest workspace is to be deleted. Continue logout ?',
buttons : Ext.Msg.YESNO,
iconCls : 'logout',
fn : function(btn) {
if (btn == 'yes'){
AmdaAction.logout(true, function(){
sessionID = '';
window.location.href ='index.html';
});
}
}
});
},
forceLogout: function(){
// myDesktopApp.warningMsg('Your guest session is finished');
AmdaAction.logout(true, function(){
sessionID = '';
window.location.href ='index.html';
});
},
saveSessionState : function()
{
var me = this;
Ext.Msg.show({
title : 'Logout',
msg :'Do you want to keep current windows sizes and locations
for the next sessions?',
buttons : Ext.Msg.YESNOCANCEL,
iconCls : 'logout',
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';
}
});
Ext.state.Manager.getProvider().saveState();
AmdaAction.logout(false);
}
else if (btn == 'no')
{
Ext.state.Manager.getProvider().on({
scope : this,
aftersave : function(provider) {
sessionID = '';
window.location.href ='index.html';
}
});
Ext.state.Manager.getProvider().set(me.desktop.id+'_wallpaper',me.desktop.getWallpaper());
Ext.state.Manager.getProvider().saveLastTime();
AmdaAction.logout(false);
}
}
});
},
onSettings: function () {
var dlg = new MyDesktop.Settings({
desktop: this.desktop
});
dlg.show();
},
/**
* 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);
moduleIds.each(function(item) {
this.getLoadedModule(item, true, function (module) {
module.createWindow();
});
}, this);
if (freeSpace < diskQuota / 20) {
myDesktopApp.warningMsg('Think of cleaning up your work space.
Only ' +
Math.round(freeSpace/1024/1024)+ 'MB of '+Math.round(diskQuota/1024/1024) +
'MB rests');
}
if (isFirstVisit && !isGuest) {
myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.help.id, true, function(module) {
module.createWindow();
});
}
else {
if (isSpecialInfo && !isNewInfo) {
myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.info.id, true, function(module) {
module.createWindow(isSpecialInfo, 'Welcome on AMDA', true);
});
}
}
if (isNewInfo) {
myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.info.id, true, function(module) {
// module.createWindow('releaseNotes.' + AMDAVERSION, 'New Release V'+ AMDAVERSION);
module.createWindow(news, 'Amda Latest News');
});
}
if (isGuest) {
myDesktopApp.warningMsg("Welcome to Guest Session
Guest session lasts for "+
guestSessionDuration/3600+" h maximum
"+
"For extended use time and functionalities (saved sessions)
please register at amda@irap.omp.eu");
Ext.Function.defer(myDesktopApp.warningMsg,(guestSessionDuration-300)*1000, this, ["Your session will be closed in 5 min!"]);
Ext.Function.defer(myDesktopApp.forceLogout, guestSessionDuration*1000);
}
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();
});
}}));
}
});