[pve-devel] [manager 6/6] Add imageRemoveButton
Wolfgang Link
w.link at proxmox.com
Wed Nov 21 17:05:39 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 | 55 +++++++++++++++++++++++++++++++++++++
1 file changed, 55 insertions(+)
diff --git a/www/manager6/storage/ContentView.js b/www/manager6/storage/ContentView.js
index 8716fba3..0b2bce4d 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,58 @@ 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);
+ if (storage_is_shared || guest_node == nodename) {
+ var msg = '<p><b>' +
+ gettext("Can't remove image Guest exists.")
+ + '</p></b>' +
+ gettext('Remove Image from guest hardware configuration.');
+ Ext.Msg.show({
+ title: gettext('Not Allowed to remove the 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 +506,7 @@ Ext.define('PVE.storage.ContentView', {
}
},
removeButton,
+ imageRemoveButton,
templateButton,
uploadButton,
{
--
2.11.0
More information about the pve-devel
mailing list