[pve-devel] [PATCH] Change iscsi provider to drop-down box Available isci providers are listed in a drop-down box for the user to choose. Fix some indentation problems as well.

mir at datanom.net mir at datanom.net
Thu Oct 24 00:07:40 CEST 2013


From: Michael Rasmussen <mir at datanom.net>

Signed-off-by: Michael Rasmussen <mir at datanom.net>
---
 www/manager/storage/ZFSEdit.js | 256 ++++++++++++++++++++++-------------------
 1 file changed, 135 insertions(+), 121 deletions(-)

diff --git a/www/manager/storage/ZFSEdit.js b/www/manager/storage/ZFSEdit.js
index 2a5a042..dc6b906 100644
--- a/www/manager/storage/ZFSEdit.js
+++ b/www/manager/storage/ZFSEdit.js
@@ -2,142 +2,156 @@ Ext.define('PVE.storage.ZFSInputPanel', {
     extend: 'PVE.panel.InputPanel',
 
     onGetValues: function(values) {
-	var me = this;
+    var me = this;
 
-	if (me.create) {
-	    values.type = 'zfs';
-	    values.content = 'images';
-	} else {
-	    delete values.storage;
-	}
+    if (me.create) {
+        values.type = 'zfs';
+        values.content = 'images';
+    } else {
+        delete values.storage;
+    }
 
-	values.disable = values.enable ? 0 : 1;
-	delete values.enable;
+    values.disable = values.enable ? 0 : 1;
+    delete values.enable;
 
-	return values;
+    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: 'ID',
-		vtype: 'StorageId',
-		allowBlank: false
-	    },
-	    {
-		xtype: me.create ? 'textfield' : 'displayfield',
-		name: 'portal',
-		height: 22, // hack: set same height as text fields
-		value: '',
-		fieldLabel: gettext('Portal'),
-		allowBlank: false
-	    },
-	    {
-		xtype: me.create ? 'textfield' : 'displayfield',
-		name: 'pool',
-		height: 22, // hack: set same height as text fields
-		value: '',
-		fieldLabel: gettext('Pool'),
-		allowBlank: false
-	    },
-	    {
-		xtype: me.create ? 'textfield' : 'displayfield',
-		name: 'blocksize',
-		height: 22, // hack: set same height as text fields
-		value: '4k',
-		fieldLabel: gettext('Block Size'),
-		allowBlank: false
-	    },
-	    {
-		xtype: me.create ? 'textfield' : 'displayfield',
-		name: 'target',
-		height: 22, // hack: set same height as text fields
-		value: 'iqn.2010-09.org.openindiana:omnios:....',
-		fieldLabel: gettext('Target'),
-		allowBlank: false
-	    }
-	];
-
-	me.column2 = [
-	    {
-		xtype: 'pvecheckbox',
-		name: 'enable',
-		checked: true,
-		uncheckedValue: 0,
-		fieldLabel: gettext('Enable')
-	    },
-	    {
-		xtype: me.create ? 'textfield' : 'displayfield',
-		name: 'iscsiprovider',
-		height: 22, // hack: set same height as text fields
-		value: 'Comstar',
-		fieldLabel: gettext('iSCSI Provider'),
-		allowBlank: false
-	    }
-	];
-
-	if (me.create || me.storageId !== 'local') {
-	    me.column2.unshift({
-		xtype: 'PVE.form.NodeSelector',
-		name: 'nodes',
-		fieldLabel: gettext('Nodes'),
-		emptyText: gettext('All') + ' (' +
-		    gettext('No restrictions') +')',
-		multiSelect: true,
-		autoSelect: false
-	    });
-	}
-
-	me.callParent();
+    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: 'ID',
+        vtype: 'StorageId',
+        allowBlank: false
+        },
+        {
+        xtype: me.create ? 'textfield' : 'displayfield',
+        name: 'portal',
+        height: 22, // hack: set same height as text fields
+        value: '',
+        fieldLabel: gettext('Portal'),
+        allowBlank: false
+        },
+        {
+        xtype: me.create ? 'textfield' : 'displayfield',
+        name: 'pool',
+        height: 22, // hack: set same height as text fields
+        value: '',
+        fieldLabel: gettext('Pool'),
+        allowBlank: false
+        },
+        {
+        xtype: me.create ? 'textfield' : 'displayfield',
+        name: 'blocksize',
+        height: 22, // hack: set same height as text fields
+        value: '4k',
+        fieldLabel: gettext('Block Size'),
+        allowBlank: false
+        },
+        {
+        xtype: me.create ? 'textfield' : 'displayfield',
+        name: 'target',
+        height: 22, // hack: set same height as text fields
+        value: 'iqn.2010-09.org.openindiana:omnios:....',
+        fieldLabel: gettext('Target'),
+        allowBlank: false
+        }
+    ];
+
+    var providers = Ext.create('Ext.data.Store', {
+        fields: ['provider', 'name'],
+        data: [
+            {'provider':'comstar', 'name':'Comstar (Solaris)'},
+            {'provider':'istgt', 'name':'Istgt (BSD)'},
+            {'provider':'iet', 'name':'Iet (Linux)'}
+        ]
+    });
+
+    me.column2 = [
+        {
+        xtype: 'pvecheckbox',
+        name: 'enable',
+        checked: true,
+        uncheckedValue: 0,
+        fieldLabel: gettext('Enable')
+        },
+        {
+        xtype: me.create ? 'combobox' : 'displayfield',
+        fieldLabel: gettext('iSCSI Provider'),
+        name: 'iscsiprovider',
+        queryMode: 'local',
+        width:120,
+        listWidth: 120,
+        editable: false,
+        value: providers.first().get('provider'),
+        store: providers,
+        displayField: 'name',
+        valueField: 'provider'
+        }
+    ];
+
+    if (me.create || me.storageId !== 'local') {
+        me.column2.unshift({
+        xtype: 'PVE.form.NodeSelector',
+        name: 'nodes',
+        fieldLabel: gettext('Nodes'),
+        emptyText: gettext('All') + ' (' +
+            gettext('No restrictions') +')',
+        multiSelect: true,
+        autoSelect: false
+        });
+    }
+
+    me.callParent();
     }
 });
 
 Ext.define('PVE.storage.ZFSEdit', {
     extend: 'PVE.window.Edit',
-    
+
     initComponent : function() {
-	var me = this;
+    var me = this;
 
-	me.create = !me.storageId;
+    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';
-        }
+    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.ZFSInputPanel', {
-	    create: me.create,
-	    storageId: me.storageId
-	});
-
-	Ext.apply(me, {
-            subject: 'ZFS Storage',
-	    isAdd: true,
-	    items: [ ipanel ]
-	});
-
-	me.callParent();
-
-        if (!me.create) {
-            me.load({
-                success:  function(response, options) {
-                    var values = response.result.data;
-                    if (values.nodes) {
-                        values.nodes = values.nodes.split(',');
-                    }
-                    values.enable = values.disable ? 0 : 1;
-                    ipanel.setValues(values);
-                }
-            });
+    var ipanel = Ext.create('PVE.storage.ZFSInputPanel', {
+        create: me.create,
+        storageId: me.storageId
+    });
+
+    Ext.apply(me, {
+        subject: 'ZFS Storage',
+        isAdd: true,
+        items: [ ipanel ]
+    });
+
+    me.callParent();
+
+    if (!me.create) {
+        me.load({
+        success:  function(response, options) {
+            var values = response.result.data;
+            if (values.nodes) {
+                values.nodes = values.nodes.split(',');
+            }
+            values.enable = values.disable ? 0 : 1;
+            ipanel.setValues(values);
         }
+        });
+    }
     }
 });
-- 
1.8.4.rc3




More information about the pve-devel mailing list