]>
Commit | Line | Data |
---|---|---|
02cebb1a DC |
1 | Ext.define('PVE.form.MDevSelector', { |
2 | extend: 'Proxmox.form.ComboGrid', | |
3 | xtype: 'pveMDevSelector', | |
4 | ||
5 | store: { | |
8058410f | 6 | fields: ['type', 'available', 'description'], |
02cebb1a DC |
7 | filterOnLoad: true, |
8 | sorters: [ | |
9 | { | |
8058410f | 10 | property: 'type', |
f6710aac TL |
11 | direction: 'ASC', |
12 | }, | |
13 | ], | |
02cebb1a DC |
14 | }, |
15 | autoSelect: false, | |
16 | valueField: 'type', | |
17 | displayField: 'type', | |
18 | listConfig: { | |
9c020707 | 19 | width: 550, |
02cebb1a DC |
20 | columns: [ |
21 | { | |
22 | header: gettext('Type'), | |
23 | dataIndex: 'type', | |
9c020707 DC |
24 | renderer: function(value, md, rec) { |
25 | if (rec.data.name !== undefined) { | |
26 | return `${rec.data.name} (${value})`; | |
27 | } | |
28 | return value; | |
29 | }, | |
f6710aac | 30 | flex: 1, |
02cebb1a DC |
31 | }, |
32 | { | |
2831d806 | 33 | header: gettext('Avail'), |
02cebb1a | 34 | dataIndex: 'available', |
9c020707 | 35 | width: 60, |
02cebb1a DC |
36 | }, |
37 | { | |
38 | header: gettext('Description'), | |
39 | dataIndex: 'description', | |
40 | flex: 1, | |
9c020707 | 41 | cellWrap: true, |
02cebb1a DC |
42 | renderer: function(value) { |
43 | if (!value) { | |
44 | return ''; | |
45 | } | |
46 | ||
47 | return value.split('\n').join('<br>'); | |
f6710aac TL |
48 | }, |
49 | }, | |
50 | ], | |
02cebb1a DC |
51 | }, |
52 | ||
53 | setPciID: function(pciid, force) { | |
54 | var me = this; | |
55 | ||
53e3ea84 | 56 | if (!force && (!pciid || me.pciid === pciid)) { |
02cebb1a DC |
57 | return; |
58 | } | |
59 | ||
60 | me.pciid = pciid; | |
61 | me.updateProxy(); | |
62 | }, | |
63 | ||
64 | ||
65 | setNodename: function(nodename) { | |
66 | var me = this; | |
67 | ||
53e3ea84 | 68 | if (!nodename || me.nodename === nodename) { |
02cebb1a DC |
69 | return; |
70 | } | |
71 | ||
72 | me.nodename = nodename; | |
73 | me.updateProxy(); | |
74 | }, | |
75 | ||
76 | updateProxy: function() { | |
77 | var me = this; | |
78 | me.store.setProxy({ | |
79 | type: 'proxmox', | |
f6710aac | 80 | url: '/api2/json/nodes/' + me.nodename + '/hardware/pci/' + me.pciid + '/mdev', |
02cebb1a DC |
81 | }); |
82 | me.store.load(); | |
83 | }, | |
84 | ||
85 | initComponent: function() { | |
86 | var me = this; | |
87 | ||
88 | if (!me.nodename) { | |
89 | throw 'no node name specified'; | |
90 | } | |
91 | ||
92 | me.callParent(); | |
93 | ||
94 | if (me.pciid) { | |
95 | me.setPciID(me.pciid, true); | |
96 | } | |
f6710aac | 97 | }, |
02cebb1a DC |
98 | }); |
99 |