Commit f3eb3e92 authored by ibuler's avatar ibuler

[Update] 修改第一次登陆窗口大小

parent 313728a0
......@@ -24,6 +24,10 @@ logger.setLevel(logging.DEBUG)
sh = logging.StreamHandler(stream=None)
logger.addHandler(sh)
logger2 = logging.getLogger('coco')
logger2.setLevel(logging.DEBUG)
logger2.addHandler(sh)
eventlet.monkey_patch()
# async_mode = 'threading'
async_mode = 'eventlet'
......@@ -38,7 +42,9 @@ nodes = '[{"id":"03059e2e-06b8-4ef1-b949-72e230b706fa","key":"0:9:5","name":"部
class Forwarder:
def __init__(self, client):
self.client = client
self.server = self.ssh_with_password()
width = client.request.meta['width']
height = client.request.meta['height']
self.server = self.ssh_with_password(width, height)
self.watch_win_size_change_async()
def proxy(self, asset, system_user):
......@@ -60,11 +66,10 @@ class Forwarder:
thread.daemon = True
thread.start()
def ssh_with_password(self):
def ssh_with_password(self, width=80, height=24):
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect("192.168.244.176", 22, "root", "redhat123")
width, height = (80, 24)
chan = ssh.invoke_shell(term='xterm', width=width, height=height)
return chan
......@@ -75,7 +80,8 @@ class Forwarder:
height = self.client.request.meta.get('height', 24)
logger.debug("Change win size: %s - %s" % (width, height))
try:
self.server.chan.resize_pty(width=width, height=height)
self.server.resize_pty(width=width, height=height)
# self.server.chan.resize_pty(width=width, height=height)
except Exception:
break
......
......@@ -34,9 +34,6 @@ export class ElementSshTermComponent implements OnInit, AfterViewInit {
background: '#1f1b1b'
}
});
const rowInit = parseInt(this._cookie.get('rows') || '24', 10);
const colsInit = parseInt(this._cookie.get('cols') || '80', 10);
this.term.resize(colsInit, rowInit);
}
ngAfterViewInit() {
......@@ -49,11 +46,21 @@ export class ElementSshTermComponent implements OnInit, AfterViewInit {
joinRoom() {
NavList.List[this.index].Term = this.term;
console.log(this.term);
console.log('Col: ', this.term.cols, 'rows', this.term.rows);
if (this.host) {
ws.emit('host', {'uuid': this.host.id, 'userid': this.userid, 'secret': this.secret});
ws.emit('host', {
'uuid': this.host.id,
'userid': this.userid,
'secret': this.secret,
'size': [this.term.cols, this.term.rows]
});
}
if (this.token) {
ws.emit('token', {'token': this.token, 'secret': this.secret});
ws.emit('token', {
'token': this.token, 'secret': this.secret,
'size': [this.term.cols, this.term.rows]
});
}
const that = this;
......
......@@ -63,10 +63,6 @@ export class ElementTermComponent implements OnInit, AfterViewInit {
Math.floor(availableHeight / (<any>this.term).renderer.dimensions.actualCellHeight) - 1
];
return geometry;
// const cols = Math.floor((activeEle.width() - 15) / markerEle.width() * 6) - 1;
// const rows = Math.floor(activeEle.height() / markerEle.height()) - 1;
// return [cols, rows];
}
resizeTerm() {
......@@ -78,8 +74,6 @@ export class ElementTermComponent implements OnInit, AfterViewInit {
this.term.resize(size[0], size[1]);
}
this.winSizeChangeTrigger.emit([this.term.cols, this.term.rows]);
this._cookie.set('cols', this.term.cols.toString(), 0, '/', document.domain);
this._cookie.set('rows', this.term.rows.toString(), 0, '/', document.domain);
}
active() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment