desktop.php 9.81 KB
<?php

/**
 * @file index.php
 * @version $Id: desktop.php 2934 2015-06-03 13:23:22Z elena $
 *
 */

require_once('php/config.php');

// error_reporting(E_ALL);
if (!isset($_POST['username'])) {
    header('Location: index.html');
    exit(1);
}

if (!isset($_POST['username'])) die('<a href="index.html">LOGIN SVP</a>');
$usrMgr = new UserMgr();

$sessionID = $usrMgr->init();
if ($sessionID === FALSE) {
    header('Location: index.html?error=1');
    exit(1);
}
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <meta http-equiv="PRAGMA" content="NO-CACHE">
    <meta http-equiv="CACHE-CONTROL" content="NO-CACHE">
    <meta http-equiv="EXPIRES" content="-1">

    <title><?php if (defined('TITLE')) {
                echo TITLE;
            } else {
                echo 'AMDANEW';
            } ?></title>
    <!-- Important ! the order of css loading : ext-all.css - should be the first -->
    <link rel="stylesheet" type="text/css" href="js/lib/ext/resources/css/ext-all.css" />
    <link rel="stylesheet" type="text/css" href="js/resources/css/desktop.css" />
    <link rel="stylesheet" type="text/css" href="js/resources/css/amda.css" />

    <link rel="stylesheet" href="js/lib/codemirror/codemirror-5.65.12/lib/codemirror.css">
    <link rel="stylesheet" href="js/lib/codemirror/codemirror-5.65.12/addon/lint/lint.css">
    <link rel="stylesheet" href="js/lib/codemirror/codemirror-5.65.12/addon/hint/show-hint.css">

    <link rel="icon" href="favicon.ico" type="image/x-icon">
    <link rel="shortcut icon" href="favicon.ico" type="image/x-icon">

    <!--  <script type="text/javascript" src="js/lib/ext/builds/ext-core.js"></script> -->
    <!--  <script type="text/javascript" src="js/lib/ext/bootstrap.js"></script> -->
    <!--  <script type="text/javascript" src="js/lib/ext/ext-all-debug-w-comments.js"></script> -->
    <script type="text/javascript" src="js/lib/ext/ext-all.js"></script>
    <!--	<script type="text/javascript" src="js/lib/ext/ext-all-dev.js"></script> -->
    <script type="text/javascript" src="js/lib/ext-override.js"></script>

    <!--  Plotly module-->
    <script src="js/lib/plotly/plotly-2.14.0.min.js"></script>

    <!--  CodeMirror module-->
    <script src="js/lib/codemirror/codemirror-5.65.12/lib/codemirror.js"></script>
    <script src="js/lib/codemirror/codemirror-5.65.12/addon/mode/simple.js"></script>
    <script src="js/lib/codemirror/codemirror-5.65.12/addon/edit/closebrackets.js"></script>
    <script src="js/lib/codemirror/codemirror-5.65.12/addon/lint/lint.js"></script>
    <script src="js/lib/codemirror/codemirror-5.65.12/addon/selection/active-line.js"></script>

    <!-- Direct API -->
    <script type="text/javascript" src="php/api.php"></script>

    <!--  <script src="help/movies/Resources/scripts/prototype.js" language="JavaScript" type="text/javascript"></script>
      <script src="help/movies/Resources/scripts/qtp_poster.js" language="JavaScript" type="text/javascript"></script>          
      <link href="help/movies/Resources/stylesheets/qtp_poster.css" rel="StyleSheet" type="text/css" /> --->


    <script type="text/javascript">
        //Enable dynamic loading for improved debugging support
        Ext.Loader.setConfig({
            enabled: true
        });

        Ext.Loader.setPath({
            'Ext': 'js/lib/ext/src',
            'Ext.ux.desktop': 'js/lib/ux/desktop',
            'Ext.ux': 'js/lib/ext/examples/ux',
            'MyDesktop': 'js/lib/ux/desktop/exampleModules',
            'extensions': 'js/lib/ux',
            'Ext.ux.amdaGrid': 'js/lib/ux/grid',
            'samp': 'js/lib/SAMP',
            'amdaDesktop': 'js/app/controllers',
            'amdaUI': 'js/app/views',
            'amdaPlotComp': 'js/app/views/PlotComponents',
            'amdaModel': 'js/app/models',
            'amdaPlotObj': 'js/app/models/PlotObjects',
            'amdaReader': 'js/app/stores',
            'amdaApp': 'js/app'
        });

        Ext.require('amdaDesktop.AmdaStateProvider');
        Ext.direct.Manager.addProvider(Ext.app.REMOTING_API);

        Ext.require('amdaDesktop.JobsMgr');
        Ext.require('amdaApp.AmdaApp');

        var myDesktopApp;

        var isMigration = false;
        var sessionID = '<?php echo $sessionID; ?>';
        var isFirstVisit = '<?php echo $usrMgr->isFirst; ?>';
        var isOldWS = false; // '<#?php echo $usrMgr->isOldWS; ?>';
        var isSpecialInfo = '<?php echo $usrMgr->isSpecialInfo; ?>';
        var isNewInfo = '<?php echo $usrMgr->isNewInfo; ?>';
        var news = '../data/' + sessionID + '/INFO';

        var AMDAVERSION = '<?php if (defined('AMDA_VERSION')) echo AMDA_VERSION; ?>';

        var wsSize = '<?php echo $usrMgr->getWsSize(); ?>';
        var diskQuota = '<?php echo DISK_QUOTA; ?>';

        var freeSpace = diskQuota - wsSize;

        var helpDir = 'help/';
        var isGuest = sessionID.match('guest');
        var amdaDefaultValues = null;
        var amdaDefaultConfigs = null;
        var amdaDefaultOptions = null;

        var max_uploaded_file_size = '<?php echo MAX_UPLOADED_FILESIZE; ?>';
        var guestSessionDuration = '<?php echo GuestSessionDuration * 60; ?>'; // in secs
        var maxGuestTimeInterval = '<?php echo MaxGuestTimeInterval; ?>'; // in days

        var gatewayTimeout = '<?php if (defined('GATEWAY_TIMEOUT')) echo GATEWAY_TIMEOUT;
                                else echo 300000; ?>'; // in msec

        var logExecTime = <?php echo (defined('LOG_EXEC_TIME') && (LOG_EXEC_TIME === TRUE) ? 'true' : 'false'); ?>;
        //create mask class (LoadMask for elements has been deprecated, use Ext.dom.Element.mask & Ext.dom.Element.unmask)
        var AMDAMask = new Ext.Class({
            show: function(interactivePlot) {
                var msg = 'Processing...Please wait';
                if (interactivePlot)
                    msg += ' <br/> <p align="center"><input id="killopBtn" type="button" value="Kill process" /></p>';

                var mask = Ext.getBody().mask(msg, 'amda-mask');

                if (interactivePlot) {
                    var killBtn = Ext.get('killopBtn');
                    killBtn.on('click', function(e, t) {
                            AmdaAction.killPlotRequest(function(result, e) {
                                var t = e.getTransaction();
                                if (e.status) {
                                    if (!result)
                                        myDesktopApp.errorMsg('Cannot kill process');
                                } else
                                    myDesktopApp.errorMsg(e.message);

                            }, this);

                        },
                        this);

                }
            },
            hide: function() {
                Ext.getBody().unmask();
                this.tid = null;
            },
            isMasked: function() {
                return Ext.getBody().isMasked();
            }
        });

        var loadMask;

        Ext.onReady(function() {
            //TODO update jobsStatus onLogin             
            Ext.Ajax.extraParams = {
                sessionID: sessionID
            };
            Ext.Ajax.timeout = gatewayTimeout; // msec ; should be the same value (or less) as gateway timeout

            Ext.Ajax.on('requestexception', function(conn, response, options, e) {

                if (loadMask && loadMask.isMasked())
                    loadMask.hide();

                if (response && response.statusText) {
                    if (response.timedout)
                        alert('Request processing time exceeds gateway timeout\n In case of parameter from Remote Bases : please re-launch the same request in 10 min,\n otherwise select "non-screen" FileOutput or contact AMDA team');
                    else
                        alert(response.statusText);
                } else
                    alert('Communication failure');
            });

            // backspace key disable           
            Ext.EventManager.on(window, 'keydown', function(e, t) {
                if (e.getKey() == e.BACKSPACE && ((!/^input$/i.test(t.tagName) && !/^textarea$/i.test(t.tagName)) || t.disabled || t.readOnly)) {
                    e.stopEvent();
                }
            });

            var stateProvider = Ext.create('amdaDesktop.AmdaStateProvider');
            stateProvider.on({
                scope: this,
                afterrestore: function(provider) {
                    AmdaAction.getDefaultValueTree(false, function(defaults){
                        if(defaults['success'])
                            amdaDefaultValues=defaults['defaultValues'];
                        AmdaAction.getDefaultValueConfigs(function(configs){
                            if(configs["success"])
                                amdaDefaultConfigs = configs["configs"];

                            AmdaAction.getDefaultValueLinks(function(links){
                                if(links["success"])
                                    amdaDefaultOptions = links['links'];
                                
                                amdaDesktop.JobsMgr.getStatus();
                                Ext.state.Manager.setProvider(provider);
                                myDesktopApp = new amdaApp.AmdaApp();
                                // global message bus
                                myDesktopApp.EventManager = new Ext.util.Observable();
                                // not needed - for documentation only
                                myDesktopApp.EventManager.addEvents('refresh');
                                loadMask = new AMDAMask();
                            }) ;
                        });
                    }) ;

                    
                }
            });

            stateProvider.restoreState();
        });
    </script>
</head>

<body />

</html>