]> git.proxmox.com Git - pve-manager.git/blob - www/manager6/storage/ZFSPoolEdit.js
remove displayfield height hack
[pve-manager.git] / www / manager6 / storage / ZFSPoolEdit.js
1 Ext.define('PVE.storage.ZFSPoolSelector', {
2 extend: 'Ext.form.field.ComboBox',
3 alias: 'widget.pveZFSPoolSelector',
4 valueField: 'pool',
5 displayField: 'pool',
6 queryMode: 'local',
7 editable: false,
8 listConfig: {
9 loadingText: gettext('Scanning...'),
10 },
11 initComponent : function() {
12 var me = this;
13
14 if (!me.nodename) {
15 me.nodename = 'localhost';
16 }
17
18 var store = Ext.create('Ext.data.Store', {
19 autoLoad: {}, // true,
20 fields: [ 'pool', 'size', 'free' ],
21 proxy: {
22 type: 'pve',
23 url: '/api2/json/nodes/' + me.nodename + '/scan/zfs'
24 }
25 });
26
27 Ext.apply(me, {
28 store: store,
29 });
30
31 me.callParent();
32 }
33 });
34
35 Ext.define('PVE.storage.ZFSPoolInputPanel', {
36 extend: 'PVE.panel.InputPanel',
37
38 onGetValues: function(values) {
39 var me = this;
40
41 if (me.create) {
42 values.type = 'zfspool';
43 } else {
44 delete values.storage;
45 }
46
47 values.disable = values.enable ? 0 : 1;
48 delete values.enable;
49
50 return values;
51 },
52
53 initComponent : function() {
54 var me = this;
55
56 me.column1 = [
57 {
58 xtype: me.create ? 'textfield' : 'displayfield',
59 name: 'storage',
60 value: me.storageId || '',
61 fieldLabel: 'ID',
62 vtype: 'StorageId',
63 allowBlank: false
64 }
65 ];
66
67 if (me.create) {
68 me.column1.push(Ext.create('PVE.storage.ZFSPoolSelector', {
69 name: 'pool',
70 fieldLabel: gettext('ZFS Pool'),
71 allowBlank: false
72 }));
73 } else {
74 me.column1.push(Ext.createWidget('displayfield', {
75 name: 'pool',
76 value: '',
77 fieldLabel: gettext('ZFS Pool'),
78 allowBlank: false
79 }));
80 }
81
82 me.column1.push(
83 {xtype: 'pveContentTypeSelector',
84 cts: ['images', 'rootdir'],
85 fieldLabel: gettext('Content'),
86 name: 'content',
87 value: ['images', 'rootdir'],
88 multiSelect: true,
89 allowBlank: false});
90
91 me.column2 = [
92 {
93 xtype: 'pvecheckbox',
94 name: 'enable',
95 checked: true,
96 uncheckedValue: 0,
97 fieldLabel: gettext('Enable')
98 },
99 {
100 xtype: 'pvecheckbox',
101 name: 'sparse',
102 checked: false,
103 uncheckedValue: 0,
104 fieldLabel: gettext('Thin provision')
105 }
106 ];
107
108 if (me.create || me.storageId !== 'local') {
109 me.column2.unshift({
110 xtype: 'pveNodeSelector',
111 name: 'nodes',
112 fieldLabel: gettext('Nodes'),
113 emptyText: gettext('All') + ' (' +
114 gettext('No restrictions') +')',
115 multiSelect: true,
116 autoSelect: false
117 });
118 }
119
120 me.callParent();
121 }
122 });
123
124 Ext.define('PVE.storage.ZFSPoolEdit', {
125 extend: 'PVE.window.Edit',
126
127 initComponent : function() {
128 var me = this;
129
130 me.create = !me.storageId;
131
132 if (me.create) {
133 me.url = '/api2/extjs/storage';
134 me.method = 'POST';
135 } else {
136 me.url = '/api2/extjs/storage/' + me.storageId;
137 me.method = 'PUT';
138 }
139
140 var ipanel = Ext.create('PVE.storage.ZFSPoolInputPanel', {
141 create: me.create,
142 storageId: me.storageId
143 });
144
145 Ext.apply(me, {
146 subject: PVE.Utils.format_storage_type('zfspool'),
147 isAdd: true,
148 items: [ ipanel ]
149 });
150
151 me.callParent();
152
153 if (!me.create) {
154 me.load({
155 success: function(response, options) {
156 var values = response.result.data;
157 var ctypes = values.content || '';
158
159 values.content = ctypes.split(',');
160
161 if (values.nodes) {
162 values.nodes = values.nodes.split(',');
163 }
164 values.enable = values.disable ? 0 : 1;
165 ipanel.setValues(values);
166 }
167 });
168 }
169 }
170 });