]>
Commit | Line | Data |
---|---|---|
f5e17f15 FE |
1 | Ext.define('PVE.storage.ImageView', { |
2 | extend: 'PVE.storage.ContentView', | |
3 | ||
4 | alias: 'widget.pveStorageImageView', | |
5 | ||
6 | initComponent: function() { | |
7 | var me = this; | |
8 | ||
9 | var nodename = me.nodename = me.pveSelNode.data.node; | |
10 | if (!me.nodename) { | |
11 | throw "no node name specified"; | |
12 | } | |
13 | ||
14 | var storage = me.storage = me.pveSelNode.data.storage; | |
15 | if (!me.storage) { | |
16 | throw "no storage ID specified"; | |
17 | } | |
18 | ||
19 | if (!me.content || (me.content !== 'images' && me.content !== 'rootdir')) { | |
20 | throw "content needs to be either 'images' or 'rootdir'"; | |
21 | } | |
22 | ||
23 | var sm = me.sm = Ext.create('Ext.selection.RowModel', {}); | |
24 | ||
25 | var reload = function() { | |
26 | me.store.load(); | |
8058410f | 27 | }; |
f5e17f15 FE |
28 | |
29 | me.tbar = [ | |
30 | { | |
31 | xtype: 'proxmoxButton', | |
32 | selModel: sm, | |
33 | text: gettext('Remove'), | |
34 | disabled: true, | |
35 | handler: function(btn, event, rec) { | |
36 | var url = "/nodes/" + nodename + "/storage/" + storage + | |
37 | "/content" + '/' + rec.data.volid; | |
38 | var vmid = rec.data.vmid; | |
39 | ||
40 | var store = PVE.data.ResourceStore; | |
41 | ||
42 | if (vmid && store.findVMID(vmid)) { | |
43 | var guest_node = store.guestNode(vmid); | |
44 | var storage_path = 'storage/' + nodename + '/' + storage; | |
45 | ||
46 | // allow to delete local backed images if a VMID exists on another node. | |
47 | if (store.storageIsShared(storage_path) || guest_node == nodename) { | |
48 | var msg = Ext.String.format( | |
49 | gettext("Cannot remove image, a guest with VMID '{0}' exists!"), vmid); | |
50 | msg += '<br />' + gettext("You can delete the image from the guest's hardware pane"); | |
51 | ||
52 | Ext.Msg.show({ | |
53 | title: gettext('Cannot remove disk image.'), | |
54 | icon: Ext.Msg.ERROR, | |
f6710aac | 55 | msg: msg, |
f5e17f15 FE |
56 | }); |
57 | return; | |
58 | } | |
59 | } | |
60 | var win = Ext.create('PVE.window.SafeDestroy', { | |
61 | title: Ext.String.format(gettext("Destroy '{0}'"), rec.data.volid), | |
62 | showProgress: true, | |
63 | url: url, | |
f6710aac | 64 | item: { type: 'Image', id: vmid }, |
f5e17f15 | 65 | }).show(); |
1fe81ce9 | 66 | win.on('destroy', reload); |
f6710aac | 67 | }, |
f5e17f15 FE |
68 | }, |
69 | ]; | |
70 | me.useCustomRemoveButton = true; | |
71 | ||
72 | me.callParent(); | |
73 | }, | |
74 | }); |