]>
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 | },{ | |
77a007e0 NB |
309 | xtype: "combo", |
310 | name: "vdevtype", | |
311 | fieldLabel: _("Vdev type"), | |
312 | queryMode: "local", | |
313 | store: Ext.create("Ext.data.ArrayStore", { | |
314 | fields: [ "value", "text" ], | |
315 | data: [ | |
316 | [ "basic", _("Basic") ], | |
317 | [ "mirror", _("Mirror") ], | |
318 | [ "raidz1", _("RAID-Z1") ], | |
319 | [ "raidz2", _("RAID-Z2") ], | |
320 | [ "raidz3", _("RAID-Z3") ] | |
321 | ] | |
322 | }), | |
323 | displayField: "text", | |
324 | valueField: "value", | |
a6c3a4dd | 325 | allowBlank: false, |
77a007e0 NB |
326 | editable: false, |
327 | triggerAction: "all", | |
328 | value: "raidz1", | |
329 | listeners: { | |
330 | scope: me, | |
331 | change: function(combo, value) { | |
332 | var devicesField = this.findField("devices"); | |
333 | switch(value) { | |
334 | case "basic": | |
335 | devicesField.minSelections = 1; | |
336 | break; | |
337 | case "mirror": | |
338 | devicesField.minSelections = 2; | |
339 | break; | |
340 | case "raidz1": | |
341 | devicesField.minSelections = 3; | |
342 | break; | |
343 | case "raidz2": | |
344 | devicesField.minSelections = 4; | |
345 | case "raidz3": | |
346 | devicesField.minSelections = 5; | |
347 | break; | |
348 | default: | |
349 | devicesField.minSelections = 2; | |
350 | break; | |
351 | } | |
352 | devicesField.validate(); | |
353 | } | |
354 | } | |
a6c3a4dd NB |
355 | },{ |
356 | xtype: "checkboxgridfield", | |
357 | name: "devices", | |
358 | fieldLabel: _("Devices"), | |
359 | valueField: "devicefile", | |
77a007e0 | 360 | minSelections: 3, // Min. number of devices for RAIDZ-1 |
a6c3a4dd NB |
361 | useStringValue: true, |
362 | height: 130, | |
363 | store: Ext.create("OMV.data.Store", { | |
364 | autoLoad: true, | |
365 | model: OMV.data.Model.createImplicit({ | |
366 | idProperty: "devicefile", | |
367 | fields: [ | |
368 | { name: "devicefile", type: "string" }, | |
369 | { name: "size", type: "string" }, | |
370 | { name: "vendor", type: "string" }, | |
371 | { name: "serialnumber", type: "string" } | |
372 | ] | |
373 | }), | |
374 | proxy: { | |
375 | type: "rpc", | |
376 | appendSortParams: false, | |
377 | rpcData: { | |
378 | service: "RaidMgmt", | |
379 | method: "getCandidates" | |
380 | } | |
381 | }, | |
382 | sorters: [{ | |
383 | direction: "ASC", | |
384 | property: "devicefile" | |
385 | }] | |
386 | }), | |
387 | gridConfig: { | |
388 | stateful: true, | |
77a007e0 | 389 | stateId: "05c60750-5074-11e4-916c-0800200c9a66", |
a6c3a4dd NB |
390 | columns: [{ |
391 | text: _("Device"), | |
392 | sortable: true, | |
393 | dataIndex: "devicefile", | |
394 | stateId: "devicefile", | |
395 | flex: 1 | |
396 | },{ | |
397 | xtype: "binaryunitcolumn", | |
398 | text: _("Capacity"), | |
399 | sortable: true, | |
400 | dataIndex: "size", | |
401 | stateId: "size", | |
402 | width: 50, | |
403 | flex: 1 | |
404 | },{ | |
405 | text: _("Vendor"), | |
406 | sortable: true, | |
407 | dataIndex: "vendor", | |
408 | stateId: "vendor", | |
409 | flex: 1 | |
410 | },{ | |
411 | text: _("Serial Number"), | |
412 | sortable: true, | |
413 | dataIndex: "serialnumber", | |
414 | stateId: "serialnumber", | |
415 | flex: 1 | |
416 | }] | |
417 | } | |
418 | }]; | |
419 | } | |
420 | }); | |
6b3ce31b MR |
421 | |
422 | ||
3415404c | 423 | Ext.define("OMV.module.admin.storage.zfs.EditProperties", { |
6b3ce31b MR |
424 | extend: "OMV.workspace.window.Grid", |
425 | requires: [ | |
426 | "OMV.data.Store", | |
427 | "OMV.data.Model", | |
428 | "OMV.data.proxy.Rpc" | |
429 | ], | |
430 | ||
431 | rpcService: "ZFS", | |
432 | rpcSetMethod: "setProperties", | |
433 | ||
434 | title: _("Edit properties"), | |
435 | width: 500, | |
436 | height: 305, | |
437 | ||
438 | getGridConfig: function() { | |
439 | var me = this; | |
440 | ||
441 | var rowEditing = Ext.create('Ext.grid.plugin.RowEditing', { | |
442 | clicksToEdit: 1, | |
443 | pluginId: 'rowEditing', | |
444 | listeners: { | |
445 | validateedit: function(editor, e, eOpts) { | |
446 | e.record.set("modified", "true"); | |
447 | }, | |
448 | beforeedit: function(editor, e, eOpts) { | |
cc1caa78 | 449 | if (e.record.get("newproperty") === "false") { |
6b3ce31b MR |
450 | e.grid.getPlugin('rowEditing').editor.form.findField("value").enable(); |
451 | e.grid.getPlugin('rowEditing').editor.form.findField("property").disable(); | |
452 | } else { | |
453 | e.grid.getPlugin('rowEditing').editor.form.findField("value").enable(); | |
454 | e.grid.getPlugin('rowEditing').editor.form.findField("property").enable(); | |
455 | } | |
456 | } | |
457 | ||
458 | } | |
459 | }); | |
460 | ||
461 | var store = Ext.create("OMV.data.Store", { | |
462 | autoLoad: true, | |
463 | model: OMV.data.Model.createImplicit({ | |
464 | fields: [ | |
465 | { name: "property", type: "string" }, | |
466 | { name: "value", type: "string" }, | |
467 | { name: "source", type: "string" }, | |
468 | { name: "modified", type: "string" }, | |
469 | { name: "newproperty", type: "string", defaultValue: "false" } | |
470 | ] | |
471 | }), | |
472 | proxy: { | |
473 | type: "rpc", | |
474 | rpcData: { | |
475 | service: "ZFS", | |
476 | method: "getProperties", | |
477 | params: { | |
478 | name: me.name, | |
479 | type: me.type | |
480 | } | |
481 | } | |
482 | } | |
483 | }); | |
484 | ||
485 | return { | |
486 | border: false, | |
487 | stateful: true, | |
488 | stateId: "8c3dc800-bdbb-11e3-b1b6-0800200c9a66", | |
489 | selType: 'rowmodel', | |
490 | plugins: [rowEditing], | |
491 | store: store, | |
492 | tbar: [{ | |
493 | text: "Add property", | |
494 | icon: "images/add.png", | |
495 | iconCls: Ext.baseCSSPrefix + "btn-icon-16x16", | |
496 | handler: function(view) { | |
497 | Ext.define('Property', { | |
498 | extend: 'Ext.data.Model', | |
499 | fields: [ | |
500 | "property", | |
501 | "value", | |
502 | "source", | |
503 | "modified", | |
504 | "newproperty" | |
505 | ] | |
506 | }); | |
507 | var newProperty = Ext.create("Property", { | |
508 | property: "", | |
509 | value: "", | |
510 | source: "local", | |
511 | modified: "true", | |
38408c3f | 512 | newproperty: "true" |
6b3ce31b MR |
513 | }); |
514 | rowEditing.cancelEdit(); | |
515 | store.insert(0, newProperty); | |
516 | rowEditing.startEdit(); | |
517 | } | |
518 | }], | |
519 | columns: [{ | |
520 | text: _("Property"), | |
521 | sortable: true, | |
522 | dataIndex: "property", | |
523 | stateId: "property", | |
524 | editor: { | |
525 | xtype: "textfield", | |
526 | allowBlank: false, | |
527 | } | |
528 | },{ | |
529 | text: _("Value"), | |
530 | sortable: true, | |
531 | dataIndex: "value", | |
532 | stateId: "value", | |
533 | flex: 1, | |
534 | readOnly: true, | |
535 | editor: { | |
536 | xtype: "textfield", | |
537 | allowBlank: false, | |
538 | } | |
539 | },{ | |
540 | text: _("Source"), | |
541 | sortable: true, | |
542 | dataIndex: "source", | |
543 | stateId: "source", | |
544 | },{ | |
545 | xtype: 'actioncolumn', | |
546 | header: 'Inherit', | |
547 | icon: "images/checkmark.png", | |
548 | tooltip: "Inherit", | |
549 | handler: function(view, rowIndex, colIndex, item, e, record, row) { | |
550 | OMV.RpcObserver.request({ | |
551 | msg : _("Updating property..."), | |
552 | rpcData : { | |
553 | service: "ZFS", | |
554 | method: "inherit", | |
555 | params: { | |
556 | name: me.name, | |
557 | type: me.type, | |
558 | property: record.get("property") | |
559 | } | |
560 | }, | |
561 | finish : function() { | |
562 | view.getStore().reload(); | |
563 | } | |
564 | }); | |
565 | }, | |
566 | isDisabled: function(view, rowIdx, colIdx, item, record) { | |
567 | var src = record.get("source"); | |
568 | if(src === "local") { | |
569 | return false; | |
570 | } else { | |
571 | return true; | |
572 | } | |
573 | } | |
574 | },{ | |
575 | text: _("New"), | |
576 | dataIndex: "newproperty", | |
577 | stateId: "newproperty", | |
578 | sortable: false, | |
579 | hidden: true | |
38408c3f | 580 | },{ |
6b3ce31b MR |
581 | text: _("Modified"), |
582 | sortable: false, | |
583 | dataIndex: "modified", | |
584 | stateId: "modified", | |
585 | hidden: true | |
586 | }], | |
587 | }; | |
588 | }, | |
589 | ||
590 | getRpcSetParams: function() { | |
591 | var me = this; | |
592 | var properties = []; | |
593 | var values = me.getValues(); | |
594 | Ext.Array.each(values, function(value) { | |
595 | if(value.modified === "false") | |
38408c3f | 596 | return; |
6b3ce31b MR |
597 | properties.push({ |
598 | "property": value.property, | |
599 | "value": value.value, | |
600 | }); | |
601 | }); | |
602 | return { | |
603 | name: me.name, | |
604 | type: me.type, | |
605 | properties: properties | |
606 | }; | |
607 | } | |
608 | ||
609 | }); | |
610 | ||
611 | ||
3415404c | 612 | Ext.define("OMV.module.admin.storage.zfs.CreateShare", { |
6b3ce31b MR |
613 | extend: "OMV.workspace.window.Form", |
614 | uses: [ | |
615 | "OMV.data.Store", | |
616 | "OMV.data.Model", | |
617 | "OMV.data.proxy.Rpc", | |
618 | "OMV.data.reader.RpcArray" | |
619 | ], | |
620 | ||
621 | rpcService: "ZFS", | |
622 | rpcSetMethod: "createShare", | |
623 | width: 500, | |
624 | ||
625 | getFormItems: function() { | |
626 | var me = this; | |
627 | return [{ | |
628 | xtype: "textfield", | |
629 | name: "sharename", | |
630 | fieldLabel: _("Name"), | |
631 | allowBlank: false, | |
632 | },{ | |
633 | xtype: "textfield", | |
634 | name: "mountpoint", | |
635 | fieldLabel: _("Path"), | |
cc1caa78 NB |
636 | allowBlank: true, |
637 | readOnly: false | |
6b3ce31b MR |
638 | },{ |
639 | xtype: "combo", | |
640 | name: "mode", | |
641 | fieldLabel: _("Permissions"), | |
642 | queryMode: "local", | |
643 | store: Ext.create("Ext.data.ArrayStore", { | |
644 | fields: [ "value", "text" ], | |
645 | data: [ | |
646 | [ "700", _("Administrator: read/write, Users: no access, Others: no access") ], | |
647 | [ "750", _("Administrator: read/write, Users: read-only, Others: no access") ], | |
648 | [ "770", _("Administrator: read/write, Users: read/write, Others: no access") ], | |
649 | [ "755", _("Administrator: read/write, Users: read-only, Others: read-only") ], | |
650 | [ "775", _("Administrator: read/write, Users: read/write, Others: read-only") ], | |
651 | [ "777", _("Everyone: read/write") ] | |
652 | ] | |
653 | }), | |
654 | displayField: "text", | |
655 | valueField: "value", | |
656 | allowBlank: false, | |
657 | editable: false, | |
658 | showItemTooltip: true, | |
659 | triggerAction: "all", | |
660 | value: "775", | |
661 | plugins: [{ | |
662 | ptype: "fieldinfo", | |
663 | text: _("The file mode of the shared folder path.") | |
664 | }] | |
665 | },{ | |
666 | xtype: "textarea", | |
667 | name: "comment", | |
668 | fieldLabel: _("Comment"), | |
669 | allowBlank: true | |
670 | },{ | |
671 | xtype: "textarea", | |
672 | name: "name", | |
673 | hidden: true | |
674 | },{ | |
675 | xtype: "textarea", | |
676 | name: "type", | |
677 | hidden: true | |
678 | }]; | |
679 | } | |
680 | }); | |
681 | ||
682 | ||
683 | ||
38408c3f MR |
684 | Ext.define("OMV.module.admin.storage.zfs.Overview", { |
685 | extend: "OMV.module.admin.storage.zfs.TreePanel", | |
6b3ce31b MR |
686 | |
687 | rpcService: "ZFS", | |
688 | rpcGetMethod: "getObjectTree", | |
689 | requires: [ | |
690 | "OMV.data.Store", | |
691 | "OMV.data.Model", | |
692 | "OMV.data.proxy.Rpc" | |
693 | ], | |
694 | ||
695 | rootVisible: false, | |
696 | stateful: true, | |
697 | stateId: "cec54550-bc2a-11e3-a5e2-0800200c9a66", | |
698 | ||
699 | columns: [{ | |
700 | text: _("Name"), | |
701 | xtype: 'treecolumn', | |
702 | dataIndex: 'name', | |
703 | sortable: true, | |
704 | flex: 2, | |
705 | stateId: 'name' | |
706 | },{ | |
707 | text: _("Type"), | |
708 | dataIndex: 'type', | |
709 | sortable: true, | |
710 | flex: 1, | |
a6c3a4dd NB |
711 | stateId: 'type', |
712 | renderer: function(value, p, r){ | |
713 | if (r.data['type'] == "Pool") { | |
714 | return r.data['type'] + ' (' + r.data['pool_type'] + ')'; | |
715 | } else { | |
716 | return r.data['type']; | |
717 | } | |
718 | } | |
54b9d43e NB |
719 | },{ |
720 | text: _("Size"), | |
721 | dataIndex: 'size', | |
722 | sortable: true, | |
723 | flex: 1, | |
724 | stateId: 'size' | |
725 | },{ | |
726 | text: _("Used"), | |
727 | dataIndex: 'used', | |
728 | sortable: true, | |
729 | flex: 1, | |
730 | stateId: 'used' | |
731 | },{ | |
732 | text: _("Available"), | |
733 | dataIndex: 'available', | |
734 | sortable: true, | |
735 | flex: 1, | |
736 | stateId: 'available' | |
737 | },{ | |
738 | text: _("Mountpoint"), | |
739 | dataIndex: 'mountpoint', | |
740 | sortable: true, | |
741 | flex: 1, | |
742 | stateId: 'mountpoint' | |
6b3ce31b MR |
743 | },{ |
744 | text: _("Share"), | |
745 | xtype: 'actioncolumn', | |
746 | tooltip: 'Create shared folder', | |
747 | align: 'center', | |
748 | icon: 'images/checkmark.png', | |
749 | handler: function(view, rowIndex, colIndex, item, e, record, row) { | |
750 | var me = this; | |
38408c3f | 751 | Ext.create("OMV.module.admin.storage.zfs.CreateShare", { |
6b3ce31b MR |
752 | title: _("Create shared folder"), |
753 | rpcGetMethod: "getSharedParams", | |
754 | rpcGetParams: { | |
755 | name: record.get('path'), | |
756 | type: record.get('type') | |
757 | } | |
758 | }).show(); | |
759 | }, | |
760 | isDisabled: function(view, rowIdx, colIdx, item, record) { | |
761 | var src = record.get("type"); | |
762 | if((src === "Filesystem") && (record.get("shared") === "false")) { | |
763 | return false; | |
764 | } else { | |
765 | return true; | |
766 | } | |
767 | } | |
6b3ce31b MR |
768 | },{ |
769 | text: _("Details"), | |
770 | xtype: 'actioncolumn', | |
771 | tooltip: 'Details', | |
772 | align: 'center', | |
54b9d43e NB |
773 | icon: 'images/search.png', |
774 | handler: function(view, rowIndex, colIndex, item, e, record, row) { | |
775 | var me = this; | |
776 | Ext.create("OMV.module.admin.storage.zfs.ShowDetails", { | |
777 | title: _("Object details"), | |
778 | rpcGetMethod: "getObjectDetails", | |
779 | rpcGetParams: { | |
780 | name: record.get('path'), | |
781 | type: record.get('type') | |
782 | } | |
783 | }).show(); | |
784 | } | |
6b3ce31b MR |
785 | },{ |
786 | text: _("Shared"), | |
787 | dataIndex: 'shared', | |
788 | sortable: false, | |
789 | stateId: 'shared', | |
790 | hidden: true | |
791 | }], | |
792 | ||
793 | initComponent: function() { | |
794 | var me = this; | |
795 | this.width = 600; | |
796 | Ext.apply(me, { | |
797 | store: Ext.create("Ext.data.TreeStore", { | |
798 | autoLoad: true, | |
799 | model: OMV.data.Model.createImplicit({ | |
800 | fields: [ | |
801 | { name: "name", type: "string" }, | |
802 | { name: "type", type: "string" }, | |
54b9d43e NB |
803 | { name: "size", type: "string" }, |
804 | { name: "used", type: "string" }, | |
805 | { name: "available", type: "string" }, | |
806 | { name: "mountpoint", type: "string" }, | |
6b3ce31b MR |
807 | { name: "id", type: "string" }, |
808 | { name: "path", type: "string" }, | |
809 | { name: "origin", type: "string", defaultValue: "none" }, | |
a6c3a4dd NB |
810 | { name: "shared", type: "string", defaultValue: "false" }, |
811 | { name: "pool_type", type: "string"}, | |
812 | { name: "nr_disks", type: "string"} | |
6b3ce31b MR |
813 | ] |
814 | }), | |
815 | proxy: { | |
816 | type: "rpc", | |
817 | rpcData: { | |
818 | service: "ZFS", | |
819 | method: "getObjectTree", | |
820 | } | |
821 | }, | |
822 | folderSort: true | |
823 | }) | |
824 | }); | |
825 | me.callParent(arguments); | |
826 | }, | |
827 | ||
7d6b772c | 828 | onAddButton: function() { |
42856e8b NB |
829 | var me = this; |
830 | Ext.create("OMV.module.admin.storage.zfs.AddPool", { | |
831 | listeners: { | |
832 | scope: me, | |
833 | submit: function() { | |
834 | this.doReload(); | |
835 | } | |
836 | } | |
837 | }).show(); | |
838 | }, | |
839 | ||
6b3ce31b MR |
840 | onAddObjButton: function() { |
841 | var me = this; | |
842 | var sm = me.getSelectionModel(); | |
843 | var records = sm.getSelection(); | |
38408c3f MR |
844 | var record = records[0]; |
845 | Ext.create("OMV.module.admin.storage.zfs.AddObject", { | |
6b3ce31b | 846 | title: _("Add Object"), |
a01b6467 | 847 | path: record.get("path"), |
6b3ce31b MR |
848 | listeners: { |
849 | scope: me, | |
850 | submit: function() { | |
851 | this.doReload(); | |
852 | } | |
853 | } | |
854 | }).show(); | |
855 | }, | |
856 | ||
857 | onEditButton: function() { | |
858 | var me = this; | |
859 | var sm = me.getSelectionModel(); | |
860 | var records = sm.getSelection(); | |
861 | var record = records[0]; | |
38408c3f | 862 | Ext.create("OMV.module.admin.storage.zfs.EditProperties", { |
6b3ce31b MR |
863 | name: record.get("path"), |
864 | type: record.get("type") | |
865 | }).show(); | |
866 | }, | |
a6c3a4dd NB |
867 | |
868 | onExpandPoolButton: function() { | |
869 | var me = this; | |
870 | var sm = me.getSelectionModel(); | |
871 | var records = sm.getSelection(); | |
872 | var record = records[0]; | |
873 | Ext.create("OMV.module.admin.storage.zfs.ExpandPool", { | |
874 | title: _("Expand Pool"), | |
875 | name: record.get("path"), | |
a6c3a4dd NB |
876 | listeners: { |
877 | scope: me, | |
878 | submit: function() { | |
879 | this.doReload(); | |
880 | } | |
881 | } | |
882 | }).show(); | |
883 | }, | |
6b3ce31b MR |
884 | |
885 | doDeletion: function(record) { | |
886 | var me = this; | |
887 | OMV.Rpc.request({ | |
888 | scope: me, | |
889 | callback: me.onDeletion, | |
890 | rpcData: { | |
891 | service: "ZFS", | |
892 | method: "deleteObject", | |
893 | params: { | |
894 | name: record.get('path'), | |
895 | type: record.get('type') | |
896 | } | |
897 | } | |
898 | }); | |
899 | } | |
900 | ||
901 | }); | |
902 | ||
903 | OMV.WorkspaceManager.registerPanel({ | |
904 | id: "overview", | |
38408c3f | 905 | path: "/storage/zfs", |
6b3ce31b MR |
906 | text: _("Overview"), |
907 | position: 10, | |
38408c3f | 908 | className: "OMV.module.admin.storage.zfs.Overview" |
6b3ce31b MR |
909 | }); |
910 | ||
911 | ||
912 |