]> git.proxmox.com Git - pve-manager.git/blob - www/manager6/storage/Browser.js
71225f7ef1d8c823ef94b05205e63b44de00977c
[pve-manager.git] / www / manager6 / storage / Browser.js
1 Ext.define('PVE.storage.Browser', {
2 extend: 'PVE.panel.Config',
3 alias: 'widget.PVE.storage.Browser',
4
5 onlineHelp: 'chapter_storage',
6
7 initComponent: function() {
8 let me = this;
9
10 let nodename = me.pveSelNode.data.node;
11 if (!nodename) {
12 throw "no node name specified";
13 }
14
15 let storeid = me.pveSelNode.data.storage;
16 if (!storeid) {
17 throw "no storage ID specified";
18 }
19
20 let storageInfo = PVE.data.ResourceStore.findRecord(
21 'id',
22 `storage/${nodename}/${storeid}`,
23 0, // startIndex
24 false, // anyMatch
25 true, // caseSensitive
26 true, // exactMatch
27 );
28 let res = storageInfo.data;
29 let plugin = res.plugintype;
30
31 me.items = plugin !== 'esxi' ? [
32 {
33 title: gettext('Summary'),
34 xtype: 'pveStorageSummary',
35 iconCls: 'fa fa-book',
36 itemId: 'summary',
37 },
38 ] : [];
39
40 let caps = Ext.state.Manager.get('GuiCap');
41
42 Ext.apply(me, {
43 title: Ext.String.format(gettext("Storage {0} on node {1}"), `'${storeid}'`, `'${nodename}'`),
44 hstateid: 'storagetab',
45 });
46
47 if (
48 caps.storage['Datastore.Allocate'] ||
49 caps.storage['Datastore.AllocateSpace'] ||
50 caps.storage['Datastore.Audit']
51 ) {
52 let contents = res.content.split(',');
53
54 let enableUpload = !!caps.storage['Datastore.AllocateTemplate'];
55 let enableDownloadUrl = enableUpload && (
56 !!(caps.nodes['Sys.Audit'] && caps.nodes['Sys.Modify']) || // for backward compat
57 !!caps.nodes['Sys.AccessNetwork'] // new explicit priv for querying (local) networks
58 );
59
60 if (contents.includes('backup')) {
61 me.items.push({
62 xtype: 'pveStorageBackupView',
63 title: gettext('Backups'),
64 iconCls: 'fa fa-floppy-o',
65 itemId: 'contentBackup',
66 pluginType: plugin,
67 });
68 }
69 if (contents.includes('images')) {
70 me.items.push({
71 xtype: 'pveStorageImageView',
72 title: gettext('VM Disks'),
73 iconCls: 'fa fa-hdd-o',
74 itemId: 'contentImages',
75 content: 'images',
76 pluginType: plugin,
77 });
78 }
79 if (contents.includes('rootdir')) {
80 me.items.push({
81 xtype: 'pveStorageImageView',
82 title: gettext('CT Volumes'),
83 iconCls: 'fa fa-hdd-o lxc',
84 itemId: 'contentRootdir',
85 content: 'rootdir',
86 pluginType: plugin,
87 });
88 }
89 if (contents.includes('iso')) {
90 me.items.push({
91 xtype: 'pveStorageContentView',
92 title: gettext('ISO Images'),
93 iconCls: 'pve-itype-treelist-item-icon-cdrom',
94 itemId: 'contentIso',
95 content: 'iso',
96 pluginType: plugin,
97 enableUploadButton: enableUpload,
98 enableDownloadUrlButton: enableDownloadUrl,
99 useUploadButton: true,
100 });
101 }
102 if (contents.includes('vztmpl')) {
103 me.items.push({
104 xtype: 'pveStorageTemplateView',
105 title: gettext('CT Templates'),
106 iconCls: 'fa fa-file-o lxc',
107 itemId: 'contentVztmpl',
108 pluginType: plugin,
109 enableUploadButton: enableUpload,
110 enableDownloadUrlButton: enableDownloadUrl,
111 useUploadButton: true,
112 });
113 }
114 if (contents.includes('snippets')) {
115 me.items.push({
116 xtype: 'pveStorageContentView',
117 title: gettext('Snippets'),
118 iconCls: 'fa fa-file-code-o',
119 itemId: 'contentSnippets',
120 content: 'snippets',
121 pluginType: plugin,
122 });
123 }
124 if (contents.includes('import')) {
125 let createGuestImportWindow = (selection) => {
126 if (!selection) {
127 return;
128 }
129
130 let volumeName = selection.data.volid.replace(/^.*?:/, '');
131
132 Ext.create('PVE.window.GuestImport', {
133 storage: storeid,
134 volumeName,
135 nodename,
136 autoShow: true,
137 });
138 };
139 me.items.push({
140 xtype: 'pveStorageContentView',
141 title: gettext('Virtual Guests'),
142 iconCls: 'fa fa-cloud-download',
143 itemId: 'contentImport',
144 content: 'import',
145 useCustomRemoveButton: true, // hide default remove button
146 showColumns: ['name', 'format'],
147 itemdblclick: (view, record) => createGuestImportWindow(record),
148 tbar: [
149 {
150 xtype: 'proxmoxButton',
151 disabled: true,
152 text: gettext('Import'),
153 handler: function() {
154 let grid = this.up('pveStorageContentView');
155 let selection = grid.getSelection()?.[0];
156
157 createGuestImportWindow(selection);
158 },
159 },
160 ],
161 pluginType: plugin,
162 });
163 }
164 }
165
166 if (caps.storage['Permissions.Modify']) {
167 me.items.push({
168 xtype: 'pveACLView',
169 title: gettext('Permissions'),
170 iconCls: 'fa fa-unlock',
171 itemId: 'permissions',
172 path: `/storage/${storeid}`,
173 });
174 }
175
176 me.callParent();
177 },
178 });