]>
Commit | Line | Data |
---|---|---|
6b3ce31b | 1 | // require("js/omv/tree/Panel.js") |
3415404c | 2 | // require("js/omv/module/admin/storage/zfs/TreePanel.js") |
6b3ce31b | 3 | // require("js/omv/workspace/window/Grid.js") |
42856e8b NB |
4 | // require("js/omv/form/field/CheckboxGrid.js") |
5 | ||
54b9d43e NB |
6 | Ext.define("OMV.module.admin.storage.zfs.ShowDetails", { |
7 | extend: "OMV.workspace.window.Form", | |
8 | requires: [ | |
9 | "OMV.data.Store", | |
10 | "OMV.data.Model", | |
11 | "OMV.data.proxy.Rpc", | |
12 | ], | |
13 | ||
14 | rpcService: "ZFS", | |
15 | title: _("Object details"), | |
16 | autoLoadData: true, | |
17 | hideResetButton: true, | |
18 | hideCancelButton: true, | |
19 | width: 550, | |
20 | height: 350, | |
21 | layout: 'fit', | |
22 | okButtonText: _("Ok"), | |
23 | ||
24 | getFormItems: function() { | |
25 | var me = this; | |
26 | ||
27 | return [{ | |
28 | xtype: "textareafield", | |
29 | name: "details", | |
30 | grow: true, | |
31 | anchor: '100%', | |
32 | readOnly: true | |
33 | }]; | |
34 | ||
35 | } | |
36 | }); | |
37 | ||
42856e8b NB |
38 | Ext.define("OMV.module.admin.storage.zfs.AddPool", { |
39 | extend: "OMV.workspace.window.Form", | |
40 | requires: [ | |
41 | "OMV.data.Store", | |
42 | "OMV.data.Model", | |
43 | "OMV.data.proxy.Rpc", | |
44 | "OMV.form.field.CheckboxGrid" | |
45 | ], | |
46 | ||
47 | rpcService: "ZFS", | |
48 | rpcSetMethod: "addPool", | |
49 | title: _("Create ZFS pool"), | |
50 | autoLoadData: false, | |
51 | hideResetButton: true, | |
52 | width: 550, | |
7d6b772c | 53 | height: 350, |
42856e8b NB |
54 | |
55 | getFormItems: function() { | |
56 | var me = this; | |
57 | return [{ | |
58 | xtype: "textfield", | |
59 | name: "name", | |
60 | fieldLabel: _("Name") | |
61 | },{ | |
62 | xtype: "combo", | |
63 | name: "pooltype", | |
64 | fieldLabel: _("Pool type"), | |
65 | queryMode: "local", | |
66 | store: Ext.create("Ext.data.ArrayStore", { | |
67 | fields: [ "value", "text" ], | |
68 | data: [ | |
69 | [ "basic", _("Basic") ], | |
70 | [ "mirror", _("Mirror") ], | |
71 | [ "raidz1", _("RAID-Z1") ], | |
72 | [ "raidz2", _("RAID-Z2") ], | |
73 | [ "raidz3", _("RAID-Z3") ] | |
74 | ] | |
75 | }), | |
76 | displayField: "text", | |
77 | valueField: "value", | |
78 | allowBlank: false, | |
79 | editable: false, | |
80 | triggerAction: "all", | |
81 | value: "raidz1", | |
82 | listeners: { | |
83 | scope: me, | |
84 | change: function(combo, value) { | |
85 | var devicesField = this.findField("devices"); | |
86 | switch(value) { | |
7d6b772c NB |
87 | case "basic": |
88 | devicesField.minSelections = 1; | |
42856e8b | 89 | break; |
7d6b772c NB |
90 | case "mirror": |
91 | devicesField.minSelections = 2; | |
42856e8b | 92 | break; |
7d6b772c NB |
93 | case "raidz1": |
94 | devicesField.minSelections = 3; | |
42856e8b | 95 | break; |
7d6b772c NB |
96 | case "raidz2": |
97 | devicesField.minSelections = 4; | |
98 | case "raidz3": | |
99 | devicesField.minSelections = 5; | |
100 | break; | |
101 | default: | |
102 | devicesField.minSelections = 2; | |
42856e8b NB |
103 | break; |
104 | } | |
105 | devicesField.validate(); | |
106 | } | |
107 | } | |
108 | },{ | |
109 | xtype: "checkboxgridfield", | |
110 | name: "devices", | |
111 | fieldLabel: _("Devices"), | |
112 | valueField: "devicefile", | |
113 | minSelections: 3, // Min. number of devices for RAIDZ-1 | |
114 | useStringValue: true, | |
115 | height: 130, | |
116 | store: Ext.create("OMV.data.Store", { | |
117 | autoLoad: true, | |
118 | model: OMV.data.Model.createImplicit({ | |
119 | idProperty: "devicefile", | |
120 | fields: [ | |
121 | { name: "devicefile", type: "string" }, | |
122 | { name: "size", type: "string" }, | |
123 | { name: "vendor", type: "string" }, | |
124 | { name: "serialnumber", type: "string" } | |
125 | ] | |
126 | }), | |
127 | proxy: { | |
128 | type: "rpc", | |
129 | appendSortParams: false, | |
130 | rpcData: { | |
131 | service: "RaidMgmt", | |
132 | method: "getCandidates" | |
133 | } | |
134 | }, | |
135 | sorters: [{ | |
136 | direction: "ASC", | |
137 | property: "devicefile" | |
138 | }] | |
139 | }), | |
140 | gridConfig: { | |
141 | stateful: true, | |
142 | stateId: "1866b5d0-327e-11e4-8c21-0800200c9a66", | |
143 | columns: [{ | |
144 | text: _("Device"), | |
145 | sortable: true, | |
146 | dataIndex: "devicefile", | |
147 | stateId: "devicefile", | |
148 | flex: 1 | |
149 | },{ | |
150 | xtype: "binaryunitcolumn", | |
151 | text: _("Capacity"), | |
152 | sortable: true, | |
153 | dataIndex: "size", | |
154 | stateId: "size", | |
155 | width: 50, | |
156 | flex: 1 | |
157 | },{ | |
158 | text: _("Vendor"), | |
159 | sortable: true, | |
160 | dataIndex: "vendor", | |
161 | stateId: "vendor", | |
162 | flex: 1 | |
163 | },{ | |
164 | text: _("Serial Number"), | |
165 | sortable: true, | |
166 | dataIndex: "serialnumber", | |
167 | stateId: "serialnumber", | |
168 | flex: 1 | |
169 | }] | |
170 | } | |
c6117b32 NB |
171 | },{ |
172 | xtype: "textfield", | |
173 | name: "mountpoint", | |
174 | fieldLabel: _("Mountpoint"), | |
175 | plugins: [{ | |
176 | ptype: "fieldinfo", | |
177 | text: _("Optional mountpoint for the pool. Default is to use pool name.") | |
178 | }] | |
7d6b772c NB |
179 | },{ |
180 | xtype: "checkbox", | |
181 | name: "force", | |
182 | fieldLabel: _("Force creation"), | |
183 | checked: false, | |
cc1caa78 NB |
184 | plugins: [{ |
185 | ptype: "fieldinfo", | |
186 | text: _("Forces the creation of the pool even if errors are reported. Use with extreme caution!") | |
187 | }] | |
42856e8b NB |
188 | }]; |
189 | }, | |
190 | ||
191 | doSubmit: function() { | |
192 | var me = this; | |
193 | OMV.MessageBox.show({ | |
194 | title: _("Confirmation"), | |
195 | msg: _("Do you really want to create the ZFS pool?"), | |
196 | buttons: Ext.Msg.YESNO, | |
197 | fn: function(answer) { | |
198 | if(answer === "no") | |
199 | return; | |
200 | me.superclass.doSubmit.call(me); | |
201 | }, | |
202 | scope: me, | |
203 | icon: Ext.Msg.QUESTION | |
204 | }); | |
205 | } | |
206 | }); | |
6b3ce31b | 207 | |
3415404c | 208 | Ext.define("OMV.module.admin.storage.zfs.AddObject", { |
6b3ce31b MR |
209 | extend: "OMV.workspace.window.Form", |
210 | uses: [ | |
211 | "OMV.data.Store", | |
212 | "OMV.data.Model", | |
213 | "OMV.data.proxy.Rpc", | |
214 | "OMV.data.reader.RpcArray" | |
215 | ], | |
216 | ||
217 | rpcService: "ZFS", | |
218 | rpcSetMethod: "addObject", | |
219 | width: 420, | |
220 | ||
221 | getFormItems: function() { | |
222 | var me = this; | |
223 | return [{ | |
224 | xtype: "combo", | |
225 | name: "type", | |
226 | fieldLabel: _("Object Type"), | |
227 | queryMode: "local", | |
228 | store: [ | |
229 | [ "filesystem", "Filesystem" ], | |
230 | [ "snapshot", "Snapshot" ], | |
231 | [ "volume", "Volume" ] | |
232 | ], | |
233 | allowBlank: true, | |
234 | editable: false, | |
235 | triggerAction: "all", | |
236 | value: "filesystem", | |
237 | listeners: { | |
238 | scope: me, | |
239 | change: function(combo, value) { | |
240 | var sizeField = this.findField("size"); | |
241 | switch(value) { | |
242 | case "volume": | |
243 | sizeField.show(); | |
244 | sizeField.allowBlank = false; | |
245 | break; | |
246 | default: | |
247 | sizeField.hide(); | |
248 | sizeField.allowBlank = true; | |
249 | break; | |
250 | } | |
251 | sizeField.validate(); | |
252 | } | |
253 | } | |
254 | },{ | |
255 | xtype: "textfield", | |
256 | name: "path", | |
257 | fieldLabel: _("Prefix"), | |
258 | allowBlank: false, | |
a01b6467 NB |
259 | readOnly: true, |
260 | value: me.path | |
6b3ce31b MR |
261 | },{ |
262 | xtype: "textfield", | |
263 | name: "name", | |
264 | fieldLabel: _("Name"), | |
265 | allowBlank: false, | |
266 | plugins: [{ | |
267 | ptype: "fieldinfo", | |
268 | text: _("Name of the new object. Prefix will prepend the name. Please omit leading /") | |
269 | }] | |
270 | },{ | |
271 | xtype: "textfield", | |
272 | name: "size", | |
273 | hidden: true, | |
274 | fieldLabel: _("Size"), | |
275 | allowBlank: true, | |
276 | plugins: [{ | |
277 | ptype: "fieldinfo", | |
278 | text: _("Size of the volume e.g. 5mb,100gb,1tb etc") | |
279 | }] | |
280 | }]; | |
281 | } | |
282 | }); | |
283 | ||
a6c3a4dd NB |
284 | Ext.define("OMV.module.admin.storage.zfs.ExpandPool", { |
285 | extend: "OMV.workspace.window.Form", | |
286 | uses: [ | |
287 | "OMV.data.Store", | |
288 | "OMV.data.Model", | |
289 | "OMV.data.proxy.Rpc", | |
290 | "OMV.data.reader.RpcArray" | |
291 | ], | |
292 | ||
293 | rpcService: "ZFS", | |
294 | rpcSetMethod: "expandPool", | |
295 | width: 550, | |
296 | height: 350, | |
297 | autoLoadData: true, | |
298 | ||
299 | getFormItems: function() { | |
300 | var me = this; | |
301 | return [{ | |
302 | xtype: "textfield", | |
303 | name: "name", | |
304 | fieldLabel: _("Name"), | |
305 | allowBlank: false, | |
306 | readOnly: true, | |
307 | value: me.name | |
308 | },{ | |
309 | xtype: "textfield", | |
310 | name: "pool_type", | |
311 | fieldLabel: _("Pool type"), | |
312 | allowBlank: false, | |
313 | readOnly: true, | |
314 | value: me.pool_type | |
315 | },{ | |
316 | xtype: "checkboxgridfield", | |
317 | name: "devices", | |
318 | fieldLabel: _("Devices"), | |
319 | valueField: "devicefile", | |
320 | listeners: { | |
321 | scope: me, | |
322 | change: function(e, eOpts) { | |
323 | var deviceField = this.findField("devices"); | |
324 | if (me.pool_type == "Basic") { | |
325 | deviceField.minSelections = 1; | |
326 | } else { | |
327 | deviceField.minSelections = me.nr_disks; | |
328 | deviceField.maxSelections = me.nr_disks; | |
329 | } | |
330 | } | |
331 | }, | |
332 | useStringValue: true, | |
333 | height: 130, | |
334 | store: Ext.create("OMV.data.Store", { | |
335 | autoLoad: true, | |
336 | model: OMV.data.Model.createImplicit({ | |
337 | idProperty: "devicefile", | |
338 | fields: [ | |
339 | { name: "devicefile", type: "string" }, | |
340 | { name: "size", type: "string" }, | |
341 | { name: "vendor", type: "string" }, | |
342 | { name: "serialnumber", type: "string" } | |
343 | ] | |
344 | }), | |
345 | proxy: { | |
346 | type: "rpc", | |
347 | appendSortParams: false, | |
348 | rpcData: { | |
349 | service: "RaidMgmt", | |
350 | method: "getCandidates" | |
351 | } | |
352 | }, | |
353 | sorters: [{ | |
354 | direction: "ASC", | |
355 | property: "devicefile" | |
356 | }] | |
357 | }), | |
358 | gridConfig: { | |
359 | stateful: true, | |
360 | stateId: "04942d40-4ee3-11e4-916c-0800200c9a66", | |
361 | columns: [{ | |
362 | text: _("Device"), | |
363 | sortable: true, | |
364 | dataIndex: "devicefile", | |
365 | stateId: "devicefile", | |
366 | flex: 1 | |
367 | },{ | |
368 | xtype: "binaryunitcolumn", | |
369 | text: _("Capacity"), | |
370 | sortable: true, | |
371 | dataIndex: "size", | |
372 | stateId: "size", | |
373 | width: 50, | |
374 | flex: 1 | |
375 | },{ | |
376 | text: _("Vendor"), | |
377 | sortable: true, | |
378 | dataIndex: "vendor", | |
379 | stateId: "vendor", | |
380 | flex: 1 | |
381 | },{ | |
382 | text: _("Serial Number"), | |
383 | sortable: true, | |
384 | dataIndex: "serialnumber", | |
385 | stateId: "serialnumber", | |
386 | flex: 1 | |
387 | }] | |
388 | } | |
389 | }]; | |
390 | } | |
391 | }); | |
6b3ce31b MR |
392 | |
393 | ||
3415404c | 394 | Ext.define("OMV.module.admin.storage.zfs.EditProperties", { |
6b3ce31b MR |
395 | extend: "OMV.workspace.window.Grid", |
396 | requires: [ | |
397 | "OMV.data.Store", | |
398 | "OMV.data.Model", | |
399 | "OMV.data.proxy.Rpc" | |
400 | ], | |
401 | ||
402 | rpcService: "ZFS", | |
403 | rpcSetMethod: "setProperties", | |
404 | ||
405 | title: _("Edit properties"), | |
406 | width: 500, | |
407 | height: 305, | |
408 | ||
409 | getGridConfig: function() { | |
410 | var me = this; | |
411 | ||
412 | var rowEditing = Ext.create('Ext.grid.plugin.RowEditing', { | |
413 | clicksToEdit: 1, | |
414 | pluginId: 'rowEditing', | |
415 | listeners: { | |
416 | validateedit: function(editor, e, eOpts) { | |
417 | e.record.set("modified", "true"); | |
418 | }, | |
419 | beforeedit: function(editor, e, eOpts) { | |
cc1caa78 | 420 | if (e.record.get("newproperty") === "false") { |
6b3ce31b MR |
421 | e.grid.getPlugin('rowEditing').editor.form.findField("value").enable(); |
422 | e.grid.getPlugin('rowEditing').editor.form.findField("property").disable(); | |
423 | } else { | |
424 | e.grid.getPlugin('rowEditing').editor.form.findField("value").enable(); | |
425 | e.grid.getPlugin('rowEditing').editor.form.findField("property").enable(); | |
426 | } | |
427 | } | |
428 | ||
429 | } | |
430 | }); | |
431 | ||
432 | var store = Ext.create("OMV.data.Store", { | |
433 | autoLoad: true, | |
434 | model: OMV.data.Model.createImplicit({ | |
435 | fields: [ | |
436 | { name: "property", type: "string" }, | |
437 | { name: "value", type: "string" }, | |
438 | { name: "source", type: "string" }, | |
439 | { name: "modified", type: "string" }, | |
440 | { name: "newproperty", type: "string", defaultValue: "false" } | |
441 | ] | |
442 | }), | |
443 | proxy: { | |
444 | type: "rpc", | |
445 | rpcData: { | |
446 | service: "ZFS", | |
447 | method: "getProperties", | |
448 | params: { | |
449 | name: me.name, | |
450 | type: me.type | |
451 | } | |
452 | } | |
453 | } | |
454 | }); | |
455 | ||
456 | return { | |
457 | border: false, | |
458 | stateful: true, | |
459 | stateId: "8c3dc800-bdbb-11e3-b1b6-0800200c9a66", | |
460 | selType: 'rowmodel', | |
461 | plugins: [rowEditing], | |
462 | store: store, | |
463 | tbar: [{ | |
464 | text: "Add property", | |
465 | icon: "images/add.png", | |
466 | iconCls: Ext.baseCSSPrefix + "btn-icon-16x16", | |
467 | handler: function(view) { | |
468 | Ext.define('Property', { | |
469 | extend: 'Ext.data.Model', | |
470 | fields: [ | |
471 | "property", | |
472 | "value", | |
473 | "source", | |
474 | "modified", | |
475 | "newproperty" | |
476 | ] | |
477 | }); | |
478 | var newProperty = Ext.create("Property", { | |
479 | property: "", | |
480 | value: "", | |
481 | source: "local", | |
482 | modified: "true", | |
38408c3f | 483 | newproperty: "true" |
6b3ce31b MR |
484 | }); |
485 | rowEditing.cancelEdit(); | |
486 | store.insert(0, newProperty); | |
487 | rowEditing.startEdit(); | |
488 | } | |
489 | }], | |
490 | columns: [{ | |
491 | text: _("Property"), | |
492 | sortable: true, | |
493 | dataIndex: "property", | |
494 | stateId: "property", | |
495 | editor: { | |
496 | xtype: "textfield", | |
497 | allowBlank: false, | |
498 | } | |
499 | },{ | |
500 | text: _("Value"), | |
501 | sortable: true, | |
502 | dataIndex: "value", | |
503 | stateId: "value", | |
504 | flex: 1, | |
505 | readOnly: true, | |
506 | editor: { | |
507 | xtype: "textfield", | |
508 | allowBlank: false, | |
509 | } | |
510 | },{ | |
511 | text: _("Source"), | |
512 | sortable: true, | |
513 | dataIndex: "source", | |
514 | stateId: "source", | |
515 | },{ | |
516 | xtype: 'actioncolumn', | |
517 | header: 'Inherit', | |
518 | icon: "images/checkmark.png", | |
519 | tooltip: "Inherit", | |
520 | handler: function(view, rowIndex, colIndex, item, e, record, row) { | |
521 | OMV.RpcObserver.request({ | |
522 | msg : _("Updating property..."), | |
523 | rpcData : { | |
524 | service: "ZFS", | |
525 | method: "inherit", | |
526 | params: { | |
527 | name: me.name, | |
528 | type: me.type, | |
529 | property: record.get("property") | |
530 | } | |
531 | }, | |
532 | finish : function() { | |
533 | view.getStore().reload(); | |
534 | } | |
535 | }); | |
536 | }, | |
537 | isDisabled: function(view, rowIdx, colIdx, item, record) { | |
538 | var src = record.get("source"); | |
539 | if(src === "local") { | |
540 | return false; | |
541 | } else { | |
542 | return true; | |
543 | } | |
544 | } | |
545 | },{ | |
546 | text: _("New"), | |
547 | dataIndex: "newproperty", | |
548 | stateId: "newproperty", | |
549 | sortable: false, | |
550 | hidden: true | |
38408c3f | 551 | },{ |
6b3ce31b MR |
552 | text: _("Modified"), |
553 | sortable: false, | |
554 | dataIndex: "modified", | |
555 | stateId: "modified", | |
556 | hidden: true | |
557 | }], | |
558 | }; | |
559 | }, | |
560 | ||
561 | getRpcSetParams: function() { | |
562 | var me = this; | |
563 | var properties = []; | |
564 | var values = me.getValues(); | |
565 | Ext.Array.each(values, function(value) { | |
566 | if(value.modified === "false") | |
38408c3f | 567 | return; |
6b3ce31b MR |
568 | properties.push({ |
569 | "property": value.property, | |
570 | "value": value.value, | |
571 | }); | |
572 | }); | |
573 | return { | |
574 | name: me.name, | |
575 | type: me.type, | |
576 | properties: properties | |
577 | }; | |
578 | } | |
579 | ||
580 | }); | |
581 | ||
582 | ||
3415404c | 583 | Ext.define("OMV.module.admin.storage.zfs.CreateShare", { |
6b3ce31b MR |
584 | extend: "OMV.workspace.window.Form", |
585 | uses: [ | |
586 | "OMV.data.Store", | |
587 | "OMV.data.Model", | |
588 | "OMV.data.proxy.Rpc", | |
589 | "OMV.data.reader.RpcArray" | |
590 | ], | |
591 | ||
592 | rpcService: "ZFS", | |
593 | rpcSetMethod: "createShare", | |
594 | width: 500, | |
595 | ||
596 | getFormItems: function() { | |
597 | var me = this; | |
598 | return [{ | |
599 | xtype: "textfield", | |
600 | name: "sharename", | |
601 | fieldLabel: _("Name"), | |
602 | allowBlank: false, | |
603 | },{ | |
604 | xtype: "textfield", | |
605 | name: "mountpoint", | |
606 | fieldLabel: _("Path"), | |
cc1caa78 NB |
607 | allowBlank: true, |
608 | readOnly: false | |
6b3ce31b MR |
609 | },{ |
610 | xtype: "combo", | |
611 | name: "mode", | |
612 | fieldLabel: _("Permissions"), | |
613 | queryMode: "local", | |
614 | store: Ext.create("Ext.data.ArrayStore", { | |
615 | fields: [ "value", "text" ], | |
616 | data: [ | |
617 | [ "700", _("Administrator: read/write, Users: no access, Others: no access") ], | |
618 | [ "750", _("Administrator: read/write, Users: read-only, Others: no access") ], | |
619 | [ "770", _("Administrator: read/write, Users: read/write, Others: no access") ], | |
620 | [ "755", _("Administrator: read/write, Users: read-only, Others: read-only") ], | |
621 | [ "775", _("Administrator: read/write, Users: read/write, Others: read-only") ], | |
622 | [ "777", _("Everyone: read/write") ] | |
623 | ] | |
624 | }), | |
625 | displayField: "text", | |
626 | valueField: "value", | |
627 | allowBlank: false, | |
628 | editable: false, | |
629 | showItemTooltip: true, | |
630 | triggerAction: "all", | |
631 | value: "775", | |
632 | plugins: [{ | |
633 | ptype: "fieldinfo", | |
634 | text: _("The file mode of the shared folder path.") | |
635 | }] | |
636 | },{ | |
637 | xtype: "textarea", | |
638 | name: "comment", | |
639 | fieldLabel: _("Comment"), | |
640 | allowBlank: true | |
641 | },{ | |
642 | xtype: "textarea", | |
643 | name: "name", | |
644 | hidden: true | |
645 | },{ | |
646 | xtype: "textarea", | |
647 | name: "type", | |
648 | hidden: true | |
649 | }]; | |
650 | } | |
651 | }); | |
652 | ||
653 | ||
654 | ||
38408c3f MR |
655 | Ext.define("OMV.module.admin.storage.zfs.Overview", { |
656 | extend: "OMV.module.admin.storage.zfs.TreePanel", | |
6b3ce31b MR |
657 | |
658 | rpcService: "ZFS", | |
659 | rpcGetMethod: "getObjectTree", | |
660 | requires: [ | |
661 | "OMV.data.Store", | |
662 | "OMV.data.Model", | |
663 | "OMV.data.proxy.Rpc" | |
664 | ], | |
665 | ||
666 | rootVisible: false, | |
667 | stateful: true, | |
668 | stateId: "cec54550-bc2a-11e3-a5e2-0800200c9a66", | |
669 | ||
670 | columns: [{ | |
671 | text: _("Name"), | |
672 | xtype: 'treecolumn', | |
673 | dataIndex: 'name', | |
674 | sortable: true, | |
675 | flex: 2, | |
676 | stateId: 'name' | |
677 | },{ | |
678 | text: _("Type"), | |
679 | dataIndex: 'type', | |
680 | sortable: true, | |
681 | flex: 1, | |
a6c3a4dd NB |
682 | stateId: 'type', |
683 | renderer: function(value, p, r){ | |
684 | if (r.data['type'] == "Pool") { | |
685 | return r.data['type'] + ' (' + r.data['pool_type'] + ')'; | |
686 | } else { | |
687 | return r.data['type']; | |
688 | } | |
689 | } | |
54b9d43e NB |
690 | },{ |
691 | text: _("Size"), | |
692 | dataIndex: 'size', | |
693 | sortable: true, | |
694 | flex: 1, | |
695 | stateId: 'size' | |
696 | },{ | |
697 | text: _("Used"), | |
698 | dataIndex: 'used', | |
699 | sortable: true, | |
700 | flex: 1, | |
701 | stateId: 'used' | |
702 | },{ | |
703 | text: _("Available"), | |
704 | dataIndex: 'available', | |
705 | sortable: true, | |
706 | flex: 1, | |
707 | stateId: 'available' | |
708 | },{ | |
709 | text: _("Mountpoint"), | |
710 | dataIndex: 'mountpoint', | |
711 | sortable: true, | |
712 | flex: 1, | |
713 | stateId: 'mountpoint' | |
6b3ce31b MR |
714 | },{ |
715 | text: _("Share"), | |
716 | xtype: 'actioncolumn', | |
717 | tooltip: 'Create shared folder', | |
718 | align: 'center', | |
719 | icon: 'images/checkmark.png', | |
720 | handler: function(view, rowIndex, colIndex, item, e, record, row) { | |
721 | var me = this; | |
38408c3f | 722 | Ext.create("OMV.module.admin.storage.zfs.CreateShare", { |
6b3ce31b MR |
723 | title: _("Create shared folder"), |
724 | rpcGetMethod: "getSharedParams", | |
725 | rpcGetParams: { | |
726 | name: record.get('path'), | |
727 | type: record.get('type') | |
728 | } | |
729 | }).show(); | |
730 | }, | |
731 | isDisabled: function(view, rowIdx, colIdx, item, record) { | |
732 | var src = record.get("type"); | |
733 | if((src === "Filesystem") && (record.get("shared") === "false")) { | |
734 | return false; | |
735 | } else { | |
736 | return true; | |
737 | } | |
738 | } | |
6b3ce31b MR |
739 | },{ |
740 | text: _("Details"), | |
741 | xtype: 'actioncolumn', | |
742 | tooltip: 'Details', | |
743 | align: 'center', | |
54b9d43e NB |
744 | icon: 'images/search.png', |
745 | handler: function(view, rowIndex, colIndex, item, e, record, row) { | |
746 | var me = this; | |
747 | Ext.create("OMV.module.admin.storage.zfs.ShowDetails", { | |
748 | title: _("Object details"), | |
749 | rpcGetMethod: "getObjectDetails", | |
750 | rpcGetParams: { | |
751 | name: record.get('path'), | |
752 | type: record.get('type') | |
753 | } | |
754 | }).show(); | |
755 | } | |
6b3ce31b MR |
756 | },{ |
757 | text: _("Shared"), | |
758 | dataIndex: 'shared', | |
759 | sortable: false, | |
760 | stateId: 'shared', | |
761 | hidden: true | |
762 | }], | |
763 | ||
764 | initComponent: function() { | |
765 | var me = this; | |
766 | this.width = 600; | |
767 | Ext.apply(me, { | |
768 | store: Ext.create("Ext.data.TreeStore", { | |
769 | autoLoad: true, | |
770 | model: OMV.data.Model.createImplicit({ | |
771 | fields: [ | |
772 | { name: "name", type: "string" }, | |
773 | { name: "type", type: "string" }, | |
54b9d43e NB |
774 | { name: "size", type: "string" }, |
775 | { name: "used", type: "string" }, | |
776 | { name: "available", type: "string" }, | |
777 | { name: "mountpoint", type: "string" }, | |
6b3ce31b MR |
778 | { name: "id", type: "string" }, |
779 | { name: "path", type: "string" }, | |
780 | { name: "origin", type: "string", defaultValue: "none" }, | |
a6c3a4dd NB |
781 | { name: "shared", type: "string", defaultValue: "false" }, |
782 | { name: "pool_type", type: "string"}, | |
783 | { name: "nr_disks", type: "string"} | |
6b3ce31b MR |
784 | ] |
785 | }), | |
786 | proxy: { | |
787 | type: "rpc", | |
788 | rpcData: { | |
789 | service: "ZFS", | |
790 | method: "getObjectTree", | |
791 | } | |
792 | }, | |
793 | folderSort: true | |
794 | }) | |
795 | }); | |
796 | me.callParent(arguments); | |
797 | }, | |
798 | ||
7d6b772c | 799 | onAddButton: function() { |
42856e8b NB |
800 | var me = this; |
801 | Ext.create("OMV.module.admin.storage.zfs.AddPool", { | |
802 | listeners: { | |
803 | scope: me, | |
804 | submit: function() { | |
805 | this.doReload(); | |
806 | } | |
807 | } | |
808 | }).show(); | |
809 | }, | |
810 | ||
6b3ce31b MR |
811 | onAddObjButton: function() { |
812 | var me = this; | |
813 | var sm = me.getSelectionModel(); | |
814 | var records = sm.getSelection(); | |
38408c3f MR |
815 | var record = records[0]; |
816 | Ext.create("OMV.module.admin.storage.zfs.AddObject", { | |
6b3ce31b | 817 | title: _("Add Object"), |
a01b6467 | 818 | path: record.get("path"), |
6b3ce31b MR |
819 | listeners: { |
820 | scope: me, | |
821 | submit: function() { | |
822 | this.doReload(); | |
823 | } | |
824 | } | |
825 | }).show(); | |
826 | }, | |
827 | ||
828 | onEditButton: function() { | |
829 | var me = this; | |
830 | var sm = me.getSelectionModel(); | |
831 | var records = sm.getSelection(); | |
832 | var record = records[0]; | |
38408c3f | 833 | Ext.create("OMV.module.admin.storage.zfs.EditProperties", { |
6b3ce31b MR |
834 | name: record.get("path"), |
835 | type: record.get("type") | |
836 | }).show(); | |
837 | }, | |
a6c3a4dd NB |
838 | |
839 | onExpandPoolButton: function() { | |
840 | var me = this; | |
841 | var sm = me.getSelectionModel(); | |
842 | var records = sm.getSelection(); | |
843 | var record = records[0]; | |
844 | Ext.create("OMV.module.admin.storage.zfs.ExpandPool", { | |
845 | title: _("Expand Pool"), | |
846 | name: record.get("path"), | |
847 | type: record.get("type"), | |
848 | pool_type: record.get("pool_type"), | |
849 | nr_disks: record.get("nr_disks"), | |
850 | listeners: { | |
851 | scope: me, | |
852 | submit: function() { | |
853 | this.doReload(); | |
854 | } | |
855 | } | |
856 | }).show(); | |
857 | }, | |
6b3ce31b MR |
858 | |
859 | doDeletion: function(record) { | |
860 | var me = this; | |
861 | OMV.Rpc.request({ | |
862 | scope: me, | |
863 | callback: me.onDeletion, | |
864 | rpcData: { | |
865 | service: "ZFS", | |
866 | method: "deleteObject", | |
867 | params: { | |
868 | name: record.get('path'), | |
869 | type: record.get('type') | |
870 | } | |
871 | } | |
872 | }); | |
873 | } | |
874 | ||
875 | }); | |
876 | ||
877 | OMV.WorkspaceManager.registerPanel({ | |
878 | id: "overview", | |
38408c3f | 879 | path: "/storage/zfs", |
6b3ce31b MR |
880 | text: _("Overview"), |
881 | position: 10, | |
38408c3f | 882 | className: "OMV.module.admin.storage.zfs.Overview" |
6b3ce31b MR |
883 | }); |
884 | ||
885 | ||
886 |