From ecb53af6d9da526cd2ec5381c767eb71bf99714b Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Thu, 30 Apr 2020 12:11:08 +0200 Subject: [PATCH] add ServerStatus.js GUI with Reboot and Shutdown buttons --- www/Makefile | 1 + www/ServerAdministration.js | 8 +++--- www/ServerStatus.js | 49 +++++++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 4 deletions(-) create mode 100644 www/ServerStatus.js diff --git a/www/Makefile b/www/Makefile index 461b5522..429da3f8 100644 --- a/www/Makefile +++ b/www/Makefile @@ -16,6 +16,7 @@ JSSRC= \ DataStoreConfig.js \ DataStoreStatus.js \ DataStoreContent.js \ + ServerStatus.js \ ServerAdministration.js \ Dashboard.js \ NavigationTree.js \ diff --git a/www/ServerAdministration.js b/www/ServerAdministration.js index de3522d7..edbc0ee3 100644 --- a/www/ServerAdministration.js +++ b/www/ServerAdministration.js @@ -18,10 +18,10 @@ Ext.define('PBS.ServerAdministration', { }, items: [ -// { -// xtype: 'pbsServerStatus', -// itemId: 'status' -// }, + { + xtype: 'pbsServerStatus', + itemId: 'status' + }, { xtype: 'proxmoxNodeServiceView', title: gettext('Services'), diff --git a/www/ServerStatus.js b/www/ServerStatus.js new file mode 100644 index 00000000..808f4d56 --- /dev/null +++ b/www/ServerStatus.js @@ -0,0 +1,49 @@ +Ext.define('PBS.ServerStatus', { + extend: 'Ext.panel.Panel', + alias: 'widget.pbsServerStatus', + + title: gettext('ServerStatus'), + + html: "Add Something usefule here ?", + + initComponent: function() { + var me = this; + + var node_command = function(cmd) { + Proxmox.Utils.API2Request({ + params: { command: cmd }, + url: '/nodes/localhost/status', + method: 'POST', + waitMsgTarget: me, + failure: function(response, opts) { + Ext.Msg.alert(gettext('Error'), response.htmlStatus); + } + }); + }; + + var restartBtn = Ext.create('Proxmox.button.Button', { + text: gettext('Reboot'), + dangerous: true, + confirmMsg: gettext("Reboot backup server?"), + handler: function() { + node_command('reboot'); + }, + iconCls: 'fa fa-undo' + }); + + var shutdownBtn = Ext.create('Proxmox.button.Button', { + text: gettext('Shutdown'), + dangerous: true, + confirmMsg: gettext("Shutdown backup server?"), + handler: function() { + node_command('shutdown'); + }, + iconCls: 'fa fa-power-off' + }); + + me.tbar = [ restartBtn, shutdownBtn ]; + + me.callParent(); + } + +}); -- 2.39.5