[pve-devel] [manager V2] Add imageRemoveButton
Wolfgang Link
w.link at proxmox.com
Thu Nov 22 11:49:37 CET 2018
If an image has a <vmid> encoded in the image name
and the guest does not exist in the cluster
we can delete it on the GUI.
Also, if a config exists on another node and the storage is local
we can delete.
In all other cases, it is not allowed to delete it.
For safety reason the safe remove windows are used.
---
www/manager6/storage/ContentView.js | 57 +++++++++++++++++++++++++++++++++++++
1 file changed, 57 insertions(+)
Change the message output as t.lamprecht suggest.
diff --git a/www/manager6/storage/ContentView.js b/www/manager6/storage/ContentView.js
index 8716fba3..6e3e9fdb 100644
--- a/www/manager6/storage/ContentView.js
+++ b/www/manager6/storage/ContentView.js
@@ -405,6 +405,8 @@ Ext.define('PVE.storage.ContentView', {
selModel: sm,
enableFn: function(rec) {
if (rec && rec.data.content !== 'images') {
+ imageRemoveButton.setVisible(false);
+ removeButton.setVisible(true);
return true;
}
return false;
@@ -415,6 +417,60 @@ Ext.define('PVE.storage.ContentView', {
baseurl: baseurl + '/'
});
+ var imageRemoveButton = Ext.create('Proxmox.button.Button',{
+ selModel: sm,
+ hidden: true,
+ text: gettext('Remove'),
+ enableFn: function(rec) {
+ if (rec && rec.data.content === 'images') {
+ removeButton.setVisible(false);
+ imageRemoveButton.setVisible(true);
+ return true;
+ }
+ return false;
+ },
+ handler: function(btn, event, rec) {
+ me = this;
+
+ var url = baseurl + '/' + rec.data.volid;
+ var vmid = rec.data.vmid;
+ var storage_path = 'storage/' + nodename + '/' + storage;
+
+ var store = PVE.data.ResourceStore;
+ var vmid_exists = vmid && store.findVMID(vmid);
+ if (vmid_exists) {
+ var guest_node = store.guestNode(vmid);
+ var storage_is_shared = store.storageIsShared(storage_path);
+
+ // allow to delete local backed images if a VMID exists on another node.
+ if (storage_is_shared || guest_node == nodename) {
+ var msg = Ext.String.format(
+ gettext("Cannot remove image, a guest with VMID: '{0}' exists!"),
+ vmid) + '</br>' +
+ gettext("You can delete the image from the guest's hardware pane");
+ Ext.Msg.show({
+ title: gettext('Cannot remove disk image.'),
+ icon: Ext.Msg.ERROR,
+ msg: msg,
+ });
+ return;
+ }
+ }
+ var win = Ext.create('PVE.window.SafeDestroy', {
+ showProgress: true,
+ url: url,
+ item: { type: 'Image', id: vmid },
+ }).show();
+ win.on('destroy', function() {
+ me.statusStore = Ext.create('Proxmox.data.ObjectStore', {
+ url: '/api2/json/nodes/' + nodename + '/storage/' + storage + '/status'
+ });
+ reload();
+
+ });
+ },
+ });
+
me.statusStore = Ext.create('Proxmox.data.ObjectStore', {
url: '/api2/json/nodes/' + nodename + '/storage/' + storage + '/status'
});
@@ -452,6 +508,7 @@ Ext.define('PVE.storage.ContentView', {
}
},
removeButton,
+ imageRemoveButton,
templateButton,
uploadButton,
{
--
2.11.0
More information about the pve-devel
mailing list