]> git.proxmox.com Git - pve-manager.git/blob - www/manager6/dc/PCIMapView.js
ui: ldap: add 'Check connection' checkbox as advanced option
[pve-manager.git] / www / manager6 / dc / PCIMapView.js
1 Ext.define('pve-resource-pci-tree', {
2 extend: 'Ext.data.Model',
3 idProperty: 'internalId',
4 fields: ['type', 'text', 'path', 'id', 'subsystem-id', 'iommugroup', 'description', 'digest'],
5 });
6
7 Ext.define('PVE.dc.PCIMapView', {
8 extend: 'PVE.tree.ResourceMapTree',
9 alias: 'widget.pveDcPCIMapView',
10
11 editWindowClass: 'PVE.window.PCIMapEditWindow',
12 baseUrl: '/cluster/mapping/pci',
13 mapIconCls: 'pve-itype-icon-pci',
14 getStatusCheckUrl: (node) => `/nodes/${node}/hardware/pci?pci-class-blacklist=`,
15 entryIdProperty: 'path',
16
17 checkValidity: function(data, node) {
18 let me = this;
19 let ids = {};
20 data.forEach((entry) => {
21 ids[entry.id] = entry;
22 });
23 me.getRootNode()?.cascade(function(rec) {
24 if (rec.data.node !== node || rec.data.type !== 'map') {
25 return;
26 }
27
28 let id = rec.data.path;
29 if (!id.match(/\.\d$/)) {
30 id += '.0';
31 }
32 let device = ids[id];
33 if (!device) {
34 rec.set('valid', 0);
35 rec.set('errmsg', Ext.String.format(gettext("Cannot find PCI id {0}"), id));
36 rec.commit();
37 return;
38 }
39
40
41 let deviceId = `${device.vendor}:${device.device}`.replace(/0x/g, '');
42 let subId = `${device.subsystem_vendor}:${device.subsystem_device}`.replace(/0x/g, '');
43
44 let toCheck = {
45 id: deviceId,
46 'subsystem-id': subId,
47 iommugroup: device.iommugroup !== -1 ? device.iommugroup : undefined,
48 };
49
50 let valid = 1;
51 let errors = [];
52 let errText = gettext("Configuration for {0} not correct ('{1}' != '{2}')");
53 for (const [key, validValue] of Object.entries(toCheck)) {
54 if (`${rec.data[key]}` !== `${validValue}`) {
55 errors.push(Ext.String.format(errText, key, rec.data[key] ?? '', validValue));
56 valid = 0;
57 }
58 }
59
60 rec.set('valid', valid);
61 rec.set('errmsg', errors.join('<br>'));
62 rec.commit();
63 });
64 },
65
66 store: {
67 sorters: 'text',
68 model: 'pve-resource-pci-tree',
69 data: {},
70 },
71
72 columns: [
73 {
74 xtype: 'treecolumn',
75 text: gettext('ID/Node/Path'),
76 dataIndex: 'text',
77 width: 200,
78 },
79 {
80 text: gettext('Vendor/Device'),
81 dataIndex: 'id',
82 },
83 {
84 text: gettext('Subsystem Vendor/Device'),
85 dataIndex: 'subsystem-id',
86 },
87 {
88 text: gettext('IOMMU-Group'),
89 dataIndex: 'iommugroup',
90 },
91 {
92 header: gettext('Status'),
93 dataIndex: 'valid',
94 flex: 1,
95 renderer: 'renderStatus',
96 },
97 {
98 header: gettext('Comment'),
99 dataIndex: 'description',
100 renderer: function(value, _meta, record) {
101 return Ext.String.htmlEncode(value ?? record.data.comment);
102 },
103 flex: 1,
104 },
105 ],
106 });