Commit 3ca0ba5c authored by zheng liu's avatar zheng liu

Merged in dev (pull request #74)

feat: add debug
parents e5e5191d b716eadc
...@@ -74,6 +74,14 @@ export class HttpService { ...@@ -74,6 +74,14 @@ export class HttpService {
const body = new HttpParams() const body = new HttpParams()
.set('username', user_id) .set('username', user_id)
.set('password', 'jumpserver'); .set('password', 'jumpserver');
// {
// "authToken": "xxxxxxx",
// "username": "xxxxxx",
// "dataSource": "jumpserver",
// "availableDataSources":[
// "jumpserver"
// ]
// }
return this.http.post('/guacamole/api/tokens', return this.http.post('/guacamole/api/tokens',
body.toString(), body.toString(),
{headers: new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded')}); {headers: new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded')});
...@@ -94,10 +102,10 @@ export class HttpService { ...@@ -94,10 +102,10 @@ export class HttpService {
); );
} }
guacamole_token_add_asset(token: string) { guacamole_token_add_asset(assetToken: string, token: string) {
const params = new HttpParams() const params = new HttpParams()
.set('asset_token', token) .set('asset_token', assetToken)
.set('token', DataStore.guacamole_token); .set('token', token);
return this.http.get( return this.http.get(
'/guacamole/api/session/ext/jumpserver/asset/token/add', '/guacamole/api/session/ext/jumpserver/asset/token/add',
{ {
......
...@@ -5,6 +5,7 @@ import {DataStore, User} from '../../globals'; ...@@ -5,6 +5,7 @@ import {DataStore, User} from '../../globals';
import {DomSanitizer} from '@angular/platform-browser'; import {DomSanitizer} from '@angular/platform-browser';
import {environment} from '../../../environments/environment'; import {environment} from '../../../environments/environment';
import {NavList} from '../../ControlPage/control/control.component'; import {NavList} from '../../ControlPage/control/control.component';
import {logger} from 'codelyzer/util/logger';
@Component({ @Component({
selector: 'app-element-guacamole', selector: 'app-element-guacamole',
...@@ -33,9 +34,10 @@ export class ElementGuacamoleComponent implements OnInit { ...@@ -33,9 +34,10 @@ export class ElementGuacamoleComponent implements OnInit {
this._http.get_guacamole_token(this.userid).subscribe( this._http.get_guacamole_token(this.userid).subscribe(
data => { data => {
DataStore.guacamole_token = data['authToken']; DataStore.guacamole_token = data['authToken'];
this._http.guacamole_token_add_asset(this.token).subscribe( this._http.guacamole_token_add_asset(this.token, data['authToken']).subscribe(
_ => { data2 => {
this.target = document.location.origin + '/guacamole/#/client/' + data['result'] + '?token=' + DataStore.guacamole_token; this._logger.debug(data);
this.target = document.location.origin + '/guacamole/#/client/' + data2['result'] + '?token=' + data['authToken'];
}, },
error2 => { error2 => {
this._logger.error(error2); this._logger.error(error2);
......
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