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