[pve-devel] r5485 - in pve-manager/pve2: . www/manager www/manager/window
svn-commits at proxmox.com
svn-commits at proxmox.com
Thu Feb 3 12:36:21 CET 2011
Author: dietmar
Date: 2011-02-03 12:36:21 +0100 (Thu, 03 Feb 2011)
New Revision: 5485
Modified:
pve-manager/pve2/ChangeLog
pve-manager/pve2/www/manager/PVEUtils.js
pve-manager/pve2/www/manager/Workspace.js
pve-manager/pve2/www/manager/window/LoginWindow.js
Log:
Modified: pve-manager/pve2/ChangeLog
===================================================================
--- pve-manager/pve2/ChangeLog 2011-02-03 07:16:40 UTC (rev 5484)
+++ pve-manager/pve2/ChangeLog 2011-02-03 11:36:21 UTC (rev 5485)
@@ -1,3 +1,13 @@
+2011-02-03 Proxmox Support Team <support at proxmox.com>
+
+ * www/manager/PVEUtils.js: add 'requestexception' event listener,
+ display login window when we receive error 401
+
+ * www/manager/Workspace.js: only display LoginWindow once
+
+ * www/manager/window/LoginWindow.js: avoid scope/this horror by
+ using 'self' variable.
+
2011-01-18 root <root at maui.maurer-it.com>
* www/manager/PVEConsole.js: test code for new TigerVNC applet
Modified: pve-manager/pve2/www/manager/PVEUtils.js
===================================================================
--- pve-manager/pve2/www/manager/PVEUtils.js 2011-02-03 07:16:40 UTC (rev 5484)
+++ pve-manager/pve2/www/manager/PVEUtils.js 2011-02-03 11:36:21 UTC (rev 5485)
@@ -15,6 +15,12 @@
// do not send '_dc' parameter
Ext.Ajax.disableCaching = false;
+Ext.Ajax.on('requestexception', function(conn, response, options) {
+ if (response.status == 401) {
+ PVE.Workspace.showLogin();
+ }
+});
+
PVE.Utils = function() {
var log_severity_hash = {
Modified: pve-manager/pve2/www/manager/Workspace.js
===================================================================
--- pve-manager/pve2/www/manager/Workspace.js 2011-02-03 07:16:40 UTC (rev 5484)
+++ pve-manager/pve2/www/manager/Workspace.js 2011-02-03 11:36:21 UTC (rev 5485)
@@ -2,7 +2,7 @@
PVE.Workspace = function() {
- var viewport, content;
+ var viewport, content, login;
var defaultView = {
//xtype: "pveTestPanel",
@@ -94,6 +94,7 @@
viewport = new Ext.Viewport({ layout : 'fit' });
if (!PVE.Utils.authOK()) {
+ console.log("auth not OK");
PVE.Workspace.showLogin();
} else {
buildContent();
@@ -114,21 +115,19 @@
showLogin: function() {
PVE.Utils.authClear();
- if (content) {
- viewport.remove(content);
- content.destroy();
- content = null;
+
+ if (!login) {
+ login = new PVE.window.LoginWindow({
+ handler: function() {
+ if (!content)
+ buildContent();
+ login = null;
+ }
+ });
}
- var login = new PVE.window.LoginWindow({
- handler: function() {
- buildContent();
- login.destroy();
- }
- });
login.show();
},
-
dummy: "ignore me"
};
Modified: pve-manager/pve2/www/manager/window/LoginWindow.js
===================================================================
--- pve-manager/pve2/www/manager/window/LoginWindow.js 2011-02-03 07:16:40 UTC (rev 5484)
+++ pve-manager/pve2/www/manager/window/LoginWindow.js 2011-02-03 11:36:21 UTC (rev 5485)
@@ -3,29 +3,32 @@
PVE.window.LoginWindow = Ext.extend(Ext.Window, {
onLogon: function() {
- var form = this.get(0).getForm();
+ var self = this;
+ var form = self.get(0).getForm();
+
if(form.isValid()){
- this.el.mask('Please wait...', 'x-mask-loading');
+ self.el.mask('Please wait...', 'x-mask-loading');
form.submit({
- scope: this,
failure: function(f, resp){
- this.el.unmask();
+ self.el.unmask();
Ext.MessageBox.alert('Failure', "Login failed. Please try again");
},
success: function(f, resp){
- this.el.unmask();
- var handler = this.handler || Ext.emptyFn;
- handler.call(this.scope || this);
- this.destroy();
+ self.el.unmask();
+ var handler = self.handler || Ext.emptyFn;
+ handler.call(self);
+ self.close();
}
});
}
},
initComponent: function() {
- Ext.apply(this, {
+ var self = this;
+
+ Ext.apply(self, {
width: 300,
height: 125,
modal: true,
@@ -48,10 +51,9 @@
anchor: '-5',
allowBlank: false,
listeners: {
- scope: this,
specialkey: function(field, e) {
if (e.getKey() === e.ENTER) {
- this.onLogon();
+ self.onLogon();
}
}
}
@@ -74,17 +76,16 @@
],
buttons: [
{
- text: 'Login',
- scope: this,
+ text: 'Login',
handler: function(){
- this.onLogon();
+ self.onLogon();
}
}
]
}]
});
- PVE.window.LoginWindow.superclass.initComponent.call(this);
+ PVE.window.LoginWindow.superclass.initComponent.call(self);
}
});
More information about the pve-devel
mailing list