]>
Commit | Line | Data |
---|---|---|
4f0c0764 DC |
1 | Ext.define('Proxmox.form.DiskSelector', { |
2 | extend: 'Proxmox.form.ComboGrid', | |
3 | xtype: 'pmxDiskSelector', | |
4 | ||
5 | // can be | |
6 | // undefined: all | |
7 | // unused: only unused | |
8 | // journal_disk: all disks with gpt | |
9 | diskType: undefined, | |
10 | ||
f340cf64 FE |
11 | // use include-partitions=1 as a parameter |
12 | includePartitions: false, | |
13 | ||
017a6376 | 14 | // the property the backend wants for the type ('type' by default) |
4f0c0764 DC |
15 | typeProperty: 'type', |
16 | ||
17 | valueField: 'devpath', | |
18 | displayField: 'devpath', | |
19 | emptyText: gettext('No Disks unused'), | |
20 | listConfig: { | |
21 | width: 600, | |
22 | columns: [ | |
23 | { | |
24 | header: gettext('Device'), | |
25 | flex: 3, | |
26 | sortable: true, | |
27 | dataIndex: 'devpath', | |
28 | }, | |
29 | { | |
30 | header: gettext('Size'), | |
31 | flex: 2, | |
32 | sortable: false, | |
33 | renderer: Proxmox.Utils.format_size, | |
34 | dataIndex: 'size', | |
35 | }, | |
36 | { | |
37 | header: gettext('Serial'), | |
38 | flex: 5, | |
39 | sortable: true, | |
40 | dataIndex: 'serial', | |
41 | }, | |
42 | ], | |
43 | }, | |
44 | ||
45 | initComponent: function() { | |
46 | var me = this; | |
47 | ||
48 | var nodename = me.nodename; | |
49 | if (!nodename) { | |
50 | throw "no node name specified"; | |
51 | } | |
52 | ||
53 | let extraParams = {}; | |
54 | ||
55 | if (me.diskType) { | |
56 | extraParams[me.typeProperty] = me.diskType; | |
57 | } | |
58 | ||
f340cf64 FE |
59 | if (me.includePartitions) { |
60 | extraParams['include-partitions'] = 1; | |
61 | } | |
62 | ||
4f0c0764 DC |
63 | var store = Ext.create('Ext.data.Store', { |
64 | filterOnLoad: true, | |
65 | model: 'pmx-disk-list', | |
66 | proxy: { | |
67 | type: 'proxmox', | |
68 | url: `/api2/json/nodes/${nodename}/disks/list`, | |
69 | extraParams, | |
70 | }, | |
71 | sorters: [ | |
72 | { | |
73 | property: 'devpath', | |
74 | direction: 'ASC', | |
75 | }, | |
76 | ], | |
77 | }); | |
78 | ||
79 | Ext.apply(me, { | |
80 | store: store, | |
81 | }); | |
82 | ||
83 | me.callParent(); | |
84 | ||
85 | store.load(); | |
86 | }, | |
87 | }); |