]> git.proxmox.com Git - pve-manager.git/blob - www/manager6/qemu/SerialEdit.js
update shipped appliance info index
[pve-manager.git] / www / manager6 / qemu / SerialEdit.js
1 Ext.define('PVE.qemu.SerialnputPanel', {
2 extend: 'Proxmox.panel.InputPanel',
3
4 autoComplete: false,
5
6 setVMConfig: function(vmconfig) {
7 var me = this, i;
8 me.vmconfig = vmconfig;
9
10 for (i = 0; i < 4; i++) {
11 var port = 'serial' + i.toString();
12 if (!me.vmconfig[port]) {
13 me.down('field[name=serialid]').setValue(i);
14 break;
15 }
16 }
17 },
18
19 onGetValues: function(values) {
20 var me = this;
21
22 var id = 'serial' + values.serialid;
23 delete values.serialid;
24 values[id] = 'socket';
25 return values;
26 },
27
28 items: [
29 {
30 xtype: 'proxmoxintegerfield',
31 name: 'serialid',
32 fieldLabel: gettext('Serial Port'),
33 minValue: 0,
34 maxValue: 3,
35 allowBlank: false,
36 validator: function(id) {
37 if (!this.rendered) {
38 return true;
39 }
40 let view = this.up('panel');
41 if (view.vmconfig !== undefined && Ext.isDefined(view.vmconfig['serial' + id])) {
42 return "This device is already in use.";
43 }
44 return true;
45 },
46 },
47 ],
48 });
49
50 Ext.define('PVE.qemu.SerialEdit', {
51 extend: 'Proxmox.window.Edit',
52
53 vmconfig: undefined,
54
55 isAdd: true,
56
57 subject: gettext('Serial Port'),
58
59 initComponent: function() {
60 var me = this;
61
62 // for now create of (socket) serial port only
63 me.isCreate = true;
64
65 var ipanel = Ext.create('PVE.qemu.SerialnputPanel', {});
66
67 Ext.apply(me, {
68 items: [ipanel],
69 });
70
71 me.callParent();
72
73 me.load({
74 success: function(response, options) {
75 ipanel.setVMConfig(response.result.data);
76 },
77 });
78 },
79 });