]> git.proxmox.com Git - pve-manager.git/blobdiff - www/manager6/qemu/OSTypeEdit.js
ui: eslint: fix various spacing related issues
[pve-manager.git] / www / manager6 / qemu / OSTypeEdit.js
index cc8cf37263e33de66bd30cd9cab32a9e05b2aeaf..ece80c39f34dfcc8768b81eccf885ffedeec4e5a 100644 (file)
@@ -1,31 +1,34 @@
 Ext.define('PVE.qemu.OSTypeInputPanel', {
-    extend: 'PVE.panel.InputPanel',
+    extend: 'Proxmox.panel.InputPanel',
     alias: 'widget.pveQemuOSTypePanel',
-    onlineHelp: 'chapter-qm.html#_os_settings',
+    onlineHelp: 'qm_os_settings',
     insideWizard: false,
 
     controller: {
        xclass: 'Ext.app.ViewController',
        control: {
-           'radiogroup': {
-                   change: function(field, value) {
-                       var me = this;
-                       if (!me.getView().insideWizard) {
-                           return;
-                       }
-
-                       var targetValues;
-
-                       if (PVE.qemu.OSDefaults[value.ostype]) {
-                           targetValues = PVE.qemu.OSDefaults[value.ostype];
-                       } else {
-                           targetValues = PVE.qemu.OSDefaults.generic;
-                       }
-
-                       me.setWidget('pveBusSelector', targetValues.busType);
-                       me.setWidget('pveNetworkCardSelector', targetValues.networkCard);
-                   }
+           'combobox[name=osbase]': {
+               change: 'onOSBaseChange',
+           },
+           'combobox[name=ostype]': {
+               afterrender: 'onOSTypeChange',
+               change: 'onOSTypeChange',
+           },
+       },
+       onOSBaseChange: function(field, value) {
+           this.lookup('ostype').getStore().setData(PVE.Utils.kvm_ostypes[value]);
+       },
+       onOSTypeChange: function(field) {
+           var me = this, ostype = field.getValue();
+           if (!me.getView().insideWizard) {
+               return;
            }
+           var targetValues = PVE.qemu.OSDefaults.getDefaults(ostype);
+
+           me.setWidget('pveBusSelector', targetValues.busType);
+           me.setWidget('pveNetworkCardSelector', targetValues.networkCard);
+           var scsihw = targetValues.scsihw || '__default__';
+           this.getViewModel().set('current.scsihw', scsihw);
        },
        setWidget: function(widget, newValue) {
            // changing a widget is safe only if ComponentQuery.query returns us
@@ -36,113 +39,79 @@ Ext.define('PVE.qemu.OSTypeInputPanel', {
            } else {
                throw 'non unique widget :' + widget + ' in Wizard';
            }
-       }
+       },
     },
 
-    initComponent : function() {
+    initComponent: function() {
        var me = this;
 
-       me.column1 = [
-           {
-               xtype: 'component', 
-               html: 'Microsoft Windows', 
-               cls:'x-form-check-group-label'
-           },
-           {
-               xtype: 'radiofield',
-               name: 'ostype',
-               inputValue: 'win8'
-           },
-           {
-               xtype: 'radiofield',
-               name: 'ostype',
-               inputValue: 'win7'
-           },
-           {
-               xtype: 'radiofield',
-               name: 'ostype',
-               inputValue: 'w2k8'
-           },
-           {
-               xtype: 'radiofield',
-               name: 'ostype',
-               inputValue: 'wxp'
-           },
-           {
-               xtype: 'radiofield',
-               name: 'ostype',
-               inputValue: 'w2k'
-           }
-       ];
-
-       me.column2 = [
+       me.items = [
            {
-               xtype: 'component', 
-               html: 'Linux/' + gettext('Other OS types'), 
-               cls:'x-form-check-group-label'
+               xtype: 'displayfield',
+               value: gettext('Guest OS') + ':',
+               hidden: !me.insideWizard,
            },
            {
-               xtype: 'radiofield',
-               name: 'ostype',
-               inputValue: 'l26'
-           },
-           {
-               xtype: 'radiofield',
-               name: 'ostype',
-               inputValue: 'l24'
+               xtype: 'combobox',
+               submitValue: false,
+               name: 'osbase',
+               fieldLabel: gettext('Type'),
+               editable: false,
+               queryMode: 'local',
+               value: 'Linux',
+               store: Object.keys(PVE.Utils.kvm_ostypes),
            },
            {
-               xtype: 'radiofield',
+               xtype: 'combobox',
                name: 'ostype',
-               inputValue: 'solaris'
+               reference: 'ostype',
+               fieldLabel: gettext('Version'),
+               value: 'l26',
+               allowBlank: false,
+               editable: false,
+               queryMode: 'local',
+               valueField: 'val',
+               displayField: 'desc',
+               store: {
+                   fields: ['desc', 'val'],
+                   data: PVE.Utils.kvm_ostypes.Linux,
+                   listeners: {
+                       datachanged: function(store) {
+                           var ostype = me.lookup('ostype');
+                           var old_val = ostype.getValue();
+                           if (!me.insideWizard && old_val && store.find('val', old_val) != -1) {
+                               ostype.setValue(old_val);
+                           } else {
+                               ostype.setValue(store.getAt(0));
+                           }
+                       },
+                   },
+               },
            },
-           {
-               xtype: 'radiofield',
-               name: 'ostype',
-               inputValue: 'other'
-           }
        ];
 
-       Ext.Array.each(me.column1, function(def) {
-           if (def.inputValue) {
-               def.boxLabel = PVE.Utils.render_kvm_ostype(def.inputValue);
-           }
-       });
-       Ext.Array.each(me.column2, function(def) {
-           if (def.inputValue) {
-               def.boxLabel = PVE.Utils.render_kvm_ostype(def.inputValue);
-           }
-       });
-
-       Ext.apply(me, {
-           useFieldContainer: {
-               xtype: 'radiogroup',
-               allowBlank: false
-           }
-       });
-
        me.callParent();
-    }   
+    },
 });
 
 Ext.define('PVE.qemu.OSTypeEdit', {
-    extend: 'PVE.window.Edit',
+    extend: 'Proxmox.window.Edit',
 
-    initComponent : function() {
+    subject: 'OS Type',
+
+    items: [{ xtype: 'pveQemuOSTypePanel' }],
+
+    initComponent: function() {
        var me = this;
-       
-       Ext.apply(me, {
-           subject: 'OS Type',
-           items: Ext.create('PVE.qemu.OSTypeInputPanel')
-       });
 
        me.callParent();
 
        me.load({
            success: function(response, options) {
                var value = response.result.data.ostype || 'other';
-               me.setValues({ ostype: value});
-           }
+               var osinfo = PVE.Utils.get_kvm_osinfo(value);
+               me.setValues({ ostype: value, osbase: osinfo.base });
+           },
        });
-    }
+    },
 });