fix: update

parent 5fb51fc9
...@@ -176,7 +176,7 @@ export class CleftbarComponent implements OnInit { ...@@ -176,7 +176,7 @@ export class CleftbarComponent implements OnInit {
NavList.List[id].type = 'rdp'; NavList.List[id].type = 'rdp';
} }
NavList.List.push(new View()); NavList.List.push(new View());
NavList.Active = id;
} }
// if (host.platform) { // if (host.platform) {
// if (host.platform.toLowerCase() === 'linux') { // if (host.platform.toLowerCase() === 'linux') {
......
div, app-element-term { app-element-term {
height: 100%; height: 100%;
display: none;
}
app-element-term.active {
display: block;
} }
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
<app-element-term [host]="m.host" <app-element-term [host]="m.host"
[userid]="m.user.id" [userid]="m.user.id"
[index]="i" [index]="i"
[ngClass]="{'active':i==NavList.Active}"
*ngIf="m.type=='ssh'"> *ngIf="m.type=='ssh'">
</app-element-term> </app-element-term>
</div> </div>
...@@ -44,7 +44,7 @@ export class ControlnavComponent implements OnInit { ...@@ -44,7 +44,7 @@ export class ControlnavComponent implements OnInit {
if (NavList.List[index].type === 'ssh') { if (NavList.List[index].type === 'ssh') {
jQuery('app-ssh').show(); jQuery('app-ssh').show();
jQuery('app-rdp').hide(); jQuery('app-rdp').hide();
NavList.List[index].Term.term.focus(); NavList.List[index].Term.focus();
} else if (NavList.List[index].type === 'rdp') { } else if (NavList.List[index].type === 'rdp') {
jQuery('app-ssh').hide(); jQuery('app-ssh').hide();
jQuery('app-rdp').show(); jQuery('app-rdp').show();
......
import {AfterViewInit, Component, Input, OnInit, ViewChild} from '@angular/core'; import {AfterViewInit, Component, Input, OnInit, ViewChild} from '@angular/core';
import {ElementRef} from '@angular/core'; import {ElementRef} from '@angular/core';
import {term, TermWS} from '../../globals'; import {term, Terminal, TermWS} from '../../globals';
import {Cookie} from 'ng2-cookies/ng2-cookies'; import {Cookie} from 'ng2-cookies/ng2-cookies';
import {NavList} from '../../ControlPage/control/control.component'; import {NavList} from '../../ControlPage/control/control.component';
import * as jQuery from 'jquery/dist/jquery.min.js'; import * as jQuery from 'jquery/dist/jquery.min.js';
...@@ -18,12 +18,19 @@ export class ElementTermComponent implements OnInit, AfterViewInit { ...@@ -18,12 +18,19 @@ export class ElementTermComponent implements OnInit, AfterViewInit {
@Input() room: string; @Input() room: string;
@ViewChild('term') el: ElementRef; @ViewChild('term') el: ElementRef;
secret: string; secret: string;
term: any;
constructor() { constructor() {
} }
ngOnInit() { ngOnInit() {
this.secret = UUID.create()['hex']; this.secret = UUID.create()['hex'];
this.term = Terminal({
cols: 80,
rows: 24,
useStyle: true,
screenKeys: true,
});
} }
ngAfterViewInit() { ngAfterViewInit() {
...@@ -37,8 +44,9 @@ export class ElementTermComponent implements OnInit, AfterViewInit { ...@@ -37,8 +44,9 @@ export class ElementTermComponent implements OnInit, AfterViewInit {
} else { } else {
term.col = Math.floor(jQuery(this.el.nativeElement).width() / jQuery('#liuzheng').width() * 8) - 3; term.col = Math.floor(jQuery(this.el.nativeElement).width() / jQuery('#liuzheng').width() * 8) - 3;
term.row = Math.floor(jQuery(this.el.nativeElement).height() / jQuery('#liuzheng').height()) - 5; term.row = Math.floor(jQuery(this.el.nativeElement).height() / jQuery('#liuzheng').height()) - 5;
term.term = this.term;
} }
term.term.open(this.el.nativeElement, true); this.term.open(this.el.nativeElement, true);
const that = this; const that = this;
window.onresize = function () { window.onresize = function () {
term.col = Math.floor(jQuery(that.el.nativeElement).width() / jQuery('#liuzheng').width() * 8) - 3; term.col = Math.floor(jQuery(that.el.nativeElement).width() / jQuery('#liuzheng').width() * 8) - 3;
...@@ -49,7 +57,7 @@ export class ElementTermComponent implements OnInit, AfterViewInit { ...@@ -49,7 +57,7 @@ export class ElementTermComponent implements OnInit, AfterViewInit {
if (term.row < 24) { if (term.row < 24) {
term.row = 24; term.row = 24;
} }
term.term.resize(term.col, term.row); that.term.resize(term.col, term.row);
if (that.host) { if (that.host) {
Cookie.set('cols', term.col.toString(), 99, '/', document.domain); Cookie.set('cols', term.col.toString(), 99, '/', document.domain);
Cookie.set('rows', term.row.toString(), 99, '/', document.domain); Cookie.set('rows', term.row.toString(), 99, '/', document.domain);
...@@ -59,19 +67,19 @@ export class ElementTermComponent implements OnInit, AfterViewInit { ...@@ -59,19 +67,19 @@ export class ElementTermComponent implements OnInit, AfterViewInit {
jQuery(window).resize(); jQuery(window).resize();
if (this.host) { if (this.host) {
NavList.List[this.index].Term = term.term; NavList.List[this.index].Term = this.term;
term.term.write('\x1b[31mWelcome to Jumpserver!\x1b[m\r\n'); this.term.write('\x1b[31mWelcome to Jumpserver!\x1b[m\r\n');
TermWS.emit('host', {'uuid': this.host.id, 'userid': this.userid, 'secret': this.secret}); TermWS.emit('host', {'uuid': this.host.id, 'userid': this.userid, 'secret': this.secret});
term.term.on('data', function (data) { this.term.on('data', function (data) {
TermWS.emit('data', {'data': data, 'room': that.room}); TermWS.emit('data', {'data': data, 'room': that.room});
}); });
TermWS.on('data', function (data) { TermWS.on('data', function (data) {
if (data['room'] === that.room) { if (data['room'] === that.room) {
term.term.write(data['data']); that.term.write(data['data']);
} }
}); });
...@@ -88,6 +96,6 @@ export class ElementTermComponent implements OnInit, AfterViewInit { ...@@ -88,6 +96,6 @@ export class ElementTermComponent implements OnInit, AfterViewInit {
TerminalDisconnect() { TerminalDisconnect() {
NavList.List[this.index].connected = false; NavList.List[this.index].connected = false;
term.term.write('\r\n\x1b[31mBye Bye!\x1b[m\r\n'); this.term.write('\r\n\x1b[31mBye Bye!\x1b[m\r\n');
} }
} }
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