]> git.proxmox.com Git - pve-manager.git/blame - www/manager6/form/IPRefSelector.js
perl: fix some common typos found with codespell
[pve-manager.git] / www / manager6 / form / IPRefSelector.js
CommitLineData
9a389924 1Ext.define('PVE.form.IPRefSelector', {
0fc95a12 2 extend: 'Proxmox.form.ComboGrid',
9a389924
DM
3 alias: ['widget.pveIPRefSelector'],
4
5 base_url: undefined,
6
7 preferredValue: '', // hack: else Form sets dirty flag?
8
9 ref_type: undefined, // undefined = any [undefined, 'ipset' or 'alias']
10
beec97dc
TL
11 valueField: 'ref',
12 displayField: 'ref',
13
9a389924
DM
14 initComponent: function() {
15 var me = this;
16
17 if (!me.base_url) {
18 throw "no base_url specified";
19 }
20
21 var url = "/api2/json" + me.base_url;
22 if (me.ref_type) {
23 url += "?type=" + me.ref_type;
24 }
25
26 var store = Ext.create('Ext.data.Store', {
27 autoLoad: true,
28 fields: [ 'type', 'name', 'ref', 'comment' ],
29 idProperty: 'ref',
30 proxy: {
56a353b9 31 type: 'proxmox',
9a389924
DM
32 url: url
33 },
34 sorters: {
35 property: 'ref',
36 order: 'DESC'
37 }
38 });
39
40 var disable_query_for_ips = function(f, value) {
41 if (value === null ||
42 value.match(/^\d/)) { // IP address starts with \d
43 f.queryDelay = 9999999999; // hack: disbale with long delay
44 } else {
45 f.queryDelay = 10;
46 }
47 };
48
49 var columns = [];
50
51 if (!me.ref_type) {
52 columns.push({
53 header: gettext('Type'),
54 dataIndex: 'type',
55 hideable: false,
56 width: 60
57 });
58 }
59
6cc50c80 60 columns.push(
9a389924
DM
61 {
62 header: gettext('Name'),
63 dataIndex: 'ref',
64 hideable: false,
65 width: 140
66 },
67 {
68 header: gettext('Comment'),
91535f2b
DC
69 dataIndex: 'comment',
70 renderer: Ext.String.htmlEncode,
9a389924
DM
71 flex: 1
72 }
6cc50c80 73 );
9a389924
DM
74
75 Ext.apply(me, {
76 store: store,
9a389924
DM
77 listConfig: { columns: columns }
78 });
79
80 me.on('change', disable_query_for_ips);
81
82 me.callParent();
83 }
84});
85