[pve-devel] r5767 - in pve-manager/pve2/www/new: . data form window
svn-commits at proxmox.com
svn-commits at proxmox.com
Tue Mar 29 14:44:20 CEST 2011
Author: dietmar
Date: 2011-03-29 14:44:20 +0200 (Tue, 29 Mar 2011)
New Revision: 5767
Added:
pve-manager/pve2/www/new/form/
pve-manager/pve2/www/new/form/RealmComboBox.js
Modified:
pve-manager/pve2/www/new/Makefile.am
pve-manager/pve2/www/new/data/PVEProxy.js
pve-manager/pve2/www/new/window/LoginWindow.js
Log:
split out RealmComboBox code
Modified: pve-manager/pve2/www/new/Makefile.am
===================================================================
--- pve-manager/pve2/www/new/Makefile.am 2011-03-29 11:47:09 UTC (rev 5766)
+++ pve-manager/pve2/www/new/Makefile.am 2011-03-29 12:44:20 UTC (rev 5767)
@@ -1,6 +1,7 @@
include $(top_builddir)/common.mk
JSSRC= \
+ form/RealmComboBox.js \
data/PVEProxy.js \
window/LoginWindow.js \
PVEUtils.js \
Modified: pve-manager/pve2/www/new/data/PVEProxy.js
===================================================================
--- pve-manager/pve2/www/new/data/PVEProxy.js 2011-03-29 11:47:09 UTC (rev 5766)
+++ pve-manager/pve2/www/new/data/PVEProxy.js 2011-03-29 12:44:20 UTC (rev 5767)
@@ -17,7 +17,18 @@
}
});
- PVE.RestProxy.superclass.constructor.apply(this, arguments);
+ PVE.RestProxy.superclass.constructor.apply(this, arguments);
}
+}, function() {
+
+ Ext.regModel('PVERealm', {
+ fields: [ 'realm', 'comment', 'default' ],
+ idProperty: 'realm',
+ proxy: {
+ type: 'pve',
+ url: "/api2/json/access/domains"
+ }
+ });
+
});
Added: pve-manager/pve2/www/new/form/RealmComboBox.js
===================================================================
--- pve-manager/pve2/www/new/form/RealmComboBox.js (rev 0)
+++ pve-manager/pve2/www/new/form/RealmComboBox.js 2011-03-29 12:44:20 UTC (rev 5767)
@@ -0,0 +1,59 @@
+Ext.define('PVE.form.RealmComboBox', {
+ extend: 'Ext.form.ComboBox',
+ requires: ['Ext.data.Store'],
+ uses: ['PVE.RestProxy'],
+ alias: ['widget.PVERealmComboBox'],
+
+ initComponent: function() {
+ var self = this;
+
+ var realmstore = Ext.create('Ext.data.Store', {
+ model: 'PVERealm',
+ autoDestory: true
+ });
+
+ Ext.apply(self, {
+ 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'
+ });
+
+ PVE.form.RealmComboBox.superclass.initComponent.call(self);
+
+ realmstore.load({
+ callback: function(r, o, success) {
+ if (success) {
+ var def = self.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)
+ self.setValue(def)
+ }
+ }
+ });
+ }
+});
\ No newline at end of file
Modified: pve-manager/pve2/www/new/window/LoginWindow.js
===================================================================
--- pve-manager/pve2/www/new/window/LoginWindow.js 2011-03-29 11:47:09 UTC (rev 5766)
+++ pve-manager/pve2/www/new/window/LoginWindow.js 2011-03-29 12:44:20 UTC (rev 5767)
@@ -31,68 +31,11 @@
return {
extend: 'Ext.window.Window',
- requires: ['Ext.data.Store', 'Ext.form.ComboBox', 'PVE.RestProxy'],
+ uses: ['PVE.form.RealmComboBox'],
initComponent: function() {
var self = this;
- Ext.regModel('PVERealm', {
- fields: [ 'realm', 'comment', 'default' ],
- idProperty: 'realm',
- proxy: {
- type: 'pve',
- url: "/api2/json/access/domains",
-
- }
- });
-
- 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'
- });
-
- 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)
- }
- }
- });
-
Ext.apply(self, {
width: 400,
height: 160,
@@ -154,7 +97,10 @@
}
}
},
- combo
+ {
+ xtype: 'PVERealmComboBox',
+ name: 'realm'
+ }
],
buttons: [
{
More information about the pve-devel
mailing list