maxLines: 500,
- initComponent : function() {
+ initComponent: function() {
var me = this;
var nodename = me.pveSelNode.data.node;
throw "no VM ID specified";
}
+ var history = [];
+ var histNum = -1;
var lines = [];
var textbox = Ext.createWidget('panel', {
autoScroll: true,
border: true,
margins: '5 5 5 5',
- bodyStyle: 'font-family: monospace;'
+ bodyStyle: 'font-family: monospace;',
});
var scrollToEnd = function() {
var executeCmd = function(cmd) {
addLine("# " + Ext.htmlEncode(cmd));
+ if (cmd) {
+ history.unshift(cmd);
+ if (history.length > 20) {
+ history.splice(20);
+ }
+ }
+ histNum = -1;
+
refresh();
- PVE.Utils.API2Request({
+ Proxmox.Utils.API2Request({
params: { command: cmd },
url: '/nodes/' + nodename + '/qemu/' + vmid + "/monitor",
method: 'POST',
waitMsgTarget: me,
success: function(response, opts) {
- var res = response.result.data;
+ var res = response.result.data;
Ext.Array.each(res.split('\n'), function(line) {
addLine(Ext.htmlEncode(line));
});
},
failure: function(response, opts) {
Ext.Msg.alert('Error', response.htmlStatus);
- }
+ },
});
};
textbox,
{
region: 'south',
- margins:'0 5 5 5',
+ margins: '0 5 5 5',
border: false,
xtype: 'textfield',
name: 'cmd',
refresh();
},
specialkey: function(f, e) {
- if (e.getKey() === e.ENTER) {
- var cmd = f.getValue();
- f.setValue('');
- executeCmd(cmd);
+ var key = e.getKey();
+ switch (key) {
+ case e.ENTER:
+ var cmd = f.getValue();
+ f.setValue('');
+ executeCmd(cmd);
+ break;
+ case e.PAGE_UP:
+ textbox.scrollBy(0, -0.9*textbox.getHeight(), false);
+ break;
+ case e.PAGE_DOWN:
+ textbox.scrollBy(0, 0.9*textbox.getHeight(), false);
+ break;
+ case e.UP:
+ if (histNum + 1 < history.length) {
+ f.setValue(history[++histNum]);
+ }
+ e.preventDefault();
+ break;
+ case e.DOWN:
+ if (histNum > 0) {
+ f.setValue(history[--histNum]);
+ }
+ e.preventDefault();
+ break;
+ default:
+ break;
}
- }
- }
- }
+ },
+ },
+ },
],
listeners: {
show: function() {
var field = me.query('textfield[name="cmd"]')[0];
field.focus(false, true);
- }
- }
- });
+ },
+ },
+ });
me.callParent();
- }
+ },
});