]> git.proxmox.com Git - pve-manager.git/blob - www/manager6/qemu/OSTypeEdit.js
Set VirtIO drivers as default when using the Qemu Wizard and the OS Type is Linux
[pve-manager.git] / www / manager6 / qemu / OSTypeEdit.js
1 Ext.define('PVE.qemu.OSTypeInputPanel', {
2 extend: 'PVE.panel.InputPanel',
3 alias: 'widget.pveQemuOSTypePanel',
4 onlineHelp: 'chapter-qm.html#_os_settings',
5 insideWizard: false,
6
7 controller: {
8 xclass: 'Ext.app.ViewController',
9 control: {
10 'radiogroup': {
11 change: function(field, value) {
12 var me = this;
13 if (!me.getView().insideWizard) {
14 return;
15 }
16
17 var targetValues;
18
19 if (PVE.qemu.OSDefaults[value.ostype]) {
20 targetValues = PVE.qemu.OSDefaults[value.ostype];
21 } else {
22 targetValues = PVE.qemu.OSDefaults.generic;
23 }
24
25 me.setWidget('pveBusSelector', targetValues.busType);
26 me.setWidget('pveNetworkCardSelector', targetValues.networkCard);
27 }
28 }
29 },
30 setWidget: function(widget, newValue) {
31 // changing a widget is safe only if ComponentQuery.query returns us
32 // a single value array
33 var widgets = Ext.ComponentQuery.query('pveQemuCreateWizard ' + widget);
34 if (widgets.length === 1) {
35 widgets[0].setValue(newValue);
36 } else {
37 throw 'non unique widget :' + widget + ' in Wizard';
38 }
39 }
40 },
41
42 initComponent : function() {
43 var me = this;
44
45 me.column1 = [
46 {
47 xtype: 'component',
48 html: 'Microsoft Windows',
49 cls:'x-form-check-group-label'
50 },
51 {
52 xtype: 'radiofield',
53 name: 'ostype',
54 inputValue: 'win8'
55 },
56 {
57 xtype: 'radiofield',
58 name: 'ostype',
59 inputValue: 'win7'
60 },
61 {
62 xtype: 'radiofield',
63 name: 'ostype',
64 inputValue: 'w2k8'
65 },
66 {
67 xtype: 'radiofield',
68 name: 'ostype',
69 inputValue: 'wxp'
70 },
71 {
72 xtype: 'radiofield',
73 name: 'ostype',
74 inputValue: 'w2k'
75 }
76 ];
77
78 me.column2 = [
79 {
80 xtype: 'component',
81 html: 'Linux/' + gettext('Other OS types'),
82 cls:'x-form-check-group-label'
83 },
84 {
85 xtype: 'radiofield',
86 name: 'ostype',
87 inputValue: 'l26'
88 },
89 {
90 xtype: 'radiofield',
91 name: 'ostype',
92 inputValue: 'l24'
93 },
94 {
95 xtype: 'radiofield',
96 name: 'ostype',
97 inputValue: 'solaris'
98 },
99 {
100 xtype: 'radiofield',
101 name: 'ostype',
102 inputValue: 'other'
103 }
104 ];
105
106 Ext.Array.each(me.column1, function(def) {
107 if (def.inputValue) {
108 def.boxLabel = PVE.Utils.render_kvm_ostype(def.inputValue);
109 }
110 });
111 Ext.Array.each(me.column2, function(def) {
112 if (def.inputValue) {
113 def.boxLabel = PVE.Utils.render_kvm_ostype(def.inputValue);
114 }
115 });
116
117 Ext.apply(me, {
118 useFieldContainer: {
119 xtype: 'radiogroup',
120 allowBlank: false
121 }
122 });
123
124 me.callParent();
125 }
126 });
127
128 Ext.define('PVE.qemu.OSTypeEdit', {
129 extend: 'PVE.window.Edit',
130
131 initComponent : function() {
132 var me = this;
133
134 Ext.apply(me, {
135 subject: 'OS Type',
136 items: Ext.create('PVE.qemu.OSTypeInputPanel')
137 });
138
139 me.callParent();
140
141 me.load({
142 success: function(response, options) {
143 var value = response.result.data.ostype || 'other';
144 me.setValues({ ostype: value});
145 }
146 });
147 }
148 });