]>
Commit | Line | Data |
---|---|---|
04f5d98e DM |
1 | Ext.define('PVE.form.VMIDSelector', { |
2 | extend: 'Ext.form.field.Number', | |
3 | alias: 'widget.pveVMIDSelector', | |
6729b178 DM |
4 | |
5 | allowBlank: false, | |
04f5d98e DM |
6 | |
7 | minValue: 100, | |
8 | ||
9 | maxValue: 999999999, | |
10 | ||
11 | validateExists: undefined, | |
12 | ||
e893439e DM |
13 | loadNextFreeVMID: false, |
14 | ||
04f5d98e DM |
15 | initComponent: function() { |
16 | var me = this; | |
17 | ||
18 | Ext.applyIf(me, { | |
10cdf3ae DM |
19 | fieldLabel: 'VM ID', |
20 | listeners: { | |
21 | 'change': function(field, newValue, oldValue) { | |
22 | if (!Ext.isDefined(me.validateExists)) { | |
23 | return; | |
24 | } | |
25 | PVE.Utils.API2Request({ | |
26 | params: { vmid: newValue }, | |
27 | url: '/cluster/nextid', | |
28 | method: 'GET', | |
29 | success: function(response, opts) { | |
30 | if (me.validateExists === true) { | |
0070ee37 | 31 | me.markInvalid(gettext('This VM ID does not exists')); |
10cdf3ae DM |
32 | } |
33 | }, | |
34 | failure: function(response, opts) { | |
35 | if (me.validateExists === false) { | |
0070ee37 | 36 | me.markInvalid(gettext('This VM ID is already in use')); |
10cdf3ae DM |
37 | } |
38 | } | |
39 | }); | |
40 | } | |
41 | } | |
04f5d98e DM |
42 | }); |
43 | ||
44 | me.callParent(); | |
e893439e DM |
45 | |
46 | if (me.loadNextFreeVMID) { | |
47 | PVE.Utils.API2Request({ | |
48 | url: '/cluster/nextid', | |
49 | method: 'GET', | |
50 | success: function(response, opts) { | |
51 | me.setRawValue(response.result.data); | |
52 | } | |
53 | }); | |
54 | } | |
04f5d98e DM |
55 | } |
56 | }); |