Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff -u /usr/share/pve-manager/js/pvemanagerlib.js.orig /usr/share/pve-manager/js/pvemanagerlib.js
- --- /usr/share/pve-manager/js/pvemanagerlib.js.orig 2019-12-04 13:57:35.147696162 +0100
- +++ /usr/share/pve-manager/js/pvemanagerlib.js 2019-12-13 18:04:18.429662045 +0100
- @@ -9669,6 +9669,173 @@
- me.callParent();
- }
- });
- +
- +/* Popup a message window
- + * where the user has to manually enter the nodename
- + * to enable the reboot/shutdown button
- + */
- +Ext.define('PVE.window.SafeNodeCommand', {
- + extend: 'Ext.window.Window',
- + alias: 'widget.pveSafeNodeCommand',
- +
- + title: gettext('Confirm'),
- + modal: true,
- + buttonAlign: 'center',
- + bodyPadding: 10,
- + width: 450,
- + layout: { type:'hbox' },
- + defaultFocus: 'confirmField',
- + showProgress: false,
- +
- + config: {
- + item: {
- + nodename: undefined,
- + command: undefined
- + },
- + url: undefined,
- + params: {}
- + },
- +
- + /*
- + getParams: function() {
- + var me = this;
- + if (Ext.Object.isEmpty(me.params)) {
- + return '';
- + }
- + return '?' + Ext.Object.toQueryString(me.params);
- + },
- + */
- +
- + controller: {
- +
- + xclass: 'Ext.app.ViewController',
- +
- + control: {
- + 'field[name=confirm]': {
- + change: function(f, value) {
- + var view = this.getView();
- + var commandButton = this.lookupReference('commandButton');
- + if (value === view.getItem().nodename.toString()) {
- + commandButton.enable();
- + } else {
- + commandButton.disable();
- + }
- + },
- + specialkey: function (field, event) {
- + var commandButton = this.lookupReference('commandButton');
- + if (!commandButton.isDisabled() && event.getKey() == event.ENTER) {
- + commandButton.fireEvent('click', commandButton, event);
- + }
- + }
- + },
- + 'button[reference=abortButton]': {
- + click: function() {
- + var view = this.getView();
- + view.close();
- + }
- + },
- + 'button[reference=commandButton]': {
- + click: function() {
- + var view = this.getView();
- +
- + Proxmox.Utils.API2Request({
- + params: { command: view.getItem().command },
- + url: '/nodes/' + view.getItem().nodename + '/status',
- + method: 'POST',
- + waitMsgTarget: view,
- + failure: function(response, opts) {
- + view.close();
- + Ext.Msg.alert('Error', response.htmlStatus);
- + },
- + success: function(response, options) {
- + view.close();
- + }
- + });
- + }
- + }
- + }
- + },
- +
- + items: [
- + {
- + xtype: 'component',
- + cls: [ Ext.baseCSSPrefix + 'message-box-icon',
- + Ext.baseCSSPrefix + 'message-box-warning',
- + Ext.baseCSSPrefix + 'dlg-icon']
- + },
- + {
- + xtype: 'container',
- + flex: 1,
- + layout: {
- + type: 'vbox',
- + align: 'stretch'
- + },
- + items: [
- + {
- + xtype: 'component',
- + reference: 'messageCmp'
- + },
- + {
- + itemId: 'confirmField',
- + reference: 'confirmField',
- + xtype: 'textfield',
- + name: 'confirm',
- + labelWidth: 300,
- + hideTrigger: true,
- + allowBlank: false
- + }
- + ]
- + }
- + ],
- + buttons: [
- + {
- + reference: 'commandButton',
- + text: gettext('Shutdown'),
- + disabled: true
- + },
- + {
- + reference: 'abortButton',
- + text: gettext('Abort'),
- + disabled: false
- + }
- + ],
- +
- + initComponent : function() {
- + var me = this;
- +
- + me.callParent();
- +
- + var item = me.getItem();
- +
- + if (!Ext.isDefined(item.nodename)) {
- + throw "no nodename specified";
- + }
- +
- + var messageCmp = me.lookupReference('messageCmp');
- + var button_text, msg;
- + if (item.command === 'reboot') {
- + msg = Ext.String.format(gettext("Reboot node '{0}'?"), item.nodename);
- + button_text = gettext('Reboot');
- + }
- + else if (item.command === 'shutdown') {
- + msg = Ext.String.format(gettext("Shutdown node '{0}'?"), item.nodename);
- + button_text = gettext('Shutdown');
- + }
- + else {
- + throw "unknown item command specified";
- + }
- + messageCmp.setHtml(msg);
- +
- + var confirmField = me.lookupReference('confirmField');
- + msg = gettext('Please enter the node name to confirm') +
- + ' (' + item.nodename + ')';
- + confirmField.setFieldLabel(msg);
- +
- + var commandButton = me.lookupReference('commandButton');
- + commandButton.setText(button_text);
- + }
- +});
- +
- /* Popup a message window
- * where the user has to manually enter the resource ID
- * to enable the destroy button
- @@ -19913,6 +20080,7 @@
- interval: 1000
- });
- +/* dead code */
- var node_command = function(cmd) {
- Proxmox.Utils.API2Request({
- params: { command: cmd },
- @@ -19979,9 +20147,11 @@
- disabled: !caps.nodes['Sys.PowerMgmt'],
- dangerous: true,
- confirmMsg: Ext.String.format(gettext("Reboot node '{0}'?"), nodename),
- - handler: function() {
- - node_command('reboot');
- - },
- + handler: function() {
- + Ext.create('PVE.window.SafeNodeCommand', {
- + item: { nodename: nodename, command: 'reboot' }
- + }).show();
- + },
- iconCls: 'fa fa-undo'
- });
- @@ -19991,7 +20161,9 @@
- dangerous: true,
- confirmMsg: Ext.String.format(gettext("Shutdown node '{0}'?"), nodename),
- handler: function() {
- - node_command('shutdown');
- + Ext.create('PVE.window.SafeNodeCommand', {
- + item: { nodename: nodename, command: 'shutdown' }
- + }).show();
- },
- iconCls: 'fa fa-power-off'
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement