]> git.datanom.net - omvzfs.git/blob - gui/js/omv/module/admin/storage/zfs/Overview.js
306edcff0b9bae92f232ccf3daa330ab4c1569ad
[omvzfs.git] / gui / js / omv / module / admin / storage / zfs / Overview.js
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
5 Ext.define("OMV.module.admin.storage.zfs.AddObject", {
6 extend: "OMV.workspace.window.Form",
7 uses: [
8 "OMV.data.Store",
9 "OMV.data.Model",
10 "OMV.data.proxy.Rpc",
11 "OMV.data.reader.RpcArray"
12 ],
13
14 rpcService: "ZFS",
15 rpcSetMethod: "addObject",
16 width: 420,
17
18 getFormItems: function() {
19 var me = this;
20 return [{
21 xtype: "combo",
22 name: "type",
23 fieldLabel: _("Object Type"),
24 queryMode: "local",
25 store: [
26 [ "filesystem", "Filesystem" ],
27 [ "snapshot", "Snapshot" ],
28 [ "volume", "Volume" ]
29 ],
30 allowBlank: true,
31 editable: false,
32 triggerAction: "all",
33 value: "filesystem",
34 listeners: {
35 scope: me,
36 change: function(combo, value) {
37 var sizeField = this.findField("size");
38 switch(value) {
39 case "volume":
40 sizeField.show();
41 sizeField.allowBlank = false;
42 break;
43 default:
44 sizeField.hide();
45 sizeField.allowBlank = true;
46 break;
47 }
48 sizeField.validate();
49 }
50 }
51 },{
52 xtype: "textfield",
53 name: "path",
54 fieldLabel: _("Prefix"),
55 allowBlank: false,
56 readOnly: true
57 },{
58 xtype: "textfield",
59 name: "name",
60 fieldLabel: _("Name"),
61 allowBlank: false,
62 plugins: [{
63 ptype: "fieldinfo",
64 text: _("Name of the new object. Prefix will prepend the name. Please omit leading /")
65 }]
66 },{
67 xtype: "textfield",
68 name: "size",
69 hidden: true,
70 fieldLabel: _("Size"),
71 allowBlank: true,
72 plugins: [{
73 ptype: "fieldinfo",
74 text: _("Size of the volume e.g. 5mb,100gb,1tb etc")
75 }]
76 }];
77 }
78 });
79
80
81
82 Ext.define("OMV.module.admin.storage.zfs.EditProperties", {
83 extend: "OMV.workspace.window.Grid",
84 requires: [
85 "OMV.data.Store",
86 "OMV.data.Model",
87 "OMV.data.proxy.Rpc"
88 ],
89
90 rpcService: "ZFS",
91 rpcSetMethod: "setProperties",
92
93 title: _("Edit properties"),
94 width: 500,
95 height: 305,
96
97 getGridConfig: function() {
98 var me = this;
99
100 var rowEditing = Ext.create('Ext.grid.plugin.RowEditing', {
101 clicksToEdit: 1,
102 pluginId: 'rowEditing',
103 listeners: {
104 validateedit: function(editor, e, eOpts) {
105 e.record.set("modified", "true");
106 },
107 beforeedit: function(editor, e, eOpts) {
108 if (e.record.get("property") === "mountpoint") {
109 e.grid.getPlugin('rowEditing').editor.form.findField("value").disable();
110 e.grid.getPlugin('rowEditing').editor.form.findField("property").disable();
111 } else if (e.record.get("newproperty") === "false") {
112 e.grid.getPlugin('rowEditing').editor.form.findField("value").enable();
113 e.grid.getPlugin('rowEditing').editor.form.findField("property").disable();
114 } else {
115 e.grid.getPlugin('rowEditing').editor.form.findField("value").enable();
116 e.grid.getPlugin('rowEditing').editor.form.findField("property").enable();
117 }
118 }
119
120 }
121 });
122
123 var store = Ext.create("OMV.data.Store", {
124 autoLoad: true,
125 model: OMV.data.Model.createImplicit({
126 fields: [
127 { name: "property", type: "string" },
128 { name: "value", type: "string" },
129 { name: "source", type: "string" },
130 { name: "modified", type: "string" },
131 { name: "newproperty", type: "string", defaultValue: "false" }
132 ]
133 }),
134 proxy: {
135 type: "rpc",
136 rpcData: {
137 service: "ZFS",
138 method: "getProperties",
139 params: {
140 name: me.name,
141 type: me.type
142 }
143 }
144 }
145 });
146
147 return {
148 border: false,
149 stateful: true,
150 stateId: "8c3dc800-bdbb-11e3-b1b6-0800200c9a66",
151 selType: 'rowmodel',
152 plugins: [rowEditing],
153 store: store,
154 tbar: [{
155 text: "Add property",
156 icon: "images/add.png",
157 iconCls: Ext.baseCSSPrefix + "btn-icon-16x16",
158 handler: function(view) {
159 Ext.define('Property', {
160 extend: 'Ext.data.Model',
161 fields: [
162 "property",
163 "value",
164 "source",
165 "modified",
166 "newproperty"
167 ]
168 });
169 var newProperty = Ext.create("Property", {
170 property: "",
171 value: "",
172 source: "local",
173 modified: "true",
174 newproperty: "true"
175 });
176 rowEditing.cancelEdit();
177 store.insert(0, newProperty);
178 rowEditing.startEdit();
179 }
180 }],
181 columns: [{
182 text: _("Property"),
183 sortable: true,
184 dataIndex: "property",
185 stateId: "property",
186 editor: {
187 xtype: "textfield",
188 allowBlank: false,
189 }
190 },{
191 text: _("Value"),
192 sortable: true,
193 dataIndex: "value",
194 stateId: "value",
195 flex: 1,
196 readOnly: true,
197 editor: {
198 xtype: "textfield",
199 allowBlank: false,
200 }
201 },{
202 text: _("Source"),
203 sortable: true,
204 dataIndex: "source",
205 stateId: "source",
206 },{
207 xtype: 'actioncolumn',
208 header: 'Inherit',
209 icon: "images/checkmark.png",
210 tooltip: "Inherit",
211 handler: function(view, rowIndex, colIndex, item, e, record, row) {
212 OMV.RpcObserver.request({
213 msg : _("Updating property..."),
214 rpcData : {
215 service: "ZFS",
216 method: "inherit",
217 params: {
218 name: me.name,
219 type: me.type,
220 property: record.get("property")
221 }
222 },
223 finish : function() {
224 view.getStore().reload();
225 }
226 });
227 },
228 isDisabled: function(view, rowIdx, colIdx, item, record) {
229 var src = record.get("source");
230 if(src === "local") {
231 return false;
232 } else {
233 return true;
234 }
235 }
236 },{
237 text: _("New"),
238 dataIndex: "newproperty",
239 stateId: "newproperty",
240 sortable: false,
241 hidden: true
242 },{
243 text: _("Modified"),
244 sortable: false,
245 dataIndex: "modified",
246 stateId: "modified",
247 hidden: true
248 }],
249 };
250 },
251
252 getRpcSetParams: function() {
253 var me = this;
254 var properties = [];
255 var values = me.getValues();
256 Ext.Array.each(values, function(value) {
257 if(value.modified === "false")
258 return;
259 properties.push({
260 "property": value.property,
261 "value": value.value,
262 });
263 });
264 return {
265 name: me.name,
266 type: me.type,
267 properties: properties
268 };
269 }
270
271 });
272
273
274 Ext.define("OMV.module.admin.storage.zfs.CreateShare", {
275 extend: "OMV.workspace.window.Form",
276 uses: [
277 "OMV.data.Store",
278 "OMV.data.Model",
279 "OMV.data.proxy.Rpc",
280 "OMV.data.reader.RpcArray"
281 ],
282
283 rpcService: "ZFS",
284 rpcSetMethod: "createShare",
285 width: 500,
286
287 getFormItems: function() {
288 var me = this;
289 return [{
290 xtype: "textfield",
291 name: "sharename",
292 fieldLabel: _("Name"),
293 allowBlank: false,
294 },{
295 xtype: "textfield",
296 name: "mountpoint",
297 fieldLabel: _("Path"),
298 allowBlank: false,
299 readOnly: true
300 },{
301 xtype: "combo",
302 name: "mode",
303 fieldLabel: _("Permissions"),
304 queryMode: "local",
305 store: Ext.create("Ext.data.ArrayStore", {
306 fields: [ "value", "text" ],
307 data: [
308 [ "700", _("Administrator: read/write, Users: no access, Others: no access") ],
309 [ "750", _("Administrator: read/write, Users: read-only, Others: no access") ],
310 [ "770", _("Administrator: read/write, Users: read/write, Others: no access") ],
311 [ "755", _("Administrator: read/write, Users: read-only, Others: read-only") ],
312 [ "775", _("Administrator: read/write, Users: read/write, Others: read-only") ],
313 [ "777", _("Everyone: read/write") ]
314 ]
315 }),
316 displayField: "text",
317 valueField: "value",
318 allowBlank: false,
319 editable: false,
320 showItemTooltip: true,
321 triggerAction: "all",
322 value: "775",
323 plugins: [{
324 ptype: "fieldinfo",
325 text: _("The file mode of the shared folder path.")
326 }]
327 },{
328 xtype: "textarea",
329 name: "comment",
330 fieldLabel: _("Comment"),
331 allowBlank: true
332 },{
333 xtype: "textarea",
334 name: "name",
335 hidden: true
336 },{
337 xtype: "textarea",
338 name: "type",
339 hidden: true
340 }];
341 }
342 });
343
344
345
346 Ext.define("OMV.module.admin.storage.zfs.Overview", {
347 extend: "OMV.module.admin.storage.zfs.TreePanel",
348
349 rpcService: "ZFS",
350 rpcGetMethod: "getObjectTree",
351 requires: [
352 "OMV.data.Store",
353 "OMV.data.Model",
354 "OMV.data.proxy.Rpc"
355 ],
356
357 rootVisible: false,
358 stateful: true,
359 stateId: "cec54550-bc2a-11e3-a5e2-0800200c9a66",
360
361 columns: [{
362 text: _("Name"),
363 xtype: 'treecolumn',
364 dataIndex: 'name',
365 sortable: true,
366 flex: 2,
367 stateId: 'name'
368 },{
369 text: _("Type"),
370 dataIndex: 'type',
371 sortable: true,
372 flex: 1,
373 stateId: 'type'
374 },{
375 text: _("Share"),
376 xtype: 'actioncolumn',
377 tooltip: 'Create shared folder',
378 align: 'center',
379 icon: 'images/checkmark.png',
380 handler: function(view, rowIndex, colIndex, item, e, record, row) {
381 var me = this;
382 Ext.create("OMV.module.admin.storage.zfs.CreateShare", {
383 title: _("Create shared folder"),
384 rpcGetMethod: "getSharedParams",
385 rpcGetParams: {
386 name: record.get('path'),
387 type: record.get('type')
388 }
389 }).show();
390 },
391 isDisabled: function(view, rowIdx, colIdx, item, record) {
392 var src = record.get("type");
393 if((src === "Filesystem") && (record.get("shared") === "false")) {
394 return false;
395 } else {
396 return true;
397 }
398 }
399
400
401 },{
402 text: _("Details"),
403 xtype: 'actioncolumn',
404 tooltip: 'Details',
405 align: 'center',
406 icon: 'images/zfs_mag.png'
407 },{
408 text: _("Shared"),
409 dataIndex: 'shared',
410 sortable: false,
411 stateId: 'shared',
412 hidden: true
413 }],
414
415 initComponent: function() {
416 var me = this;
417 this.width = 600;
418 Ext.apply(me, {
419 store: Ext.create("Ext.data.TreeStore", {
420 autoLoad: true,
421 model: OMV.data.Model.createImplicit({
422 fields: [
423 { name: "name", type: "string" },
424 { name: "type", type: "string" },
425 { name: "id", type: "string" },
426 { name: "path", type: "string" },
427 { name: "origin", type: "string", defaultValue: "none" },
428 { name: "shared", type: "string", defaultValue: "false" }
429 ]
430 }),
431 proxy: {
432 type: "rpc",
433 rpcData: {
434 service: "ZFS",
435 method: "getObjectTree",
436 }
437 },
438 folderSort: true
439 })
440 });
441 me.callParent(arguments);
442 },
443
444 onAddObjButton: function() {
445 var me = this;
446 var sm = me.getSelectionModel();
447 var records = sm.getSelection();
448 var record = records[0];
449 Ext.create("OMV.module.admin.storage.zfs.AddObject", {
450 title: _("Add Object"),
451 rpcGetMethod: "passParam",
452 rpcGetParams: {
453 key: "path",
454 value: record.get('path')
455 },
456 listeners: {
457 scope: me,
458 submit: function() {
459 this.doReload();
460 }
461 }
462 }).show();
463 },
464
465 onEditButton: function() {
466 var me = this;
467 var sm = me.getSelectionModel();
468 var records = sm.getSelection();
469 var record = records[0];
470 Ext.create("OMV.module.admin.storage.zfs.EditProperties", {
471 name: record.get("path"),
472 type: record.get("type")
473 }).show();
474 },
475
476 doDeletion: function(record) {
477 var me = this;
478 OMV.Rpc.request({
479 scope: me,
480 callback: me.onDeletion,
481 rpcData: {
482 service: "ZFS",
483 method: "deleteObject",
484 params: {
485 name: record.get('path'),
486 type: record.get('type')
487 }
488 }
489 });
490 }
491
492 });
493
494 OMV.WorkspaceManager.registerPanel({
495 id: "overview",
496 path: "/storage/zfs",
497 text: _("Overview"),
498 position: 10,
499 className: "OMV.module.admin.storage.zfs.Overview"
500 });
501
502
503
This page took 0.109868 seconds and 4 git commands to generate.