]> git.proxmox.com Git - pve-manager.git/blob - www/manager6/storage/ZFSPoolEdit.js
Sort all lists in the storage what we load dynamically.
[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.create) {
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.create ? 'textfield' : 'displayfield',
61 name: 'storage',
62 value: me.storageId || '',
63 fieldLabel: 'ID',
64 vtype: 'StorageId',
65 allowBlank: false
66 }
67 ];
68
69 if (me.create) {
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: 'pvecheckbox',
100 name: 'enable',
101 checked: true,
102 uncheckedValue: 0,
103 fieldLabel: gettext('Enable')
104 },
105 {
106 xtype: 'pvecheckbox',
107 name: 'sparse',
108 checked: false,
109 uncheckedValue: 0,
110 fieldLabel: gettext('Thin provision')
111 }
112 ];
113
114 if (me.create || me.storageId !== 'local') {
115 me.column2.unshift({
116 xtype: 'pveNodeSelector',
117 name: 'nodes',
118 fieldLabel: gettext('Nodes'),
119 emptyText: gettext('All') + ' (' +
120 gettext('No restrictions') +')',
121 multiSelect: true,
122 autoSelect: false
123 });
124 }
125
126 me.callParent();
127 }
128 });
129
130 Ext.define('PVE.storage.ZFSPoolEdit', {
131 extend: 'PVE.window.Edit',
132
133 initComponent : function() {
134 var me = this;
135
136 me.create = !me.storageId;
137
138 if (me.create) {
139 me.url = '/api2/extjs/storage';
140 me.method = 'POST';
141 } else {
142 me.url = '/api2/extjs/storage/' + me.storageId;
143 me.method = 'PUT';
144 }
145
146 var ipanel = Ext.create('PVE.storage.ZFSPoolInputPanel', {
147 create: me.create,
148 storageId: me.storageId
149 });
150
151 Ext.apply(me, {
152 subject: PVE.Utils.format_storage_type('zfspool'),
153 isAdd: true,
154 items: [ ipanel ]
155 });
156
157 me.callParent();
158
159 if (!me.create) {
160 me.load({
161 success: function(response, options) {
162 var values = response.result.data;
163 var ctypes = values.content || '';
164
165 values.content = ctypes.split(',');
166
167 if (values.nodes) {
168 values.nodes = values.nodes.split(',');
169 }
170 values.enable = values.disable ? 0 : 1;
171 ipanel.setValues(values);
172 }
173 });
174 }
175 }
176 });