1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/**
* 控制页面的已连接主机选项卡
*
* 展示所有已连接的主机
*
* @date 2017-11-07
* @author liuzheng <liuzheng712@gmail.com>
*/
import {Component, OnInit} from '@angular/core';
import {NavList} from '../control.component'
import {SshComponent} from '../ssh/ssh.component'
import {RdpComponent} from '../rdp/rdp.component'
declare let jQuery: any;
@Component({
selector: 'app-controlnav',
templateUrl: './controlnav.component.html',
styleUrls: ['./controlnav.component.css'],
})
export class ControlnavComponent implements OnInit {
setActive = ControlnavComponent.setActive;
NavList = NavList;
constructor() {
}
ngOnInit() {
}
static checkActive(index) {
let len = NavList.List.length;
if (len == 1) {
// 唯一一个
NavList.Active = 0;
} else if (len - 1 == index) {
// 删了最后一个
NavList.Active = len - 2;
} else {
NavList.Active = index;
}
ControlnavComponent.setActive(NavList.Active)
}
static setActive(index) {
for (let m in NavList.List) {
NavList.List[m].hide = true;
}
NavList.List[index].hide = false;
NavList.Active = index;
if (NavList.List[index].type === "ssh") {
jQuery("app-ssh").show();
jQuery("app-rdp").hide()
} else if (NavList.List[index].type === 'rdp') {
jQuery("app-ssh").hide();
jQuery("app-rdp").show();
}
}
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)
}
}