]>
git.proxmox.com Git - pve-manager.git/blob - www/manager6/qemu/Monitor.js
686950adf930add680e695afed085566f9552a0c
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";
23 var textbox
= Ext
.createWidget('panel', {
29 bodyStyle
: 'font-family: monospace;'
32 var scrollToEnd = function() {
33 var el
= textbox
.getTargetEl();
34 var dom
= Ext
.getDom(el
);
36 var clientHeight
= dom
.clientHeight
;
37 // BrowserBug: clientHeight reports 0 in IE9 StrictMode
38 // Instead we are using offsetHeight and hardcoding borders
39 if (Ext
.isIE9
&& Ext
.isStrict
) {
40 clientHeight
= dom
.offsetHeight
+ 2;
42 dom
.scrollTop
= dom
.scrollHeight
- clientHeight
;
45 var refresh = function() {
46 textbox
.update('<pre>' + lines
.join('\n') + '</pre>');
50 var addLine = function(line
) {
52 if (lines
.length
> me
.maxLines
) {
57 var executeCmd = function(cmd
) {
58 addLine("# " + Ext
.htmlEncode(cmd
));
60 Proxmox
.Utils
.API2Request({
61 params
: { command
: cmd
},
62 url
: '/nodes/' + nodename
+ '/qemu/' + vmid
+ "/monitor",
65 success: function(response
, opts
) {
66 var res
= response
.result
.data
;
67 Ext
.Array
.each(res
.split('\n'), function(line
) {
68 addLine(Ext
.htmlEncode(line
));
72 failure: function(response
, opts
) {
73 Ext
.Msg
.alert('Error', response
.htmlStatus
);
79 layout
: { type
: 'border' },
90 fieldStyle
: 'font-family: monospace;',
93 afterrender: function(f
) {
95 addLine("Type 'help' for help.");
98 specialkey: function(f
, e
) {
99 if (e
.getKey() === e
.ENTER
) {
100 var cmd
= f
.getValue();
103 } else if (e
.getKey() === e
.PAGE_UP
) {
104 textbox
.scrollBy(0, -0.9*textbox
.getHeight(), false);
105 } else if (e
.getKey() === e
.PAGE_DOWN
) {
106 textbox
.scrollBy(0, 0.9*textbox
.getHeight(), false);
114 var field
= me
.query('textfield[name="cmd"]')[0];
115 field
.focus(false, true);