]>
Commit | Line | Data |
---|---|---|
45071714 DM |
1 | Ext.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 | ||
ddbddff7 DC |
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' ? [ | |
45071714 | 32 | { |
232c96e0 DC |
33 | title: gettext('Summary'), |
34 | xtype: 'pveStorageSummary', | |
7ccbcc6c | 35 | iconCls: 'fa fa-book', |
f6710aac TL |
36 | itemId: 'summary', |
37 | }, | |
ddbddff7 | 38 | ] : []; |
45071714 | 39 | |
7ef80fa8 | 40 | let caps = Ext.state.Manager.get('GuiCap'); |
232c96e0 | 41 | |
45071714 | 42 | Ext.apply(me, { |
7ef80fa8 | 43 | title: Ext.String.format(gettext("Storage {0} on node {1}"), `'${storeid}'`, `'${nodename}'`), |
f6710aac | 44 | hstateid: 'storagetab', |
45071714 DM |
45 | }); |
46 | ||
7ef80fa8 TL |
47 | if ( |
48 | caps.storage['Datastore.Allocate'] || | |
0110314c | 49 | caps.storage['Datastore.AllocateSpace'] || |
7ef80fa8 TL |
50 | caps.storage['Datastore.Audit'] |
51 | ) { | |
1be81ae0 | 52 | let contents = res.content.split(','); |
e8b422bc | 53 | |
af3c0a92 | 54 | let enableUpload = !!caps.storage['Datastore.AllocateTemplate']; |
846defd8 TL |
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 | ); | |
af3c0a92 | 59 | |
d2ac5451 FE |
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', | |
1be81ae0 | 66 | pluginType: plugin, |
d2ac5451 FE |
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', | |
1be81ae0 | 76 | pluginType: plugin, |
d2ac5451 FE |
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', | |
1be81ae0 | 86 | pluginType: plugin, |
d2ac5451 FE |
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', | |
1be81ae0 | 96 | pluginType: plugin, |
af3c0a92 LS |
97 | enableUploadButton: enableUpload, |
98 | enableDownloadUrlButton: enableDownloadUrl, | |
d2ac5451 FE |
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', | |
1be81ae0 | 108 | pluginType: plugin, |
af3c0a92 LS |
109 | enableUploadButton: enableUpload, |
110 | enableDownloadUrlButton: enableDownloadUrl, | |
111 | useUploadButton: true, | |
d2ac5451 FE |
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', | |
1be81ae0 | 121 | pluginType: plugin, |
d2ac5451 FE |
122 | }); |
123 | } | |
bb3fa9de DC |
124 | if (contents.includes('import')) { |
125 | me.items.push({ | |
126 | xtype: 'pveStorageContentView', | |
127 | title: gettext('Import'), | |
128 | iconCls: 'fa fa-cloud-download', | |
129 | itemId: 'contentImport', | |
130 | content: 'import', | |
131 | useCustomRemoveButton: true, // hide default remove button | |
132 | showColumns: ['name', 'format'], | |
133 | tbar: [ | |
134 | { | |
135 | xtype: 'proxmoxButton', | |
136 | disabled: true, | |
137 | text: gettext('Start Import'), | |
138 | handler: function() { | |
139 | let grid = this.up('pveStorageContentView'); | |
140 | let selection = grid.getSelection()?.[0]; | |
141 | ||
142 | if (!selection) { | |
143 | return; | |
144 | } | |
145 | ||
146 | let volumeName = selection.data.volid.replace(/^.*?:/, ''); | |
147 | ||
148 | Ext.create('PVE.window.GuestImport', { | |
149 | storage: storeid, | |
150 | volumeName, | |
151 | nodename, | |
152 | autoShow: true, | |
153 | }); | |
154 | }, | |
155 | }, | |
156 | ], | |
157 | pluginType: plugin, | |
158 | }); | |
159 | } | |
45071714 DM |
160 | } |
161 | ||
162 | if (caps.storage['Permissions.Modify']) { | |
d2ac5451 FE |
163 | me.items.push({ |
164 | xtype: 'pveACLView', | |
165 | title: gettext('Permissions'), | |
166 | iconCls: 'fa fa-unlock', | |
167 | itemId: 'permissions', | |
7ef80fa8 | 168 | path: `/storage/${storeid}`, |
d2ac5451 | 169 | }); |
45071714 | 170 | } |
d2ac5451 FE |
171 | |
172 | me.callParent(); | |
f6710aac | 173 | }, |
45071714 | 174 | }); |