投放本站广告请联系:
extjscn#126.com
ExtJs 3.4 和 Web SSH(Ajaxterm)
今天在整理服务器列表的时候,想着可以不可以快速连接到服务器,之前也见过webssh ,google一番后发现了Ajaxterm,是用python开发的,下载下来试用一下还不错,速度还可以,Ajaxterm我大致看了下,没看的很明白,以后清楚了再补上,先看下图片

连接Ajaxterm

代码(前端js),先装一个插件
Ext.ns('Ext.ux.grid');
Ext.ux.grid.RightMenu = function(options) {
var currRecord = false;
var currRowIndex = false;
var currGrid = false;
var menuItems = Ext.each(options.items, function() {
var item = this;
this.handler = function() {
item.recHandler && item.recHandler(currRecord, currRowIndex, currGrid);
};
});
var menu = new Ext.menu.Menu({
items:options.items
});
this.init = function(grid) {
grid.addListener('rowcontextmenu', function(client, rowIndex, e) {
e.preventDefault();
if (rowIndex < 0) {
return;
}
currRowIndex = rowIndex;
currRecord = grid.getStore().getAt(rowIndex);
currGrid = grid;
menu.showAt(e.getXY());
});
};
};
具体参考:
http://www.oschina.net/code/snippet_122683_12333
配置右键menu插件
var rightMenu = new Ext.ux.grid.RightMenu({
items:[{
text : '连接主机',
recHandler:function(record, rowIndex, grid) {
// var ip = record.get('ip'); //取得选择行ip地址
window.open("http://192.168.78.140:8080"); //这儿是ajaxterm主机的url,
//..传入参数为右键单击的record,行索引及所属的grid对象
}
}, {
text : '查看主机',
recHandler:function(record, rowIndex, grid) {
window.open("http://www.baidu.com&"+"zbxid="+record.get('zbxid'));
}
}]
})
最后配置grid中plugins,增加rightMenu
总结
虽然达到了预期的效果,但是没有具体测试并发连接很多的情况,还有ajaxterm 是无时无刻都会产生post连接请求,我看了下源代码发现是个死循环sleep极短的时间,我猜测是为了保持跟主机的连接,确保主机是alive
作者: howge
原文: http://blog.chinaunix.net/uid-17291169-id-3568450.html
- 要发表评论,请先登录

