mirror of
https://git.proxmox.com/git/pve-manager
synced 2025-05-05 09:55:19 +00:00
create ImageView and use it for VM and CT images
The enableFn's that were responsible for switching between the image remove button and the standard remove button are not needed anymore. Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
This commit is contained in:
parent
4323c70b47
commit
f5e17f156a
@ -242,6 +242,7 @@ JSSRC= \
|
||||
storage/ContentView.js \
|
||||
storage/DirEdit.js \
|
||||
storage/GlusterFsEdit.js \
|
||||
storage/ImageView.js \
|
||||
storage/IScsiEdit.js \
|
||||
storage/LVMEdit.js \
|
||||
storage/LvmThinEdit.js \
|
||||
|
@ -59,7 +59,7 @@ Ext.define('PVE.storage.Browser', {
|
||||
}
|
||||
if (contents.includes('images')) {
|
||||
items.push({
|
||||
xtype: 'pveStorageContentView',
|
||||
xtype: 'pveStorageImageView',
|
||||
title: gettext('Disk Images'),
|
||||
iconCls: 'fa fa-hdd-o',
|
||||
itemId: 'contentImages',
|
||||
@ -82,7 +82,7 @@ Ext.define('PVE.storage.Browser', {
|
||||
}
|
||||
if (contents.includes('rootdir')) {
|
||||
items.push({
|
||||
xtype: 'pveStorageContentView',
|
||||
xtype: 'pveStorageImageView',
|
||||
title: gettext('Container Data'),
|
||||
iconCls: 'fa fa-hdd-o',
|
||||
itemId: 'contentRootdir',
|
||||
|
@ -269,83 +269,25 @@ Ext.define('PVE.storage.ContentView', {
|
||||
}
|
||||
});
|
||||
|
||||
var imageRemoveButton;
|
||||
var removeButton = Ext.create('Proxmox.button.StdRemoveButton',{
|
||||
selModel: sm,
|
||||
delay: 5,
|
||||
enableFn: function(rec) {
|
||||
if (rec && rec.data.content !== 'images' &&
|
||||
rec.data.content !== 'rootdir') {
|
||||
imageRemoveButton.setVisible(false);
|
||||
removeButton.setVisible(true);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
callback: function() {
|
||||
reload();
|
||||
},
|
||||
baseurl: baseurl + '/'
|
||||
});
|
||||
|
||||
imageRemoveButton = Ext.create('Proxmox.button.Button',{
|
||||
selModel: sm,
|
||||
hidden: true,
|
||||
text: gettext('Remove'),
|
||||
enableFn: function(rec) {
|
||||
if (rec && (rec.data.content === 'images' ||
|
||||
rec.data.content === 'rootdir')) {
|
||||
removeButton.setVisible(false);
|
||||
imageRemoveButton.setVisible(true);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
handler: function(btn, event, rec) {
|
||||
var url = baseurl + '/' + rec.data.volid;
|
||||
var vmid = rec.data.vmid;
|
||||
|
||||
var store = PVE.data.ResourceStore;
|
||||
|
||||
if (vmid && store.findVMID(vmid)) {
|
||||
var guest_node = store.guestNode(vmid);
|
||||
var storage_path = 'storage/' + nodename + '/' + storage;
|
||||
|
||||
// allow to delete local backed images if a VMID exists on another node.
|
||||
if (store.storageIsShared(storage_path) || guest_node == nodename) {
|
||||
var msg = Ext.String.format(
|
||||
gettext("Cannot remove image, a guest with VMID '{0}' exists!"), vmid);
|
||||
msg += '<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', {
|
||||
title: Ext.String.format(gettext("Destroy '{0}'"), rec.data.volid),
|
||||
showProgress: true,
|
||||
url: url,
|
||||
item: { type: 'Image', id: vmid }
|
||||
}).show();
|
||||
win.on('destroy', function() {
|
||||
reload();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
if (!me.tbar) {
|
||||
me.tbar = [];
|
||||
}
|
||||
if (me.useUploadButton) {
|
||||
me.tbar.push(uploadButton);
|
||||
}
|
||||
if (!me.useCustomRemoveButton) {
|
||||
me.tbar.push(removeButton);
|
||||
}
|
||||
me.tbar.push(
|
||||
removeButton,
|
||||
imageRemoveButton,
|
||||
'->',
|
||||
gettext('Search') + ':', ' ',
|
||||
{
|
||||
|
76
www/manager6/storage/ImageView.js
Normal file
76
www/manager6/storage/ImageView.js
Normal file
@ -0,0 +1,76 @@
|
||||
Ext.define('PVE.storage.ImageView', {
|
||||
extend: 'PVE.storage.ContentView',
|
||||
|
||||
alias: 'widget.pveStorageImageView',
|
||||
|
||||
initComponent: function() {
|
||||
var me = this;
|
||||
|
||||
var nodename = me.nodename = me.pveSelNode.data.node;
|
||||
if (!me.nodename) {
|
||||
throw "no node name specified";
|
||||
}
|
||||
|
||||
var storage = me.storage = me.pveSelNode.data.storage;
|
||||
if (!me.storage) {
|
||||
throw "no storage ID specified";
|
||||
}
|
||||
|
||||
if (!me.content || (me.content !== 'images' && me.content !== 'rootdir')) {
|
||||
throw "content needs to be either 'images' or 'rootdir'";
|
||||
}
|
||||
|
||||
var sm = me.sm = Ext.create('Ext.selection.RowModel', {});
|
||||
|
||||
var reload = function() {
|
||||
me.store.load();
|
||||
}
|
||||
|
||||
me.tbar = [
|
||||
{
|
||||
xtype: 'proxmoxButton',
|
||||
selModel: sm,
|
||||
text: gettext('Remove'),
|
||||
disabled: true,
|
||||
handler: function(btn, event, rec) {
|
||||
var url = "/nodes/" + nodename + "/storage/" + storage +
|
||||
"/content" + '/' + rec.data.volid;
|
||||
var vmid = rec.data.vmid;
|
||||
|
||||
var store = PVE.data.ResourceStore;
|
||||
|
||||
if (vmid && store.findVMID(vmid)) {
|
||||
var guest_node = store.guestNode(vmid);
|
||||
var storage_path = 'storage/' + nodename + '/' + storage;
|
||||
|
||||
// allow to delete local backed images if a VMID exists on another node.
|
||||
if (store.storageIsShared(storage_path) || guest_node == nodename) {
|
||||
var msg = Ext.String.format(
|
||||
gettext("Cannot remove image, a guest with VMID '{0}' exists!"), vmid);
|
||||
msg += '<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', {
|
||||
title: Ext.String.format(gettext("Destroy '{0}'"), rec.data.volid),
|
||||
showProgress: true,
|
||||
url: url,
|
||||
item: { type: 'Image', id: vmid }
|
||||
}).show();
|
||||
win.on('destroy', function() {
|
||||
reload();
|
||||
});
|
||||
}
|
||||
},
|
||||
];
|
||||
me.useCustomRemoveButton = true;
|
||||
|
||||
me.callParent();
|
||||
},
|
||||
});
|
Loading…
Reference in New Issue
Block a user