]> git.proxmox.com Git - pve-manager.git/blob - www/manager6/storage/Browser.js
ui: storage: enable download-url button with Sys.AccessNetwork capability
[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 me.items = [
21 {
22 title: gettext('Summary'),
23 xtype: 'pveStorageSummary',
24 iconCls: 'fa fa-book',
25 itemId: 'summary',
26 },
27 ];
28
29 let caps = Ext.state.Manager.get('GuiCap');
30
31 Ext.apply(me, {
32 title: Ext.String.format(gettext("Storage {0} on node {1}"), `'${storeid}'`, `'${nodename}'`),
33 hstateid: 'storagetab',
34 });
35
36 if (
37 caps.storage['Datastore.Allocate'] ||
38 caps.storage['Datastore.AllocateSpace'] ||
39 caps.storage['Datastore.Audit']
40 ) {
41 let storageInfo = PVE.data.ResourceStore.findRecord(
42 'id',
43 `storage/${nodename}/${storeid}`,
44 0, // startIndex
45 false, // anyMatch
46 true, // caseSensitive
47 true, // exactMatch
48 );
49 let res = storageInfo.data;
50 let plugin = res.plugintype;
51 let contents = res.content.split(',');
52
53 let enableUpload = !!caps.storage['Datastore.AllocateTemplate'];
54 let enableDownloadUrl = enableUpload && (
55 !!(caps.nodes['Sys.Audit'] && caps.nodes['Sys.Modify']) || // for backward compat
56 !!caps.nodes['Sys.AccessNetwork'] // new explicit priv for querying (local) networks
57 );
58
59 if (contents.includes('backup')) {
60 me.items.push({
61 xtype: 'pveStorageBackupView',
62 title: gettext('Backups'),
63 iconCls: 'fa fa-floppy-o',
64 itemId: 'contentBackup',
65 pluginType: plugin,
66 });
67 }
68 if (contents.includes('images')) {
69 me.items.push({
70 xtype: 'pveStorageImageView',
71 title: gettext('VM Disks'),
72 iconCls: 'fa fa-hdd-o',
73 itemId: 'contentImages',
74 content: 'images',
75 pluginType: plugin,
76 });
77 }
78 if (contents.includes('rootdir')) {
79 me.items.push({
80 xtype: 'pveStorageImageView',
81 title: gettext('CT Volumes'),
82 iconCls: 'fa fa-hdd-o lxc',
83 itemId: 'contentRootdir',
84 content: 'rootdir',
85 pluginType: plugin,
86 });
87 }
88 if (contents.includes('iso')) {
89 me.items.push({
90 xtype: 'pveStorageContentView',
91 title: gettext('ISO Images'),
92 iconCls: 'pve-itype-treelist-item-icon-cdrom',
93 itemId: 'contentIso',
94 content: 'iso',
95 pluginType: plugin,
96 enableUploadButton: enableUpload,
97 enableDownloadUrlButton: enableDownloadUrl,
98 useUploadButton: true,
99 });
100 }
101 if (contents.includes('vztmpl')) {
102 me.items.push({
103 xtype: 'pveStorageTemplateView',
104 title: gettext('CT Templates'),
105 iconCls: 'fa fa-file-o lxc',
106 itemId: 'contentVztmpl',
107 pluginType: plugin,
108 enableUploadButton: enableUpload,
109 enableDownloadUrlButton: enableDownloadUrl,
110 useUploadButton: true,
111 });
112 }
113 if (contents.includes('snippets')) {
114 me.items.push({
115 xtype: 'pveStorageContentView',
116 title: gettext('Snippets'),
117 iconCls: 'fa fa-file-code-o',
118 itemId: 'contentSnippets',
119 content: 'snippets',
120 pluginType: plugin,
121 });
122 }
123 }
124
125 if (caps.storage['Permissions.Modify']) {
126 me.items.push({
127 xtype: 'pveACLView',
128 title: gettext('Permissions'),
129 iconCls: 'fa fa-unlock',
130 itemId: 'permissions',
131 path: `/storage/${storeid}`,
132 });
133 }
134
135 me.callParent();
136 },
137 });