]>
Commit | Line | Data |
---|---|---|
1 | // require("js/omv/tree/Panel.js") | |
2 | // require("js/omv/module/admin/storage/zfs/TreePanel.js") | |
3 | // require("js/omv/workspace/window/Grid.js") | |
4 | // require("js/omv/form/field/CheckboxGrid.js") | |
5 | ||
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 | ||
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, | |
53 | height: 350, | |
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) { | |
87 | case "basic": | |
88 | devicesField.minSelections = 1; | |
89 | break; | |
90 | case "mirror": | |
91 | devicesField.minSelections = 2; | |
92 | break; | |
93 | case "raidz1": | |
94 | devicesField.minSelections = 3; | |
95 | break; | |
96 | case "raidz2": | |
97 | devicesField.minSelections = 4; | |
98 | break; | |
99 | case "raidz3": | |
100 | devicesField.minSelections = 5; | |
101 | break; | |
102 | default: | |
103 | devicesField.minSelections = 2; | |
104 | break; | |
105 | } | |
106 | devicesField.validate(); | |
107 | } | |
108 | } | |
109 | },{ | |
110 | xtype: "checkboxgridfield", | |
111 | name: "devices", | |
112 | fieldLabel: _("Devices"), | |
113 | valueField: "devicefile", | |
114 | minSelections: 3, // Min. number of devices for RAIDZ-1 | |
115 | useStringValue: true, | |
116 | height: 130, | |
117 | store: Ext.create("OMV.data.Store", { | |
118 | autoLoad: true, | |
119 | model: OMV.data.Model.createImplicit({ | |
120 | idProperty: "devicefile", | |
121 | fields: [ | |
122 | { name: "devicefile", type: "string" }, | |
123 | { name: "size", type: "string" }, | |
124 | { name: "vendor", type: "string" }, | |
125 | { name: "serialnumber", type: "string" } | |
126 | ] | |
127 | }), | |
128 | proxy: { | |
129 | type: "rpc", | |
130 | appendSortParams: false, | |
131 | rpcData: { | |
132 | service: "RaidMgmt", | |
133 | method: "getCandidates" | |
134 | } | |
135 | }, | |
136 | sorters: [{ | |
137 | direction: "ASC", | |
138 | property: "devicefile" | |
139 | }] | |
140 | }), | |
141 | gridConfig: { | |
142 | stateful: true, | |
143 | stateId: "1866b5d0-327e-11e4-8c21-0800200c9a66", | |
144 | columns: [{ | |
145 | text: _("Device"), | |
146 | sortable: true, | |
147 | dataIndex: "devicefile", | |
148 | stateId: "devicefile", | |
149 | flex: 1 | |
150 | },{ | |
151 | xtype: "binaryunitcolumn", | |
152 | text: _("Capacity"), | |
153 | sortable: true, | |
154 | dataIndex: "size", | |
155 | stateId: "size", | |
156 | width: 50, | |
157 | flex: 1 | |
158 | },{ | |
159 | text: _("Vendor"), | |
160 | sortable: true, | |
161 | dataIndex: "vendor", | |
162 | stateId: "vendor", | |
163 | flex: 1 | |
164 | },{ | |
165 | text: _("Serial Number"), | |
166 | sortable: true, | |
167 | dataIndex: "serialnumber", | |
168 | stateId: "serialnumber", | |
169 | flex: 1 | |
170 | }] | |
171 | } | |
172 | },{ | |
173 | xtype: "textfield", | |
174 | name: "mountpoint", | |
175 | fieldLabel: _("Mountpoint"), | |
176 | plugins: [{ | |
177 | ptype: "fieldinfo", | |
178 | text: _("Optional mountpoint for the pool. Default is to use pool name.") | |
179 | }] | |
180 | },{ | |
181 | xtype: "checkbox", | |
182 | name: "diskpath", | |
183 | fieldLabel: _("Disk-by-path"), | |
184 | plugins: [{ | |
185 | ptype: "fieldinfo", | |
186 | text: _("Use /dev/disk/by-path when creating the pool. Recommended.") | |
187 | }] | |
188 | },{ | |
189 | xtype: "checkbox", | |
190 | name: "force", | |
191 | fieldLabel: _("Force creation"), | |
192 | checked: false, | |
193 | plugins: [{ | |
194 | ptype: "fieldinfo", | |
195 | text: _("Forces the creation of the pool even if errors are reported. Use with extreme caution!") | |
196 | }] | |
197 | }]; | |
198 | }, | |
199 | ||
200 | doSubmit: function() { | |
201 | var me = this; | |
202 | OMV.MessageBox.show({ | |
203 | title: _("Confirmation"), | |
204 | msg: _("Do you really want to create the ZFS pool?"), | |
205 | buttons: Ext.Msg.YESNO, | |
206 | fn: function(answer) { | |
207 | if(answer === "no") | |
208 | return; | |
209 | me.superclass.doSubmit.call(me); | |
210 | }, | |
211 | scope: me, | |
212 | icon: Ext.Msg.QUESTION | |
213 | }); | |
214 | } | |
215 | }); | |
216 | ||
217 | Ext.define("OMV.module.admin.storage.zfs.AddObject", { | |
218 | extend: "OMV.workspace.window.Form", | |
219 | uses: [ | |
220 | "OMV.data.Store", | |
221 | "OMV.data.Model", | |
222 | "OMV.data.proxy.Rpc", | |
223 | "OMV.data.reader.RpcArray" | |
224 | ], | |
225 | ||
226 | rpcService: "ZFS", | |
227 | rpcSetMethod: "addObject", | |
228 | width: 420, | |
229 | ||
230 | getFormItems: function() { | |
231 | var me = this; | |
232 | ||
233 | var store = new Ext.data.ArrayStore({ | |
234 | autoDestroy: true, | |
235 | storeId: 'my_store', | |
236 | fields: [ | |
237 | {name: 'value', type: 'string'}, | |
238 | {name: 'display', type: 'string'} | |
239 | ] | |
240 | }); | |
241 | ||
242 | var combodata; | |
243 | if (me.parenttype === "Snapshot") { | |
244 | combodata = [["clone","Clone"]]; | |
245 | } else if (me.parenttype === "Volume") { | |
246 | combodata = [["snapshot", "Snapshot"]]; | |
247 | } else { | |
248 | combodata = [["filesystem","Filesystem"], | |
249 | ["volume","Volume"], | |
250 | ["snapshot","Snapshot"]]; | |
251 | } | |
252 | store.loadData(combodata,false); | |
253 | ||
254 | return [{ | |
255 | xtype: "combo", | |
256 | name: "type", | |
257 | fieldLabel: _("Object Type"), | |
258 | queryMode: "local", | |
259 | store: store, | |
260 | allowBlank: true, | |
261 | editable: false, | |
262 | triggerAction: "all", | |
263 | valueField: "value", | |
264 | displayField: "display", | |
265 | value: combodata[0][0], | |
266 | listeners: { | |
267 | scope: me, | |
268 | change: function(combo, value) { | |
269 | var sizeField = this.findField("size"); | |
270 | var cloneField = this.findField("clonename"); | |
271 | var nameField = this.findField("name"); | |
272 | var mountField = this.findField("mountpoint"); | |
273 | switch(value) { | |
274 | case "filesystem": | |
275 | sizeField.hide(); | |
276 | sizeField.allowBlank = true; | |
277 | cloneField.hide(); | |
278 | nameField.show(); | |
279 | mountField.show(); | |
280 | case "volume": | |
281 | sizeField.show(); | |
282 | sizeField.allowBlank = false; | |
283 | cloneField.hide(); | |
284 | nameField.show(); | |
285 | mountField.hide(); | |
286 | break; | |
287 | case "clone": | |
288 | sizeField.hide(); | |
289 | sizeField.allowBlank = true; | |
290 | cloneField.show(); | |
291 | nameField.hide(); | |
292 | mountField.hide(); | |
293 | default: | |
294 | sizeField.hide(); | |
295 | sizeField.allowBlank = true; | |
296 | cloneField.hide(); | |
297 | nameField.show(); | |
298 | mountField.hide(); | |
299 | break; | |
300 | } | |
301 | sizeField.validate(); | |
302 | } | |
303 | } | |
304 | },{ | |
305 | xtype: "textfield", | |
306 | name: "path", | |
307 | fieldLabel: _("Prefix"), | |
308 | allowBlank: false, | |
309 | readOnly: true, | |
310 | value: me.path, | |
311 | listeners: { | |
312 | scope: me, | |
313 | beforerender: function(e, eOpts) { | |
314 | var pathField = this.findField("path"); | |
315 | if (me.parenttype === "Snapshot") { | |
316 | pathField.fieldLabel = _("Snapshot to clone"); | |
317 | } else { | |
318 | pathField.fieldLabel = _("Prefix"); | |
319 | } | |
320 | } | |
321 | } | |
322 | },{ | |
323 | xtype: "textfield", | |
324 | name: "name", | |
325 | id: "name", | |
326 | fieldLabel: _("Name"), | |
327 | allowBlank: false, | |
328 | plugins: [{ | |
329 | ptype: "fieldinfo", | |
330 | text: _("Name of the new object. Prefix will prepend the name. Please omit leading /") | |
331 | }], | |
332 | listeners: { | |
333 | scope: me, | |
334 | beforerender: function(e, eOpts) { | |
335 | var nameField = this.findField("name"); | |
336 | if (me.parenttype === "Snapshot") { | |
337 | nameField.hide(); | |
338 | nameField.allowBlank = true; | |
339 | } else { | |
340 | nameField.show(); | |
341 | nameField.allowBlank = false; | |
342 | } | |
343 | } | |
344 | } | |
345 | },{ | |
346 | xtype: "textfield", | |
347 | name: "mountpoint", | |
348 | fieldLabel: _("Mountpoint"), | |
349 | allowBlank: true, | |
350 | plugins: [{ | |
351 | ptype: "fieldinfo", | |
352 | text: _("Optional mountpoint of the filesystem. If left blank parent mountpoint will be prepended to name of the filesystem.") | |
353 | }], | |
354 | listeners: { | |
355 | scope: me, | |
356 | beforerender: function(e, eOpts) { | |
357 | var mountField = this.findField("mountpoint"); | |
358 | if (combodata[0][0] === "filesystem") { | |
359 | mountField.show(); | |
360 | } else { | |
361 | mountField.hide(); | |
362 | } | |
363 | } | |
364 | } | |
365 | },{ | |
366 | xtype: "textfield", | |
367 | name: "clonename", | |
368 | id: "clonename", | |
369 | fieldLabel: _("Clone name"), | |
370 | allowBlank: false, | |
371 | plugins: [{ | |
372 | ptype: "fieldinfo", | |
373 | text: _("Name of the new Clone. It can be placed anywhere within the ZFS hierarchy.") | |
374 | }], | |
375 | listeners: { | |
376 | scope: me, | |
377 | beforerender: function(e, eOpts) { | |
378 | var cloneField = this.findField("clonename"); | |
379 | if (me.parenttype === "Snapshot") { | |
380 | cloneField.show(); | |
381 | cloneField.allowBlank = false; | |
382 | } else { | |
383 | cloneField.hide(); | |
384 | cloneField.allowBlank = true; | |
385 | } | |
386 | } | |
387 | } | |
388 | },{ | |
389 | xtype: "textfield", | |
390 | name: "size", | |
391 | id: "size", | |
392 | hidden: true, | |
393 | fieldLabel: _("Size"), | |
394 | allowBlank: true, | |
395 | plugins: [{ | |
396 | ptype: "fieldinfo", | |
397 | text: _("Size of the volume e.g. 5mb,100gb,1tb etc") | |
398 | }] | |
399 | }]; | |
400 | } | |
401 | }); | |
402 | ||
403 | Ext.define("OMV.module.admin.storage.zfs.ExpandPool", { | |
404 | extend: "OMV.workspace.window.Form", | |
405 | uses: [ | |
406 | "OMV.data.Store", | |
407 | "OMV.data.Model", | |
408 | "OMV.data.proxy.Rpc", | |
409 | "OMV.data.reader.RpcArray" | |
410 | ], | |
411 | ||
412 | rpcService: "ZFS", | |
413 | rpcSetMethod: "expandPool", | |
414 | width: 550, | |
415 | height: 350, | |
416 | autoLoadData: true, | |
417 | ||
418 | getFormItems: function() { | |
419 | var me = this; | |
420 | return [{ | |
421 | xtype: "textfield", | |
422 | name: "name", | |
423 | fieldLabel: _("Name"), | |
424 | allowBlank: false, | |
425 | readOnly: true, | |
426 | value: me.name | |
427 | },{ | |
428 | xtype: "combo", | |
429 | name: "vdevtype", | |
430 | fieldLabel: _("Vdev type"), | |
431 | queryMode: "local", | |
432 | store: Ext.create("Ext.data.ArrayStore", { | |
433 | fields: [ "value", "text" ], | |
434 | data: [ | |
435 | [ "basic", _("Basic") ], | |
436 | [ "mirror", _("Mirror") ], | |
437 | [ "raidz1", _("RAID-Z1") ], | |
438 | [ "raidz2", _("RAID-Z2") ], | |
439 | [ "raidz3", _("RAID-Z3") ] | |
440 | ] | |
441 | }), | |
442 | displayField: "text", | |
443 | valueField: "value", | |
444 | allowBlank: false, | |
445 | editable: false, | |
446 | triggerAction: "all", | |
447 | value: "raidz1", | |
448 | listeners: { | |
449 | scope: me, | |
450 | change: function(combo, value) { | |
451 | var devicesField = this.findField("devices"); | |
452 | switch(value) { | |
453 | case "basic": | |
454 | devicesField.minSelections = 1; | |
455 | break; | |
456 | case "mirror": | |
457 | devicesField.minSelections = 2; | |
458 | break; | |
459 | case "raidz1": | |
460 | devicesField.minSelections = 3; | |
461 | break; | |
462 | case "raidz2": | |
463 | devicesField.minSelections = 4; | |
464 | break; | |
465 | case "raidz3": | |
466 | devicesField.minSelections = 5; | |
467 | break; | |
468 | default: | |
469 | devicesField.minSelections = 2; | |
470 | break; | |
471 | } | |
472 | devicesField.validate(); | |
473 | } | |
474 | } | |
475 | },{ | |
476 | xtype: "checkboxgridfield", | |
477 | name: "devices", | |
478 | fieldLabel: _("Devices"), | |
479 | valueField: "devicefile", | |
480 | minSelections: 3, // Min. number of devices for RAIDZ-1 | |
481 | useStringValue: true, | |
482 | height: 130, | |
483 | store: Ext.create("OMV.data.Store", { | |
484 | autoLoad: true, | |
485 | model: OMV.data.Model.createImplicit({ | |
486 | idProperty: "devicefile", | |
487 | fields: [ | |
488 | { name: "devicefile", type: "string" }, | |
489 | { name: "size", type: "string" }, | |
490 | { name: "vendor", type: "string" }, | |
491 | { name: "serialnumber", type: "string" } | |
492 | ] | |
493 | }), | |
494 | proxy: { | |
495 | type: "rpc", | |
496 | appendSortParams: false, | |
497 | rpcData: { | |
498 | service: "RaidMgmt", | |
499 | method: "getCandidates" | |
500 | } | |
501 | }, | |
502 | sorters: [{ | |
503 | direction: "ASC", | |
504 | property: "devicefile" | |
505 | }] | |
506 | }), | |
507 | gridConfig: { | |
508 | stateful: true, | |
509 | stateId: "05c60750-5074-11e4-916c-0800200c9a66", | |
510 | columns: [{ | |
511 | text: _("Device"), | |
512 | sortable: true, | |
513 | dataIndex: "devicefile", | |
514 | stateId: "devicefile", | |
515 | flex: 1 | |
516 | },{ | |
517 | xtype: "binaryunitcolumn", | |
518 | text: _("Capacity"), | |
519 | sortable: true, | |
520 | dataIndex: "size", | |
521 | stateId: "size", | |
522 | width: 50, | |
523 | flex: 1 | |
524 | },{ | |
525 | text: _("Vendor"), | |
526 | sortable: true, | |
527 | dataIndex: "vendor", | |
528 | stateId: "vendor", | |
529 | flex: 1 | |
530 | },{ | |
531 | text: _("Serial Number"), | |
532 | sortable: true, | |
533 | dataIndex: "serialnumber", | |
534 | stateId: "serialnumber", | |
535 | flex: 1 | |
536 | }] | |
537 | } | |
538 | },{ | |
539 | xtype: "checkbox", | |
540 | name: "diskpath", | |
541 | fieldLabel: _("Disk-by-path"), | |
542 | plugins: [{ | |
543 | ptype: "fieldinfo", | |
544 | text: _("Use /dev/disk/by-path when creating the vdev. Recommended.") | |
545 | }] | |
546 | },{ | |
547 | xtype: "checkbox", | |
548 | name: "force", | |
549 | fieldLabel: _("Force creation"), | |
550 | checked: false, | |
551 | plugins: [{ | |
552 | ptype: "fieldinfo", | |
553 | text: _("Forces the creation of the Vdev even if errors are reported. Use with extreme caution!") | |
554 | }] | |
555 | }]; | |
556 | } | |
557 | }); | |
558 | ||
559 | ||
560 | Ext.define("OMV.module.admin.storage.zfs.EditProperties", { | |
561 | extend: "OMV.workspace.window.Grid", | |
562 | requires: [ | |
563 | "OMV.data.Store", | |
564 | "OMV.data.Model", | |
565 | "OMV.data.proxy.Rpc" | |
566 | ], | |
567 | ||
568 | rpcService: "ZFS", | |
569 | rpcSetMethod: "setProperties", | |
570 | ||
571 | title: _("Edit properties"), | |
572 | width: 500, | |
573 | height: 305, | |
574 | ||
575 | getGridConfig: function() { | |
576 | var me = this; | |
577 | ||
578 | var rowEditing = Ext.create('Ext.grid.plugin.RowEditing', { | |
579 | clicksToEdit: 1, | |
580 | pluginId: 'rowEditing', | |
581 | listeners: { | |
582 | validateedit: function(editor, e, eOpts) { | |
583 | e.record.set("modified", "true"); | |
584 | }, | |
585 | beforeedit: function(editor, e, eOpts) { | |
586 | if (e.record.get("newproperty") === "false") { | |
587 | e.grid.getPlugin('rowEditing').editor.form.findField("value").enable(); | |
588 | e.grid.getPlugin('rowEditing').editor.form.findField("property").disable(); | |
589 | } else { | |
590 | e.grid.getPlugin('rowEditing').editor.form.findField("value").enable(); | |
591 | e.grid.getPlugin('rowEditing').editor.form.findField("property").enable(); | |
592 | } | |
593 | } | |
594 | ||
595 | } | |
596 | }); | |
597 | ||
598 | var store = Ext.create("OMV.data.Store", { | |
599 | autoLoad: true, | |
600 | model: OMV.data.Model.createImplicit({ | |
601 | fields: [ | |
602 | { name: "property", type: "string" }, | |
603 | { name: "value", type: "string" }, | |
604 | { name: "source", type: "string" }, | |
605 | { name: "modified", type: "string" }, | |
606 | { name: "newproperty", type: "string", defaultValue: "false" } | |
607 | ] | |
608 | }), | |
609 | proxy: { | |
610 | type: "rpc", | |
611 | rpcData: { | |
612 | service: "ZFS", | |
613 | method: "getProperties", | |
614 | params: { | |
615 | name: me.name, | |
616 | type: me.type | |
617 | } | |
618 | } | |
619 | } | |
620 | }); | |
621 | ||
622 | return { | |
623 | border: false, | |
624 | stateful: true, | |
625 | stateId: "8c3dc800-bdbb-11e3-b1b6-0800200c9a66", | |
626 | selType: 'rowmodel', | |
627 | plugins: [rowEditing], | |
628 | store: store, | |
629 | tbar: [{ | |
630 | text: "Add property", | |
631 | icon: "images/add.png", | |
632 | iconCls: Ext.baseCSSPrefix + "btn-icon-16x16", | |
633 | handler: function(view) { | |
634 | Ext.define('Property', { | |
635 | extend: 'Ext.data.Model', | |
636 | fields: [ | |
637 | "property", | |
638 | "value", | |
639 | "source", | |
640 | "modified", | |
641 | "newproperty" | |
642 | ] | |
643 | }); | |
644 | var newProperty = Ext.create("Property", { | |
645 | property: "", | |
646 | value: "", | |
647 | source: "local", | |
648 | modified: "true", | |
649 | newproperty: "true" | |
650 | }); | |
651 | rowEditing.cancelEdit(); | |
652 | store.insert(0, newProperty); | |
653 | rowEditing.startEdit(); | |
654 | } | |
655 | }], | |
656 | columns: [{ | |
657 | text: _("Property"), | |
658 | sortable: true, | |
659 | dataIndex: "property", | |
660 | stateId: "property", | |
661 | editor: { | |
662 | xtype: "textfield", | |
663 | allowBlank: false, | |
664 | } | |
665 | },{ | |
666 | text: _("Value"), | |
667 | sortable: true, | |
668 | dataIndex: "value", | |
669 | stateId: "value", | |
670 | flex: 1, | |
671 | readOnly: true, | |
672 | editor: { | |
673 | xtype: "textfield", | |
674 | allowBlank: false, | |
675 | } | |
676 | },{ | |
677 | text: _("Source"), | |
678 | sortable: true, | |
679 | dataIndex: "source", | |
680 | stateId: "source", | |
681 | },{ | |
682 | xtype: 'actioncolumn', | |
683 | header: 'Inherit', | |
684 | icon: "images/checkmark.png", | |
685 | tooltip: "Inherit", | |
686 | handler: function(view, rowIndex, colIndex, item, e, record, row) { | |
687 | OMV.RpcObserver.request({ | |
688 | msg : _("Updating property..."), | |
689 | rpcData : { | |
690 | service: "ZFS", | |
691 | method: "inherit", | |
692 | params: { | |
693 | name: me.name, | |
694 | type: me.type, | |
695 | property: record.get("property") | |
696 | } | |
697 | }, | |
698 | finish : function() { | |
699 | view.getStore().reload(); | |
700 | } | |
701 | }); | |
702 | }, | |
703 | isDisabled: function(view, rowIdx, colIdx, item, record) { | |
704 | var src = record.get("source"); | |
705 | if(src === "local") { | |
706 | return false; | |
707 | } else { | |
708 | return true; | |
709 | } | |
710 | } | |
711 | },{ | |
712 | text: _("New"), | |
713 | dataIndex: "newproperty", | |
714 | stateId: "newproperty", | |
715 | sortable: false, | |
716 | hidden: true | |
717 | },{ | |
718 | text: _("Modified"), | |
719 | sortable: false, | |
720 | dataIndex: "modified", | |
721 | stateId: "modified", | |
722 | hidden: true | |
723 | }], | |
724 | }; | |
725 | }, | |
726 | ||
727 | getRpcSetParams: function() { | |
728 | var me = this; | |
729 | var properties = []; | |
730 | var values = me.getValues(); | |
731 | Ext.Array.each(values, function(value) { | |
732 | if(value.modified === "false") | |
733 | return; | |
734 | properties.push({ | |
735 | "property": value.property, | |
736 | "value": value.value, | |
737 | }); | |
738 | }); | |
739 | return { | |
740 | name: me.name, | |
741 | type: me.type, | |
742 | properties: properties | |
743 | }; | |
744 | } | |
745 | ||
746 | }); | |
747 | ||
748 | ||
749 | Ext.define("OMV.module.admin.storage.zfs.CreateShare", { | |
750 | extend: "OMV.workspace.window.Form", | |
751 | uses: [ | |
752 | "OMV.data.Store", | |
753 | "OMV.data.Model", | |
754 | "OMV.data.proxy.Rpc", | |
755 | "OMV.data.reader.RpcArray" | |
756 | ], | |
757 | ||
758 | rpcService: "ZFS", | |
759 | rpcSetMethod: "createShare", | |
760 | width: 500, | |
761 | ||
762 | getFormItems: function() { | |
763 | var me = this; | |
764 | return [{ | |
765 | xtype: "textfield", | |
766 | name: "sharename", | |
767 | fieldLabel: _("Name"), | |
768 | allowBlank: false, | |
769 | },{ | |
770 | xtype: "textfield", | |
771 | name: "mountpoint", | |
772 | fieldLabel: _("Path"), | |
773 | allowBlank: true, | |
774 | readOnly: false | |
775 | },{ | |
776 | xtype: "combo", | |
777 | name: "mode", | |
778 | fieldLabel: _("Permissions"), | |
779 | queryMode: "local", | |
780 | store: Ext.create("Ext.data.ArrayStore", { | |
781 | fields: [ "value", "text" ], | |
782 | data: [ | |
783 | [ "700", _("Administrator: read/write, Users: no access, Others: no access") ], | |
784 | [ "750", _("Administrator: read/write, Users: read-only, Others: no access") ], | |
785 | [ "770", _("Administrator: read/write, Users: read/write, Others: no access") ], | |
786 | [ "755", _("Administrator: read/write, Users: read-only, Others: read-only") ], | |
787 | [ "775", _("Administrator: read/write, Users: read/write, Others: read-only") ], | |
788 | [ "777", _("Everyone: read/write") ] | |
789 | ] | |
790 | }), | |
791 | displayField: "text", | |
792 | valueField: "value", | |
793 | allowBlank: false, | |
794 | editable: false, | |
795 | showItemTooltip: true, | |
796 | triggerAction: "all", | |
797 | value: "775", | |
798 | plugins: [{ | |
799 | ptype: "fieldinfo", | |
800 | text: _("The file mode of the shared folder path.") | |
801 | }] | |
802 | },{ | |
803 | xtype: "textarea", | |
804 | name: "comment", | |
805 | fieldLabel: _("Comment"), | |
806 | allowBlank: true | |
807 | },{ | |
808 | xtype: "textarea", | |
809 | name: "name", | |
810 | hidden: true | |
811 | },{ | |
812 | xtype: "textarea", | |
813 | name: "type", | |
814 | hidden: true | |
815 | }]; | |
816 | } | |
817 | }); | |
818 | ||
819 | ||
820 | ||
821 | Ext.define("OMV.module.admin.storage.zfs.Overview", { | |
822 | extend: "OMV.module.admin.storage.zfs.TreePanel", | |
823 | ||
824 | rpcService: "ZFS", | |
825 | rpcGetMethod: "getObjectTree", | |
826 | requires: [ | |
827 | "OMV.data.Store", | |
828 | "OMV.data.Model", | |
829 | "OMV.data.proxy.Rpc" | |
830 | ], | |
831 | ||
832 | rootVisible: false, | |
833 | stateful: true, | |
834 | stateId: "cec54550-bc2a-11e3-a5e2-0800200c9a66", | |
835 | ||
836 | columns: [{ | |
837 | text: _("Name"), | |
838 | xtype: 'treecolumn', | |
839 | dataIndex: 'name', | |
840 | sortable: true, | |
841 | flex: 2, | |
842 | stateId: 'name', | |
843 | renderer: function(value, p, r){ | |
844 | if (r.data['origin'] === "n/a") { | |
845 | return r.data['name']; | |
846 | } else { | |
847 | return r.data['name'] + ' (' + r.data['origin'] + ')'; | |
848 | } | |
849 | } | |
850 | },{ | |
851 | text: _("Type"), | |
852 | dataIndex: 'type', | |
853 | sortable: true, | |
854 | flex: 1, | |
855 | stateId: 'type', | |
856 | renderer: function(value, p, r){ | |
857 | if (r.data['origin'] === "n/a") { | |
858 | return r.data['type']; | |
859 | } else { | |
860 | return 'Clone'; | |
861 | } | |
862 | } | |
863 | },{ | |
864 | text: _("Size"), | |
865 | dataIndex: 'size', | |
866 | sortable: true, | |
867 | flex: 1, | |
868 | stateId: 'size' | |
869 | },{ | |
870 | text: _("Used"), | |
871 | dataIndex: 'used', | |
872 | sortable: true, | |
873 | flex: 1, | |
874 | stateId: 'used' | |
875 | },{ | |
876 | text: _("Available"), | |
877 | dataIndex: 'available', | |
878 | sortable: true, | |
879 | flex: 1, | |
880 | stateId: 'available' | |
881 | },{ | |
882 | text: _("Mountpoint"), | |
883 | dataIndex: 'mountpoint', | |
884 | sortable: true, | |
885 | flex: 1, | |
886 | stateId: 'mountpoint' | |
887 | },{ | |
888 | text: _("Share"), | |
889 | xtype: 'actioncolumn', | |
890 | tooltip: 'Create shared folder', | |
891 | align: 'center', | |
892 | icon: 'images/checkmark.png', | |
893 | handler: function(view, rowIndex, colIndex, item, e, record, row) { | |
894 | var me = this; | |
895 | Ext.create("OMV.module.admin.storage.zfs.CreateShare", { | |
896 | title: _("Create shared folder"), | |
897 | rpcGetMethod: "getSharedParams", | |
898 | rpcGetParams: { | |
899 | name: record.get('path'), | |
900 | type: record.get('type') | |
901 | } | |
902 | }).show(); | |
903 | }, | |
904 | isDisabled: function(view, rowIdx, colIdx, item, record) { | |
905 | var src = record.get("type"); | |
906 | if((src === "Filesystem") && (record.get("shared") === "false")) { | |
907 | return false; | |
908 | } else { | |
909 | return true; | |
910 | } | |
911 | } | |
912 | },{ | |
913 | text: _("Details"), | |
914 | xtype: 'actioncolumn', | |
915 | tooltip: 'Details', | |
916 | align: 'center', | |
917 | icon: 'images/search.png', | |
918 | handler: function(view, rowIndex, colIndex, item, e, record, row) { | |
919 | var me = this; | |
920 | Ext.create("OMV.module.admin.storage.zfs.ShowDetails", { | |
921 | title: _("Object details"), | |
922 | rpcGetMethod: "getObjectDetails", | |
923 | rpcGetParams: { | |
924 | name: record.get('path'), | |
925 | type: record.get('type') | |
926 | } | |
927 | }).show(); | |
928 | } | |
929 | },{ | |
930 | text: _("Shared"), | |
931 | dataIndex: 'shared', | |
932 | sortable: false, | |
933 | stateId: 'shared', | |
934 | hidden: true | |
935 | }], | |
936 | ||
937 | initComponent: function() { | |
938 | var me = this; | |
939 | this.width = 600; | |
940 | Ext.apply(me, { | |
941 | store: Ext.create("Ext.data.TreeStore", { | |
942 | autoLoad: true, | |
943 | model: OMV.data.Model.createImplicit({ | |
944 | fields: [ | |
945 | { name: "name", type: "string" }, | |
946 | { name: "type", type: "string" }, | |
947 | { name: "size", type: "string" }, | |
948 | { name: "used", type: "string" }, | |
949 | { name: "available", type: "string" }, | |
950 | { name: "mountpoint", type: "string" }, | |
951 | { name: "id", type: "string" }, | |
952 | { name: "path", type: "string" }, | |
953 | { name: "origin", type: "string", defaultValue: "none" }, | |
954 | { name: "shared", type: "string", defaultValue: "false" }, | |
955 | { name: "pool_type", type: "string"}, | |
956 | { name: "nr_disks", type: "string"} | |
957 | ] | |
958 | }), | |
959 | proxy: { | |
960 | type: "rpc", | |
961 | rpcData: { | |
962 | service: "ZFS", | |
963 | method: "getObjectTree", | |
964 | } | |
965 | }, | |
966 | folderSort: true | |
967 | }) | |
968 | }); | |
969 | me.callParent(arguments); | |
970 | }, | |
971 | ||
972 | onAddButton: function() { | |
973 | var me = this; | |
974 | Ext.create("OMV.module.admin.storage.zfs.AddPool", { | |
975 | listeners: { | |
976 | scope: me, | |
977 | submit: function() { | |
978 | this.doReload(); | |
979 | } | |
980 | } | |
981 | }).show(); | |
982 | }, | |
983 | ||
984 | onAddObjButton: function() { | |
985 | var me = this; | |
986 | var sm = me.getSelectionModel(); | |
987 | var records = sm.getSelection(); | |
988 | var record = records[0]; | |
989 | Ext.create("OMV.module.admin.storage.zfs.AddObject", { | |
990 | title: _("Add Object"), | |
991 | path: record.get("path"), | |
992 | parenttype: record.get("type"), | |
993 | listeners: { | |
994 | scope: me, | |
995 | submit: function() { | |
996 | this.doReload(); | |
997 | } | |
998 | } | |
999 | }).show(); | |
1000 | }, | |
1001 | ||
1002 | onEditButton: function() { | |
1003 | var me = this; | |
1004 | var sm = me.getSelectionModel(); | |
1005 | var records = sm.getSelection(); | |
1006 | var record = records[0]; | |
1007 | Ext.create("OMV.module.admin.storage.zfs.EditProperties", { | |
1008 | name: record.get("path"), | |
1009 | type: record.get("type") | |
1010 | }).show(); | |
1011 | }, | |
1012 | ||
1013 | onExpandPoolButton: function() { | |
1014 | var me = this; | |
1015 | var sm = me.getSelectionModel(); | |
1016 | var records = sm.getSelection(); | |
1017 | var record = records[0]; | |
1018 | Ext.create("OMV.module.admin.storage.zfs.ExpandPool", { | |
1019 | title: _("Expand Pool"), | |
1020 | name: record.get("path"), | |
1021 | listeners: { | |
1022 | scope: me, | |
1023 | submit: function() { | |
1024 | this.doReload(); | |
1025 | } | |
1026 | } | |
1027 | }).show(); | |
1028 | }, | |
1029 | ||
1030 | doDeletion: function(record) { | |
1031 | var me = this; | |
1032 | OMV.Rpc.request({ | |
1033 | scope: me, | |
1034 | callback: me.onDeletion, | |
1035 | rpcData: { | |
1036 | service: "ZFS", | |
1037 | method: "deleteObject", | |
1038 | params: { | |
1039 | name: record.get('path'), | |
1040 | type: record.get('type') | |
1041 | } | |
1042 | } | |
1043 | }); | |
1044 | } | |
1045 | ||
1046 | }); | |
1047 | ||
1048 | OMV.WorkspaceManager.registerPanel({ | |
1049 | id: "overview", | |
1050 | path: "/storage/zfs", | |
1051 | text: _("Overview"), | |
1052 | position: 10, | |
1053 | className: "OMV.module.admin.storage.zfs.Overview" | |
1054 | }); | |
1055 | ||
1056 | ||
1057 |