]>
Commit | Line | Data |
---|---|---|
3e970252 DM |
1 | Ext.define('PVE.form.VMIDSelector', { |
2 | extend: 'Ext.form.field.Number', | |
3 | alias: 'widget.pveVMIDSelector', | |
4 | ||
5 | allowBlank: false, | |
6 | ||
7 | minValue: 100, | |
8 | ||
9 | maxValue: 999999999, | |
10 | ||
11 | validateExists: undefined, | |
12 | ||
13 | loadNextFreeVMID: false, | |
14 | ||
15 | initComponent: function() { | |
16 | var me = this; | |
17 | ||
18 | Ext.applyIf(me, { | |
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) { | |
31 | me.markInvalid(gettext('This VM ID does not exists')); | |
32 | } | |
33 | }, | |
34 | failure: function(response, opts) { | |
35 | if (me.validateExists === false) { | |
36 | me.markInvalid(gettext('This VM ID is already in use')); | |
37 | } | |
38 | } | |
39 | }); | |
40 | } | |
41 | } | |
42 | }); | |
43 | ||
44 | me.callParent(); | |
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 | } | |
55 | } | |
56 | }); |