]>
git.proxmox.com Git - pve-manager.git/blob - www/manager6/qemu/Monitor.js
7f1626e3c4c89324beac8e2d7e42b111e393c8ed
1 Ext
.define('PVE.qemu.Monitor', {
2 extend
: 'Ext.panel.Panel',
4 alias
: 'widget.pveQemuMonitor',
6 // ouput is trimmed when it's over both commandLimit and lineLimit
7 // by removing the first commands and their output
11 initComponent: function() {
14 var nodename
= me
.pveSelNode
.data
.node
;
16 throw "no node name specified";
19 var vmid
= me
.pveSelNode
.data
.vmid
;
21 throw "no VM ID specified";
28 var textbox
= Ext
.createWidget('panel', {
34 bodyStyle
: 'font-family: monospace;',
37 var scrollToEnd = function() {
38 var el
= textbox
.getTargetEl();
39 var dom
= Ext
.getDom(el
);
41 var clientHeight
= dom
.clientHeight
;
42 // BrowserBug: clientHeight reports 0 in IE9 StrictMode
43 // Instead we are using offsetHeight and hardcoding borders
44 if (Ext
.isIE9
&& Ext
.isStrict
) {
45 clientHeight
= dom
.offsetHeight
+ 2;
47 dom
.scrollTop
= dom
.scrollHeight
- clientHeight
;
50 var refresh = function() {
51 textbox
.update(`<pre>${commands.flat(2).join('\n')}</pre>`);
55 let recordInput
= line
=> {
56 commands
.push([line
]);
58 // drop oldest commands and their output until we're not over both limits anymore
59 while (commands
.length
> me
.commandLimit
&& commands
.flat(2).length
> me
.lineLimit
) {
64 let addResponse
= lines
=> commands
[commands
.length
- 1].push(lines
);
66 var executeCmd = function(cmd
) {
67 recordInput("# " + Ext
.htmlEncode(cmd
), true);
70 if (history
.length
> 20) {
77 Proxmox
.Utils
.API2Request({
78 params
: { command
: cmd
},
79 url
: '/nodes/' + nodename
+ '/qemu/' + vmid
+ "/monitor",
82 success: function(response
, opts
) {
83 var res
= response
.result
.data
;
84 addResponse(res
.split('\n').map(line
=> Ext
.htmlEncode(line
)));
87 failure: function(response
, opts
) {
88 Ext
.Msg
.alert('Error', response
.htmlStatus
);
94 layout
: { type
: 'border' },
105 fieldStyle
: 'font-family: monospace;',
108 afterrender: function(f
) {
110 recordInput("Type 'help' for help.");
113 specialkey: function(f
, e
) {
114 var key
= e
.getKey();
117 var cmd
= f
.getValue();
122 textbox
.scrollBy(0, -0.9*textbox
.getHeight(), false);
125 textbox
.scrollBy(0, 0.9*textbox
.getHeight(), false);
128 if (histNum
+ 1 < history
.length
) {
129 f
.setValue(history
[++histNum
]);
135 f
.setValue(history
[--histNum
]);
148 var field
= me
.query('textfield[name="cmd"]')[0];
149 field
.focus(false, true);