]> git.proxmox.com Git - pve-manager.git/blame - www/manager6/qemu/OSTypeEdit.js
ui: qemu: show progress bar for resize task
[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);
e05c2d49 32 this.getViewModel().set('current.ostype', ostype);
0f421616 33 },
6cc8cfb3
EK
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 {
eb7075d0 41 // ignore multiple disks, we only want to set the type if there is a single disk
6cc8cfb3 42 }
f6710aac 43 },
6cc8cfb3 44 },
d3ce36d9 45
8058410f 46 initComponent: function() {
d3ce36d9
DM
47 var me = this;
48
e41bb8b9 49 me.items = [
d3ce36d9 50 {
e41bb8b9
TL
51 xtype: 'displayfield',
52 value: gettext('Guest OS') + ':',
f6710aac 53 hidden: !me.insideWizard,
d3ce36d9
DM
54 },
55 {
e41bb8b9
TL
56 xtype: 'combobox',
57 submitValue: false,
58 name: 'osbase',
59 fieldLabel: gettext('Type'),
60 editable: false,
61 queryMode: 'local',
62 value: 'Linux',
f6710aac 63 store: Object.keys(PVE.Utils.kvm_ostypes),
d3ce36d9
DM
64 },
65 {
e41bb8b9 66 xtype: 'combobox',
d3ce36d9 67 name: 'ostype',
e41bb8b9
TL
68 reference: 'ostype',
69 fieldLabel: gettext('Version'),
70 value: 'l26',
8058410f 71 allowBlank: false,
e41bb8b9
TL
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: {
8058410f 80 datachanged: function(store) {
e41bb8b9
TL
81 var ostype = me.lookup('ostype');
82 var old_val = ostype.getValue();
91a47a76 83 if (!me.insideWizard && old_val && store.find('val', old_val) !== -1) {
e41bb8b9
TL
84 ostype.setValue(old_val);
85 } else {
86 ostype.setValue(store.getAt(0));
87 }
f6710aac
TL
88 },
89 },
90 },
91 },
d3ce36d9 92 ];
d3ce36d9
DM
93
94 me.callParent();
f6710aac 95 },
d3ce36d9
DM
96});
97
98Ext.define('PVE.qemu.OSTypeEdit', {
9fccc702 99 extend: 'Proxmox.window.Edit',
d3ce36d9 100
d24064e4
TL
101 subject: 'OS Type',
102
103 items: [{ xtype: 'pveQemuOSTypePanel' }],
104
8058410f 105 initComponent: function() {
d3ce36d9 106 var me = this;
e41bb8b9 107
d3ce36d9
DM
108 me.callParent();
109
110 me.load({
111 success: function(response, options) {
112 var value = response.result.data.ostype || 'other';
e41bb8b9
TL
113 var osinfo = PVE.Utils.get_kvm_osinfo(value);
114 me.setValues({ ostype: value, osbase: osinfo.base });
f6710aac 115 },
d3ce36d9 116 });
f6710aac 117 },
d3ce36d9 118});