From 21cd6c09e2a476b5a32f42915feb9e7c2a27ab48 Mon Sep 17 00:00:00 2001 From: Dominik Csapak Date: Tue, 29 Oct 2019 12:08:48 +0100 Subject: [PATCH] NetworkView: add apply config button when the host has ifupdown2 installed, we can hot apply the config add a button to do this if the user does not meet the requirements, the api call will show why and throw an error (without changing anything) the button has to be enabled via 'showApplyBtn', because for now, we do not want it for pmg Signed-off-by: Dominik Csapak --- node/NetworkView.js | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/node/NetworkView.js b/node/NetworkView.js index af2da87..5880c4e 100644 --- a/node/NetworkView.js +++ b/node/NetworkView.js @@ -20,6 +20,8 @@ Ext.define('Proxmox.node.NetworkView', { // order is always the same types: ['bridge', 'bond', 'ovs'], + showApplyBtn: false, + initComponent : function() { var me = this; @@ -45,6 +47,7 @@ Ext.define('Proxmox.node.NetworkView', { var reload = function() { var changeitem = me.down('#changes'); + var apply_btn = me.down('#apply'); Proxmox.Utils.API2Request({ url: baseUrl, failure: function(response, opts) { @@ -60,9 +63,11 @@ Ext.define('Proxmox.node.NetworkView', { if (changes === undefined || changes === '') { changes = gettext("No changes"); changeitem.setHidden(true); + apply_btn.setDisabled(true); } else { changeitem.update("
" + Ext.htmlEncode(changes) + "
"); changeitem.setHidden(false); + apply_btn.setDisabled(false); } } }); @@ -118,6 +123,32 @@ Ext.define('Proxmox.node.NetworkView', { } }); + var apply_btn = Ext.create('Proxmox.button.Button', { + text: gettext('Apply Configuration'), + itemId: 'apply', + disabled: true, + hidden: !me.showApplyBtn, + handler: function() { + Proxmox.Utils.API2Request({ + url: baseUrl, + method: 'PUT', + waitMsgTarget: me, + success: function(response, opts) { + var upid = response.result.data; + + var win = Ext.create('Proxmox.window.TaskProgress', { + taskDone: reload, + upid: upid + }); + win.show(); + }, + failure: function(response, opts) { + Ext.Msg.alert(gettext('Error'), response.htmlStatus); + } + }); + } + }); + var set_button_status = function() { var grid = me.down('gridpanel'); var sm = grid.getSelectionModel(); @@ -265,7 +296,9 @@ Ext.define('Proxmox.node.NetworkView', { } }, edit_btn, - del_btn + del_btn, + ' ', + apply_btn ], items: [ { @@ -383,7 +416,7 @@ Ext.define('Proxmox.node.NetworkView', { itemId: 'changes', tbar: [ gettext('Pending changes') + ' (' + - gettext('Please reboot to activate changes') + ')' + gettext('Please reboot or apply to activate changes') + ')' ], split: true, bodyPadding: 5,