[pve-devel] r5902 - in pve-manager/pve2/www/new: . form qemu
svn-commits at proxmox.com
svn-commits at proxmox.com
Thu May 5 10:06:33 CEST 2011
Author: dietmar
Date: 2011-05-05 10:06:33 +0200 (Thu, 05 May 2011)
New Revision: 5902
Added:
pve-manager/pve2/www/new/form/FileSelector.js
Modified:
pve-manager/pve2/www/new/Makefile.am
pve-manager/pve2/www/new/PVEUtils.js
pve-manager/pve2/www/new/form/ComboGrid.js
pve-manager/pve2/www/new/form/StorageSelector.js
pve-manager/pve2/www/new/qemu/CreateWizard.js
pve-manager/pve2/www/new/qemu/HardwareView.js
Log:
Modified: pve-manager/pve2/www/new/Makefile.am
===================================================================
--- pve-manager/pve2/www/new/Makefile.am 2011-05-05 08:06:18 UTC (rev 5901)
+++ pve-manager/pve2/www/new/Makefile.am 2011-05-05 08:06:33 UTC (rev 5902)
@@ -14,6 +14,7 @@
form/RealmComboBox.js \
form/ViewSelector.js \
form/NodeSelector.js \
+ form/FileSelector.js \
form/StorageSelector.js \
panel/StatusPanel.js \
window/LoginWindow.js \
Modified: pve-manager/pve2/www/new/PVEUtils.js
===================================================================
--- pve-manager/pve2/www/new/PVEUtils.js 2011-05-05 08:06:18 UTC (rev 5901)
+++ pve-manager/pve2/www/new/PVEUtils.js 2011-05-05 08:06:33 UTC (rev 5902)
@@ -46,6 +46,13 @@
Ext.util.Cookies.clear("PVEAuthCookie");
},
+ gridLineHeigh: function() {
+ if (Ext.isGecko)
+ return 23;
+
+ return 21;
+ },
+
format_size: function(size) {
var kb = size / 1024;
Modified: pve-manager/pve2/www/new/form/ComboGrid.js
===================================================================
--- pve-manager/pve2/www/new/form/ComboGrid.js 2011-05-05 08:06:18 UTC (rev 5901)
+++ pve-manager/pve2/www/new/form/ComboGrid.js 2011-05-05 08:06:33 UTC (rev 5902)
@@ -5,11 +5,18 @@
],
alias: ['widget.PVE.form.ComboGrid'],
+ computeHeight: function() {
+ var me = this;
+
+ return (me.store.totalCount > 10) ? 10*23 : 25+me.store.totalCount*23;
+ },
+
// copied from ComboBox
createPicker: function() {
var me = this,
picker,
menuCls = Ext.baseCSSPrefix + 'menu',
+
opts = Ext.apply({
selModel: {
mode: me.multiSelect ? 'SIMPLE' : 'SINGLE'
@@ -21,6 +28,7 @@
store: me.store,
displayField: me.displayField,
focusOnToFront: false,
+ height: me.computeHeight(),
pageSize: me.pageSize
}, me.listConfig, me.defaultListConfig);
@@ -36,6 +44,9 @@
me.mon(picker, {
itemclick: me.onItemClick,
refresh: me.onListRefresh,
+ show: function() {
+ picker.setHeight(me.computeHeight());
+ },
scope: me
});
@@ -53,7 +64,6 @@
Ext.apply(me, {
queryMode: 'local',
editable: false,
- autoSelect: true,
matchFieldWidth: false
});
@@ -61,18 +71,26 @@
me.callParent();
+ me.store.on('beforeload', function() {
+ console.log("start load");
+ //me.up('form').setLoading(true, true);
+ });
+
// hack: autoSelect does not work
me.store.on('load', function(store, r, success, o) {
if (success) {
var def = me.getValue();
if (!def || !store.findRecord(me.valueField, def)) {
var rec = me.store.first();
- if (rec && rec.data) {
+ if (me.autoSelect && rec && rec.data) {
def = rec.data[me.valueField];
me.setValue(def);
+ } else {
+ me.setValue('');
}
}
}
+ //me.up('form').setLoading(false);
});
}
});
\ No newline at end of file
Added: pve-manager/pve2/www/new/form/FileSelector.js
===================================================================
--- pve-manager/pve2/www/new/form/FileSelector.js (rev 0)
+++ pve-manager/pve2/www/new/form/FileSelector.js 2011-05-05 08:06:33 UTC (rev 5902)
@@ -0,0 +1,83 @@
+Ext.define('PVE.form.FileSelector', {
+ extend: 'PVE.form.ComboGrid',
+ requires: [
+ 'Ext.data.Store',
+ 'PVE.RestProxy'
+ ],
+ alias: ['widget.PVE.form.FileSelector'],
+
+ setStorage: function(storage, nodename) {
+ var me = this;
+
+ var change = false;
+ if (storage && (me.storage !== storage)) {
+ me.storage = storage;
+ change = true;
+ }
+
+ if (nodename && (me.nodename !== nodename)) {
+ me.nodename = nodename;
+ change = true;
+ }
+
+ if (!(me.storage && me.nodename && change))
+ return;
+
+ console.log("setStorage " + me.storage + " node " + me.nodename);
+
+ //me.setValue('');
+
+ me.store.setProxy({
+ type: 'pve',
+ url: '/api2/json/nodes/' + me.nodename + '/storage/' + me.storage
+ });
+
+ me.store.load({
+ callback: function() {
+ console.log("TEST " + me.store.totalCount);
+ }
+ });
+ },
+
+ initComponent: function() {
+ var me = this;
+
+ var store = Ext.create('Ext.data.Store', {
+ fields: [ 'volid', 'format', 'size', 'used', 'vmid' ],
+ autoDestory: true
+ });
+
+ Ext.apply(me, {
+ store: store,
+ allowBlank: false,
+ autoSelect: false,
+ valueField: 'volid',
+ displayField: 'volid',
+ listConfig: {
+ columns: [
+ {
+ header: 'Name',
+ dataIndex: 'volid',
+ hideable: false,
+ flex: 1
+ },
+ {
+ header: 'Format',
+ width: 60,
+ dataIndex: 'format'
+ },
+ {
+ header: 'Size',
+ width: 60,
+ dataIndex: 'size',
+ renderer: PVE.Utils.format_size
+ }
+ ]
+ }
+ });
+
+ me.callParent();
+
+ me.setStorage(me.storage, me.nodename);
+ }
+});
\ No newline at end of file
Modified: pve-manager/pve2/www/new/form/StorageSelector.js
===================================================================
--- pve-manager/pve2/www/new/form/StorageSelector.js 2011-05-05 08:06:18 UTC (rev 5901)
+++ pve-manager/pve2/www/new/form/StorageSelector.js 2011-05-05 08:06:33 UTC (rev 5902)
@@ -9,7 +9,7 @@
setNodename: function(nodename) {
var me = this;
- if (!nodename)
+ if (!nodename || (me.nodename === nodename))
return;
me.nodename = nodename;
@@ -30,8 +30,6 @@
autoDestory: true
});
- me.setNodename(me.nodename);
-
Ext.apply(me, {
store: store,
allowBlank: false,
@@ -67,5 +65,7 @@
});
me.callParent();
+
+ me.setNodename(me.nodename);
}
});
\ No newline at end of file
Modified: pve-manager/pve2/www/new/qemu/CreateWizard.js
===================================================================
--- pve-manager/pve2/www/new/qemu/CreateWizard.js 2011-05-05 08:06:18 UTC (rev 5901)
+++ pve-manager/pve2/www/new/qemu/CreateWizard.js 2011-05-05 08:06:33 UTC (rev 5902)
@@ -20,12 +20,23 @@
var nextvmid = PVE.data.ResourceStore.findNextVMID();
+ var cdfilesel = Ext.create('PVE.form.FileSelector', {
+ name: 'cdimage',
+ fieldLabel: 'ISO Image',
+ labelAlign: 'right',
+ allowBlank: false
+ });
+
var cdstoragesel = Ext.create('PVE.form.StorageSelector', {
name: 'cdstorage',
fieldLabel: 'Storage',
labelAlign: 'right',
- //disabled: true,
- allowBlank: false
+ allowBlank: false,
+ listeners: {
+ change: function(f, value) {
+ cdfilesel.setStorage(value);
+ }
+ }
});
Ext.applyIf(me, {
@@ -42,6 +53,7 @@
listeners: {
change: function(f, value) {
cdstoragesel.setNodename(value);
+ cdfilesel.setStorage(undefined, value);
}
}
},
@@ -62,7 +74,6 @@
}
]
},
-
{
title: 'OS Type',
layout: 'fit',
@@ -145,24 +156,22 @@
name: 'mediaType',
inputValue: 'iso',
boxLabel: 'Use CD/DVD disc image file (iso)',
- // hideLabel: true,
- //checked: true
-
+ checked: true,
+ listeners: {
+ change: function(f, value) {
+ me.down('field[name=cdstorage]').setDisabled(!value);
+ me.down('field[name=cdimage]').setDisabled(!value);
+ console.log("CHANGE: " + value);
+ }
+ }
},
- cdstoragesel,
+ cdstoragesel,
+ cdfilesel,
{
- xtype: 'textfield',
- name: 'cdimage',
- fieldLabel: 'ISO Image',
- labelAlign: 'right',
- disabled: true,
- allowBlank: false
- },
- {
xtype: 'radiofield',
name: 'mediaType',
inputValue: 'cdrom',
- boxLabel: 'Use physical CD/DVD Drive',
+ boxLabel: 'Use physical CD/DVD Drive'
// hideLabel: true,
//checked: true
@@ -171,7 +180,7 @@
xtype: 'radiofield',
name: 'mediaType',
inputValue: 'none',
- boxLabel: 'Do not use any installation media',
+ boxLabel: 'Do not use any installation media'
// hideLabel: true,
//checked: true
}
Modified: pve-manager/pve2/www/new/qemu/HardwareView.js
===================================================================
--- pve-manager/pve2/www/new/qemu/HardwareView.js 2011-05-05 08:06:18 UTC (rev 5901)
+++ pve-manager/pve2/www/new/qemu/HardwareView.js 2011-05-05 08:06:33 UTC (rev 5902)
@@ -96,7 +96,7 @@
interval: 1000,
tbar: [
{
- text: "Edit",
+ text: "Edit"
//handler: run_editor
}
],
More information about the pve-devel
mailing list