]>
Commit | Line | Data |
---|---|---|
6cbcc546 DM |
1 | Ext.define('PVE.storage.ZFSPoolSelector', { |
2 | extend: 'Ext.form.field.ComboBox', | |
3 | alias: 'widget.pveZFSPoolSelector', | |
c2317525 DC |
4 | valueField: 'pool', |
5 | displayField: 'pool', | |
6 | queryMode: 'local', | |
7 | editable: false, | |
8 | listConfig: { | |
22f2f9d6 | 9 | loadingText: gettext('Scanning...') |
c2317525 | 10 | }, |
6cbcc546 DM |
11 | initComponent : function() { |
12 | var me = this; | |
13 | ||
14 | if (!me.nodename) { | |
15 | me.nodename = 'localhost'; | |
16 | } | |
17 | ||
18 | var store = Ext.create('Ext.data.Store', { | |
19 | autoLoad: {}, // true, | |
20 | fields: [ 'pool', 'size', 'free' ], | |
21 | proxy: { | |
22 | type: 'pve', | |
23 | url: '/api2/json/nodes/' + me.nodename + '/scan/zfs' | |
24 | } | |
25 | }); | |
26 | ||
9e9ab96f WL |
27 | store.sort('pool', 'ASC'); |
28 | ||
6cbcc546 | 29 | Ext.apply(me, { |
22f2f9d6 | 30 | store: store |
6cbcc546 DM |
31 | }); |
32 | ||
33 | me.callParent(); | |
34 | } | |
35 | }); | |
36 | ||
37 | Ext.define('PVE.storage.ZFSPoolInputPanel', { | |
38 | extend: 'PVE.panel.InputPanel', | |
39 | ||
40 | onGetValues: function(values) { | |
41 | var me = this; | |
42 | ||
d5e771ce | 43 | if (me.isCreate) { |
6cbcc546 DM |
44 | values.type = 'zfspool'; |
45 | } else { | |
46 | delete values.storage; | |
47 | } | |
48 | ||
49 | values.disable = values.enable ? 0 : 1; | |
50 | delete values.enable; | |
51 | ||
52 | return values; | |
53 | }, | |
54 | ||
55 | initComponent : function() { | |
56 | var me = this; | |
57 | ||
58 | me.column1 = [ | |
59 | { | |
d5e771ce | 60 | xtype: me.isCreate ? 'textfield' : 'displayfield', |
6cbcc546 | 61 | name: 'storage', |
6cbcc546 DM |
62 | value: me.storageId || '', |
63 | fieldLabel: 'ID', | |
64 | vtype: 'StorageId', | |
65 | allowBlank: false | |
66 | } | |
67 | ]; | |
68 | ||
d5e771ce | 69 | if (me.isCreate) { |
6cbcc546 DM |
70 | me.column1.push(Ext.create('PVE.storage.ZFSPoolSelector', { |
71 | name: 'pool', | |
72 | fieldLabel: gettext('ZFS Pool'), | |
73 | allowBlank: false | |
74 | })); | |
75 | } else { | |
76 | me.column1.push(Ext.createWidget('displayfield', { | |
6cbcc546 DM |
77 | name: 'pool', |
78 | value: '', | |
79 | fieldLabel: gettext('ZFS Pool'), | |
80 | allowBlank: false | |
81 | })); | |
82 | } | |
83 | ||
ec0bd652 DC |
84 | // value is an array, |
85 | // while before it was a string | |
86 | /*jslint confusion: true*/ | |
6cbcc546 DM |
87 | me.column1.push( |
88 | {xtype: 'pveContentTypeSelector', | |
89 | cts: ['images', 'rootdir'], | |
90 | fieldLabel: gettext('Content'), | |
91 | name: 'content', | |
92 | value: ['images', 'rootdir'], | |
93 | multiSelect: true, | |
ec0bd652 DC |
94 | allowBlank: false |
95 | }); | |
96 | /*jslint confusion: false*/ | |
6cbcc546 DM |
97 | me.column2 = [ |
98 | { | |
896c0d50 | 99 | xtype: 'proxmoxcheckbox', |
6cbcc546 DM |
100 | name: 'enable', |
101 | checked: true, | |
102 | uncheckedValue: 0, | |
103 | fieldLabel: gettext('Enable') | |
104 | }, | |
105 | { | |
896c0d50 | 106 | xtype: 'proxmoxcheckbox', |
6cbcc546 DM |
107 | name: 'sparse', |
108 | checked: false, | |
109 | uncheckedValue: 0, | |
110 | fieldLabel: gettext('Thin provision') | |
4e31f56f FG |
111 | }, |
112 | { | |
113 | xtype: 'textfield', | |
114 | name: 'blocksize', | |
115 | emptyText: '8k', | |
116 | fieldLabel: gettext('Block Size'), | |
117 | allowBlank: true | |
177de3de | 118 | } |
6cbcc546 DM |
119 | ]; |
120 | ||
d5e771ce | 121 | if (me.isCreate || me.storageId !== 'local') { |
6cbcc546 | 122 | me.column2.unshift({ |
5198365d | 123 | xtype: 'pveNodeSelector', |
6cbcc546 DM |
124 | name: 'nodes', |
125 | fieldLabel: gettext('Nodes'), | |
126 | emptyText: gettext('All') + ' (' + | |
127 | gettext('No restrictions') +')', | |
128 | multiSelect: true, | |
129 | autoSelect: false | |
130 | }); | |
131 | } | |
132 | ||
133 | me.callParent(); | |
134 | } | |
135 | }); | |
136 | ||
137 | Ext.define('PVE.storage.ZFSPoolEdit', { | |
9fccc702 | 138 | extend: 'Proxmox.window.Edit', |
177de3de | 139 | |
6cbcc546 DM |
140 | initComponent : function() { |
141 | var me = this; | |
142 | ||
d5e771ce | 143 | me.isCreate = !me.storageId; |
6cbcc546 | 144 | |
d5e771ce | 145 | if (me.isCreate) { |
6cbcc546 DM |
146 | me.url = '/api2/extjs/storage'; |
147 | me.method = 'POST'; | |
148 | } else { | |
149 | me.url = '/api2/extjs/storage/' + me.storageId; | |
150 | me.method = 'PUT'; | |
151 | } | |
152 | ||
153 | var ipanel = Ext.create('PVE.storage.ZFSPoolInputPanel', { | |
d5e771ce | 154 | isCreate: me.isCreate, |
6cbcc546 DM |
155 | storageId: me.storageId |
156 | }); | |
157 | ||
158 | Ext.apply(me, { | |
2a82a528 | 159 | subject: PVE.Utils.format_storage_type('zfspool'), |
6cbcc546 DM |
160 | isAdd: true, |
161 | items: [ ipanel ] | |
162 | }); | |
163 | ||
164 | me.callParent(); | |
165 | ||
d5e771ce | 166 | if (!me.isCreate) { |
6cbcc546 DM |
167 | me.load({ |
168 | success: function(response, options) { | |
169 | var values = response.result.data; | |
170 | var ctypes = values.content || ''; | |
171 | ||
172 | values.content = ctypes.split(','); | |
173 | ||
174 | if (values.nodes) { | |
175 | values.nodes = values.nodes.split(','); | |
176 | } | |
177 | values.enable = values.disable ? 0 : 1; | |
178 | ipanel.setValues(values); | |
179 | } | |
180 | }); | |
181 | } | |
182 | } | |
183 | }); |