]>
git.proxmox.com Git - pve-manager.git/blob - www/manager6/qemu/Monitor.js
1 Ext
.define('PVE.qemu.Monitor', {
2 extend
: 'Ext.panel.Panel',
4 alias
: 'widget.pveQemuMonitor',
8 initComponent: function() {
11 var nodename
= me
.pveSelNode
.data
.node
;
13 throw "no node name specified";
16 var vmid
= me
.pveSelNode
.data
.vmid
;
18 throw "no VM ID specified";
25 var textbox
= Ext
.createWidget('panel', {
31 bodyStyle
: 'font-family: monospace;',
34 var scrollToEnd = function() {
35 var el
= textbox
.getTargetEl();
36 var dom
= Ext
.getDom(el
);
38 var clientHeight
= dom
.clientHeight
;
39 // BrowserBug: clientHeight reports 0 in IE9 StrictMode
40 // Instead we are using offsetHeight and hardcoding borders
41 if (Ext
.isIE9
&& Ext
.isStrict
) {
42 clientHeight
= dom
.offsetHeight
+ 2;
44 dom
.scrollTop
= dom
.scrollHeight
- clientHeight
;
47 var refresh = function() {
48 textbox
.update('<pre>' + lines
.join('\n') + '</pre>');
52 var addLine = function(line
) {
54 if (lines
.length
> me
.maxLines
) {
59 var executeCmd = function(cmd
) {
60 addLine("# " + Ext
.htmlEncode(cmd
));
63 if (history
.length
> 20) {
70 Proxmox
.Utils
.API2Request({
71 params
: { command
: cmd
},
72 url
: '/nodes/' + nodename
+ '/qemu/' + vmid
+ "/monitor",
75 success: function(response
, opts
) {
76 var res
= response
.result
.data
;
77 Ext
.Array
.each(res
.split('\n'), function(line
) {
78 addLine(Ext
.htmlEncode(line
));
82 failure: function(response
, opts
) {
83 Ext
.Msg
.alert('Error', response
.htmlStatus
);
89 layout
: { type
: 'border' },
100 fieldStyle
: 'font-family: monospace;',
103 afterrender: function(f
) {
105 addLine("Type 'help' for help.");
108 specialkey: function(f
, e
) {
109 var key
= e
.getKey();
112 var cmd
= f
.getValue();
117 textbox
.scrollBy(0, -0.9*textbox
.getHeight(), false);
120 textbox
.scrollBy(0, 0.9*textbox
.getHeight(), false);
123 if (histNum
+ 1 < history
.length
) {
124 f
.setValue(history
[++histNum
]);
130 f
.setValue(history
[--histNum
]);
143 var field
= me
.query('textfield[name="cmd"]')[0];
144 field
.focus(false, true);