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