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

feat: update

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