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