]> git.proxmox.com Git - pve-manager.git/blame - www/manager6/dc/StorageView.js
controller: StorageEdit: check if 'maxfiles' could be looked up
[pve-manager.git] / www / manager6 / dc / StorageView.js
CommitLineData
2f8915cf
DM
1
2Ext.define('PVE.dc.StorageView', {
3 extend: 'Ext.grid.GridPanel',
4
5 alias: ['widget.pveStorageView'],
6
ba93a9c6
DC
7 onlineHelp: 'chapter_storage',
8
c4bb9405
DC
9 stateful: true,
10 stateId: 'grid-dc-storage',
11
2f8915cf
DM
12 initComponent : function() {
13 var me = this;
14
15 var store = new Ext.data.Store({
16 model: 'pve-storage',
17 proxy: {
56a353b9 18 type: 'proxmox',
2f8915cf
DM
19 url: "/api2/json/storage"
20 },
a9f71282
DC
21 sorters: {
22 property: 'storage',
23 order: 'DESC'
2f8915cf
DM
24 }
25 });
26
27 var reload = function() {
28 store.load();
29 };
30
31 var sm = Ext.create('Ext.selection.RowModel', {});
32
33 var run_editor = function() {
34 var rec = sm.getSelection()[0];
35 if (!rec) {
36 return;
37 }
38 var type = rec.data.type;
a9f71282 39
2f8915cf
DM
40 var editor;
41 if (type === 'dir') {
42 editor = 'PVE.storage.DirEdit';
43 } else if (type === 'nfs') {
44 editor = 'PVE.storage.NFSEdit';
ca9a198a
WL
45 } else if (type === 'cifs') {
46 editor = 'PVE.storage.CIFSEdit';
2f8915cf
DM
47 } else if (type === 'glusterfs') {
48 editor = 'PVE.storage.GlusterFsEdit';
49 } else if (type === 'lvm') {
50 editor = 'PVE.storage.LVMEdit';
c3378f7b
DC
51 } else if (type === 'lvmthin') {
52 editor = 'PVE.storage.LvmThinEdit';
2f8915cf
DM
53 } else if (type === 'iscsi') {
54 editor = 'PVE.storage.IScsiEdit';
55 } else if (type === 'rbd') {
56 editor = 'PVE.storage.RBDEdit';
57 } else if (type === 'sheepdog') {
58 editor = 'PVE.storage.SheepdogEdit';
59 } else if (type === 'zfs') {
60 editor = 'PVE.storage.ZFSEdit';
61 } else if (type === 'zfspool') {
62 editor = 'PVE.storage.ZFSPoolEdit';
63 } else {
64 return;
65 }
66 var win = Ext.create(editor, {
3c23c025
DC
67 storageId: rec.data.storage,
68 pveceph: !rec.data.monhost
2f8915cf
DM
69 });
70
71 win.show();
72 win.on('destroy', reload);
73 };
a9f71282 74
5720fafa 75 var edit_btn = new Proxmox.button.Button({
2f8915cf
DM
76 text: gettext('Edit'),
77 disabled: true,
78 selModel: sm,
79 handler: run_editor
80 });
81
3b1ca3ff 82 var remove_btn = Ext.create('Proxmox.button.StdRemoveButton', {
2f8915cf 83 selModel: sm,
3b1ca3ff
DC
84 baseurl: '/storage/',
85 callback: function() {
86 reload();
2f8915cf
DM
87 }
88 });
89
90 Ext.apply(me, {
91 store: store,
92 selModel: sm,
2f8915cf
DM
93 viewConfig: {
94 trackOver: false
95 },
a9f71282 96 tbar: [
2f8915cf
DM
97 {
98 text: gettext('Add'),
99 menu: new Ext.menu.Menu({
100 items: [
101 {
102 text: PVE.Utils.format_storage_type('dir'),
0ef7ade9 103 iconCls: 'fa fa-fw fa-folder',
2f8915cf
DM
104 handler: function() {
105 var win = Ext.create('PVE.storage.DirEdit', {});
106 win.on('destroy', reload);
107 win.show();
108 }
109
110 },
111 {
112 text: PVE.Utils.format_storage_type('lvm'),
0ef7ade9 113 iconCls: 'fa fa-fw fa-folder',
2f8915cf
DM
114 handler: function() {
115 var win = Ext.create('PVE.storage.LVMEdit', {});
116 win.on('destroy', reload);
117 win.show();
118 }
119 },
c3378f7b
DC
120 {
121 text: PVE.Utils.format_storage_type('lvmthin'),
0ef7ade9 122 iconCls: 'fa fa-fw fa-folder',
c3378f7b
DC
123 handler: function() {
124 var win = Ext.create('PVE.storage.LvmThinEdit', {});
125 win.on('destroy', reload);
126 win.show();
127 }
128 },
2f8915cf
DM
129 {
130 text: PVE.Utils.format_storage_type('nfs'),
0ef7ade9 131 iconCls: 'fa fa-fw fa-building',
2f8915cf
DM
132 handler: function() {
133 var win = Ext.create('PVE.storage.NFSEdit', {});
134 win.on('destroy', reload);
135 win.show();
136 }
137 },
ca9a198a
WL
138 {
139 text: PVE.Utils.format_storage_type('cifs'),
140 iconCls: 'fa fa-fw fa-building',
141 handler: function() {
142 var win = Ext.create('PVE.storage.CIFSEdit', {});
143 win.on('destroy', reload);
144 win.show();
145 }
146 },
2f8915cf
DM
147 {
148 text: PVE.Utils.format_storage_type('iscsi'),
0ef7ade9 149 iconCls: 'fa fa-fw fa-building',
2f8915cf
DM
150 handler: function() {
151 var win = Ext.create('PVE.storage.IScsiEdit', {});
152 win.on('destroy', reload);
153 win.show();
154 }
155 },
156 {
157 text: PVE.Utils.format_storage_type('glusterfs'),
0ef7ade9 158 iconCls: 'fa fa-fw fa-building',
2f8915cf
DM
159 handler: function() {
160 var win = Ext.create('PVE.storage.GlusterFsEdit', {});
161 win.on('destroy', reload);
162 win.show();
163 }
164 },
3c23c025
DC
165 {
166 text: PVE.Utils.format_storage_type('pveceph'),
167 iconCls: 'fa fa-fw fa-building',
168 handler: function() {
169 var win = Ext.create('PVE.storage.RBDEdit', {
170 pveceph: 1
171 });
172 win.on('destroy', reload);
173 win.show();
174 }
175 },
2f8915cf 176 {
6760ab92 177 text: PVE.Utils.format_storage_type('rbd_ext'),
0ef7ade9 178 iconCls: 'fa fa-fw fa-building',
2f8915cf
DM
179 handler: function() {
180 var win = Ext.create('PVE.storage.RBDEdit', {});
181 win.on('destroy', reload);
182 win.show();
183 }
184 },
185 {
186 text: PVE.Utils.format_storage_type('zfs'),
0ef7ade9 187 iconCls: 'fa fa-fw fa-building',
2f8915cf
DM
188 handler: function() {
189 var win = Ext.create('PVE.storage.ZFSEdit', {});
190 win.on('destroy', reload);
191 win.show();
192 }
193 },
194 {
195 text: PVE.Utils.format_storage_type('zfspool'),
0ef7ade9 196 iconCls: 'fa fa-fw fa-folder',
2f8915cf
DM
197 handler: function() {
198 var win = Ext.create('PVE.storage.ZFSPoolEdit', {});
199 win.on('destroy', reload);
200 win.show();
201 }
22f2f9d6 202 }
2f8915cf
DM
203
204/* the following type are conidered unstable
205 * so we do not enable that on the GUI for now
206 {
207 text: PVE.Utils.format_storage_type('sheepdog'),
0ef7ade9 208 iconCls: 'fa fa-fw fa-building',
2f8915cf
DM
209 handler: function() {
210 var win = Ext.create('PVE.storage.SheepdogEdit', {});
211 win.on('destroy', reload);
212 win.show();
213 }
214 }
215*/
216 ]
217 })
218 },
219 remove_btn,
220 edit_btn
221 ],
222 columns: [
223 {
224 header: 'ID',
99acd7d9 225 flex: 2,
2f8915cf
DM
226 sortable: true,
227 dataIndex: 'storage'
228 },
229 {
230 header: gettext('Type'),
99acd7d9 231 flex: 1,
2f8915cf
DM
232 sortable: true,
233 dataIndex: 'type',
234 renderer: PVE.Utils.format_storage_type
235 },
236 {
237 header: gettext('Content'),
99acd7d9 238 flex: 3,
2f8915cf
DM
239 sortable: true,
240 dataIndex: 'content',
241 renderer: PVE.Utils.format_content_types
242 },
243 {
244 header: gettext('Path') + '/' + gettext('Target'),
99acd7d9 245 flex: 2,
2f8915cf
DM
246 sortable: true,
247 dataIndex: 'path',
248 renderer: function(value, metaData, record) {
249 if (record.data.target) {
250 return record.data.target;
251 }
252 return value;
253 }
254 },
255 {
256 header: gettext('Shared'),
99acd7d9 257 flex: 1,
2f8915cf
DM
258 sortable: true,
259 dataIndex: 'shared',
e7ade592 260 renderer: Proxmox.Utils.format_boolean
2f8915cf
DM
261 },
262 {
185a77e5 263 header: gettext('Enabled'),
99acd7d9 264 flex: 1,
2f8915cf
DM
265 sortable: true,
266 dataIndex: 'disable',
e7ade592 267 renderer: Proxmox.Utils.format_neg_boolean
a8abd7a1
TL
268 },
269 {
270 header: gettext('Bandwidth Limit'),
271 flex: 2,
272 sortable: true,
273 dataIndex: 'bwlimit'
2f8915cf
DM
274 }
275 ],
276 listeners: {
c0b3df6e 277 activate: reload,
2f8915cf
DM
278 itemdblclick: run_editor
279 }
280 });
281
282 me.callParent();
283 }
284}, function() {
285
286 Ext.define('pve-storage', {
287 extend: 'Ext.data.Model',
a9f71282 288 fields: [
2f8915cf
DM
289 'path', 'type', 'content', 'server', 'portal', 'target', 'export', 'storage',
290 { name: 'shared', type: 'boolean'},
a9f71282 291 { name: 'disable', type: 'boolean'}
2f8915cf
DM
292 ],
293 idProperty: 'storage'
294 });
295
296});