Skip to content

Commit

Permalink
Merge branch 'proxmox:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
wy414012 authored Nov 11, 2024
2 parents ac3bc6f + 5db7aab commit 09a9fb2
Show file tree
Hide file tree
Showing 14 changed files with 141 additions and 54 deletions.
1 change: 1 addition & 0 deletions www/manager6/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ JSSRC= \
panel/GuestSummary.js \
panel/TemplateStatusView.js \
panel/MultiDiskEdit.js \
panel/TagConfig.js \
tree/ResourceTree.js \
tree/SnapshotTree.js \
tree/ResourceMapTree.js \
Expand Down
4 changes: 4 additions & 0 deletions www/manager6/Utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1960,6 +1960,10 @@ Ext.define('PVE.Utils', {
}
return languageCookie || Proxmox.defaultLang || 'en';
},

formatGuestTaskConfirmation: function(taskType, vmid, guestName) {
return Proxmox.Utils.format_task_description(taskType, `${vmid} (${guestName})`);
},
},

singleton: true,
Expand Down
4 changes: 3 additions & 1 deletion www/manager6/Workspace.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ Ext.define('PVE.StdWorkspace', {
storage: 'PVE.storage.Browser',
sdn: 'PVE.sdn.Browser',
pool: 'pvePoolConfig',
tag: 'pveTagConfig',
};
PVE.curSelectedNode = treeNode;
me.setContent({
Expand Down Expand Up @@ -531,7 +532,8 @@ Ext.define('PVE.StdWorkspace', {
let tagSelectors = [];
['circle', 'dense'].forEach((style) => {
['dark', 'light'].forEach((variant) => {
tagSelectors.push(`.proxmox-tags-${style} .proxmox-tag-${variant}`);
let selector = `.proxmox-tags-${style} :not(.proxmox-tags-full) > .proxmox-tag-${variant}`;
tagSelectors.push(selector);
});
});

Expand Down
28 changes: 28 additions & 0 deletions www/manager6/form/ViewSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,34 @@ Ext.define('PVE.form.ViewSelector', {
// Pool View only lists VMs and Containers
filterfn: ({ data }) => data.type === 'qemu' || data.type === 'lxc' || data.type === 'pool',
},
tags: {
text: gettext('Tag View'),
groups: ['tag'],
filterfn: ({ data }) => data.type === 'qemu' || data.type === 'lxc',
groupRenderer: function(info) {
let tag = PVE.Utils.renderTags(info.tag, PVE.UIOptions.tagOverrides);
return `<span class="proxmox-tags-full">${tag}</span>`;
},
itemMap: function(item) {
let tags = (item.data.tags ?? '').split(/[;, ]/);
if (tags.length === 1 && tags[0] === '') {
return item;
}
let items = [];
for (const tag of tags) {
let id = `${item.data.id}-${tag}`;
let info = Ext.apply({ leaf: true }, item.data);
info.tag = tag;
info.realId = info.id;
info.id = id;
items.push(Ext.create('Ext.data.TreeModel', info));
}
return items;
},
attrMoveChecks: {
tag: (newitem, olditem) => newitem.data.tags !== olditem.data.tags,
},
},
};
let groupdef = Object.entries(default_views).map(([name, config]) => [name, config.text]);

Expand Down
2 changes: 1 addition & 1 deletion www/manager6/grid/ResourceGrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Ext.define('PVE.grid.ResourceGrid', {
return;
}
for (let child of node.childNodes) {
let orgNode = rstore.data.get(child.data.id);
let orgNode = rstore.data.get(child.data.realId ?? child.data.id);
if (orgNode) {
if ((!filterfn || filterfn(child)) && (!textfilter || textfilterMatch(child))) {
nodeidx[child.data.id] = orgNode;
Expand Down
4 changes: 2 additions & 2 deletions www/manager6/lxc/CmdMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Ext.define('PVE.lxc.CmdMenu', {
});
};
let confirmedVMCommand = (cmd, params) => {
let msg = Proxmox.Utils.format_task_description(`vz${cmd}`, info.vmid);
let msg = PVE.Utils.formatGuestTaskConfirmation(`vz${cmd}`, info.vmid, info.name);
Ext.Msg.confirm(gettext('Confirm'), msg, btn => {
if (btn === 'yes') {
vm_command(cmd, params);
Expand Down Expand Up @@ -108,7 +108,7 @@ Ext.define('PVE.lxc.CmdMenu', {
text: gettext('Convert to template'),
iconCls: 'fa fa-fw fa-file-o',
handler: function() {
let msg = Proxmox.Utils.format_task_description('vztemplate', info.vmid);
let msg = PVE.Utils.formatGuestTaskConfirmation('vztemplate', info.vmid, info.name);
Ext.Msg.confirm(gettext('Confirm'), msg, function(btn) {
if (btn === 'yes') {
Proxmox.Utils.API2Request({
Expand Down
6 changes: 3 additions & 3 deletions www/manager6/lxc/Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ Ext.define('PVE.lxc.Config', {
text: gettext('Shutdown'),
disabled: !caps.vms['VM.PowerMgmt'] || !running,
hidden: template,
confirmMsg: Proxmox.Utils.format_task_description('vzshutdown', vmid),
confirmMsg: PVE.Utils.formatGuestTaskConfirmation('vzshutdown', vmid, vm.name),
handler: function() {
vm_command('shutdown');
},
menu: {
items: [{
text: gettext('Reboot'),
disabled: !caps.vms['VM.PowerMgmt'],
confirmMsg: Proxmox.Utils.format_task_description('vzreboot', vmid),
confirmMsg: PVE.Utils.formatGuestTaskConfirmation('vzreboot', vmid, vm.name),
tooltip: Ext.String.format(gettext('Reboot {0}'), 'CT'),
handler: function() {
vm_command("reboot");
Expand Down Expand Up @@ -124,7 +124,7 @@ Ext.define('PVE.lxc.Config', {
xtype: 'pveMenuItem',
iconCls: 'fa fa-fw fa-file-o',
hidden: !caps.vms['VM.Allocate'],
confirmMsg: Proxmox.Utils.format_task_description('vztemplate', vmid),
confirmMsg: PVE.Utils.formatGuestTaskConfirmation('vztemplate', vmid, vm.name),
handler: function() {
Proxmox.Utils.API2Request({
url: base_url + '/template',
Expand Down
1 change: 1 addition & 0 deletions www/manager6/lxc/MPEdit.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ Ext.define('PVE.lxc.MountPointInputPanel', {
fieldLabel: gettext('Mount options'),
deleteEmpty: false,
comboItems: [
['discard', 'discard'],
['lazytime', 'lazytime'],
['noatime', 'noatime'],
['nodev', 'nodev'],
Expand Down
7 changes: 7 additions & 0 deletions www/manager6/panel/TagConfig.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Ext.define('PVE.panel.TagConfig', {
extend: 'PVE.panel.Config',
alias: 'widget.pveTagConfig',

//onlineHelp: 'gui_tags', // TODO: use this one once available
onlineHelp: 'chapter_gui',
});
39 changes: 8 additions & 31 deletions www/manager6/qemu/CloudInit.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ Ext.define('PVE.qemu.CloudInit', {
waitMsgTarget: view,
method: 'PUT',
params: params,
failure: function(response, opts) {
Ext.Msg.alert('Error', response.htmlStatus);
},
failure: response => Ext.Msg.alert('Error', response.htmlStatus),
callback: function() {
view.reload();
},
Expand Down Expand Up @@ -82,38 +80,14 @@ Ext.define('PVE.qemu.CloudInit', {
text: gettext('Regenerate Image'),
handler: function() {
let view = this.up('grid');
var eject_params = {};
var insert_params = {};
let disk = PVE.Parser.parseQemuDrive(view.ciDriveId, view.ciDrive);
var storage = '';
var stormatch = disk.file.match(/^([^:]+):/);
if (stormatch) {
storage = stormatch[1];
}
eject_params[view.ciDriveId] = 'none,media=cdrom';
insert_params[view.ciDriveId] = storage + ':cloudinit';

var failure = function(response, opts) {
Ext.Msg.alert('Error', response.htmlStatus);
};

Proxmox.Utils.API2Request({
url: view.baseurl + '/config',
url: view.baseurl + '/cloudinit',
waitMsgTarget: view,
method: 'PUT',
params: eject_params,
failure: failure,
failure: response => Ext.Msg.alert('Error', response.htmlStatus),
callback: function() {
Proxmox.Utils.API2Request({
url: view.baseurl + '/config',
waitMsgTarget: view,
method: 'PUT',
params: insert_params,
failure: failure,
callback: function() {
view.reload();
},
});
view.reload();
},
});
},
Expand Down Expand Up @@ -142,7 +116,10 @@ Ext.define('PVE.qemu.CloudInit', {
}
});

me.down('#savebtn').setDisabled(!found);
let caps = Ext.state.Manager.get('GuiCap');
let canRegenerateImage = !!caps.vms['VM.Config.Cloudinit'];
me.down('#savebtn').setDisabled(!found || !canRegenerateImage);

me.setDisabled(!found);
if (!found) {
me.getView().mask(gettext('No CloudInit Drive found'), ['pve-static-mask']);
Expand Down
4 changes: 2 additions & 2 deletions www/manager6/qemu/CmdMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Ext.define('PVE.qemu.CmdMenu', {
};
let confirmedVMCommand = (cmd, params, confirmTask) => {
let task = confirmTask || `qm${cmd}`;
let msg = Proxmox.Utils.format_task_description(task, info.vmid);
let msg = PVE.Utils.formatGuestTaskConfirmation(task, info.vmid, info.name);
Ext.Msg.confirm(gettext('Confirm'), msg, btn => {
if (btn === 'yes') {
vm_command(cmd, params);
Expand Down Expand Up @@ -136,7 +136,7 @@ Ext.define('PVE.qemu.CmdMenu', {
iconCls: 'fa fa-fw fa-file-o',
hidden: !caps.vms['VM.Allocate'],
handler: function() {
let msg = Proxmox.Utils.format_task_description('qmtemplate', info.vmid);
let msg = PVE.Utils.formatGuestTaskConfirmation('qmtemplate', info.vmid, info.name);
Ext.Msg.confirm(gettext('Confirm'), msg, btn => {
if (btn === 'yes') {
Proxmox.Utils.API2Request({
Expand Down
12 changes: 6 additions & 6 deletions www/manager6/qemu/Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ Ext.define('PVE.qemu.Config', {
xtype: 'pveMenuItem',
iconCls: 'fa fa-fw fa-file-o',
hidden: !caps.vms['VM.Allocate'],
confirmMsg: Proxmox.Utils.format_task_description('qmtemplate', vmid),
confirmMsg: PVE.Utils.formatGuestTaskConfirmation('qmtemplate', vmid, vm.name),
handler: function() {
Proxmox.Utils.API2Request({
url: base_url + '/template',
Expand Down Expand Up @@ -142,7 +142,7 @@ Ext.define('PVE.qemu.Config', {
text: gettext('Shutdown'),
disabled: !caps.vms['VM.PowerMgmt'] || !running,
hidden: template,
confirmMsg: Proxmox.Utils.format_task_description('qmshutdown', vmid),
confirmMsg: PVE.Utils.formatGuestTaskConfirmation('qmshutdown', vmid, vm.name),
handler: function() {
vm_command('shutdown');
},
Expand All @@ -151,23 +151,23 @@ Ext.define('PVE.qemu.Config', {
text: gettext('Reboot'),
disabled: !caps.vms['VM.PowerMgmt'],
tooltip: Ext.String.format(gettext('Shutdown, apply pending changes and reboot {0}'), 'VM'),
confirmMsg: Proxmox.Utils.format_task_description('qmreboot', vmid),
confirmMsg: PVE.Utils.formatGuestTaskConfirmation('qmreboot', vmid, vm.name),
handler: function() {
vm_command("reboot");
},
iconCls: 'fa fa-refresh',
}, {
text: gettext('Pause'),
disabled: !caps.vms['VM.PowerMgmt'],
confirmMsg: Proxmox.Utils.format_task_description('qmpause', vmid),
confirmMsg: PVE.Utils.formatGuestTaskConfirmation('qmpause', vmid, vm.name),
handler: function() {
vm_command("suspend");
},
iconCls: 'fa fa-pause',
}, {
text: gettext('Hibernate'),
disabled: !caps.vms['VM.PowerMgmt'],
confirmMsg: Proxmox.Utils.format_task_description('qmsuspend', vmid),
confirmMsg: PVE.Utils.formatGuestTaskConfirmation('qmsuspend', vmid, vm.name),
tooltip: gettext('Suspend to disk'),
handler: function() {
vm_command("suspend", { todisk: 1 });
Expand All @@ -189,7 +189,7 @@ Ext.define('PVE.qemu.Config', {
text: gettext('Reset'),
disabled: !caps.vms['VM.PowerMgmt'],
tooltip: Ext.String.format(gettext('Reset {0} immediately'), 'VM'),
confirmMsg: Proxmox.Utils.format_task_description('qmreset', vmid),
confirmMsg: PVE.Utils.formatGuestTaskConfirmation('qmreset', vmid, vm.name),
handler: function() {
vm_command("reset");
},
Expand Down
Loading

0 comments on commit 09a9fb2

Please sign in to comment.