-
Notifications
You must be signed in to change notification settings - Fork 195
Expand file tree
/
Copy pathadvanced-option.component.ts
More file actions
226 lines (208 loc) · 6.76 KB
/
Copy pathadvanced-option.component.ts
File metadata and controls
226 lines (208 loc) · 6.76 KB
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
import { SettingService } from '@app/services';
import { resolutionsChoices } from '@app/globals';
import { Component, Input, OnChanges, OnInit } from '@angular/core';
import { ConnectMethod, ConnectOption, GlobalSetting, Protocol, Setting } from '@app/model';
@Component({
standalone: false,
selector: 'elements-advanced-option',
templateUrl: 'advanced-option.component.html',
styleUrls: ['advanced-option.component.scss']
})
export class ElementAdvancedOptionComponent implements OnChanges, OnInit {
@Input() protocol: Protocol;
@Input() connectMethod: ConnectMethod;
@Input() connectOption: any = {};
public isShowAdvancedOption = false;
private boolChoices = [
{ label: 'Yes', value: true },
{ label: 'No', value: false }
];
public setting: Setting;
public globalSetting: GlobalSetting;
private allOptions: ConnectOption[] = [];
public advancedOptions: ConnectOption[] = [];
constructor(public _settingSvc: SettingService) {
this.setting = _settingSvc.setting;
this.globalSetting = _settingSvc.globalSetting;
}
ngOnInit() {
this.allOptions = this.buildAllOptions();
this.checkOptions();
}
buildAllOptions(): ConnectOption[] {
const gs = this._settingSvc.globalSetting;
const hasX = this._settingSvc.hasXPack?.() ?? false;
return [
{
type: 'select',
field: 'charset',
label: 'Charset',
hidden: () => {
const protocolsCanCharset: Array<string> = ['ssh', 'telnet'];
return (
(this.connectMethod && this.connectMethod.component !== 'koko') ||
!protocolsCanCharset.includes(this.protocol.name)
);
},
value: 'default',
options: [
{ label: 'Default', value: 'default' },
{ label: 'UTF-8', value: 'utf8' },
{ label: 'GBK', value: 'gbk' },
{ label: 'GB2312', value: 'gb2312' },
{ label: 'IOS-8859-1', value: 'ios-8859-1' }
]
},
{
type: 'select',
field: 'disableautohash',
hidden: () => {
const protocolsCanAutoHash: Array<string> = ['mysql', 'mariadb'];
if (this.connectMethod) {
if (this.connectMethod.component === 'koko') {
return (
this.connectMethod.component !== 'koko' ||
!protocolsCanAutoHash.includes(this.protocol.name)
);
}
if (this.connectMethod.component === 'chen') {
return false;
}
}
return true;
},
label: 'Disable auto completion',
value: false,
options: this.boolChoices
},
{
type: 'select',
field: 'token_reusable',
hidden: () => {
return !(
this.connectMethod.component === 'magnus' &&
this.connectMethod.value === 'db_client' &&
this.globalSetting.CONNECTION_TOKEN_REUSABLE
);
},
label: 'Set reusable',
value: false,
options: this.boolChoices
},
{
type: 'select',
field: 'resolution',
hidden: () => {
const protocolsCanResolution: Array<string> = ['rdp'];
return !protocolsCanResolution.includes(this.protocol.name);
},
options: resolutionsChoices.map(i => ({ label: i, value: i.toLowerCase() })),
label: 'RDP resolution',
value: this.setting.graphics.rdp_resolution || 'auto'
},
{
type: 'select',
field: 'backspaceAsCtrlH',
hidden: () => {
return this.connectMethod && this.connectMethod.component !== 'koko';
},
options: this.boolChoices,
label: 'Backspace as Ctrl+H',
value: this.setting.command_line.is_backspace_as_ctrl_h
},
{
type: 'select',
field: 'appletConnectMethod',
options: [
{ label: 'Web', value: 'web' },
...(gs.TERMINAL_RAZOR_ENABLED ? [{ label: 'Client', value: 'client' }] : [])
],
label: 'Applet connect method',
value: this.setting.graphics.applet_connection_method,
hidden: () => {
if (!this._settingSvc.hasXPack()) {
return true;
}
return !this.connectMethod || this.connectMethod.component !== 'tinker';
}
},
{
type: 'select',
field: 'virtualappConnectMethod',
options: [
{ label: 'Web', value: 'web' },
...(true ? [{ label: 'Client', value: 'client' }] : [])
],
label: 'Virtualapp connect method',
value: this.setting.graphics.applet_connection_method,
hidden: () => {
if (!hasX) return true;
return !this.connectMethod || this.connectMethod.component !== 'panda';
}
},
{
type: 'select',
field: 'reusable',
options: this.boolChoices,
label: ' RDP file reusable',
value: false,
hidden: () => {
if (!this.connectMethod) return true;
if (!gs.CONNECTION_TOKEN_REUSABLE) return true;
// razor 直接显示
if (this.connectMethod.component === 'razor') return false;
if (this.connectMethod.component === 'tinker') {
const method = (
this.connectOption.appletConnectMethod ??
this.connectOption.virtualappConnectMethod ??
this.setting.graphics.applet_connection_method ??
''
)
.toString()
.toLowerCase();
return method !== 'client';
}
return true;
}
},
{
type: 'select',
field: 'rdp_connection_speed',
label: 'RDP connection speed',
hidden: () => {
return this.connectMethod && this.connectMethod.component !== 'razor';
},
value: 'auto',
options: [
{ label: 'Auto', value: 'auto' },
{ label: 'Low Speed Broadband (256 Kbps - 2 Mbps)', value: 'low_speed_broadband' },
{ label: 'High-speed broadband (2 Mbps – 10 Mbps )', value: 'high_speed_broadband' }
]
}
];
}
checkOptions() {
if (!this.protocol) {
return;
}
const onlyUsingDefaultFields = ['reusable'];
this.allOptions.forEach(i => {
if (this.connectOption[i.field] === undefined) {
this.connectOption[i.field] = i.value;
}
if (onlyUsingDefaultFields.includes(i.field)) {
i.value = this.connectOption[i.field];
}
});
this.advancedOptions = this.allOptions.filter(i => !i.hidden());
this.isShowAdvancedOption = this.advancedOptions.length > 0;
}
onChange() {
this.allOptions = this.buildAllOptions();
this.checkOptions();
}
ngOnChanges() {
this.allOptions = this.buildAllOptions();
this.checkOptions();
}
}