]>
Commit | Line | Data |
---|---|---|
1 | Ext.define('PVE.qemu.OSTypeInputPanel', { | |
2 | extend: 'Proxmox.panel.InputPanel', | |
3 | alias: 'widget.pveQemuOSTypePanel', | |
4 | onlineHelp: 'qm_os_settings', | |
5 | insideWizard: false, | |
6 | ||
7 | controller: { | |
8 | xclass: 'Ext.app.ViewController', | |
9 | control: { | |
10 | 'combobox[name=osbase]': { | |
11 | change: 'onOSBaseChange', | |
12 | }, | |
13 | 'combobox[name=ostype]': { | |
14 | afterrender: 'onOSTypeChange', | |
15 | change: 'onOSTypeChange', | |
16 | }, | |
17 | }, | |
18 | onOSBaseChange: function(field, value) { | |
19 | this.lookup('ostype').getStore().setData(PVE.Utils.kvm_ostypes[value]); | |
20 | }, | |
21 | onOSTypeChange: function(field) { | |
22 | var me = this, ostype = field.getValue(); | |
23 | if (!me.getView().insideWizard) { | |
24 | return; | |
25 | } | |
26 | var targetValues = PVE.qemu.OSDefaults.getDefaults(ostype); | |
27 | ||
28 | me.setWidget('pveBusSelector', targetValues.busType); | |
29 | me.setWidget('pveNetworkCardSelector', targetValues.networkCard); | |
30 | var scsihw = targetValues.scsihw || '__default__'; | |
31 | this.getViewModel().set('current.scsihw', scsihw); | |
32 | this.getViewModel().set('current.ostype', ostype); | |
33 | }, | |
34 | setWidget: function(widget, newValue) { | |
35 | // changing a widget is safe only if ComponentQuery.query returns us | |
36 | // a single value array | |
37 | var widgets = Ext.ComponentQuery.query('pveQemuCreateWizard ' + widget); | |
38 | if (widgets.length === 1) { | |
39 | widgets[0].setValue(newValue); | |
40 | } else { | |
41 | // ignore multiple disks, we only want to set the type if there is a single disk | |
42 | } | |
43 | }, | |
44 | }, | |
45 | ||
46 | initComponent: function() { | |
47 | var me = this; | |
48 | ||
49 | me.items = [ | |
50 | { | |
51 | xtype: 'displayfield', | |
52 | value: gettext('Guest OS') + ':', | |
53 | hidden: !me.insideWizard, | |
54 | }, | |
55 | { | |
56 | xtype: 'combobox', | |
57 | submitValue: false, | |
58 | name: 'osbase', | |
59 | fieldLabel: gettext('Type'), | |
60 | editable: false, | |
61 | queryMode: 'local', | |
62 | value: 'Linux', | |
63 | store: Object.keys(PVE.Utils.kvm_ostypes), | |
64 | }, | |
65 | { | |
66 | xtype: 'combobox', | |
67 | name: 'ostype', | |
68 | reference: 'ostype', | |
69 | fieldLabel: gettext('Version'), | |
70 | value: 'l26', | |
71 | allowBlank: false, | |
72 | editable: false, | |
73 | queryMode: 'local', | |
74 | valueField: 'val', | |
75 | displayField: 'desc', | |
76 | store: { | |
77 | fields: ['desc', 'val'], | |
78 | data: PVE.Utils.kvm_ostypes.Linux, | |
79 | listeners: { | |
80 | datachanged: function(store) { | |
81 | var ostype = me.lookup('ostype'); | |
82 | var old_val = ostype.getValue(); | |
83 | if (!me.insideWizard && old_val && store.find('val', old_val) !== -1) { | |
84 | ostype.setValue(old_val); | |
85 | } else { | |
86 | ostype.setValue(store.getAt(0)); | |
87 | } | |
88 | }, | |
89 | }, | |
90 | }, | |
91 | }, | |
92 | ]; | |
93 | ||
94 | me.callParent(); | |
95 | }, | |
96 | }); | |
97 | ||
98 | Ext.define('PVE.qemu.OSTypeEdit', { | |
99 | extend: 'Proxmox.window.Edit', | |
100 | ||
101 | subject: 'OS Type', | |
102 | ||
103 | items: [{ xtype: 'pveQemuOSTypePanel' }], | |
104 | ||
105 | initComponent: function() { | |
106 | var me = this; | |
107 | ||
108 | me.callParent(); | |
109 | ||
110 | me.load({ | |
111 | success: function(response, options) { | |
112 | var value = response.result.data.ostype || 'other'; | |
113 | var osinfo = PVE.Utils.get_kvm_osinfo(value); | |
114 | me.setValues({ ostype: value, osbase: osinfo.base }); | |
115 | }, | |
116 | }); | |
117 | }, | |
118 | }); |