]> git.proxmox.com Git - pve-manager.git/blame - www/manager6/dc/StorageView.js
ui: ldap: add 'Check connection' checkbox as advanced option
[pve-manager.git] / www / manager6 / dc / StorageView.js
CommitLineData
2f8915cf
DM
1Ext.define('PVE.dc.StorageView', {
2 extend: 'Ext.grid.GridPanel',
3
4 alias: ['widget.pveStorageView'],
5
ba93a9c6
DC
6 onlineHelp: 'chapter_storage',
7
c4bb9405
DC
8 stateful: true,
9 stateId: 'grid-dc-storage',
10
f28ec3e4 11 createStorageEditWindow: function(type, sid) {
9f84f443 12 let schema = PVE.Utils.storageSchema[type];
f28ec3e4
TL
13 if (!schema || !schema.ipanel) {
14 throw "no editor registered for storage type: " + type;
15 }
16
17 Ext.create('PVE.storage.BaseEdit', {
18 paneltype: 'PVE.storage.' + schema.ipanel,
19 type: type,
20 storageId: sid,
06c8315d 21 canDoBackups: schema.backups,
f28ec3e4
TL
22 autoShow: true,
23 listeners: {
f6710aac
TL
24 destroy: this.reloadStore,
25 },
f28ec3e4
TL
26 });
27 },
28
8058410f 29 initComponent: function() {
9f84f443 30 let me = this;
2f8915cf 31
9f84f443 32 let store = new Ext.data.Store({
2f8915cf
DM
33 model: 'pve-storage',
34 proxy: {
56a353b9 35 type: 'proxmox',
f6710aac 36 url: "/api2/json/storage",
2f8915cf 37 },
a9f71282
DC
38 sorters: {
39 property: 'storage',
392e3cf1 40 direction: 'ASC',
f6710aac 41 },
2f8915cf
DM
42 });
43
9f84f443 44 let sm = Ext.create('Ext.selection.RowModel', {});
2f8915cf 45
9f84f443
TL
46 let run_editor = function() {
47 let rec = sm.getSelection()[0];
2f8915cf
DM
48 if (!rec) {
49 return;
50 }
9f84f443
TL
51 let { type, storage } = rec.data;
52 me.createStorageEditWindow(type, storage);
2f8915cf 53 };
a9f71282 54
9f84f443 55 let edit_btn = new Proxmox.button.Button({
2f8915cf
DM
56 text: gettext('Edit'),
57 disabled: true,
58 selModel: sm,
f6710aac 59 handler: run_editor,
2f8915cf 60 });
9f84f443 61 let remove_btn = Ext.create('Proxmox.button.StdRemoveButton', {
2f8915cf 62 selModel: sm,
3b1ca3ff 63 baseurl: '/storage/',
9f84f443 64 callback: () => store.load(),
2f8915cf
DM
65 });
66
f28ec3e4 67 // else we cannot dynamically generate the add menu handlers
9f84f443 68 let addHandleGenerator = function(type) {
f28ec3e4
TL
69 return function() { me.createStorageEditWindow(type); };
70 };
9f84f443
TL
71 let addMenuItems = [];
72 for (const [type, storage] of Object.entries(PVE.Utils.storageSchema)) {
f28ec3e4
TL
73 if (storage.hideAdd) {
74 continue;
75 }
76 addMenuItems.push({
8058410f 77 text: PVE.Utils.format_storage_type(type),
f28ec3e4 78 iconCls: 'fa fa-fw fa-' + storage.faIcon,
f6710aac 79 handler: addHandleGenerator(type),
f28ec3e4
TL
80 });
81 }
82
2f8915cf
DM
83 Ext.apply(me, {
84 store: store,
9f84f443 85 reloadStore: () => store.load(),
2f8915cf 86 selModel: sm,
2f8915cf 87 viewConfig: {
f6710aac 88 trackOver: false,
2f8915cf 89 },
a9f71282 90 tbar: [
2f8915cf
DM
91 {
92 text: gettext('Add'),
93 menu: new Ext.menu.Menu({
f6710aac
TL
94 items: addMenuItems,
95 }),
2f8915cf
DM
96 },
97 remove_btn,
f6710aac 98 edit_btn,
2f8915cf
DM
99 ],
100 columns: [
101 {
102 header: 'ID',
99acd7d9 103 flex: 2,
2f8915cf 104 sortable: true,
f6710aac 105 dataIndex: 'storage',
2f8915cf
DM
106 },
107 {
108 header: gettext('Type'),
99acd7d9 109 flex: 1,
2f8915cf
DM
110 sortable: true,
111 dataIndex: 'type',
f6710aac 112 renderer: PVE.Utils.format_storage_type,
2f8915cf
DM
113 },
114 {
115 header: gettext('Content'),
99acd7d9 116 flex: 3,
2f8915cf
DM
117 sortable: true,
118 dataIndex: 'content',
f6710aac 119 renderer: PVE.Utils.format_content_types,
2f8915cf
DM
120 },
121 {
122 header: gettext('Path') + '/' + gettext('Target'),
99acd7d9 123 flex: 2,
2f8915cf
DM
124 sortable: true,
125 dataIndex: 'path',
126 renderer: function(value, metaData, record) {
127 if (record.data.target) {
128 return record.data.target;
129 }
130 return value;
f6710aac 131 },
2f8915cf
DM
132 },
133 {
134 header: gettext('Shared'),
99acd7d9 135 flex: 1,
2f8915cf
DM
136 sortable: true,
137 dataIndex: 'shared',
f6710aac 138 renderer: Proxmox.Utils.format_boolean,
2f8915cf
DM
139 },
140 {
185a77e5 141 header: gettext('Enabled'),
99acd7d9 142 flex: 1,
2f8915cf
DM
143 sortable: true,
144 dataIndex: 'disable',
f6710aac 145 renderer: Proxmox.Utils.format_neg_boolean,
a8abd7a1
TL
146 },
147 {
148 header: gettext('Bandwidth Limit'),
149 flex: 2,
150 sortable: true,
f6710aac
TL
151 dataIndex: 'bwlimit',
152 },
2f8915cf
DM
153 ],
154 listeners: {
9f84f443 155 activate: () => store.load(),
f6710aac
TL
156 itemdblclick: run_editor,
157 },
2f8915cf
DM
158 });
159
160 me.callParent();
f6710aac 161 },
2f8915cf 162}, function() {
2f8915cf
DM
163 Ext.define('pve-storage', {
164 extend: 'Ext.data.Model',
a9f71282 165 fields: [
2f8915cf 166 'path', 'type', 'content', 'server', 'portal', 'target', 'export', 'storage',
8058410f
TL
167 { name: 'shared', type: 'boolean' },
168 { name: 'disable', type: 'boolean' },
2f8915cf 169 ],
f6710aac 170 idProperty: 'storage',
2f8915cf 171 });
2f8915cf 172});