]> git.proxmox.com Git - pve-manager.git/blame - www/manager6/ceph/Pool.js
ui: eslint: fix various spacing related issues
[pve-manager.git] / www / manager6 / ceph / Pool.js
CommitLineData
024be9c7 1Ext.define('PVE.CephCreatePool', {
9fccc702 2 extend: 'Proxmox.window.Edit',
9ad28182 3 alias: 'widget.pveCephCreatePool',
024be9c7 4
7244f4bf 5 showProgress: true,
35085f4a 6 onlineHelp: 'pve_ceph_pools',
7244f4bf 7
024be9c7 8 subject: 'Ceph Pool',
d5e771ce 9 isCreate: true,
c449c89a
DC
10 method: 'POST',
11 items: [
12 {
13 xtype: 'textfield',
14 fieldLabel: gettext('Name'),
15 name: 'name',
f6710aac 16 allowBlank: false,
c449c89a
DC
17 },
18 {
bf96f60d 19 xtype: 'proxmoxintegerfield',
c449c89a
DC
20 fieldLabel: gettext('Size'),
21 name: 'size',
f441a266 22 value: 3,
c449c89a 23 minValue: 1,
eef1979c 24 maxValue: 7,
f6710aac 25 allowBlank: false,
c449c89a
DC
26 },
27 {
bf96f60d 28 xtype: 'proxmoxintegerfield',
c449c89a
DC
29 fieldLabel: gettext('Min. Size'),
30 name: 'min_size',
f441a266 31 value: 2,
c449c89a 32 minValue: 1,
eef1979c 33 maxValue: 7,
f6710aac 34 allowBlank: false,
c449c89a
DC
35 },
36 {
d2692b86
DC
37 xtype: 'pveCephRuleSelector',
38 fieldLabel: 'Crush Rule', // do not localize
39 name: 'crush_rule',
f6710aac 40 allowBlank: false,
c449c89a 41 },
384132c3
AA
42 {
43 xtype: 'proxmoxKVComboBox',
44 fieldLabel: 'PG Autoscale Mode', // do not localize
45 name: 'pg_autoscale_mode',
46 comboItems: [
47 ['warn', 'warn'],
48 ['on', 'on'],
49 ['off', 'off'],
50 ],
51 value: 'warn',
52 allowBlank: false,
53 autoSelect: false,
54 },
c449c89a 55 {
bf96f60d 56 xtype: 'proxmoxintegerfield',
c449c89a
DC
57 fieldLabel: 'pg_num',
58 name: 'pg_num',
6ad70a2b 59 value: 128,
c449c89a
DC
60 minValue: 8,
61 maxValue: 32768,
23b316a3
TL
62 allowBlank: true,
63 emptyText: gettext('Autoscale'),
5947248f
DC
64 },
65 {
896c0d50 66 xtype: 'proxmoxcheckbox',
59e33080
TL
67 fieldLabel: gettext('Add as Storage'),
68 value: true,
69 name: 'add_storages',
70 autoEl: {
71 tag: 'div',
72 'data-qtip': gettext('Add the new pool to the cluster storage configuration.'),
73 },
f6710aac 74 },
c449c89a 75 ],
8058410f 76 initComponent: function() {
024be9c7
DM
77 var me = this;
78
79 if (!me.nodename) {
80 throw "no node name specified";
81 }
82
d2692b86
DC
83 Ext.apply(me, {
84 url: "/nodes/" + me.nodename + "/ceph/pools",
85 defaults: {
f6710aac
TL
86 nodename: me.nodename,
87 },
024be9c7
DM
88 });
89
90 me.callParent();
f6710aac 91 },
024be9c7
DM
92});
93
94Ext.define('PVE.node.CephPoolList', {
95 extend: 'Ext.grid.GridPanel',
9ad28182 96 alias: 'widget.pveNodeCephPoolList',
024be9c7 97
ba93a9c6 98 onlineHelp: 'chapter_pveceph',
5b7b4b76 99
361aafd0
DC
100 stateful: true,
101 stateId: 'grid-ceph-pools',
c449c89a 102 bufferedRenderer: false,
5b7b4b76 103
8058410f 104 features: [{ ftype: 'summary' }],
5b7b4b76 105
c449c89a
DC
106 columns: [
107 {
108 header: gettext('Name'),
5b7b4b76 109 width: 120,
c449c89a 110 sortable: true,
f6710aac 111 dataIndex: 'pool_name',
c449c89a
DC
112 },
113 {
114 header: gettext('Size') + '/min',
5b7b4b76
TL
115 width: 100,
116 align: 'right',
c449c89a
DC
117 renderer: function(v, meta, rec) {
118 return v + '/' + rec.data.min_size;
119 },
f6710aac 120 dataIndex: 'size',
c449c89a
DC
121 },
122 {
06bd1c52
AA
123 text: 'Placement Groups',
124 columns: [
125 {
126 text: '# of PGs', // pg_num',
23b316a3 127 width: 150,
06bd1c52 128 align: 'right',
f6710aac 129 dataIndex: 'pg_num',
06bd1c52
AA
130 },
131 {
23b316a3 132 text: gettext('Autoscale'),
06bd1c52
AA
133 width: 140,
134 align: 'right',
f6710aac 135 dataIndex: 'pg_autoscale_mode',
06bd1c52 136 },
f6710aac 137 ],
c449c89a
DC
138 },
139 {
5b7b4b76
TL
140 text: 'CRUSH Rule',
141 columns: [
142 {
143 text: 'ID',
144 align: 'right',
145 width: 50,
f6710aac 146 dataIndex: 'crush_rule',
5b7b4b76
TL
147 },
148 {
149 text: gettext('Name'),
150 width: 150,
151 dataIndex: 'crush_rule_name',
152 },
f6710aac 153 ],
c9508b5d 154 },
c449c89a 155 {
5b7b4b76 156 text: gettext('Used'),
c449c89a
DC
157 columns: [
158 {
5b7b4b76
TL
159 text: '%',
160 width: 100,
c449c89a
DC
161 sortable: true,
162 align: 'right',
ac1308a7
DC
163 renderer: function(val) {
164 return Ext.util.Format.percent(val, '0.00');
165 },
c449c89a 166 dataIndex: 'percent_used',
c449c89a
DC
167 },
168 {
5b7b4b76 169 text: gettext('Total'),
c449c89a
DC
170 width: 100,
171 sortable: true,
172 renderer: PVE.Utils.render_size,
173 align: 'right',
174 dataIndex: 'bytes_used',
175 summaryType: 'sum',
f6710aac
TL
176 summaryRenderer: PVE.Utils.render_size,
177 },
178 ],
179 },
c449c89a 180 ],
024be9c7
DM
181 initComponent: function() {
182 var me = this;
183
184 var nodename = me.pveSelNode.data.node;
185 if (!nodename) {
186 throw "no node name specified";
187 }
188
189 var sm = Ext.create('Ext.selection.RowModel', {});
190
0c7c0d6b 191 var rstore = Ext.create('Proxmox.data.UpdateStore', {
024be9c7 192 interval: 3000,
d5066d84 193 storeid: 'ceph-pool-list' + nodename,
024be9c7
DM
194 model: 'ceph-pool-list',
195 proxy: {
56a353b9 196 type: 'proxmox',
f6710aac
TL
197 url: "/api2/json/nodes/" + nodename + "/ceph/pools",
198 },
024be9c7
DM
199 });
200
eaa018d7 201 var store = Ext.create('Proxmox.data.DiffStore', { rstore: rstore });
024be9c7 202
4616a55b 203 var regex = new RegExp("not (installed|initialized)", "i");
8058410f 204 PVE.Utils.handleStoreErrorOrMask(me, rstore, regex, function(me, error) {
4616a55b
TM
205 me.store.rstore.stopUpdate();
206 PVE.Utils.showCephInstallOrMask(me, error.statusText, nodename,
8058410f
TL
207 function(win) {
208 me.mon(win, 'cephInstallWindowClosed', function() {
4616a55b
TM
209 me.store.rstore.startUpdate();
210 });
f6710aac 211 },
4616a55b
TM
212 );
213 });
024be9c7
DM
214
215 var create_btn = new Ext.Button({
216 text: gettext('Create'),
217 handler: function() {
218 var win = Ext.create('PVE.CephCreatePool', {
f6710aac 219 nodename: nodename,
024be9c7
DM
220 });
221 win.show();
0e9a34c6
DC
222 win.on('destroy', function() {
223 rstore.load();
224 });
f6710aac 225 },
024be9c7
DM
226 });
227
5720fafa 228 var destroy_btn = Ext.create('Proxmox.button.Button', {
4358abfd 229 text: gettext('Destroy'),
024be9c7
DM
230 selModel: sm,
231 disabled: true,
024be9c7
DM
232 handler: function() {
233 var rec = sm.getSelection()[0];
234
235 if (!rec.data.pool_name) {
236 return;
237 }
c9a8015d
EK
238 var base_url = '/nodes/' + nodename + '/ceph/pools/' +
239 rec.data.pool_name;
024be9c7 240
0e9a34c6 241 var win = Ext.create('PVE.window.SafeDestroy', {
7244f4bf 242 showProgress: true,
c9a8015d 243 url: base_url,
cb852a4d 244 params: {
f6710aac 245 remove_storages: 1,
cb852a4d 246 },
f6710aac 247 item: { type: 'CephPool', id: rec.data.pool_name },
c9a8015d 248 }).show();
0e9a34c6
DC
249 win.on('destroy', function() {
250 rstore.load();
251 });
f6710aac 252 },
024be9c7
DM
253 });
254
255 Ext.apply(me, {
256 store: store,
257 selModel: sm,
8058410f 258 tbar: [create_btn, destroy_btn],
024be9c7 259 listeners: {
6386068d
TL
260 activate: () => rstore.startUpdate(),
261 destroy: () => rstore.stopUpdate(),
f6710aac 262 },
024be9c7
DM
263 });
264
265 me.callParent();
f6710aac 266 },
024be9c7 267}, function() {
024be9c7
DM
268 Ext.define('ceph-pool-list', {
269 extend: 'Ext.data.Model',
8058410f
TL
270 fields: ['pool_name',
271 { name: 'pool', type: 'integer' },
272 { name: 'size', type: 'integer' },
273 { name: 'min_size', type: 'integer' },
274 { name: 'pg_num', type: 'integer' },
275 { name: 'bytes_used', type: 'integer' },
276 { name: 'percent_used', type: 'number' },
277 { name: 'crush_rule', type: 'integer' },
278 { name: 'crush_rule_name', type: 'string' },
024be9c7 279 ],
f6710aac 280 idProperty: 'pool_name',
024be9c7
DM
281 });
282});
d2692b86
DC
283
284Ext.define('PVE.form.CephRuleSelector', {
285 extend: 'Ext.form.field.ComboBox',
286 alias: 'widget.pveCephRuleSelector',
287
288 allowBlank: false,
289 valueField: 'name',
290 displayField: 'name',
291 editable: false,
292 queryMode: 'local',
293
294 initComponent: function() {
295 var me = this;
296
297 if (!me.nodename) {
298 throw "no nodename given";
299 }
300
301 var store = Ext.create('Ext.data.Store', {
302 fields: ['name'],
303 sorters: 'name',
304 proxy: {
56a353b9 305 type: 'proxmox',
f6710aac
TL
306 url: '/api2/json/nodes/' + me.nodename + '/ceph/rules',
307 },
d2692b86
DC
308 });
309
310 Ext.apply(me, {
f6710aac 311 store: store,
d2692b86
DC
312 });
313
314 me.callParent();
315
316 store.load({
8058410f 317 callback: function(rec, op, success) {
d2692b86
DC
318 if (success && rec.length > 0) {
319 me.select(rec[0]);
320 }
f6710aac 321 },
d2692b86 322 });
f6710aac 323 },
d2692b86
DC
324
325});