Commit aa8719d0 authored by ibuler's avatar ibuler

[Update] 修改支持弹窗输入密码

parent 6b20364c
......@@ -60,5 +60,6 @@
"set font": "设置字体",
"font": "字体",
"font size": "字体大小",
"full screen": "全屏显示"
"full screen": "全屏显示",
"manual input password": "输入密码"
}
......@@ -60,5 +60,6 @@
"set font": "设置字体",
"font": "字体",
"font size": "字体大小",
"full screen": "全屏显示"
"full screen": "全屏显示",
"manual input password": "输入密码"
}
......@@ -60,5 +60,6 @@
"set font": "设置字体",
"font": "字体",
"font size": "字体大小",
"full screen": "全屏显示"
"full screen": "全屏显示",
"manual input password": "输入密码"
}
......@@ -30,7 +30,7 @@ import {ChangLanWarningDialogComponent, RDPSolutionDialogComponent, FontDialogCo
import {DialogService, ElementDialogAlertComponent} from './elements/dialog/dialog.service';
import {PluginModules} from './plugins/plugins';
import {TestPageComponent} from './test-page/test-page.component';
import {AssetTreeDialogComponent} from './elements/asset-tree/asset-tree.component';
import {AssetTreeDialogComponent, ManualPasswordDialogComponent} from './elements/asset-tree/asset-tree.component';
import {SftpComponent} from './elements/sftp/sftp.component';
......@@ -53,6 +53,7 @@ import {SftpComponent} from './elements/sftp/sftp.component';
],
entryComponents: [
AssetTreeDialogComponent,
ManualPasswordDialogComponent,
ElementDialogAlertComponent,
ChangLanWarningDialogComponent,
RDPSolutionDialogComponent,
......
......@@ -100,12 +100,18 @@ export class HttpService {
{headers: new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded')});
}
guacamole_add_asset(user_id: string, asset_id: string, system_user_id: string) {
guacamole_add_asset(user_id: string, asset_id: string, system_user_id: string, system_user_username?: string, system_user_password?: string) {
let params = new HttpParams()
.set('user_id', user_id)
.set('asset_id', asset_id)
.set('system_user_id', system_user_id)
.set('token', DataStore.guacamole_token);
if (system_user_username) {
params.set('username', system_user_username);
}
if (system_user_password) {
params.set('password', system_user_password);
}
const solution = localStorage.getItem('rdpSolution') || 'Auto';
if (solution !== 'Auto') {
const width = solution.split('x')[0];
......
......@@ -278,10 +278,26 @@ export class ElementAssetTreeComponent implements OnInit, OnChanges {
this.Connect(host);
}
manualSetUserAuthLogin(host, user) {
const dialogRef = this._dialog.open(ManualPasswordDialogComponent, {
height: '250px',
width: '400px',
data: {username: user.username}
});
dialogRef.afterClosed().subscribe(result => {
user.username = result.username;
user.password = result.password;
return this.login(host, user);
});
}
login(host, user) {
const id = NavList.List.length - 1;
this._logger.debug(NavList);
this._logger.debug(host);
if (user.login_mode === 'manual' && !user.password && user.protocol === 'rdp') {
return this.manualSetUserAuthLogin(host, user);
}
if (user) {
NavList.List[id].nick = host.hostname;
NavList.List[id].connected = true;
......@@ -420,3 +436,22 @@ export class AssetTreeDialogComponent implements OnInit {
return f1 && f2 && f1.value === f2.value;
}
}
@Component({
selector: 'elements-manual-password-dialog',
templateUrl: 'manual-password-dialog.html',
})
export class ManualPasswordDialogComponent implements OnInit {
PasswordControl = new FormControl('', [Validators.required]);
constructor(@Inject(MAT_DIALOG_DATA) public data: any,
public dialogRef: MatDialogRef<ManualPasswordDialogComponent>) {
}
onNoClick() {
this.dialogRef.close();
}
ngOnInit(): void {
}
}
<h1 mat-dialog-title>{{"Found"|trans}} {{data.users.length}} {{"Users "|trans}}</h1>
<mat-form-field>
<mat-form-field style="width: 100%">
<mat-select [(value)]="selected"
[compareWith]="compareFn"
[formControl]="UserSelectControl"
......
<h1 mat-dialog-title>{{"Manual input password"|trans}}</h1>
<mat-form-field style="width: 100%">
<input matInput placeholder="Username" [(ngModel)]="data.username">
</mat-form-field>
<mat-form-field style="width: 100%">
<input matInput [type]="'password'" [(ngModel)]="data.password" [formControl]="PasswordControl" placeholder="Password">
</mat-form-field>
<div style="float: right">
<button mat-raised-button (click)="onNoClick()" >{{"Cancel"|trans}}</button>
<button mat-raised-button color="primary" [mat-dialog-close]="data" >{{"Confirm"|trans}}</button>
</div>
......@@ -13,7 +13,7 @@ import {ElementIframeComponent} from './iframe/iframe.component';
import {ElementDialogAlertComponent} from './dialog/dialog.service';
import {ElementGuacamoleComponent} from './guacamole/guacamole.component';
import {ElementSshTermComponent} from './ssh-term/ssh-term.component';
import {AssetTreeDialogComponent, ElementAssetTreeComponent} from './asset-tree/asset-tree.component';
import {AssetTreeDialogComponent, ElementAssetTreeComponent, ManualPasswordDialogComponent} from './asset-tree/asset-tree.component';
import {RDPSolutionDialogComponent, FontDialogComponent} from './nav/nav.component';
export const ElementComponents = [
......@@ -33,6 +33,7 @@ export const ElementComponents = [
ElementAssetTreeComponent,
ElementSshTermComponent,
AssetTreeDialogComponent,
ManualPasswordDialogComponent,
RDPSolutionDialogComponent,
FontDialogComponent
];
......@@ -13,7 +13,7 @@ import {NavList} from '../../pages/control/control/control.component';
})
export class ElementGuacamoleComponent implements OnInit {
@Input() host: any;
@Input() userid: any;
@Input() sysUser: any;
@Input() remoteAppId: string;
@Input() target: string;
@Input() index: number;
......@@ -31,7 +31,7 @@ export class ElementGuacamoleComponent implements OnInit {
if (this.remoteAppId) {
action = this._http.guacamole_add_remote_app(User.id, this.remoteAppId);
} else {
action = this._http.guacamole_add_asset(User.id, this.host.id, this.userid);
action = this._http.guacamole_add_asset(User.id, this.host.id, this.sysUser.id, this.sysUser.username, this.sysUser.password);
}
action.subscribe(
data => {
......
......@@ -14,7 +14,7 @@ import {getWsSocket} from '../../globals';
})
export class ElementSshTermComponent implements OnInit, AfterViewInit, OnDestroy {
@Input() host: any;
@Input() userid: any;
@Input() sysUser: any;
@Input() index: number;
@Input() token: string;
......@@ -63,7 +63,7 @@ export class ElementSshTermComponent implements OnInit, AfterViewInit, OnDestroy
if (this.host) {
const data = {
uuid: this.host.id,
userid: this.userid,
userid: this.sysUser.id,
secret: this.secret,
size: [this.term.cols, this.term.rows]
};
......
......@@ -7,12 +7,12 @@
[ngClass]="{'active':i==NavList.Active}" style="height: 100%">
<elements-ssh-term [index]="i"
[host]="m.host"
[userid]="m.user.id"
[sysUser]="m.user"
*ngIf="m.type=='ssh'">
</elements-ssh-term>
<elements-guacamole [index]="i"
[host]="m.host"
[userid]="m.user?.id"
[sysUser]="m.user"
[remoteAppId]="m.remoteApp"
*ngIf="m.type=='rdp'">
</elements-guacamole>
......
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