ui: buttons: eslint fixes and code cleanup/refactoring

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2021-05-17 19:58:52 +02:00
parent 063997ed16
commit f729096099
2 changed files with 35 additions and 16 deletions

View File

@ -33,14 +33,31 @@ Ext.define('PVE.button.ConsoleButton', {
me.down('#xtermjs').setDisabled(!enable); me.down('#xtermjs').setDisabled(!enable);
}, },
handler: function() { handler: function() { // main, general, handler
var me = this; let me = this;
var consoles = { PVE.Utils.openDefaultConsoleWindow(
spice: me.enableSpice, {
xtermjs: me.enableXtermjs, spice: me.enableSpice,
}; xtermjs: me.enableXtermjs,
PVE.Utils.openDefaultConsoleWindow(consoles, me.consoleType, me.vmid, },
me.nodename, me.consoleName, me.cmd); me.consoleType,
me.vmid,
me.nodename,
me.consoleName,
me.cmd,
);
},
openConsole: function(types) { // used by split-menu buttons
let me = this;
PVE.Utils.openConsoleWindow(
types,
me.consoleType,
me.vmid,
me.nodename,
me.consoleName,
me.cmd,
);
}, },
menu: [ menu: [
@ -50,8 +67,8 @@ Ext.define('PVE.button.ConsoleButton', {
iconCls: 'pve-itype-icon-novnc', iconCls: 'pve-itype-icon-novnc',
type: 'html5', type: 'html5',
handler: function(button) { handler: function(button) {
var me = this.up('button'); let view = this.up('button');
PVE.Utils.openConsoleWindow(button.type, me.consoleType, me.vmid, me.nodename, me.consoleName, me.cmd); view.openConsole(button.type);
}, },
}, },
{ {
@ -61,8 +78,8 @@ Ext.define('PVE.button.ConsoleButton', {
type: 'vv', type: 'vv',
iconCls: 'pve-itype-icon-virt-viewer', iconCls: 'pve-itype-icon-virt-viewer',
handler: function(button) { handler: function(button) {
var me = this.up('button'); let view = this.up('button');
PVE.Utils.openConsoleWindow(button.type, me.consoleType, me.vmid, me.nodename, me.consoleName, me.cmd); view.openConsole(button.type);
}, },
}, },
{ {
@ -71,14 +88,14 @@ Ext.define('PVE.button.ConsoleButton', {
iconCls: 'pve-itype-icon-xtermjs', iconCls: 'pve-itype-icon-xtermjs',
type: 'xtermjs', type: 'xtermjs',
handler: function(button) { handler: function(button) {
var me = this.up('button'); let view = this.up('button');
PVE.Utils.openConsoleWindow(button.type, me.consoleType, me.vmid, me.nodename, me.consoleName, me.cmd); view.openConsole(button.type);
}, },
}, },
], ],
initComponent: function() { initComponent: function() {
var me = this; let me = this;
if (!me.nodename) { if (!me.nodename) {
throw "no node name specified"; throw "no node name specified";

View File

@ -12,7 +12,9 @@ Ext.define('PVE.button.Split', {
selModel: undefined, selModel: undefined,
// if 'false' handler will not be called (button disabled) // if 'false' handler will not be called (button disabled)
enableFn: function(record) { }, enableFn: function(record) {
// do nothing
},
// function(record) or text // function(record) or text
confirmMsg: false, confirmMsg: false,