]>
Commit | Line | Data |
---|---|---|
d3ce36d9 DM |
1 | Ext.define('PVE.qemu.OSTypeInputPanel', { |
2 | extend: 'PVE.panel.InputPanel', | |
42902182 | 3 | alias: 'widget.pveQemuOSTypePanel', |
8aa37826 | 4 | onlineHelp: 'chapter-qm.html#_os_settings', |
6cc8cfb3 EK |
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); | |
2c0e2890 | 27 | me.setWizardHiddenValue('qemuScsiController', targetValues.scsihw); |
6cc8cfb3 EK |
28 | } |
29 | } | |
30 | }, | |
31 | setWidget: function(widget, newValue) { | |
32 | // changing a widget is safe only if ComponentQuery.query returns us | |
33 | // a single value array | |
34 | var widgets = Ext.ComponentQuery.query('pveQemuCreateWizard ' + widget); | |
35 | if (widgets.length === 1) { | |
36 | widgets[0].setValue(newValue); | |
37 | } else { | |
38 | throw 'non unique widget :' + widget + ' in Wizard'; | |
39 | } | |
2c0e2890 EK |
40 | }, |
41 | setWizardHiddenValue: function(property, newValue) { | |
42 | var wizards = Ext.ComponentQuery.query('pveQemuCreateWizard '); | |
43 | if (wizards.length === 1) { | |
44 | wizards[0][property] = newValue; | |
45 | } else { | |
46 | throw 'non unique wizard, unable to set ' + property; | |
47 | } | |
6cc8cfb3 EK |
48 | } |
49 | }, | |
d3ce36d9 DM |
50 | |
51 | initComponent : function() { | |
52 | var me = this; | |
53 | ||
54 | me.column1 = [ | |
55 | { | |
56 | xtype: 'component', | |
57 | html: 'Microsoft Windows', | |
58 | cls:'x-form-check-group-label' | |
59 | }, | |
60 | { | |
61 | xtype: 'radiofield', | |
62 | name: 'ostype', | |
63 | inputValue: 'win8' | |
64 | }, | |
65 | { | |
66 | xtype: 'radiofield', | |
67 | name: 'ostype', | |
68 | inputValue: 'win7' | |
69 | }, | |
70 | { | |
71 | xtype: 'radiofield', | |
72 | name: 'ostype', | |
73 | inputValue: 'w2k8' | |
74 | }, | |
75 | { | |
76 | xtype: 'radiofield', | |
77 | name: 'ostype', | |
78 | inputValue: 'wxp' | |
79 | }, | |
80 | { | |
81 | xtype: 'radiofield', | |
82 | name: 'ostype', | |
83 | inputValue: 'w2k' | |
84 | } | |
85 | ]; | |
86 | ||
87 | me.column2 = [ | |
88 | { | |
89 | xtype: 'component', | |
90 | html: 'Linux/' + gettext('Other OS types'), | |
91 | cls:'x-form-check-group-label' | |
92 | }, | |
93 | { | |
94 | xtype: 'radiofield', | |
95 | name: 'ostype', | |
96 | inputValue: 'l26' | |
97 | }, | |
98 | { | |
99 | xtype: 'radiofield', | |
100 | name: 'ostype', | |
101 | inputValue: 'l24' | |
102 | }, | |
103 | { | |
104 | xtype: 'radiofield', | |
105 | name: 'ostype', | |
106 | inputValue: 'solaris' | |
107 | }, | |
108 | { | |
109 | xtype: 'radiofield', | |
110 | name: 'ostype', | |
111 | inputValue: 'other' | |
112 | } | |
113 | ]; | |
114 | ||
115 | Ext.Array.each(me.column1, function(def) { | |
116 | if (def.inputValue) { | |
117 | def.boxLabel = PVE.Utils.render_kvm_ostype(def.inputValue); | |
118 | } | |
119 | }); | |
120 | Ext.Array.each(me.column2, function(def) { | |
121 | if (def.inputValue) { | |
122 | def.boxLabel = PVE.Utils.render_kvm_ostype(def.inputValue); | |
123 | } | |
124 | }); | |
125 | ||
126 | Ext.apply(me, { | |
127 | useFieldContainer: { | |
128 | xtype: 'radiogroup', | |
129 | allowBlank: false | |
130 | } | |
131 | }); | |
132 | ||
133 | me.callParent(); | |
134 | } | |
135 | }); | |
136 | ||
137 | Ext.define('PVE.qemu.OSTypeEdit', { | |
138 | extend: 'PVE.window.Edit', | |
139 | ||
140 | initComponent : function() { | |
141 | var me = this; | |
142 | ||
143 | Ext.apply(me, { | |
144 | subject: 'OS Type', | |
145 | items: Ext.create('PVE.qemu.OSTypeInputPanel') | |
146 | }); | |
147 | ||
148 | me.callParent(); | |
149 | ||
150 | me.load({ | |
151 | success: function(response, options) { | |
152 | var value = response.result.data.ostype || 'other'; | |
153 | me.setValues({ ostype: value}); | |
154 | } | |
155 | }); | |
156 | } | |
157 | }); |