Commit 4cc433c3 authored by liuzheng712's avatar liuzheng712

publish

parent 34c5cb72
...@@ -94,11 +94,11 @@ export class CleftbarComponent implements OnInit { ...@@ -94,11 +94,11 @@ export class CleftbarComponent implements OnInit {
Connect(host) { Connect(host) {
console.log(host); console.log(host);
let username: string; let userid: string;
if (host.system_users_granted.length > 1) { if (host.system_users_granted.length > 1) {
let options = ''; let options = '';
for (let u of host.system_users_granted) { for (let u of host.system_users_granted) {
options += '<option value="' + u.username + '">' + u.username + '</option>'; options += '<option value="' + u.id + '">' + u.username + '</option>';
} }
layer.open({ layer.open({
title: 'Please Choose a User', title: 'Please Choose a User',
...@@ -108,7 +108,7 @@ export class CleftbarComponent implements OnInit { ...@@ -108,7 +108,7 @@ export class CleftbarComponent implements OnInit {
btn: ['确定', '取消'], btn: ['确定', '取消'],
content: '<select id="selectuser">' + options + '</select>', content: '<select id="selectuser">' + options + '</select>',
yes: function (index, layero) { yes: function (index, layero) {
username = jQuery('#selectuser').val(); userid = jQuery('#selectuser').val();
layer.close(index); layer.close(index);
}, },
btn2: function (index, layero) { btn2: function (index, layero) {
...@@ -119,24 +119,23 @@ export class CleftbarComponent implements OnInit { ...@@ -119,24 +119,23 @@ export class CleftbarComponent implements OnInit {
} }
}); });
} else if (host.system_users_granted.length === 1) { } else if (host.system_users_granted.length === 1) {
username = host.system_users_granted[0].username; userid = host.system_users_granted[0].id;
} }
if (username === '') { if (userid === '') {
return; return;
} }
if (host.system === 'linux') { if (host.system === 'linux') {
jQuery('app-ssh').show(); jQuery('app-ssh').show();
jQuery('app-rdp').hide(); jQuery('app-rdp').hide();
this._term.TerminalConnect(host, username); this._term.TerminalConnect(host, userid);
} else if (host.system === 'windows') { } else if (host.system === 'windows') {
jQuery('app-ssh').hide(); jQuery('app-ssh').hide();
jQuery('app-rdp').show(); jQuery('app-rdp').show();
this._rdp.Connect(host, username); this._rdp.Connect(host, userid);
} else { } else {
jQuery('app-ssh').show(); jQuery('app-ssh').show();
jQuery('app-rdp').hide(); jQuery('app-rdp').hide();
this._term.TerminalConnect(host, username); this._term.TerminalConnect(host, userid);
} }
} }
......
...@@ -48,8 +48,8 @@ export class SshComponent implements OnInit { ...@@ -48,8 +48,8 @@ export class SshComponent implements OnInit {
ngOnInit() { ngOnInit() {
} }
TerminalConnect(host, username) { TerminalConnect(host, userid) {
console.log(host, username); console.log(host, userid);
const socket = io.connect('/ssh'); const socket = io.connect('/ssh');
let cols = '80'; let cols = '80';
let rows = '24'; let rows = '24';
...@@ -99,7 +99,7 @@ export class SshComponent implements OnInit { ...@@ -99,7 +99,7 @@ export class SshComponent implements OnInit {
NavList.List[id].Term.term.write('\x1b[31mWelcome to Jumpserver!\x1b[m\r\n'); NavList.List[id].Term.term.write('\x1b[31mWelcome to Jumpserver!\x1b[m\r\n');
socket.on('connect', function () { socket.on('connect', function () {
socket.emit('host', {'asset': host, 'username': username}); socket.emit('host', {'uuid': host.id, 'userid': userid});
NavList.List[id].Term.term.on('data', function (data) { NavList.List[id].Term.term.on('data', function (data) {
socket.emit('data', data); socket.emit('data', data);
......
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