fix: single page

parent f4c84c3e
...@@ -20,6 +20,7 @@ export class ElementGuacamoleComponent implements OnInit { ...@@ -20,6 +20,7 @@ export class ElementGuacamoleComponent implements OnInit {
@ViewChild('rdp') el: ElementRef; @ViewChild('rdp') el: ElementRef;
authToken: string; authToken: string;
base: string; base: string;
time: number;
constructor(private sanitizer: DomSanitizer, constructor(private sanitizer: DomSanitizer,
private _http: HttpService, private _http: HttpService,
...@@ -34,15 +35,18 @@ export class ElementGuacamoleComponent implements OnInit { ...@@ -34,15 +35,18 @@ export class ElementGuacamoleComponent implements OnInit {
this.userid = this._localStorage.get('user-' + this.token); this.userid = this._localStorage.get('user-' + this.token);
this.authToken = this._localStorage.get('authToken-' + this.token); this.authToken = this._localStorage.get('authToken-' + this.token);
this.base = this._localStorage.get('base-' + this.token); this.base = this._localStorage.get('base-' + this.token);
this.time = 0;
if (!this.userid) { if (!this.userid) {
this._http.get_user_id_from_token(this.token) this._http.get_user_id_from_token(this.token)
.subscribe( .subscribe(
data => { data => {
this._localStorage.set('user-' + this.token, data['user']); this._localStorage.set('user-' + this.token, data['user']);
this.time = this.time + 1;
} }
); );
} else {
this.time = this.time + 1;
} }
if (!this.authToken) { if (!this.authToken) {
...@@ -51,9 +55,12 @@ export class ElementGuacamoleComponent implements OnInit { ...@@ -51,9 +55,12 @@ export class ElementGuacamoleComponent implements OnInit {
if (data['authToken']) { if (data['authToken']) {
this._localStorage.set('authToken-' + this.token, data['authToken']); this._localStorage.set('authToken-' + this.token, data['authToken']);
this.authToken = data['authToken']; this.authToken = data['authToken'];
this.time = this.time + 1;
} }
} }
); );
} else {
this.time = this.time + 1;
} }
if (!this.base) { if (!this.base) {
this._http.guacamole_token_add_asset(this.token, this.authToken).subscribe( this._http.guacamole_token_add_asset(this.token, this.authToken).subscribe(
...@@ -61,16 +68,24 @@ export class ElementGuacamoleComponent implements OnInit { ...@@ -61,16 +68,24 @@ export class ElementGuacamoleComponent implements OnInit {
if (data['result']) { if (data['result']) {
this._localStorage.set('base-' + this.token, data['result']); this._localStorage.set('base-' + this.token, data['result']);
this.base = 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 { } 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 { } else {
const base = window.btoa(this.host.id + '\0' + 'c' + '\0' + 'jumpserver'); const base = window.btoa(this.host.id + '\0' + 'c' + '\0' + 'jumpserver');
if (environment.production) { 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