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