feat: udpate

parent 2e1bfb6d
......@@ -51,30 +51,30 @@ export class CleftbarComponent implements OnInit {
static Hide() {
DataStore.leftbarshow = false;
DataStore.Nav.map(function (value, i) {
for (var ii in value['children']) {
if (DataStore.Nav[i]['children'][ii]['id'] === 'HindLeftManager') {
DataStore.Nav[i]['children'][ii] = {
value['children'].forEach((v, key) => {
if (DataStore.Nav[i]['children'][key]['id'] === 'HindLeftManager') {
DataStore.Nav[i]['children'][key] = {
'id': 'ShowLeftManager',
'click': 'ShowLeft',
'name': 'Show left manager'
};
}
}
});
});
}
static Show() {
DataStore.leftbarshow = true;
DataStore.Nav.map(function (value, i) {
for (var ii in value['children']) {
if (DataStore.Nav[i]['children'][ii]['id'] === 'ShowLeftManager') {
DataStore.Nav[i]['children'][ii] = {
value['children'].forEach((v, key) => {
if (DataStore.Nav[i]['children'][key]['id'] === 'ShowLeftManager') {
DataStore.Nav[i]['children'][key] = {
'id': 'HindLeftManager',
'click': 'HideLeft',
'name': 'Hind left manager'
};
}
}
});
});
}
......@@ -101,12 +101,12 @@ export class CleftbarComponent implements OnInit {
if (id) {
for (let g of this.HostGroups) {
if (g['assets_granted']) {
for (let u of g['assets_granted']) {
if (u.id.toString() === id.toString()) {
this.Connect(u);
g['assets_granted'].forEach((v, k) => {
if (v.id.toSource() === id.toString()) {
this.Connect(v);
return;
}
}
});
}
}
......
......@@ -53,13 +53,9 @@ export class ControlComponent implements OnInit {
NavList = NavList;
static active(id) {
for (let i in NavList.List) {
if (id.toString() === i) {
NavList.List[id].hide = false;
} else {
NavList.List[i].hide = true;
}
}
NavList.List.forEach((v, k) => {
v.hide = id.toString() !== k;
});
NavList.Active = id;
}
......
......@@ -8,9 +8,9 @@
<ul [ngStyle]="{'width':150*NavList.List.length+'px'}">
<li *ngFor="let m of NavList.List;let i = index"
[ngClass]="{'active':i==NavList.Active,'disconnected':!m.connected, 'hidden': m.closed != false}"
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"/>
id="termnav-{{i}}" (click)="setActive(i)" (dblclick)="m.edit=true;setActive(i)">
<span *ngIf="!m.edit">{{m.nick}}</span>
<input *ngIf="m.edit" [(ngModel)]="m.nick" (blur)="m.edit=false" (keyup.enter)="m.edit=false" autofocus="true"/>
<a class="close" (click)="close(m,i)">&times;</a>
</li>
</ul>
......
......@@ -35,14 +35,18 @@ export class ControlnavComponent implements OnInit {
}
static setActive(index) {
for (let m in NavList.List) {
NavList.List[m].hide = true;
}
NavList.List.forEach((value, key) => {
NavList.List[key].hide = true;
});
NavList.List[index].hide = false;
NavList.Active = index;
if (NavList.List[index].type === 'ssh') {
NavList.List[index].Term.focus();
} else if (NavList.List[index].type === 'rdp') {
if (!NavList.List[index].edit) {
if (NavList.List[index].type === 'ssh') {
NavList.List[index].Term.focus();
} else if (NavList.List[index].type === 'rdp') {
}
} else {
}
}
......
......@@ -16,6 +16,8 @@ export class ElementTermComponent implements OnInit, AfterViewInit {
@Input() userid: any;
@Input() index: number;
@Input() token: string;
@Input() monitor: string;
@ViewChild('term') el: ElementRef;
secret: string;
term: any;
......@@ -72,11 +74,16 @@ export class ElementTermComponent implements OnInit, AfterViewInit {
TermWS.emit('host', {'uuid': this.host.id, 'userid': this.userid, 'secret': this.secret});
}
if (this.token) {
TermWS.emit('token', {'token': this.token, 'secrte': this.secret});
TermWS.emit('token', {'token': this.token, 'secret': this.secret});
}
this.term.on('data', function (data) {
TermWS.emit('data', {'data': data, 'room': NavList.List[that.index].room});
});
if (this.monitor) {
TermWS.emit('monitor', {'token': this.monitor, 'secret': this.secret});
} else {
this.term.on('data', function (data) {
TermWS.emit('data', {'data': data, 'room': NavList.List[that.index].room});
});
}
TermWS.on('data', function (data) {
if (data['room'] === NavList.List[that.index].room) {
......
......@@ -39,15 +39,13 @@ export let Video: {
};
export let Monitor: {
sessionid: string,
token: string,
room: string,
type: string,
socket: any,
} = {
sessionid: '',
token: '',
room: '',
type: 'term',
socket: io.connect(),
};
export class Group {
......
<app-element-term></app-element-term>
<app-element-term
[index]="0"
[monitor]="token"
></app-element-term>
import {Component, OnInit} from '@angular/core';
import {Monitor, term} from '../../globals';
import * as io from 'socket.io-client';
import * as jQuery from 'jquery/dist/jquery.min.js';
import {Monitor} from '../../globals';
@Component({
selector: 'app-monitor-linux',
......@@ -10,27 +7,13 @@ import * as jQuery from 'jquery/dist/jquery.min.js';
styleUrls: ['./linux.component.css']
})
export class LinuxComponent implements OnInit {
token: string;
constructor() {
}
ngOnInit() {
Monitor.socket = io.connect('/ssh');
Monitor.socket.on('connect', function () {
Monitor.socket.emit('room', Monitor.sessionid);
Monitor.socket.on('room', function (room) {
Monitor.room = room;
console.log(room);
Monitor.socket.emit('join', room);
console.log(Monitor);
});
Monitor.socket.on('data', function (data) {
term.term.write(data);
});
Monitor.socket.on('error', function (data) {
alert(data);
});
});
this.token = Monitor.token;
}
......
......@@ -15,7 +15,7 @@ export class MonitorPageComponent implements OnInit {
ngOnInit() {
this.activatedRoute.params.subscribe((params: Params) => {
Monitor.sessionid = params['token'];
Monitor.token = params['token'];
Monitor.type = 'term';
console.log(Monitor);
});
......
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