fix: update

parent 2af98186
......@@ -2,7 +2,7 @@ import {Component, Input, OnInit} from '@angular/core';
import {DomSanitizer} from '@angular/platform-browser';
import {NavList} from '../../ControlPage/control/control.component';
import {User, guacamole} from '../../globals';
import {User, DataStore} from '../../globals';
import {HttpService, LogService} from '../../app.service';
@Component({
......@@ -15,7 +15,6 @@ export class ElementIframeComponent implements OnInit {
@Input() userid: any;
@Input() index: number;
target: string;
guacamole = guacamole;
constructor(private sanitizer: DomSanitizer,
private _http: HttpService,
......@@ -25,15 +24,15 @@ export class ElementIframeComponent implements OnInit {
ngOnInit() {
// /guacamole/api/tokens will redirect to http://guacamole/api/tokens
const base = window.btoa(this.host.hostname + '\0' + 'c' + '\0' + 'jumpserver');
if (this.guacamole.token) {
this.target = document.location.origin + '/guacamole/#/client/' + base + '?token=' + this.guacamole.token;
if (DataStore.guacamole_token) {
this.target = document.location.origin + '/guacamole/#/client/' + base + '?token=' + DataStore.guacamole_token;
} else {
this._http.get_guacamole_token(User.name, this.host.id, this.userid).subscribe(
data => {
// /guacamole/client will redirect to http://guacamole/#/client
this.target = document.location.origin +
'/guacamole/#/client/' + base + '?token=' + data['authToken'];
this.guacamole.token = data['authToken'];
DataStore.guacamole_token = data['authToken'];
},
error2 => {
this._logger.error(error2);
......
......@@ -104,6 +104,7 @@ export let DataStore: {
leftbarshow: boolean;
windowsize: Array<number>;
autologin: boolean;
guacamole_token: string;
} = {
socket: io.connect(),
Nav: [{}],
......@@ -115,6 +116,7 @@ export let DataStore: {
leftbarshow: true,
windowsize: [],
autologin: false,
guacamole_token: ''
};
export let CSRF = '';
......@@ -147,4 +149,3 @@ export let wsEvent: {
export const i18n = new Map();
export let guacamole: { token: string } = {token: ''};
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