]> git.proxmox.com Git - pve-manager.git/blame - www/manager6/storage/Browser.js
ui: storage: enable download-url button with Sys.AccessNetwork capability
[pve-manager.git] / www / manager6 / storage / Browser.js
CommitLineData
45071714
DM
1Ext.define('PVE.storage.Browser', {
2 extend: 'PVE.panel.Config',
3 alias: 'widget.PVE.storage.Browser',
4
c8802a60 5 onlineHelp: 'chapter_storage',
565a68be 6
45071714 7 initComponent: function() {
7ef80fa8 8 let me = this;
45071714 9
7ef80fa8 10 let nodename = me.pveSelNode.data.node;
45071714
DM
11 if (!nodename) {
12 throw "no node name specified";
13 }
14
7ef80fa8 15 let storeid = me.pveSelNode.data.storage;
45071714
DM
16 if (!storeid) {
17 throw "no storage ID specified";
18 }
19
45071714
DM
20 me.items = [
21 {
232c96e0
DC
22 title: gettext('Summary'),
23 xtype: 'pveStorageSummary',
7ccbcc6c 24 iconCls: 'fa fa-book',
f6710aac
TL
25 itemId: 'summary',
26 },
45071714
DM
27 ];
28
7ef80fa8 29 let caps = Ext.state.Manager.get('GuiCap');
232c96e0 30
45071714 31 Ext.apply(me, {
7ef80fa8 32 title: Ext.String.format(gettext("Storage {0} on node {1}"), `'${storeid}'`, `'${nodename}'`),
f6710aac 33 hstateid: 'storagetab',
45071714
DM
34 });
35
7ef80fa8
TL
36 if (
37 caps.storage['Datastore.Allocate'] ||
0110314c 38 caps.storage['Datastore.AllocateSpace'] ||
7ef80fa8
TL
39 caps.storage['Datastore.Audit']
40 ) {
d2ac5451
FE
41 let storageInfo = PVE.data.ResourceStore.findRecord(
42 'id',
43 `storage/${nodename}/${storeid}`,
57f6c79b
DC
44 0, // startIndex
45 false, // anyMatch
46 true, // caseSensitive
47 true, // exactMatch
d2ac5451 48 );
1be81ae0
TL
49 let res = storageInfo.data;
50 let plugin = res.plugintype;
51 let contents = res.content.split(',');
e8b422bc 52
af3c0a92 53 let enableUpload = !!caps.storage['Datastore.AllocateTemplate'];
846defd8
TL
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 );
af3c0a92 58
d2ac5451
FE
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',
1be81ae0 65 pluginType: plugin,
d2ac5451
FE
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',
1be81ae0 75 pluginType: plugin,
d2ac5451
FE
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',
1be81ae0 85 pluginType: plugin,
d2ac5451
FE
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',
1be81ae0 95 pluginType: plugin,
af3c0a92
LS
96 enableUploadButton: enableUpload,
97 enableDownloadUrlButton: enableDownloadUrl,
d2ac5451
FE
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',
1be81ae0 107 pluginType: plugin,
af3c0a92
LS
108 enableUploadButton: enableUpload,
109 enableDownloadUrlButton: enableDownloadUrl,
110 useUploadButton: true,
d2ac5451
FE
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',
1be81ae0 120 pluginType: plugin,
d2ac5451
FE
121 });
122 }
45071714
DM
123 }
124
125 if (caps.storage['Permissions.Modify']) {
d2ac5451
FE
126 me.items.push({
127 xtype: 'pveACLView',
128 title: gettext('Permissions'),
129 iconCls: 'fa fa-unlock',
130 itemId: 'permissions',
7ef80fa8 131 path: `/storage/${storeid}`,
d2ac5451 132 });
45071714 133 }
d2ac5451
FE
134
135 me.callParent();
f6710aac 136 },
45071714 137});