]> git.proxmox.com Git - pve-manager.git/blame - www/manager6/qemu/OSTypeEdit.js
ui: eslint: fix trailing comma and comma related whitespaces errors
[pve-manager.git] / www / manager6 / qemu / OSTypeEdit.js
CommitLineData
d3ce36d9 1Ext.define('PVE.qemu.OSTypeInputPanel', {
ef4ef788 2 extend: 'Proxmox.panel.InputPanel',
42902182 3 alias: 'widget.pveQemuOSTypePanel',
c8802a60 4 onlineHelp: 'qm_os_settings',
6cc8cfb3
EK
5 insideWizard: false,
6
7 controller: {
8 xclass: 'Ext.app.ViewController',
9 control: {
e41bb8b9 10 'combobox[name=osbase]': {
f6710aac 11 change: 'onOSBaseChange',
e41bb8b9
TL
12 },
13 'combobox[name=ostype]': {
14 afterrender: 'onOSTypeChange',
f6710aac
TL
15 change: 'onOSTypeChange',
16 },
6cc8cfb3 17 },
e41bb8b9
TL
18 onOSBaseChange: function(field, value) {
19 this.lookup('ostype').getStore().setData(PVE.Utils.kvm_ostypes[value]);
20 },
0f421616
TL
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);
471d03aa
DC
30 var scsihw = targetValues.scsihw || '__default__';
31 this.getViewModel().set('current.scsihw', scsihw);
0f421616 32 },
6cc8cfb3
EK
33 setWidget: function(widget, newValue) {
34 // changing a widget is safe only if ComponentQuery.query returns us
35 // a single value array
36 var widgets = Ext.ComponentQuery.query('pveQemuCreateWizard ' + widget);
37 if (widgets.length === 1) {
38 widgets[0].setValue(newValue);
39 } else {
40 throw 'non unique widget :' + widget + ' in Wizard';
41 }
f6710aac 42 },
6cc8cfb3 43 },
d3ce36d9
DM
44
45 initComponent : function() {
46 var me = this;
47
e41bb8b9 48 me.items = [
d3ce36d9 49 {
e41bb8b9
TL
50 xtype: 'displayfield',
51 value: gettext('Guest OS') + ':',
f6710aac 52 hidden: !me.insideWizard,
d3ce36d9
DM
53 },
54 {
e41bb8b9
TL
55 xtype: 'combobox',
56 submitValue: false,
57 name: 'osbase',
58 fieldLabel: gettext('Type'),
59 editable: false,
60 queryMode: 'local',
61 value: 'Linux',
f6710aac 62 store: Object.keys(PVE.Utils.kvm_ostypes),
d3ce36d9
DM
63 },
64 {
e41bb8b9 65 xtype: 'combobox',
d3ce36d9 66 name: 'ostype',
e41bb8b9
TL
67 reference: 'ostype',
68 fieldLabel: gettext('Version'),
69 value: 'l26',
70 allowBlank : false,
71 editable: false,
72 queryMode: 'local',
73 valueField: 'val',
74 displayField: 'desc',
75 store: {
76 fields: ['desc', 'val'],
77 data: PVE.Utils.kvm_ostypes.Linux,
78 listeners: {
79 datachanged: function (store) {
80 var ostype = me.lookup('ostype');
81 var old_val = ostype.getValue();
82 if (!me.insideWizard && old_val && store.find('val', old_val) != -1) {
83 ostype.setValue(old_val);
84 } else {
85 ostype.setValue(store.getAt(0));
86 }
f6710aac
TL
87 },
88 },
89 },
90 },
d3ce36d9 91 ];
d3ce36d9
DM
92
93 me.callParent();
f6710aac 94 },
d3ce36d9
DM
95});
96
97Ext.define('PVE.qemu.OSTypeEdit', {
9fccc702 98 extend: 'Proxmox.window.Edit',
d3ce36d9 99
d24064e4
TL
100 subject: 'OS Type',
101
102 items: [{ xtype: 'pveQemuOSTypePanel' }],
103
d3ce36d9
DM
104 initComponent : function() {
105 var me = this;
e41bb8b9 106
d3ce36d9
DM
107 me.callParent();
108
109 me.load({
110 success: function(response, options) {
111 var value = response.result.data.ostype || 'other';
e41bb8b9
TL
112 var osinfo = PVE.Utils.get_kvm_osinfo(value);
113 me.setValues({ ostype: value, osbase: osinfo.base });
f6710aac 114 },
d3ce36d9 115 });
f6710aac 116 },
d3ce36d9 117});