Commit 07ffe53c authored by zheng liu's avatar zheng liu

Merged in dev (pull request #84)

fix: single page
parents 5420ab2e 00ee9f1e
......@@ -20,6 +20,7 @@ export class ElementGuacamoleComponent implements OnInit {
@ViewChild('rdp') el: ElementRef;
authToken: string;
base: string;
time: number;
constructor(private sanitizer: DomSanitizer,
private _http: HttpService,
......@@ -34,15 +35,18 @@ export class ElementGuacamoleComponent implements OnInit {
this.userid = this._localStorage.get('user-' + this.token);
this.authToken = this._localStorage.get('authToken-' + this.token);
this.base = this._localStorage.get('base-' + this.token);
this.time = 0;
if (!this.userid) {
this._http.get_user_id_from_token(this.token)
.subscribe(
data => {
this._localStorage.set('user-' + this.token, data['user']);
this.time = this.time + 1;
}
);
} else {
this.time = this.time + 1;
}
if (!this.authToken) {
......@@ -51,9 +55,12 @@ export class ElementGuacamoleComponent implements OnInit {
if (data['authToken']) {
this._localStorage.set('authToken-' + this.token, data['authToken']);
this.authToken = data['authToken'];
this.time = this.time + 1;
}
}
);
} else {
this.time = this.time + 1;
}
if (!this.base) {
this._http.guacamole_token_add_asset(this.token, this.authToken).subscribe(
......@@ -61,16 +68,24 @@ export class ElementGuacamoleComponent implements OnInit {
if (data['result']) {
this._localStorage.set('base-' + this.token, data['result']);
this.base = data['result'];
this.time = this.time + 1;
}
});
}
if (this.authToken && this.base) {
this.target = document.location.origin + '/guacamole/#/client/' + this.base +
'?asset_token=jumpserver&token=' + this.authToken;
} else {
window.location.reload();
this.time = this.time + 1;
}
setTimeout(() => {
if (this.time === 3) {
if (this.authToken && this.base) {
this.target = document.location.origin + '/guacamole/#/client/' + this.base +
'?asset_token=jumpserver&token=' + this.authToken;
} else {
window.location.reload();
}
}
},
50
);
} else {
const base = window.btoa(this.host.id + '\0' + 'c' + '\0' + 'jumpserver');
if (environment.production) {
......
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