* [pve-devel] [PATCH manager/qemu-server/container v3 0/1] Add checkbox for automatic restart of CT/VM after rollback @ 2022-09-14 8:30 Stefan Hanreich 2022-09-14 8:30 ` [pve-devel] [PATCH pve-container v3 1/1] fix #4228: add start parameter to rollback endpoint for automatic restarting of CT Stefan Hanreich ` (2 more replies) 0 siblings, 3 replies; 6+ messages in thread From: Stefan Hanreich @ 2022-09-14 8:30 UTC (permalink / raw) To: pve-devel Since the previous patch we have decided to implement a new component that can be used for creating confirmation dialogs with form fields. The new component should be similar to the MessageBox, except it can contain form fields. It also automatically calls an API endpoint when the user confirms the message. pve-container: Stefan Hanreich (1): fix #4228: add start parameter to rollback endpoint for automatic restarting of CT src/PVE/API2/LXC/Snapshot.pm | 10 ++++++++++ 1 file changed, 10 insertions(+) pve-manager: Stefan Hanreich (1): fix #4228: ui: add automatic restarting to snapshot rollback dialog www/manager6/Makefile | 1 + www/manager6/tree/SnapshotTree.js | 42 +++++++--- www/manager6/window/Confirm.js | 135 ++++++++++++++++++++++++++++++ 3 files changed, 165 insertions(+), 13 deletions(-) create mode 100644 www/manager6/window/Confirm.js qemu-server: Stefan Hanreich (1): fix #4228: add start parameter to rollback endpoint for automatic restarting of VM PVE/API2/Qemu.pm | 10 ++++++++++ 1 file changed, 10 insertions(+) -- 2.30.2 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [pve-devel] [PATCH pve-container v3 1/1] fix #4228: add start parameter to rollback endpoint for automatic restarting of CT 2022-09-14 8:30 [pve-devel] [PATCH manager/qemu-server/container v3 0/1] Add checkbox for automatic restart of CT/VM after rollback Stefan Hanreich @ 2022-09-14 8:30 ` Stefan Hanreich 2022-11-08 17:16 ` [pve-devel] applied: " Thomas Lamprecht 2022-09-14 8:30 ` [pve-devel] [PATCH qemu-server v3 1/1] fix #4228: add start parameter to rollback endpoint for automatic restarting of VM Stefan Hanreich 2022-09-14 8:30 ` [pve-devel] [PATCH pve-manager v3 1/1] fix #4228: ui: add automatic restarting to snapshot rollback dialog Stefan Hanreich 2 siblings, 1 reply; 6+ messages in thread From: Stefan Hanreich @ 2022-09-14 8:30 UTC (permalink / raw) To: pve-devel Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com> --- src/PVE/API2/LXC/Snapshot.pm | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/PVE/API2/LXC/Snapshot.pm b/src/PVE/API2/LXC/Snapshot.pm index 4be16ad..0999fbc 100644 --- a/src/PVE/API2/LXC/Snapshot.pm +++ b/src/PVE/API2/LXC/Snapshot.pm @@ -272,6 +272,12 @@ __PACKAGE__->register_method({ node => get_standard_option('pve-node'), vmid => get_standard_option('pve-vmid'), snapname => get_standard_option('pve-snapshot-name'), + start => { + type => 'boolean', + description => "Whether the container should get started after rolling back successfully", + optional => 1, + default => 0, + }, }, }, returns => { @@ -294,6 +300,10 @@ __PACKAGE__->register_method({ my $realcmd = sub { PVE::Cluster::log_msg('info', $authuser, "rollback snapshot LXC $vmid: $snapname"); PVE::LXC::Config->snapshot_rollback($vmid, $snapname); + + if ($param->{start}) { + PVE::API2::LXC::Status->vm_start({ vmid => $vmid, node => $node }) + } }; my $worker = sub { -- 2.30.2 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [pve-devel] applied: [PATCH pve-container v3 1/1] fix #4228: add start parameter to rollback endpoint for automatic restarting of CT 2022-09-14 8:30 ` [pve-devel] [PATCH pve-container v3 1/1] fix #4228: add start parameter to rollback endpoint for automatic restarting of CT Stefan Hanreich @ 2022-11-08 17:16 ` Thomas Lamprecht 0 siblings, 0 replies; 6+ messages in thread From: Thomas Lamprecht @ 2022-11-08 17:16 UTC (permalink / raw) To: Proxmox VE development discussion, Stefan Hanreich Am 14/09/2022 um 10:30 schrieb Stefan Hanreich: > Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com> > --- > src/PVE/API2/LXC/Snapshot.pm | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > applied, thanks! ^ permalink raw reply [flat|nested] 6+ messages in thread
* [pve-devel] [PATCH qemu-server v3 1/1] fix #4228: add start parameter to rollback endpoint for automatic restarting of VM 2022-09-14 8:30 [pve-devel] [PATCH manager/qemu-server/container v3 0/1] Add checkbox for automatic restart of CT/VM after rollback Stefan Hanreich 2022-09-14 8:30 ` [pve-devel] [PATCH pve-container v3 1/1] fix #4228: add start parameter to rollback endpoint for automatic restarting of CT Stefan Hanreich @ 2022-09-14 8:30 ` Stefan Hanreich 2022-11-08 17:16 ` [pve-devel] applied: " Thomas Lamprecht 2022-09-14 8:30 ` [pve-devel] [PATCH pve-manager v3 1/1] fix #4228: ui: add automatic restarting to snapshot rollback dialog Stefan Hanreich 2 siblings, 1 reply; 6+ messages in thread From: Stefan Hanreich @ 2022-09-14 8:30 UTC (permalink / raw) To: pve-devel Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com> --- PVE/API2/Qemu.pm | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm index 3ec31c2..e6f8f31 100644 --- a/PVE/API2/Qemu.pm +++ b/PVE/API2/Qemu.pm @@ -4764,6 +4764,12 @@ __PACKAGE__->register_method({ node => get_standard_option('pve-node'), vmid => get_standard_option('pve-vmid', { completion => \&PVE::QemuServer::complete_vmid }), snapname => get_standard_option('pve-snapshot-name'), + start => { + type => 'boolean', + description => "Whether the VM should get started after rolling back successfully", + optional => 1, + default => 0, + }, }, }, returns => { @@ -4786,6 +4792,10 @@ __PACKAGE__->register_method({ my $realcmd = sub { PVE::Cluster::log_msg('info', $authuser, "rollback snapshot VM $vmid: $snapname"); PVE::QemuConfig->snapshot_rollback($vmid, $snapname); + + if ($param->{start}) { + PVE::API2::Qemu->vm_start({ vmid => $vmid, node => $node }); + } }; my $worker = sub { -- 2.30.2 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [pve-devel] applied: [PATCH qemu-server v3 1/1] fix #4228: add start parameter to rollback endpoint for automatic restarting of VM 2022-09-14 8:30 ` [pve-devel] [PATCH qemu-server v3 1/1] fix #4228: add start parameter to rollback endpoint for automatic restarting of VM Stefan Hanreich @ 2022-11-08 17:16 ` Thomas Lamprecht 0 siblings, 0 replies; 6+ messages in thread From: Thomas Lamprecht @ 2022-11-08 17:16 UTC (permalink / raw) To: Proxmox VE development discussion, Stefan Hanreich Am 14/09/2022 um 10:30 schrieb Stefan Hanreich: > Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com> > --- > PVE/API2/Qemu.pm | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > applied, thanks! ^ permalink raw reply [flat|nested] 6+ messages in thread
* [pve-devel] [PATCH pve-manager v3 1/1] fix #4228: ui: add automatic restarting to snapshot rollback dialog 2022-09-14 8:30 [pve-devel] [PATCH manager/qemu-server/container v3 0/1] Add checkbox for automatic restart of CT/VM after rollback Stefan Hanreich 2022-09-14 8:30 ` [pve-devel] [PATCH pve-container v3 1/1] fix #4228: add start parameter to rollback endpoint for automatic restarting of CT Stefan Hanreich 2022-09-14 8:30 ` [pve-devel] [PATCH qemu-server v3 1/1] fix #4228: add start parameter to rollback endpoint for automatic restarting of VM Stefan Hanreich @ 2022-09-14 8:30 ` Stefan Hanreich 2 siblings, 0 replies; 6+ messages in thread From: Stefan Hanreich @ 2022-09-14 8:30 UTC (permalink / raw) To: pve-devel Added a new component, Confirm. It acts similar to a messagebox, except it can contain form elements. It also automatically calls an API endpoint when the user confirms the message. This component was then used for implementing the new rollback dialog window. Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com> --- www/manager6/Makefile | 1 + www/manager6/tree/SnapshotTree.js | 42 +++++++--- www/manager6/window/Confirm.js | 135 ++++++++++++++++++++++++++++++ 3 files changed, 165 insertions(+), 13 deletions(-) create mode 100644 www/manager6/window/Confirm.js diff --git a/www/manager6/Makefile b/www/manager6/Makefile index d16770b1..a1d179f5 100644 --- a/www/manager6/Makefile +++ b/www/manager6/Makefile @@ -97,6 +97,7 @@ JSSRC= \ window/BulkAction.js \ window/CephInstall.js \ window/Clone.js \ + window/Confirm.js \ window/FirewallEnableEdit.js \ window/FirewallLograteEdit.js \ window/LoginWindow.js \ diff --git a/www/manager6/tree/SnapshotTree.js b/www/manager6/tree/SnapshotTree.js index 97268072..856126c5 100644 --- a/www/manager6/tree/SnapshotTree.js +++ b/www/manager6/tree/SnapshotTree.js @@ -61,7 +61,7 @@ Ext.define('PVE.guest.SnapshotTree', { me.mon(win, 'destroy', me.reload, me); }, - snapshotAction: function(action, method) { + remove: function() { let me = this; let view = me.getView(); let vm = me.getViewModel(); @@ -73,8 +73,8 @@ Ext.define('PVE.guest.SnapshotTree', { let vmid = vm.get('vmid'); Proxmox.Utils.API2Request({ - url: `/nodes/${nodename}/${type}/${vmid}/snapshot/${snapname}/${action}`, - method: method, + url: `/nodes/${nodename}/${type}/${vmid}/snapshot/${snapname}`, + method: 'DELETE', waitMsgTarget: view, callback: function() { me.reload(); @@ -90,12 +90,6 @@ Ext.define('PVE.guest.SnapshotTree', { }); }, - rollback: function() { - this.snapshotAction('rollback', 'POST'); - }, - remove: function() { - this.snapshotAction('', 'DELETE'); - }, cancel: function() { this.load_task.cancel(); }, @@ -255,14 +249,36 @@ Ext.define('PVE.guest.SnapshotTree', { bind: { disabled: '{!canRollback}', }, - confirmMsg: function() { + handler: function() { let view = this.up('treepanel'); + let viewModel = view.getViewModel(); + let rec = view.getSelection()[0]; - let vmid = view.getViewModel().get('vmid'); - return Proxmox.Utils.format_task_description('qmrollback', vmid) + + let vmid = viewModel.get('vmid'); + let label = Proxmox.Utils.format_task_description('qmrollback', vmid) + ` '${rec.data.name}'? ${gettext("Current state will be lost.")}`; + + let nodename = viewModel.get('nodename'); + let type = viewModel.get('type'); + let snapname = viewModel.get('selected'); + if (!snapname) { return; } + + Ext.create({ + xtype: 'proxmoxConfirmWindow', + autoShow: true, + message: label, + url: `/nodes/${nodename}/${type}/${vmid}/snapshot/${snapname}/rollback`, + hasProgress: true, + formItems: [ + { + xtype: 'proxmoxcheckbox', + name: 'start', + margin: '5 0 0 0', + boxLabel: gettext('Start guest after rollback'), + }, + ], + }); }, - handler: 'rollback', }, '-', { diff --git a/www/manager6/window/Confirm.js b/www/manager6/window/Confirm.js new file mode 100644 index 00000000..98a0ba0f --- /dev/null +++ b/www/manager6/window/Confirm.js @@ -0,0 +1,135 @@ +Ext.define('PVE.window.Confirm', { + extend: 'Ext.window.Window', + alias: 'widget.proxmoxConfirmWindow', + + layout: { + type: 'hbox', + align: 'center', + }, + + bodyPadding: 10, + + modal: true, + resizable: false, + + buttonAlign: 'center', + + hasProgress: false, + + message: null, + + VALID_ICON_TYPES: ['info', 'warning', 'question', 'error'], + + ICON_CLASS_PREFIX: Ext.baseCSSPrefix + 'message-box-', + + /** + * can be one of VALID_ICON_TYPES + */ + iconType: 'question', + + /** + * The components that should be rendered to this component's InputPanel + */ + formItems: [], + + showProgress: function(response) { + let upid = response.result.data; + + if (!upid) { + return; + } + + Ext.create('Proxmox.window.TaskProgress', { + autoShow: true, + upid: upid, + }); + }, + + yesHandler: function() { + Proxmox.Utils.API2Request({ + method: 'POST', + url: this.url, + params: this.inputPanel.getValues(), + success: (response, options) => { + if (this.hasProgress) { + this.showProgress(response); + } + }, + failure: (response, options) => { + Ext.Msg.alert(gettext('Error'), response.htmlStatus); + }, + }); + + this.close(); + }, + + noHandler: function() { + this.close(); + }, + + initButtons: function() { + return [ + { + text: 'Yes', + handler: () => this.yesHandler(), + }, + { + text: 'No', + handler: () => this.noHandler(), + }, + ]; + }, + + initIcon: function() { + return { + xtype: 'component', + docked: 'left', + width: 40, + height: 40, + cls: this.ICON_CLASS_PREFIX + this.iconType, + }; + }, + + initInputPanel: function() { + return Ext.create({ + xtype: 'inputpanel', + items: this.formItems, + }); + }, + + initLabel: function() { + return { + xtype: 'label', + html: this.message, + }; + }, + + initComponent: function() { + if (!this.url) { + throw 'URL parameter required!'; + } + + if (!this.VALID_ICON_TYPES.includes(this.iconType)) { + throw 'Invalid icon type specified!'; + } + + this.title = this.title || gettext('Confirm'); + + this.buttons = this.initButtons(); + + if (this.message) { + this.formItems.unshift( + this.initLabel(), + ); + } + + this.inputPanel = this.initInputPanel(); + + this.items = [ + this.initIcon(), + this.inputPanel, + ]; + + this.callParent(); + }, +}); -- 2.30.2 ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-11-08 17:16 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2022-09-14 8:30 [pve-devel] [PATCH manager/qemu-server/container v3 0/1] Add checkbox for automatic restart of CT/VM after rollback Stefan Hanreich 2022-09-14 8:30 ` [pve-devel] [PATCH pve-container v3 1/1] fix #4228: add start parameter to rollback endpoint for automatic restarting of CT Stefan Hanreich 2022-11-08 17:16 ` [pve-devel] applied: " Thomas Lamprecht 2022-09-14 8:30 ` [pve-devel] [PATCH qemu-server v3 1/1] fix #4228: add start parameter to rollback endpoint for automatic restarting of VM Stefan Hanreich 2022-11-08 17:16 ` [pve-devel] applied: " Thomas Lamprecht 2022-09-14 8:30 ` [pve-devel] [PATCH pve-manager v3 1/1] fix #4228: ui: add automatic restarting to snapshot rollback dialog Stefan Hanreich
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox