]>
Commit | Line | Data |
---|---|---|
6cbcc546 DM |
1 | Ext.define('PVE.storage.ZFSPoolSelector', { |
2 | extend: 'Ext.form.field.ComboBox', | |
3 | alias: 'widget.pveZFSPoolSelector', | |
c2317525 DC |
4 | valueField: 'pool', |
5 | displayField: 'pool', | |
6 | queryMode: 'local', | |
7 | editable: false, | |
8 | listConfig: { | |
22f2f9d6 | 9 | loadingText: gettext('Scanning...') |
c2317525 | 10 | }, |
6cbcc546 DM |
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, { | |
22f2f9d6 | 28 | store: store |
6cbcc546 DM |
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', | |
6cbcc546 DM |
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', { | |
6cbcc546 DM |
75 | name: 'pool', |
76 | value: '', | |
77 | fieldLabel: gettext('ZFS Pool'), | |
78 | allowBlank: false | |
79 | })); | |
80 | } | |
81 | ||
ec0bd652 DC |
82 | // value is an array, |
83 | // while before it was a string | |
84 | /*jslint confusion: true*/ | |
6cbcc546 DM |
85 | me.column1.push( |
86 | {xtype: 'pveContentTypeSelector', | |
87 | cts: ['images', 'rootdir'], | |
88 | fieldLabel: gettext('Content'), | |
89 | name: 'content', | |
90 | value: ['images', 'rootdir'], | |
91 | multiSelect: true, | |
ec0bd652 DC |
92 | allowBlank: false |
93 | }); | |
94 | /*jslint confusion: false*/ | |
6cbcc546 DM |
95 | me.column2 = [ |
96 | { | |
97 | xtype: 'pvecheckbox', | |
98 | name: 'enable', | |
99 | checked: true, | |
100 | uncheckedValue: 0, | |
101 | fieldLabel: gettext('Enable') | |
102 | }, | |
103 | { | |
104 | xtype: 'pvecheckbox', | |
105 | name: 'sparse', | |
106 | checked: false, | |
107 | uncheckedValue: 0, | |
108 | fieldLabel: gettext('Thin provision') | |
177de3de | 109 | } |
6cbcc546 DM |
110 | ]; |
111 | ||
112 | if (me.create || me.storageId !== 'local') { | |
113 | me.column2.unshift({ | |
5198365d | 114 | xtype: 'pveNodeSelector', |
6cbcc546 DM |
115 | name: 'nodes', |
116 | fieldLabel: gettext('Nodes'), | |
117 | emptyText: gettext('All') + ' (' + | |
118 | gettext('No restrictions') +')', | |
119 | multiSelect: true, | |
120 | autoSelect: false | |
121 | }); | |
122 | } | |
123 | ||
124 | me.callParent(); | |
125 | } | |
126 | }); | |
127 | ||
128 | Ext.define('PVE.storage.ZFSPoolEdit', { | |
129 | extend: 'PVE.window.Edit', | |
177de3de | 130 | |
6cbcc546 DM |
131 | initComponent : function() { |
132 | var me = this; | |
133 | ||
134 | me.create = !me.storageId; | |
135 | ||
136 | if (me.create) { | |
137 | me.url = '/api2/extjs/storage'; | |
138 | me.method = 'POST'; | |
139 | } else { | |
140 | me.url = '/api2/extjs/storage/' + me.storageId; | |
141 | me.method = 'PUT'; | |
142 | } | |
143 | ||
144 | var ipanel = Ext.create('PVE.storage.ZFSPoolInputPanel', { | |
145 | create: me.create, | |
146 | storageId: me.storageId | |
147 | }); | |
148 | ||
149 | Ext.apply(me, { | |
2a82a528 | 150 | subject: PVE.Utils.format_storage_type('zfspool'), |
6cbcc546 DM |
151 | isAdd: true, |
152 | items: [ ipanel ] | |
153 | }); | |
154 | ||
155 | me.callParent(); | |
156 | ||
157 | if (!me.create) { | |
158 | me.load({ | |
159 | success: function(response, options) { | |
160 | var values = response.result.data; | |
161 | var ctypes = values.content || ''; | |
162 | ||
163 | values.content = ctypes.split(','); | |
164 | ||
165 | if (values.nodes) { | |
166 | values.nodes = values.nodes.split(','); | |
167 | } | |
168 | values.enable = values.disable ? 0 : 1; | |
169 | ipanel.setValues(values); | |
170 | } | |
171 | }); | |
172 | } | |
173 | } | |
174 | }); |