]> git.datanom.net - omvzfs.git/blobdiff - gui/js/omv/module/admin/storage/zfs/Overview.js
Support optional mountpoint value when creating filesystem.
[omvzfs.git] / gui / js / omv / module / admin / storage / zfs / Overview.js
index 07f86af59545dae3f9b90cc84155aa50494d66d6..4acc897bbcc6f3c402d0a6d243c7408dd0961475 100644 (file)
@@ -95,6 +95,7 @@ Ext.define("OMV.module.admin.storage.zfs.AddPool", {
                                                break;
                                                case "raidz2":
                                                        devicesField.minSelections = 4;
+                                                       break;
                                                case "raidz3":
                                                        devicesField.minSelections = 5;
                                                break;
@@ -220,32 +221,73 @@ Ext.define("OMV.module.admin.storage.zfs.AddObject", {
 
        getFormItems: function() {
                var me = this;
+       
+               var store = new Ext.data.ArrayStore({
+                       autoDestroy: true,
+                       storeId: 'my_store',
+               fields: [
+                       {name: 'value', type: 'string'},
+                       {name: 'display', type: 'string'}
+               ]
+               });
+       
+               var combodata;
+               if (me.parenttype === "Snapshot") {
+                       combodata = [["clone","Clone"]];
+               } else if (me.parenttype === "Volume") {
+                       combodata = [["snapshot", "Snapshot"]];
+               } else {
+                       combodata = [["filesystem","Filesystem"],
+                                               ["volume","Volume"],
+                                               ["snapshot","Snapshot"]];
+               }
+               store.loadData(combodata,false);
+
                return [{
                        xtype: "combo",
                        name: "type",
                        fieldLabel: _("Object Type"),
                        queryMode: "local",
-                       store: [
-                               [ "filesystem", "Filesystem" ],
-                               [ "snapshot", "Snapshot" ],
-                               [ "volume", "Volume" ]
-                       ],
+                       store: store,
                        allowBlank: true,
                        editable: false,
                        triggerAction: "all",
-                       value: "filesystem",
+                       valueField: "value",
+                       displayField: "display",
+                       value: combodata[0][0],
                        listeners: {
                                scope: me,
                                change: function(combo, value) {
                                        var sizeField = this.findField("size");
+                                       var cloneField = this.findField("clonename");
+                                       var nameField = this.findField("name");
+                                       var mountField = this.findField("mountpoint");
                                        switch(value) {
+                                               case "filesystem":
+                                                       sizeField.hide();
+                                                       sizeField.allowBlank = true;
+                                                       cloneField.hide();
+                                                       nameField.show();
+                                                       mountField.show();
                                                case "volume":
                                                        sizeField.show();
-                                               sizeField.allowBlank = false;
+                                                       sizeField.allowBlank = false;
+                                                       cloneField.hide();
+                                                       nameField.show();
+                                                       mountField.hide();
                                                break;
+                                               case "clone":
+                                                       sizeField.hide();
+                                                       sizeField.allowBlank = true;
+                                                       cloneField.show();
+                                                       nameField.hide();
+                                                       mountField.hide();
                                                default:
                                                        sizeField.hide();
-                                               sizeField.allowBlank = true;
+                                                       sizeField.allowBlank = true;
+                                                       cloneField.hide();
+                                                       nameField.show();
+                                                       mountField.hide();
                                                break;
                                        }
                                        sizeField.validate();
@@ -257,19 +299,88 @@ Ext.define("OMV.module.admin.storage.zfs.AddObject", {
                        fieldLabel: _("Prefix"),
                        allowBlank: false,
                        readOnly: true,
-                       value: me.path
+                       value: me.path,
+                       listeners: {
+                               scope: me,
+                               beforerender: function(e, eOpts) {
+                                       var pathField = this.findField("path");
+                                       if (me.parenttype === "Snapshot") {
+                                               pathField.fieldLabel = _("Snapshot to clone");
+                                       } else {
+                                               pathField.fieldLabel = _("Prefix");
+                                       }
+                               }
+                       }
                },{
                        xtype: "textfield",
                        name: "name",
+                       id: "name",
                        fieldLabel: _("Name"),
                        allowBlank: false,
                        plugins: [{
                                ptype: "fieldinfo",
                                text: _("Name of the new object. Prefix will prepend the name. Please omit leading /")
-                       }]
+                       }],
+                       listeners: {
+                               scope: me,
+                               beforerender: function(e, eOpts) {
+                                       var nameField = this.findField("name");
+                                       if (me.parenttype === "Snapshot") {
+                                               nameField.hide();
+                                               nameField.allowBlank = true;
+                                       } else {
+                                               nameField.show();
+                                               nameField.allowBlank = false;
+                                       }
+                               }
+                       }
+               },{
+                       xtype: "textfield",
+                       name: "mountpoint",
+                       fieldLabel: _("Mountpoint"),
+                       allowBlank: true,
+                       plugins: [{
+                               ptype: "fieldinfo",
+                               text: _("Optional mountpoint of the filesystem. If left blank parent mountpoint will be prepended to name of the filesystem.")
+                       }],
+                       listeners: {
+                               scope: me,
+                               beforerender: function(e, eOpts) {
+                                       var mountField = this.findField("mountpoint");
+                                       if (combodata[0][0] === "filesystem") {
+                                               mountField.show();
+                                       } else {
+                                               mountField.hide();
+                                       }
+                               }
+                       }
+               },{
+                       xtype: "textfield",
+                       name: "clonename",
+                       id: "clonename",
+                       fieldLabel: _("Clone name"),
+                       allowBlank: false,
+                       plugins: [{
+                               ptype: "fieldinfo",
+                               text: _("Name of the new Clone. It can be placed anywhere within the ZFS hierarchy.")
+                       }],
+                       listeners: {
+                               scope: me,
+                               beforerender: function(e, eOpts) {
+                                       var cloneField = this.findField("clonename");
+                                       if (me.parenttype === "Snapshot") {
+                                               cloneField.show();
+                                               cloneField.allowBlank = false;
+                                       } else {
+                                               cloneField.hide();
+                                               cloneField.allowBlank = true;
+                                       }
+                               }
+                       }
                },{
                        xtype: "textfield",
                        name: "size",
+                       id: "size",
                        hidden: true,
                        fieldLabel: _("Size"),
                        allowBlank: true,
@@ -342,6 +453,7 @@ Ext.define("OMV.module.admin.storage.zfs.ExpandPool", {
                                                break;
                                                case "raidz2":
                                                        devicesField.minSelections = 4;
+                                                       break;
                                                case "raidz3":
                                                        devicesField.minSelections = 5;
                                                break;
@@ -415,6 +527,15 @@ Ext.define("OMV.module.admin.storage.zfs.ExpandPool", {
                                        flex: 1
                                }]
                        }
+               },{
+                       xtype: "checkbox",
+                       name: "force",
+                       fieldLabel: _("Force creation"),
+                       checked: false,
+                       plugins: [{
+                               ptype: "fieldinfo",
+                               text: _("Forces the creation of the Vdev even if errors are reported. Use with extreme caution!")
+                       }]
                }];
        }
 });
@@ -702,7 +823,14 @@ Ext.define("OMV.module.admin.storage.zfs.Overview", {
                dataIndex: 'name',
                sortable: true,
                flex: 2,
-               stateId: 'name'
+               stateId: 'name',
+               renderer: function(value, p, r){
+                       if (r.data['origin'] === "n/a") {
+                               return r.data['name'];
+                       } else {
+                               return r.data['name'] + ' (' + r.data['origin'] + ')';
+                       }
+               }
        },{
                text: _("Type"),
                dataIndex: 'type',
@@ -710,10 +838,10 @@ Ext.define("OMV.module.admin.storage.zfs.Overview", {
                flex: 1,
                stateId: 'type',
                renderer: function(value, p, r){
-                       if (r.data['type'] == "Pool") {
-                               return r.data['type'] + ' (' + r.data['pool_type'] + ')';
-                       } else {
+                       if (r.data['origin'] === "n/a") {
                                return r.data['type'];
+                       } else {
+                               return 'Clone';
                        }
                }
        },{
@@ -845,6 +973,7 @@ Ext.define("OMV.module.admin.storage.zfs.Overview", {
                Ext.create("OMV.module.admin.storage.zfs.AddObject", {
                        title: _("Add Object"),
                        path: record.get("path"),
+                       parenttype: record.get("type"),
                        listeners: {
                                scope: me,
                                submit: function() {
This page took 0.063864 seconds and 5 git commands to generate.