]>
Commit | Line | Data |
---|---|---|
d6f5549e DC |
1 | Ext.define('PVE.form.CephPoolSelector', { |
2 | extend: 'Ext.form.field.ComboBox', | |
3 | alias: 'widget.pveCephPoolSelector', | |
4 | ||
5 | allowBlank: false, | |
6 | valueField: 'pool_name', | |
7 | displayField: 'pool_name', | |
8 | editable: false, | |
9 | queryMode: 'local', | |
10 | ||
11 | initComponent: function() { | |
12 | var me = this; | |
13 | ||
14 | if (!me.nodename) { | |
15 | throw "no nodename given"; | |
16 | } | |
17 | ||
eba38fa4 SS |
18 | let onlyRBDPools = ({ data }) => |
19 | !data?.application_metadata || !!data?.application_metadata?.rbd; | |
20 | ||
d6f5549e DC |
21 | var store = Ext.create('Ext.data.Store', { |
22 | fields: ['name'], | |
23 | sorters: 'name', | |
eba38fa4 SS |
24 | filters: [ |
25 | onlyRBDPools, | |
26 | ], | |
d6f5549e | 27 | proxy: { |
56a353b9 | 28 | type: 'proxmox', |
b5bbcb4c | 29 | url: '/api2/json/nodes/' + me.nodename + '/ceph/pool', |
f6710aac | 30 | }, |
d6f5549e DC |
31 | }); |
32 | ||
33 | Ext.apply(me, { | |
f6710aac | 34 | store: store, |
d6f5549e DC |
35 | }); |
36 | ||
37 | me.callParent(); | |
38 | ||
39 | store.load({ | |
8058410f | 40 | callback: function(rec, op, success) { |
eba38fa4 SS |
41 | let filteredRec = rec.filter(onlyRBDPools); |
42 | ||
43 | if (success && filteredRec.length > 0) { | |
44 | me.select(filteredRec[0]); | |
d6f5549e | 45 | } |
f6710aac | 46 | }, |
d6f5549e | 47 | }); |
f6710aac | 48 | }, |
d6f5549e DC |
49 | |
50 | }); |