]> git.proxmox.com Git - pve-manager.git/blobdiff - www/manager6/storage/IScsiEdit.js
ui: eslint: fix various spacing related issues
[pve-manager.git] / www / manager6 / storage / IScsiEdit.js
index 7b363f097c47994305e6ca326e638eab638438ee..2052c05f58f738a15dd12c0f03df0eb729cd149d 100644 (file)
@@ -3,7 +3,13 @@ Ext.define('PVE.storage.IScsiScan', {
     alias: 'widget.pveIScsiScan',
 
     queryParam: 'portal',
-
+    valueField: 'target',
+    displayField: 'target',
+    matchFieldWidth: false,
+    listConfig: {
+       loadingText: gettext('Scanning...'),
+       width: 350,
+    },
     doRawQuery: function() {
     },
 
@@ -25,7 +31,7 @@ Ext.define('PVE.storage.IScsiScan', {
        me.portal = portal;
     },
 
-    initComponent : function() {
+    initComponent: function() {
        var me = this;
 
        if (!me.nodename) {
@@ -33,174 +39,81 @@ Ext.define('PVE.storage.IScsiScan', {
        }
 
        var store = Ext.create('Ext.data.Store', {
-           fields: [ 'target', 'portal' ],
+           fields: ['target', 'portal'],
            proxy: {
-               type: 'pve',
-               url: '/api2/json/nodes/' + me.nodename + '/scan/iscsi'
-           }
+               type: 'proxmox',
+               url: '/api2/json/nodes/' + me.nodename + '/scan/iscsi',
+           },
        });
 
+       store.sort('target', 'ASC');
+
        Ext.apply(me, {
            store: store,
-           valueField: 'target',
-           displayField: 'target',
-           matchFieldWidth: false,
-           listConfig: {
-               loadingText: gettext('Scanning...'),
-               listeners: {
-                   // hack: call setHeight to show scroll bars correctly
-                   refresh: function(list) {
-                       var lh = PVE.Utils.gridLineHeigh();
-                       var count = store.getCount();
-                       list.setHeight(lh * ((count > 10) ? 10 : count));
-                   }
-               },
-               width: 350
-           }
        });
 
        me.callParent();
-    }
+    },
 });
 
 Ext.define('PVE.storage.IScsiInputPanel', {
-    extend: 'PVE.panel.InputPanel',
+    extend: 'PVE.panel.StorageBase',
+
+    onlineHelp: 'storage_open_iscsi',
 
     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;
+       return me.callParent([values]);
     },
 
-    initComponent : function() {
-       var me = this;
+    setValues: function(values) {
+       values.luns = (values.content.indexOf('images') !== -1) ? true : false;
+       this.callParent([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',
-               height: 22, // hack: set same height as text fields
+               xtype: me.isCreate ? 'textfield' : 'displayfield',
                name: 'portal',
                value: '',
                fieldLabel: 'Portal',
                allowBlank: false,
                listeners: {
                    change: function(f, value) {
-                       if (me.create) {
+                       if (me.isCreate) {
                            var exportField = me.down('field[name=target]');
                            exportField.setPortal(value);
                            exportField.setValue('');
                        }
-                   }
-               }
+                   },
+               },
            },
            {
-               readOnly: !me.create,
-               xtype: me.create ? 'pveIScsiScan' : 'displayfield',
+               readOnly: !me.isCreate,
+               xtype: me.isCreate ? 'pveIScsiScan' : 'displayfield',
                name: 'target',
                value: '',
                fieldLabel: 'Target',
-               allowBlank: false
-           }
+               allowBlank: false,
+           },
        ];
 
        me.column2 = [
-           {
-               xtype: 'PVE.form.NodeSelector',
-               name: 'nodes',
-               fieldLabel: gettext('Nodes'),
-               emptyText: gettext('All') + ' (' + 
-                   gettext('No restrictions') +')',
-               multiSelect: true,
-               autoSelect: false
-           },
-           {
-               xtype: 'pvecheckbox',
-               name: 'enable',
-               checked: true,
-               uncheckedValue: 0,
-               fieldLabel: gettext('Enable')
-           },
            {
                xtype: 'checkbox',
                name: 'luns',
                checked: true,
-               fieldLabel: gettext('Use LUNs directly')
-           }
+               fieldLabel: gettext('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, {
-            subject: PVE.Utils.format_storage_type('iscsi'),
-           isAdd: true,
-           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(',');
-                   }
-                   if (values.nodes) {
-                       values.nodes = values.nodes.split(',');
-                   }
-                   values.enable = values.disable ? 0 : 1;
-                   values.luns = (values.content === 'images') ? true : false;
-
-                   ipanel.setValues(values);
-               }
-           });
-       }
-    }
+    },
 });