]> git.proxmox.com Git - pve-manager.git/blame - www/manager6/dc/StorageView.js
use Proxmox.button.StdRemoveButton where possible
[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: {
18 type: 'pve',
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';
45 } else if (type === 'glusterfs') {
46 editor = 'PVE.storage.GlusterFsEdit';
47 } else if (type === 'lvm') {
48 editor = 'PVE.storage.LVMEdit';
c3378f7b
DC
49 } else if (type === 'lvmthin') {
50 editor = 'PVE.storage.LvmThinEdit';
2f8915cf
DM
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, {
3c23c025
DC
65 storageId: rec.data.storage,
66 pveceph: !rec.data.monhost
2f8915cf
DM
67 });
68
69 win.show();
70 win.on('destroy', reload);
71 };
a9f71282 72
2f8915cf
DM
73 var edit_btn = new PVE.button.Button({
74 text: gettext('Edit'),
75 disabled: true,
76 selModel: sm,
77 handler: run_editor
78 });
79
3b1ca3ff 80 var remove_btn = Ext.create('Proxmox.button.StdRemoveButton', {
2f8915cf 81 selModel: sm,
3b1ca3ff
DC
82 baseurl: '/storage/',
83 callback: function() {
84 reload();
2f8915cf
DM
85 }
86 });
87
88 Ext.apply(me, {
89 store: store,
90 selModel: sm,
2f8915cf
DM
91 viewConfig: {
92 trackOver: false
93 },
a9f71282 94 tbar: [
2f8915cf
DM
95 {
96 text: gettext('Add'),
97 menu: new Ext.menu.Menu({
98 items: [
99 {
100 text: PVE.Utils.format_storage_type('dir'),
0ef7ade9 101 iconCls: 'fa fa-fw fa-folder',
2f8915cf
DM
102 handler: function() {
103 var win = Ext.create('PVE.storage.DirEdit', {});
104 win.on('destroy', reload);
105 win.show();
106 }
107
108 },
109 {
110 text: PVE.Utils.format_storage_type('lvm'),
0ef7ade9 111 iconCls: 'fa fa-fw fa-folder',
2f8915cf
DM
112 handler: function() {
113 var win = Ext.create('PVE.storage.LVMEdit', {});
114 win.on('destroy', reload);
115 win.show();
116 }
117 },
c3378f7b
DC
118 {
119 text: PVE.Utils.format_storage_type('lvmthin'),
0ef7ade9 120 iconCls: 'fa fa-fw fa-folder',
c3378f7b
DC
121 handler: function() {
122 var win = Ext.create('PVE.storage.LvmThinEdit', {});
123 win.on('destroy', reload);
124 win.show();
125 }
126 },
2f8915cf
DM
127 {
128 text: PVE.Utils.format_storage_type('nfs'),
0ef7ade9 129 iconCls: 'fa fa-fw fa-building',
2f8915cf
DM
130 handler: function() {
131 var win = Ext.create('PVE.storage.NFSEdit', {});
132 win.on('destroy', reload);
133 win.show();
134 }
135 },
136 {
137 text: PVE.Utils.format_storage_type('iscsi'),
0ef7ade9 138 iconCls: 'fa fa-fw fa-building',
2f8915cf
DM
139 handler: function() {
140 var win = Ext.create('PVE.storage.IScsiEdit', {});
141 win.on('destroy', reload);
142 win.show();
143 }
144 },
145 {
146 text: PVE.Utils.format_storage_type('glusterfs'),
0ef7ade9 147 iconCls: 'fa fa-fw fa-building',
2f8915cf
DM
148 handler: function() {
149 var win = Ext.create('PVE.storage.GlusterFsEdit', {});
150 win.on('destroy', reload);
151 win.show();
152 }
153 },
3c23c025
DC
154 {
155 text: PVE.Utils.format_storage_type('pveceph'),
156 iconCls: 'fa fa-fw fa-building',
157 handler: function() {
158 var win = Ext.create('PVE.storage.RBDEdit', {
159 pveceph: 1
160 });
161 win.on('destroy', reload);
162 win.show();
163 }
164 },
2f8915cf 165 {
6760ab92 166 text: PVE.Utils.format_storage_type('rbd_ext'),
0ef7ade9 167 iconCls: 'fa fa-fw fa-building',
2f8915cf
DM
168 handler: function() {
169 var win = Ext.create('PVE.storage.RBDEdit', {});
170 win.on('destroy', reload);
171 win.show();
172 }
173 },
174 {
175 text: PVE.Utils.format_storage_type('zfs'),
0ef7ade9 176 iconCls: 'fa fa-fw fa-building',
2f8915cf
DM
177 handler: function() {
178 var win = Ext.create('PVE.storage.ZFSEdit', {});
179 win.on('destroy', reload);
180 win.show();
181 }
182 },
183 {
184 text: PVE.Utils.format_storage_type('zfspool'),
0ef7ade9 185 iconCls: 'fa fa-fw fa-folder',
2f8915cf
DM
186 handler: function() {
187 var win = Ext.create('PVE.storage.ZFSPoolEdit', {});
188 win.on('destroy', reload);
189 win.show();
190 }
22f2f9d6 191 }
2f8915cf
DM
192
193/* the following type are conidered unstable
194 * so we do not enable that on the GUI for now
195 {
196 text: PVE.Utils.format_storage_type('sheepdog'),
0ef7ade9 197 iconCls: 'fa fa-fw fa-building',
2f8915cf
DM
198 handler: function() {
199 var win = Ext.create('PVE.storage.SheepdogEdit', {});
200 win.on('destroy', reload);
201 win.show();
202 }
203 }
204*/
205 ]
206 })
207 },
208 remove_btn,
209 edit_btn
210 ],
211 columns: [
212 {
213 header: 'ID',
214 width: 100,
215 sortable: true,
216 dataIndex: 'storage'
217 },
218 {
219 header: gettext('Type'),
220 width: 60,
221 sortable: true,
222 dataIndex: 'type',
223 renderer: PVE.Utils.format_storage_type
224 },
225 {
226 header: gettext('Content'),
227 width: 150,
228 sortable: true,
229 dataIndex: 'content',
230 renderer: PVE.Utils.format_content_types
231 },
232 {
233 header: gettext('Path') + '/' + gettext('Target'),
234 flex: 1,
235 sortable: true,
236 dataIndex: 'path',
237 renderer: function(value, metaData, record) {
238 if (record.data.target) {
239 return record.data.target;
240 }
241 return value;
242 }
243 },
244 {
245 header: gettext('Shared'),
246 width: 80,
247 sortable: true,
248 dataIndex: 'shared',
249 renderer: PVE.Utils.format_boolean
250 },
251 {
185a77e5 252 header: gettext('Enabled'),
2f8915cf
DM
253 width: 80,
254 sortable: true,
255 dataIndex: 'disable',
256 renderer: PVE.Utils.format_neg_boolean
257 }
258 ],
259 listeners: {
c0b3df6e 260 activate: reload,
2f8915cf
DM
261 itemdblclick: run_editor
262 }
263 });
264
265 me.callParent();
266 }
267}, function() {
268
269 Ext.define('pve-storage', {
270 extend: 'Ext.data.Model',
a9f71282 271 fields: [
2f8915cf
DM
272 'path', 'type', 'content', 'server', 'portal', 'target', 'export', 'storage',
273 { name: 'shared', type: 'boolean'},
a9f71282 274 { name: 'disable', type: 'boolean'}
2f8915cf
DM
275 ],
276 idProperty: 'storage'
277 });
278
279});