Commit 51d5f055 authored by ibuler's avatar ibuler

[Update] 修改token

parent e0613f81
...@@ -26,6 +26,30 @@ export class ElementGuacamoleComponent implements OnInit { ...@@ -26,6 +26,30 @@ export class ElementGuacamoleComponent implements OnInit {
private _logger: LogService) { private _logger: LogService) {
} }
registerHost() {
if (this.remoteAppId) {
this._http.guacamole_add_remote_app(User.id, this.remoteAppId).subscribe(
data => {
const base = data.result;
this.target = document.location.origin + '/guacamole/#/client/' + base + '?token=' + DataStore.guacamole_token;
},
error => {
this._logger.error(error);
}
);
} else {
this._http.guacamole_add_asset(User.id, this.host.id, this.userid).subscribe(
data => {
const base = data.result;
this.target = document.location.origin + '/guacamole/#/client/' + base + '?token=' + DataStore.guacamole_token;
},
error2 => {
this._logger.error(error2);
}
);
}
}
ngOnInit() { ngOnInit() {
// /guacamole/api/tokens will redirect to http://guacamole/api/tokens // /guacamole/api/tokens will redirect to http://guacamole/api/tokens
if (this.target) { if (this.target) {
...@@ -43,6 +67,7 @@ export class ElementGuacamoleComponent implements OnInit { ...@@ -43,6 +67,7 @@ export class ElementGuacamoleComponent implements OnInit {
data => { data => {
// /guacamole/client will redirect to http://guacamole/#/client // /guacamole/client will redirect to http://guacamole/#/client
DataStore.guacamole_token = data['authToken']; DataStore.guacamole_token = data['authToken'];
this.registerHost();
}, },
error => { error => {
this._logger.error(error); this._logger.error(error);
...@@ -50,27 +75,8 @@ export class ElementGuacamoleComponent implements OnInit { ...@@ -50,27 +75,8 @@ export class ElementGuacamoleComponent implements OnInit {
return null; return null;
} }
); );
}
if (this.remoteAppId !== '') {
this._http.guacamole_add_remote_app(User.id, this.remoteAppId).subscribe(
data => {
const base = data.result;
this.target = document.location.origin + '/guacamole/#/client/' + base + '?token=' + DataStore.guacamole_token;
},
error => {
this._logger.error(error);
}
);
} else { } else {
this._http.guacamole_add_asset(User.id, this.host.id, this.userid).subscribe( this.registerHost();
data => {
const base = data.result;
this.target = document.location.origin + '/guacamole/#/client/' + base + '?token=' + DataStore.guacamole_token;
},
error2 => {
this._logger.error(error2);
}
);
} }
NavList.List[this.index].Rdp = this.el.nativeElement; NavList.List[this.index].Rdp = this.el.nativeElement;
......
...@@ -19,7 +19,7 @@ export class View { ...@@ -19,7 +19,7 @@ export class View {
closed: boolean; closed: boolean;
host: any; host: any;
user: any; user: any;
remoteApp: any; remoteApp: string;
room: string; room: string;
Rdp: any; Rdp: any;
Term: any; Term: any;
......
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