]> git.proxmox.com Git - pve-manager.git/blob - www/manager6/storage/ZFSPoolEdit.js
32231b9c0e78e35dc7434ad86aa7e4150639b653
[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 store.sort('pool', 'ASC');
28
29 Ext.apply(me, {
30 store: store
31 });
32
33 me.callParent();
34 }
35 });
36
37 Ext.define('PVE.storage.ZFSPoolInputPanel', {
38 extend: 'PVE.panel.InputPanel',
39
40 onGetValues: function(values) {
41 var me = this;
42
43 if (me.isCreate) {
44 values.type = 'zfspool';
45 } else {
46 delete values.storage;
47 }
48
49 values.disable = values.enable ? 0 : 1;
50 delete values.enable;
51
52 return values;
53 },
54
55 initComponent : function() {
56 var me = this;
57
58 me.column1 = [
59 {
60 xtype: me.isCreate ? 'textfield' : 'displayfield',
61 name: 'storage',
62 value: me.storageId || '',
63 fieldLabel: 'ID',
64 vtype: 'StorageId',
65 allowBlank: false
66 }
67 ];
68
69 if (me.isCreate) {
70 me.column1.push(Ext.create('PVE.storage.ZFSPoolSelector', {
71 name: 'pool',
72 fieldLabel: gettext('ZFS Pool'),
73 allowBlank: false
74 }));
75 } else {
76 me.column1.push(Ext.createWidget('displayfield', {
77 name: 'pool',
78 value: '',
79 fieldLabel: gettext('ZFS Pool'),
80 allowBlank: false
81 }));
82 }
83
84 // value is an array,
85 // while before it was a string
86 /*jslint confusion: true*/
87 me.column1.push(
88 {xtype: 'pveContentTypeSelector',
89 cts: ['images', 'rootdir'],
90 fieldLabel: gettext('Content'),
91 name: 'content',
92 value: ['images', 'rootdir'],
93 multiSelect: true,
94 allowBlank: false
95 });
96 /*jslint confusion: false*/
97 me.column2 = [
98 {
99 xtype: 'proxmoxcheckbox',
100 name: 'enable',
101 checked: true,
102 uncheckedValue: 0,
103 fieldLabel: gettext('Enable')
104 },
105 {
106 xtype: 'proxmoxcheckbox',
107 name: 'sparse',
108 checked: false,
109 uncheckedValue: 0,
110 fieldLabel: gettext('Thin provision')
111 },
112 {
113 xtype: 'textfield',
114 name: 'blocksize',
115 emptyText: '8k',
116 fieldLabel: gettext('Block Size'),
117 allowBlank: true
118 }
119 ];
120
121 if (me.isCreate || me.storageId !== 'local') {
122 me.column2.unshift({
123 xtype: 'pveNodeSelector',
124 name: 'nodes',
125 fieldLabel: gettext('Nodes'),
126 emptyText: gettext('All') + ' (' +
127 gettext('No restrictions') +')',
128 multiSelect: true,
129 autoSelect: false
130 });
131 }
132
133 me.callParent();
134 }
135 });
136
137 Ext.define('PVE.storage.ZFSPoolEdit', {
138 extend: 'PVE.window.Edit',
139
140 initComponent : function() {
141 var me = this;
142
143 me.isCreate = !me.storageId;
144
145 if (me.isCreate) {
146 me.url = '/api2/extjs/storage';
147 me.method = 'POST';
148 } else {
149 me.url = '/api2/extjs/storage/' + me.storageId;
150 me.method = 'PUT';
151 }
152
153 var ipanel = Ext.create('PVE.storage.ZFSPoolInputPanel', {
154 isCreate: me.isCreate,
155 storageId: me.storageId
156 });
157
158 Ext.apply(me, {
159 subject: PVE.Utils.format_storage_type('zfspool'),
160 isAdd: true,
161 items: [ ipanel ]
162 });
163
164 me.callParent();
165
166 if (!me.isCreate) {
167 me.load({
168 success: function(response, options) {
169 var values = response.result.data;
170 var ctypes = values.content || '';
171
172 values.content = ctypes.split(',');
173
174 if (values.nodes) {
175 values.nodes = values.nodes.split(',');
176 }
177 values.enable = values.disable ? 0 : 1;
178 ipanel.setValues(values);
179 }
180 });
181 }
182 }
183 });