Commit 74b26dc1 authored by liuzheng712's avatar liuzheng712 Committed by i317280

feat: update

parent c8e5ea43
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
.filetree li { .filetree li {
list-style: none; list-style: none;
cursor: pointer;
} }
.filetree label { .filetree label {
......
...@@ -5,6 +5,8 @@ import {AppService, DataStore} from '../../app.service'; ...@@ -5,6 +5,8 @@ import {AppService, DataStore} from '../../app.service';
import {SshComponent} from '../control/ssh/ssh.component'; import {SshComponent} from '../control/ssh/ssh.component';
import {RdpComponent} from "../control/rdp/rdp.component"; import {RdpComponent} from "../control/rdp/rdp.component";
declare let jQuery: any;
@Component({ @Component({
selector: 'app-cleftbar', selector: 'app-cleftbar',
templateUrl: './cleftbar.component.html', templateUrl: './cleftbar.component.html',
...@@ -17,11 +19,11 @@ export class CleftbarComponent implements OnInit { ...@@ -17,11 +19,11 @@ export class CleftbarComponent implements OnInit {
DataStore = DataStore; DataStore = DataStore;
HostGroups = [ HostGroups = [
{ {
name: "msa-us", name: "ops",
id: "ccc", id: "ccc",
children: [ children: [
{ {
name: "ops-redis", name: "ops-linux",
uuid: "xxxx", uuid: "xxxx",
type: "ssh" type: "ssh"
}, { }, {
...@@ -46,9 +48,13 @@ export class CleftbarComponent implements OnInit { ...@@ -46,9 +48,13 @@ export class CleftbarComponent implements OnInit {
Connect(host) { Connect(host) {
if (host.type === 'ssh') { if (host.type === 'ssh') {
this._term.TerminalConnect(host.uuid); jQuery("app-ssh").show();
jQuery("app-rdp").hide();
this._term.TerminalConnect(host);
} else { } else {
this._rdp.Connect() jQuery("app-ssh").hide();
jQuery("app-rdp").show();
this._rdp.Connect(host);
} }
} }
......
<app-controlnav></app-controlnav> <app-controlnav></app-controlnav>
<!--<app-ssh></app-ssh>--> <app-ssh></app-ssh>
<app-rdp></app-rdp> <app-rdp></app-rdp>
...@@ -81,5 +81,4 @@ ...@@ -81,5 +81,4 @@
color: white; color: white;
padding: 5px 20px 4px 15px; padding: 5px 20px 4px 15px;
height: 18px; height: 18px;
border-bottom: 3px solid #7f3f98 !important;
} }
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
id="termnav-{{i}}" (click)="setActive(i)"> id="termnav-{{i}}" (click)="setActive(i)">
<span *ngIf="!m.edit" (dblclick)="m.edit=true;setActive(i)">{{m.nick}}</span> <span *ngIf="!m.edit" (dblclick)="m.edit=true;setActive(i)">{{m.nick}}</span>
<input *ngIf="m.edit" [(ngModel)]="m.nick" autofocus (blur)="m.edit=false" (keyup.enter)="m.edit=false"/> <input *ngIf="m.edit" [(ngModel)]="m.nick" autofocus (blur)="m.edit=false" (keyup.enter)="m.edit=false"/>
<a class="close" (click)="close(i)">&times;</a> <a class="close" (click)="close(m,i)">&times;</a>
</li> </li>
</ul> </ul>
</div> </div>
import {Component, OnInit} from '@angular/core'; import {Component, OnInit} from '@angular/core';
import {NavList} from '../control.component' import {NavList} from '../control.component'
import {SshComponent} from '../ssh/ssh.component'
import {RdpComponent} from '../rdp/rdp.component'
import {NavComponent} from "../../../BasicPage/nav/nav.component";
declare let jQuery: any; declare let jQuery: any;
...@@ -39,12 +43,23 @@ export class ControlnavComponent implements OnInit { ...@@ -39,12 +43,23 @@ export class ControlnavComponent implements OnInit {
NavList.List[index].hide = false; NavList.List[index].hide = false;
NavList.Active = index; NavList.Active = index;
if (NavList.List[index].type === "ssh") { if (NavList.List[index].type === "ssh") {
jQuery("#ssh").show(); jQuery("app-ssh").show();
jQuery("#rdp").hide() jQuery("app-rdp").hide()
} else { } else if (NavList.List[index].type === 'rdp') {
jQuery("#ssh").hide(); jQuery("app-ssh").hide();
jQuery("#rdp").show() jQuery("app-rdp").show();
jQuery("#rdp-" + index + " iframe")[0].contentWindow.focus();
}
}
close(host, index) {
if (host.type === 'rdp') {
RdpComponent.Disconnect(host)
} else if (host.type === 'ssh') {
SshComponent.TerminalDisconnect(host)
} }
NavList.List.splice(index, 1);
ControlnavComponent.checkActive(index)
} }
} }
import {Component, OnInit} from '@angular/core'; import {Component, OnInit} from '@angular/core';
import {NavList, View, Rdp} from '../control.component'; import {NavList, View, Rdp} from '../control.component';
declare let jQuery: any;
@Component({ @Component({
selector: 'app-rdp', selector: 'app-rdp',
templateUrl: './rdp.component.html', templateUrl: './rdp.component.html',
...@@ -15,17 +17,31 @@ export class RdpComponent implements OnInit { ...@@ -15,17 +17,31 @@ export class RdpComponent implements OnInit {
ngOnInit() { ngOnInit() {
} }
Connect() { Connect(host) {
let id = NavList.List.length - 1; let id = NavList.List.length - 1;
NavList.List[id].nick = 'localhost'; NavList.List[id].nick = host.name;
NavList.List[id].connected = true; NavList.List[id].connected = true;
NavList.List[id].edit = false; NavList.List[id].edit = false;
NavList.List[id].closed = false; NavList.List[id].closed = false;
NavList.List[id].type = "rdp"; NavList.List[id].type = "rdp";
NavList.List[id].Rdp = new Rdp; NavList.List[id].Rdp = new Rdp;
NavList.List[id].Rdp.token = "xxx"; NavList.List[id].Rdp.token = "xxx";
NavList.List[id].Rdp.machine = "xxx" NavList.List[id].Rdp.machine = "xxx";
NavList.List.push(new View());
for (let m in NavList.List) {
NavList.List[m].hide = true;
}
NavList.List[id].hide = false;
NavList.Active = id;
jQuery("#rdp-" + id + " iframe")[0].contentWindow.focus();
}
static Disconnect(host) {
host.connected = false;
// document.getElementById("templatesrc").remove();
} }
......
...@@ -25,7 +25,7 @@ export class SshComponent implements OnInit { ...@@ -25,7 +25,7 @@ export class SshComponent implements OnInit {
ngOnInit() { ngOnInit() {
} }
TerminalConnect(uuid) { TerminalConnect(host) {
let socket = io.connect(); let socket = io.connect();
let cols = '80'; let cols = '80';
let rows = '24'; let rows = '24';
...@@ -40,7 +40,7 @@ export class SshComponent implements OnInit { ...@@ -40,7 +40,7 @@ export class SshComponent implements OnInit {
let id = NavList.List.length - 1; let id = NavList.List.length - 1;
NavList.List[id].nick = 'localhost'; NavList.List[id].nick = host.name;
NavList.List[id].connected = true; NavList.List[id].connected = true;
NavList.List[id].edit = false; NavList.List[id].edit = false;
NavList.List[id].closed = false; NavList.List[id].closed = false;
...@@ -72,7 +72,7 @@ export class SshComponent implements OnInit { ...@@ -72,7 +72,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('machine', uuid); socket.emit('machine', host.id);
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);
...@@ -115,14 +115,15 @@ export class SshComponent implements OnInit { ...@@ -115,14 +115,15 @@ export class SshComponent implements OnInit {
Cookie.set('rows', String(row), 99, '/', document.domain); Cookie.set('rows', String(row), 99, '/', document.domain);
} }
}; };
jQuery(window).resize();
}); });
} }
static TerminalDisconnect(i) { static TerminalDisconnect(host) {
NavList.List[i].connected = false; host.connected = false;
NavList.List[i].Term.socket.destroy(); host.Term.socket.destroy();
NavList.List[i].Term.term.write('\r\n\x1b[31mBye Bye!\x1b[m\r\n'); host.Term.term.write('\r\n\x1b[31mBye Bye!\x1b[m\r\n');
} }
static TerminalDisconnectAll() { static TerminalDisconnectAll() {
......
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