[pve-devel] r5765 - pve-manager/pve2/www/new/window

svn-commits at proxmox.com svn-commits at proxmox.com
Tue Mar 29 13:29:11 CEST 2011


Author: dietmar
Date: 2011-03-29 13:29:11 +0200 (Tue, 29 Mar 2011)
New Revision: 5765

Modified:
   pve-manager/pve2/www/new/window/LoginWindow.js
Log:
make onLogon private


Modified: pve-manager/pve2/www/new/window/LoginWindow.js
===================================================================
--- pve-manager/pve2/www/new/window/LoginWindow.js	2011-03-29 11:14:56 UTC (rev 5764)
+++ pve-manager/pve2/www/new/window/LoginWindow.js	2011-03-29 11:29:11 UTC (rev 5765)
@@ -1,9 +1,6 @@
-Ext.define('PVE.window.LoginWindow', {
-    extend: 'Ext.window.Window',
-    requires: ['Ext.data.Store', 'Ext.form.ComboBox'],
+Ext.define('PVE.window.LoginWindow', function() {
 
-    onLogon: function() {
-	var self = this;
+    var onLogon = function(self) {
 
 	var form = self.getComponent(0).getForm();
 
@@ -13,14 +10,14 @@
 	    form.submit({
 		failure: function(f, resp){
 		    self.el.unmask();
-		    Ext.MessageBox.alert('Failure', "Login failed. Please try again", function() {
+		    Ext.MessageBox.alert('Failure', "Login faailed. Please try again", function() {
 			var uf = form.findField('username');
 			uf.focus(true);
 		    });
 		},
 		success: function(f, resp){
 		    self.el.unmask();
-
+		    
 		    if (resp.result && resp.result.data)
 			PVECSRFPreventionToken = resp.result.data.CSRFPreventionToken;
 
@@ -30,155 +27,158 @@
 		}
 	    });
 	}
-    },
+    };
 
-    initComponent: function() {
-	var self = this;
+    return {
+	extend: 'Ext.window.Window',
+	requires: ['Ext.data.Store', 'Ext.form.ComboBox'],
 
-	Ext.regModel('PVERealm', {
-	    fields: [ 'realm', 'comment', 'default' ],
-	    idProperty: 'realm',
-	    proxy: {
-		type: 'rest',
-		url: "/api2/json/access/domains",
+	initComponent: function() {
+	    var self = this;
 
-		pageParam : null,
-		startParam: null,
-		limitParam: null,
-		groupParam: null,
-		sortParam: null,
-		filterParam: null,
-		noCache : false,
+	    Ext.regModel('PVERealm', {
+		fields: [ 'realm', 'comment', 'default' ],
+		idProperty: 'realm',
+		proxy: {
+		    type: 'rest',
+		    url: "/api2/json/access/domains",
 
-		reader: {
-		    type: 'json',
-		    root: 'data'
+		    pageParam : null,
+		    startParam: null,
+		    limitParam: null,
+		    groupParam: null,
+		    sortParam: null,
+		    filterParam: null,
+		    noCache : false,
+
+		    reader: {
+			type: 'json',
+			root: 'data'
+		    }
 		}
-	    }
-	});
+	    });
  
-	var realmstore = Ext.create('Ext.data.Store', {
-	    model: 'PVERealm',
-	    autoDestory: true
-	});
+	    var realmstore = Ext.create('Ext.data.Store', {
+		model: 'PVERealm',
+		autoDestory: true
+	    });
 
-	var combo = Ext.create('Ext.form.ComboBox', {
-	    fieldLabel: 'Realm',
-	    name: 'realm',
-	    store: realmstore,
-	    queryMode: 'local',
-	    allowBlank: false,
-	    forceSelection: true,
-	    autoSelect: false,
-	    triggerAction: 'all',
-	    valueField: 'realm',
-	    displayField: 'comment',
-	    getState: function() {
-		return { value: this.getValue() };
-	    },
-	    applyState : function(state) {
-		if (state && state.value) {
-		    this.setValue(state.value);
-		}
-	    },
-	    stateEvents: [ 'select' ],
-	    stateful: true,
-	    stateId: 'pveloginrealm'        
-	});
+	    var combo = Ext.create('Ext.form.ComboBox', {
+		fieldLabel: 'Realm',
+		name: 'realm',
+		store: realmstore,
+		queryMode: 'local',
+		allowBlank: false,
+		forceSelection: true,
+		autoSelect: false,
+		triggerAction: 'all',
+		valueField: 'realm',
+		displayField: 'comment',
+		getState: function() {
+		    return { value: this.getValue() };
+		},
+		applyState : function(state) {
+		    if (state && state.value) {
+			this.setValue(state.value);
+		    }
+		},
+		stateEvents: [ 'select' ],
+		stateful: true,
+		stateId: 'pveloginrealm'        
+	    });
 
-	realmstore.load({
-	    callback: function(r, o, success) {
-		if (success) {
-		    var def = combo.getValue();
-		    if (!def) {
-			if (r[0] && r[0].data)
-			    def = r[0].data.realm;
-			Ext.each(r, function(record) {
-			    if (record.data && record.data["default"]) 
-				def = record.data.realm;
-			});
+	    realmstore.load({
+		callback: function(r, o, success) {
+		    if (success) {
+			var def = combo.getValue();
+			if (!def) {
+			    if (r[0] && r[0].data)
+				def = r[0].data.realm;
+			    Ext.each(r, function(record) {
+				if (record.data && record.data["default"]) 
+				    def = record.data.realm;
+			    });
+			}
+			if (def)
+			    combo.setValue(def)
 		    }
-		    if (def)
-			combo.setValue(def)
 		}
-	    }
-	});
+	    });
 
-	Ext.apply(self, {
-            width: 400,
-            height: 160,
-            modal: true,
-	    border: false,
-            draggable: true,
-	    closable: false,
-	    resizable: false,
-	    layout: 'fit',
-            title: 'PVE Manager Login',
+	    Ext.apply(self, {
+		width: 400,
+		height: 160,
+		modal: true,
+		border: false,
+		draggable: true,
+		closable: false,
+		resizable: false,
+		layout: 'fit',
+		title: 'PVE Manager Login',
 
-	    items: [{
-		xtype: 'form',
-		frame: true,
-		url: '/api2/extjs/access/ticket',
+		items: [{
+		    xtype: 'form',
+		    frame: true,
+		    url: '/api2/extjs/access/ticket',
 
-		labelWidth: 70,
-		labelAlign  : 'right',
+		    labelWidth: 70,
+		    labelAlign  : 'right',
 
-		defaults: {
-		    anchor: '-5',
-		    allowBlank: false
-		},
+		    defaults: {
+			anchor: '-5',
+			allowBlank: false
+		    },
 
-		items: [
-		    { 
-			xtype: 'textfield', 
-			fieldLabel: 'User name', 
-			name: 'username',
-			blankText: "Enter your user name",
-			listeners: {
-			    render: function(f) {
-				f.focus(true, 500);
-			    },
-			    specialkey: function(f, e) {
-				var form = f.findParentByType("form").getForm();
-				if (e.getKey() === e.ENTER) {
-				    var pf = form.findField('password');
-				    if (pf.getValue()) {
-					self.onLogon();
-				    } else {
-					pf.focus(false);
+		    items: [
+			{ 
+			    xtype: 'textfield', 
+			    fieldLabel: 'User name', 
+			    name: 'username',
+			    blankText: "Enter your user name",
+			    listeners: {
+				render: function(f) {
+				    f.focus(true, 500);
+				},
+				specialkey: function(f, e) {
+				    var form = f.findParentByType("form").getForm();
+				    if (e.getKey() === e.ENTER) {
+					var pf = form.findField('password');
+					if (pf.getValue()) {
+					    onLogon(self);
+					} else {
+					    pf.focus(false);
+					}
 				    }
 				}
 			    }
-			}
-		    },
-		    { 
-			xtype: 'textfield', 
-			inputType: 'password',
-			fieldLabel: 'Password', 
-			name: 'password',
-			blankText:"Enter your password",
-			listeners: {
-			    specialkey: function(field, e) {
-				if (e.getKey() === e.ENTER) {
-				    self.onLogon();
+			},
+			{ 
+			    xtype: 'textfield', 
+			    inputType: 'password',
+			    fieldLabel: 'Password', 
+			    name: 'password',
+			    blankText:"Enter your password",
+			    listeners: {
+				specialkey: function(field, e) {
+				    if (e.getKey() === e.ENTER) {
+					onLogon(self);
+				    }
 				}
 			    }
+			},
+			combo
+		    ],
+		    buttons: [
+			{
+			    text: 'Login',
+			    handler: function(){
+				onLogon(self);
+			    }
 			}
-		    },
-		    combo
-		],
-		buttons: [
-		    {
-			text: 'Login',
-			handler: function(){
-			    self.onLogon();
-			}
-		    }
-		]
-	    }]
-	});
+		    ]
+		}]
+	    });
 
-	PVE.window.LoginWindow.superclass.initComponent.call(self);
-    }
-
-});
+	    PVE.window.LoginWindow.superclass.initComponent.call(self);
+	}
+    }}());



More information about the pve-devel mailing list