]> git.proxmox.com Git - pve-manager.git/blobdiff - www/manager6/storage/NFSEdit.js
update shipped appliance info index
[pve-manager.git] / www / manager6 / storage / NFSEdit.js
index 82cbd0b75fa8b1ef0c16cec961912a7766246695..202c7de087fd824e85fff5b1953feb156798f930 100644 (file)
@@ -9,9 +9,10 @@ Ext.define('PVE.storage.NFSScan', {
     matchFieldWidth: false,
     listConfig: {
        loadingText: gettext('Scanning...'),
-       width: 350
+       width: 350,
     },
     doRawQuery: function() {
+       // do nothing
     },
 
     onTriggerClick: function() {
@@ -32,7 +33,7 @@ Ext.define('PVE.storage.NFSScan', {
        me.nfsServer = server;
     },
 
-    initComponent : function() {
+    initComponent: function() {
        var me = this;
 
        if (!me.nodename) {
@@ -40,58 +41,75 @@ Ext.define('PVE.storage.NFSScan', {
        }
 
        var store = Ext.create('Ext.data.Store', {
-           fields: [ 'path', 'options' ],
+           fields: ['path', 'options'],
            proxy: {
-               type: 'pve',
-               url: '/api2/json/nodes/' + me.nodename + '/scan/nfs'
-           }
+               type: 'proxmox',
+               url: '/api2/json/nodes/' + me.nodename + '/scan/nfs',
+           },
        });
 
        store.sort('path', 'ASC');
 
        Ext.apply(me, {
-           store: store
+           store: store,
        });
 
        me.callParent();
-    }
+    },
 });
 
 Ext.define('PVE.storage.NFSInputPanel', {
-    extend: 'PVE.panel.InputPanel',
-    controller: 'storageEdit',
+    extend: 'PVE.panel.StorageBase',
+
+    onlineHelp: 'storage_nfs',
+
+    options: [],
 
     onGetValues: function(values) {
        var me = this;
 
-       if (me.isCreate) {
-           values.type = 'nfs';
-           // hack: for now we always create nvf v3
-           // fixme: make this configurable
-           values.options = 'vers=3';
-       } else {
-           delete values.storage;
+       var i;
+       var res = [];
+       for (i = 0; i < me.options.length; i++) {
+           var item = me.options[i];
+           if (!item.match(/^vers=(.*)$/)) {
+               res.push(item);
+           }
+       }
+       if (values.nfsversion && values.nfsversion !== '__default__') {
+           res.push('vers=' + values.nfsversion);
+       }
+       delete values.nfsversion;
+       values.options = res.join(',');
+       if (values.options === '') {
+           delete values.options;
+           if (!me.isCreate) {
+               values.delete = "options";
+           }
        }
 
-       values.disable = values.enable ? 0 : 1;
-       delete values.enable;
+       return me.callParent([values]);
+    },
 
-       return values;
+    setValues: function(values) {
+       var me = this;
+       if (values.options) {
+           me.options = values.options.split(',');
+           me.options.forEach(function(item) {
+               var match = item.match(/^vers=(.*)$/);
+               if (match) {
+                   values.nfsversion = match[1];
+               }
+           });
+       }
+       return me.callParent([values]);
     },
 
-    initComponent : function() {
+    initComponent: function() {
        var me = this;
 
 
        me.column1 = [
-           {
-               xtype: me.isCreate ? 'textfield' : 'displayfield',
-               name: 'storage',
-               value: me.storageId || '',
-               fieldLabel: 'ID',
-               vtype: 'StorageId',
-               allowBlank: false
-           },
            {
                xtype: me.isCreate ? 'textfield' : 'displayfield',
                name: 'server',
@@ -105,15 +123,15 @@ Ext.define('PVE.storage.NFSInputPanel', {
                            exportField.setServer(value);
                            exportField.setValue('');
                        }
-                   }
-               }
+                   },
+               },
            },
            {
                xtype: me.isCreate ? 'pveNFSScan' : 'displayfield',
                name: 'export',
                value: '',
                fieldLabel: 'Export',
-               allowBlank: false
+               allowBlank: false,
            },
            {
                xtype: 'pveContentTypeSelector',
@@ -121,88 +139,27 @@ Ext.define('PVE.storage.NFSInputPanel', {
                value: 'images',
                multiSelect: true,
                fieldLabel: gettext('Content'),
-               allowBlank: false
-           }
+               allowBlank: false,
+           },
        ];
 
-       me.column2 = [
+       me.advancedColumn2 = [
            {
-               xtype: 'pveNodeSelector',
-               name: 'nodes',
-               fieldLabel: gettext('Nodes'),
-               emptyText: gettext('All') + ' (' +
-                   gettext('No restrictions') +')',
-               multiSelect: true,
-               autoSelect: false
+               xtype: 'proxmoxKVComboBox',
+               fieldLabel: gettext('NFS Version'),
+               name: 'nfsversion',
+               value: '__default__',
+               deleteEmpty: false,
+               comboItems: [
+                       ['__default__', Proxmox.Utils.defaultText],
+                       ['3', '3'],
+                       ['4', '4'],
+                       ['4.1', '4.1'],
+                       ['4.2', '4.2'],
+               ],
            },
-           {
-               xtype: 'proxmoxcheckbox',
-               name: 'enable',
-               checked: true,
-               uncheckedValue: 0,
-               fieldLabel: gettext('Enable')
-           },
-           {
-               xtype: 'proxmoxintegerfield',
-               fieldLabel: gettext('Max Backups'),
-               disabled: true,
-               name: 'maxfiles',
-               reference: 'maxfiles',
-               minValue: 0,
-               maxValue: 365,
-               value: me.isCreate ? '1' : undefined,
-               allowBlank: false
-           }
        ];
 
        me.callParent();
-    }
-});
-
-Ext.define('PVE.storage.NFSEdit', {
-    extend: 'PVE.window.Edit',
-
-    initComponent : function() {
-       var me = this;
-
-       me.isCreate = !me.storageId;
-
-       if (me.isCreate) {
-            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.NFSInputPanel', {
-           isCreate: me.isCreate,
-           storageId: me.storageId
-       });
-
-       Ext.apply(me, {
-            subject: 'NFS',
-           isAdd: true,
-           items: [ ipanel ]
-       });
-
-       me.callParent();
-
-       if (!me.isCreate) {
-           me.load({
-               success:  function(response, options) {
-                   var values = response.result.data;
-                   var ctypes = values.content || '';
-
-                   values.content = ctypes.split(',');
-
-                   if (values.nodes) {
-                       values.nodes = values.nodes.split(',');
-                   }
-                   values.enable = values.disable ? 0 : 1;
-                   ipanel.setValues(values);
-               }
-           });
-       }
-    }
+    },
 });