]> git.proxmox.com Git - pve-manager.git/blame - www/manager6/qemu/SerialEdit.js
ui: eslint: fix trailing spaces
[pve-manager.git] / www / manager6 / qemu / SerialEdit.js
CommitLineData
37977fa5
TL
1Ext.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
20 onGetValues: function(values) {
21 var me = this;
22
23 var id = 'serial' + values.serialid;
24 delete values.serialid;
25 values[id] = 'socket';
26 return values;
27 },
28
29 items: [
30 {
31 xtype: 'proxmoxintegerfield',
32 name: 'serialid',
33 fieldLabel: gettext('Serial Port'),
34 minValue: 0,
35 maxValue: 3,
36 allowBlank: false,
37 validator: function(id) {
38 if (!this.rendered) {
39 return true;
40 }
41 var me = this.up('panel');
42 if (me.vmconfig !== undefined && Ext.isDefined(me.vmconfig['serial' + id])) {
43 return "This device is already in use.";
44 }
45 return true;
46 }
47 }
48 ]
49});
50
51Ext.define('PVE.qemu.SerialEdit', {
52 extend: 'Proxmox.window.Edit',
53
54 vmconfig: undefined,
55
56 isAdd: true,
57
58 subject: gettext('Serial Port'),
59
60 initComponent : function() {
61 var me = this;
62
63 // for now create of (socket) serial port only
64 me.isCreate = true;
65
66 var ipanel = Ext.create('PVE.qemu.SerialnputPanel', {});
67
68 Ext.apply(me, {
69 items: [ ipanel ]
70 });
71
72 me.callParent();
73
74 me.load({
75 success: function(response, options) {
76 ipanel.setVMConfig(response.result.data);
77 }
78 });
79 }
80});