Commits

Sebastian Sdorra  committed 7dba697

added cancel button to login window

  • Participants
  • Parent commits 20b168a

Comments (0)

Files changed (3)

File scm-webapp/src/main/webapp/resources/js/sonia.global.js

   Ext.getCmp('navigationPanel').removeAll();
 }
 
+function checkLogin(){
+  Ext.Ajax.request({
+    url: restUrl + 'authentication.json',
+    method: 'GET',
+    success: function(response){
+      if ( debug ){
+        console.debug('login success');
+      }
+      var s = Ext.decode(response.responseText);
+      loadState(s);
+    },
+    failure: function(){
+      if ( debug ){
+        console.debug('login failed');
+      }
+      var loginWin = new Sonia.login.Window();
+      loginWin.show();
+    }
+  });
+}
+
 function login(){
   clearState();
   var loginWin = new Sonia.login.Window();

File scm-webapp/src/main/webapp/resources/js/sonia.login.js

         }
       }],
       buttons:[{
-        text: 'Login',
-        formBind: true,
-        scope: this,
-        handler: this.authenticate
+          text: 'Cancel',
+          scope: this,
+          handler: this.cancel
+        },{
+          text: 'Login',
+          formBind: true,
+          scope: this,
+          handler: this.authenticate
       }]
     };
 
+    this.addEvents('cancel');
+
     Ext.apply(this, Ext.apply(this.initialConfig, config));
     Sonia.login.Form.superclass.initComponent.apply(this, arguments);
   },
 
+  cancel: function(){
+    this.fireEvent('cancel');
+    checkLogin();
+  },
+
   authenticate: function(){
     var form = this.getForm();
     form.submit({
       this.fireEvent('success');
       this.close();
     }, this);
+    form.on('cancel', function(){
+      this.close();
+    }, this);
 
     var config = {
       layout:'fit',

File scm-webapp/src/main/webapp/resources/js/sonia.scm.js

     ]
   });
 
-  // check login
-  Ext.Ajax.request({
-    url: restUrl + 'authentication.json',
-    method: 'GET',
-    success: function(response){
-      if ( debug ){
-        console.debug('login success');
-      }
-      var s = Ext.decode(response.responseText);
-      loadState(s);
-    },
-    failure: function(){
-      if ( debug ){
-        console.debug('login failed');
-      }
-      var loginWin = new Sonia.login.Window();
-      loginWin.show();
-    }
-  });
+  checkLogin();
 
   // adds a tab to main TabPanel
   function addTabPanel(id, xtype, title){