[pve-devel] r6362 - in pve-manager/pve2: . www/manager www/manager/dc www/manager/storage

svn-commits at proxmox.com svn-commits at proxmox.com
Tue Jul 26 10:25:32 CEST 2011


Author: dietmar
Date: 2011-07-26 10:25:32 +0200 (Tue, 26 Jul 2011)
New Revision: 6362

Added:
   pve-manager/pve2/www/manager/storage/iSCSIEdit.js
Modified:
   pve-manager/pve2/ChangeLog
   pve-manager/pve2/www/manager/Makefile.am
   pve-manager/pve2/www/manager/Utils.js
   pve-manager/pve2/www/manager/dc/StorageView.js
   pve-manager/pve2/www/manager/storage/NFSEdit.js
Log:

iSCSIEdit.js impl.



Modified: pve-manager/pve2/ChangeLog
===================================================================
--- pve-manager/pve2/ChangeLog	2011-07-26 06:49:36 UTC (rev 6361)
+++ pve-manager/pve2/ChangeLog	2011-07-26 08:25:32 UTC (rev 6362)
@@ -1,3 +1,7 @@
+2011-07-26  Proxmox Support Team  <support at proxmox.com>
+
+	* www/manager/storage/iSCSIEdit.js: impl.
+
 2011-07-25  Proxmox Support Team  <support at proxmox.com>
 
 	* www/manager/tree/ResourceTree.js (addChildSorted): use other

Modified: pve-manager/pve2/www/manager/Makefile.am
===================================================================
--- pve-manager/pve2/www/manager/Makefile.am	2011-07-26 06:49:36 UTC (rev 6361)
+++ pve-manager/pve2/www/manager/Makefile.am	2011-07-26 08:25:32 UTC (rev 6362)
@@ -85,6 +85,7 @@
 	storage/Browser.js				\
 	storage/DirEdit.js				\
 	storage/NFSEdit.js				\
+	storage/iSCSIEdit.js				\
 	dc/StorageView.js				\
 	dc/UserEdit.js					\
 	dc/UserView.js					\

Modified: pve-manager/pve2/www/manager/Utils.js
===================================================================
--- pve-manager/pve2/www/manager/Utils.js	2011-07-26 06:49:36 UTC (rev 6361)
+++ pve-manager/pve2/www/manager/Utils.js	2011-07-26 08:25:32 UTC (rev 6362)
@@ -310,14 +310,8 @@
 
 	var target = newopts.waitMsgTarget;
 	if (target) {
-	    if (target.rendered) {
-		target.setLoading(newopts.waitMsg, true);
-	    } else {
-		// hack: extjs should do that for us
-		target.on('afterlayout', function() {
-		    target.setLoading(newopts.waitMsg, true);
-		});
-	    }
+	    // Note: ExtJS bug - this does not work when component is not rendered
+	    target.setLoading(newopts.waitMsg, true);
 	}
 	Ext.Ajax.request(newopts);
     },

Modified: pve-manager/pve2/www/manager/dc/StorageView.js
===================================================================
--- pve-manager/pve2/www/manager/dc/StorageView.js	2011-07-26 06:49:36 UTC (rev 6361)
+++ pve-manager/pve2/www/manager/dc/StorageView.js	2011-07-26 08:25:32 UTC (rev 6362)
@@ -35,6 +35,8 @@
 		editor = 'PVE.storage.DirEdit';
 	    } else if (type === 'nfs') {
 		editor = 'PVE.storage.NFSEdit';
+	    } else if (type === 'iscsi') {
+		editor = 'PVE.storage.IScsiEdit';
 	    } else {
 		return;
 	    }
@@ -135,7 +137,12 @@
 			    },
 			    {
 				text: 'iSCSI target',
-				iconCls: 'pve-itype-icon-node'
+				iconCls: 'pve-itype-icon-node',
+				handler: function() {
+				    var win = Ext.create('PVE.storage.IScsiEdit', {});
+				    win.on('destroy', reload);
+				    win.show();
+				}
 			    }
 			]
 		    })
@@ -165,10 +172,16 @@
 		    renderer: PVE.Utils.format_content_types
 		},
 		{
-		    header: 'Path',
-		    width: 200,
+		    header: 'Path/Target',
+		    flex: 1,
 		    sortable: true,
-		    dataIndex: 'path'
+		    dataIndex: 'path',
+		    renderer: function(value, metaData, record) {
+			if (record.data.target) {
+			    return record.data.target;
+			}
+			return value;
+		    }
 		},
 		{
 		    header: 'Shared',
@@ -199,7 +212,7 @@
     Ext.define('pve-storage', {
 	extend: 'Ext.data.Model',
 	fields: [ 
-	    'path', 'type', 'content', 'server', 'export', 'storage',
+	    'path', 'type', 'content', 'server', 'portal', 'target', 'export', 'storage',
 	    { name: 'shared', type: 'boolean'},
 	    { name: 'disable', type: 'boolean'} 
 	],

Modified: pve-manager/pve2/www/manager/storage/NFSEdit.js
===================================================================
--- pve-manager/pve2/www/manager/storage/NFSEdit.js	2011-07-26 06:49:36 UTC (rev 6361)
+++ pve-manager/pve2/www/manager/storage/NFSEdit.js	2011-07-26 08:25:32 UTC (rev 6362)
@@ -38,13 +38,17 @@
 		type: 'pve',
 		url: '/api2/json/nodes/' + me.nodename + '/scan/nfs'
 	    }
-	    //filterOnLoad: true
 	});
 
 	Ext.apply(me, {
 	    store: store,
 	    valueField: 'path',
-	    displayField: 'path'
+	    displayField: 'path',
+	    matchFieldWidth: false,
+	    listConfig: {
+		loadingText: 'Scanning...',
+		width: 350
+	    }
 	});
 
 	me.callParent();

Added: pve-manager/pve2/www/manager/storage/iSCSIEdit.js
===================================================================
--- pve-manager/pve2/www/manager/storage/iSCSIEdit.js	                        (rev 0)
+++ pve-manager/pve2/www/manager/storage/iSCSIEdit.js	2011-07-26 08:25:32 UTC (rev 6362)
@@ -0,0 +1,186 @@
+Ext.define('PVE.storage.IScsiScan', {
+    extend: 'Ext.form.field.ComboBox',
+    alias: 'widget.pveIScsiScan',
+
+    queryParam: 'portal',
+
+    doRawQuery: function() {
+    },
+
+    onTriggerClick: function() {
+	var me = this;
+
+	if (!me.queryCaching || me.lastQuery !== me.portal) {
+	    me.store.removeAll();
+	}
+
+	me.allQuery = me.portal;
+
+	me.callParent();
+    },
+
+    setPortal: function(portal) {
+	var me = this;
+
+	me.portal = portal;
+    },
+
+    initComponent : function() {
+	var me = this;
+
+	if (!me.nodename) {
+	    me.nodename = 'localhost';
+	}
+
+	var store = Ext.create('Ext.data.Store', {
+	    fields: [ 'target', 'portal' ],
+	    proxy: {
+		type: 'pve',
+		url: '/api2/json/nodes/' + me.nodename + '/scan/iscsi'
+	    }
+	});
+
+	Ext.apply(me, {
+	    store: store,
+	    valueField: 'target',
+	    displayField: 'target',
+	    matchFieldWidth: false,
+	    listConfig: {
+		loadingText: 'Scanning...',
+		width: 350
+	    }
+	});
+
+	me.callParent();
+    }
+});
+
+Ext.define('PVE.storage.IScsiInputPanel', {
+    extend: 'PVE.panel.InputPanel',
+
+    onGetValues: function(values) {
+	var me = this;
+
+	if (me.create) {
+	    values.type = 'iscsi';
+	} else {
+	    delete values.storage;
+	}
+
+	values.content = values.luns ? 'images' : 'none';
+	delete values.luns;
+
+	values.disable = values.enable ? 0 : 1;	    
+	delete values.enable;
+	
+	return values;
+    },
+
+    initComponent : function() {
+	var me = this;
+
+
+	me.column1 = [
+	    {
+		xtype: me.create ? 'textfield' : 'displayfield',
+		name: 'storage',
+		height: 22, // hack: set same height as text fields
+		value: me.storageId || '',
+		fieldLabel: 'Storage ID',
+		vtype: 'StorageId',
+		allowBlank: false
+	    },
+	    {
+		xtype: me.create ? 'textfield' : 'displayfield',
+		height: 22, // hack: set same height as text fields
+		name: 'portal',
+		value: '',
+		fieldLabel: 'Portal',
+		allowBlank: false,
+		listeners: {
+		    change: function(f, value) {
+			if (me.create) {
+			    var exportField = me.down('field[name=target]');
+			    exportField.setPortal(value);
+			    exportField.setValue('');
+			}
+		    }
+		}
+	    },
+	    {
+		readOnly: !me.create,
+		xtype: me.create ? 'pveIScsiScan' : 'displayfield',
+		name: 'target',
+		value: '',
+		fieldLabel: 'Target',
+		allowBlank: false
+	    }
+	];
+
+	me.column2 = [
+	    {
+		xtype: 'pvecheckbox',
+		name: 'enable',
+		checked: true,
+		uncheckedValue: 0,
+		fieldLabel: 'Enable'
+	    },
+	    {
+		xtype: 'checkbox',
+		name: 'luns',
+		checked: true,
+		fieldLabel: 'Use LUNs directly'
+	    }
+	];
+
+	me.callParent();
+    }
+});
+
+Ext.define('PVE.storage.IScsiEdit', {
+    extend: 'PVE.window.Edit',
+
+    initComponent : function() {
+	var me = this;
+ 
+	me.create = !me.storageId;
+
+	if (me.create) {
+            me.url = '/api2/extjs/storage';
+            me.method = 'POST';
+        } else {
+            me.url = '/api2/extjs/storage/' + me.storageId;
+            me.method = 'PUT';
+        }
+
+	var ipanel = Ext.create('PVE.storage.IScsiInputPanel', {
+	    create: me.create,
+	    storageId: me.storageId
+	});
+	
+	Ext.apply(me, {
+	    title: me.create ? "Create iSCSI storage" :
+		"Edit iSCSI storage '" + me.storageId + "'",
+	    items: [ ipanel ]
+	});
+
+	me.callParent();
+
+	if (!me.create) {
+	    me.load({
+		success:  function(response, options) {
+		    var values = response.result.data;
+		    var ctypes = values.content || '';
+
+		    if (values.storage === 'local') {
+			values.content = ctypes.split(',');
+		    }
+		    values.enable = values.disable ? 0 : 1;
+		    values.luns = (values.content === 'images') ? true : false;
+
+		    ipanel.setValues(values);
+		}
+	    });
+	}
+    }
+});




More information about the pve-devel mailing list