diff --git a/jumpserver/views.py b/jumpserver/views.py index bd00aed99..766ae021f 100644 --- a/jumpserver/views.py +++ b/jumpserver/views.py @@ -352,6 +352,10 @@ def exec_cmd(request): def web_terminal(request): asset_id = request.GET.get('id') role_name = request.GET.get('role') + asset = get_object(Asset, id=asset_id) + if asset: + print asset + hostname = asset.hostname web_terminal_uri = 'ws://%s/terminal?id=%s&role=%s' % (WEB_SOCKET_HOST, asset_id, role_name) return render_to_response('jlog/web_terminal.html', locals()) diff --git a/run_websocket.py b/run_websocket.py index 757923a0a..4a1a185dc 100755 --- a/run_websocket.py +++ b/run_websocket.py @@ -333,7 +333,13 @@ class WebTerminalHandler(tornado.websocket.WebSocketHandler): data = json.loads(message) if not data: return - if data.get('data'): + + if 'resize' in data.get('data'): + self.channel.resize_pty( + data.get('data').get('resize').get('cols', 80), + data.get('data').get('resize').get('rows', 24) + ) + elif data.get('data'): self.term.input_mode = True if str(data['data']) in ['\r', '\n', '\r\n']: if self.term.vim_flag: @@ -350,6 +356,8 @@ class WebTerminalHandler(tornado.websocket.WebSocketHandler): self.term.data = '' self.term.input_mode = False self.channel.send(data['data']) + else: + pass def on_close(self): logger.debug('Websocket: Close request') diff --git a/templates/jasset/asset_list.html b/templates/jasset/asset_list.html index 56d64ce9b..1da808c3c 100644 --- a/templates/jasset/asset_list.html +++ b/templates/jasset/asset_list.html @@ -233,6 +233,7 @@ layer.alert('没有授权系统用户') } else if (dataArray.length == 1 && data != 'error' && navigator.platform == 'Win32'){ + /* var title = 'Jumpserver Web Terminal' + ' '+ hostname +''; layer.open({ type: 2, @@ -242,8 +243,10 @@ area: ['628px', '420px'], content: new_url+data }); + */ + window.open(new_url+data, '', 'width=628px, height=420px') } else if (dataArray.length == 1 && data != 'error'){ - layer.open({ + /*layer.open({ type: 2, title: title, maxmin: true, @@ -251,6 +254,9 @@ area: ['628px', '452px'], content: new_url+data }); + */ + window.open(new_url+data, '', 'width=628px, height=440px') + } else { aUrl = ''; @@ -276,6 +282,7 @@ var hostname = $(a).attr('value'); var title = 'Jumpserver Web Terminal - ' + ' '+ hostname +''; if (navigator.platform == 'Win32'){ + /* layer.open({ type: 2, title: title, @@ -284,8 +291,11 @@ shade: false, content: new_url }); + */ + window.open(new_url, '', 'height=628px, width=420px') } else { + /* layer.open({ type: 2, title: title, @@ -294,6 +304,8 @@ shade: false, content: new_url }); + */ + window.open(new_url, '', 'height=628px, width=452px') } return false @@ -310,7 +322,6 @@ shade: false, content: new_url }); - console.log(new_url); return false } diff --git a/templates/jlog/web_terminal.html b/templates/jlog/web_terminal.html index 514fe6850..e5b864a79 100644 --- a/templates/jlog/web_terminal.html +++ b/templates/jlog/web_terminal.html @@ -2,7 +2,7 @@ - Jumpserver web terminal + Jumpserver Web Terminal: {{ hostname }}