Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
L
luna
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ops
luna
Commits
5420ab2e
Commit
5420ab2e
authored
Mar 13, 2018
by
zheng liu
Browse files
Options
Browse Files
Download
Plain Diff
Merged in dev (pull request #83)
fix: single page reload bug
parents
7dcf08de
f4c84c3e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
21 deletions
+33
-21
guacamole.component.ts
src/app/elements/guacamole/guacamole.component.ts
+33
-21
No files found.
src/app/elements/guacamole/guacamole.component.ts
View file @
5420ab2e
...
@@ -5,7 +5,6 @@ import {DataStore, User} from '../../globals';
...
@@ -5,7 +5,6 @@ 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'
,
...
@@ -19,6 +18,8 @@ export class ElementGuacamoleComponent implements OnInit {
...
@@ -19,6 +18,8 @@ export class ElementGuacamoleComponent implements OnInit {
@
Input
()
index
:
number
;
@
Input
()
index
:
number
;
target
:
string
;
target
:
string
;
@
ViewChild
(
'rdp'
)
el
:
ElementRef
;
@
ViewChild
(
'rdp'
)
el
:
ElementRef
;
authToken
:
string
;
base
:
string
;
constructor
(
private
sanitizer
:
DomSanitizer
,
constructor
(
private
sanitizer
:
DomSanitizer
,
private
_http
:
HttpService
,
private
_http
:
HttpService
,
...
@@ -30,34 +31,45 @@ export class ElementGuacamoleComponent implements OnInit {
...
@@ -30,34 +31,45 @@ export class ElementGuacamoleComponent implements OnInit {
ngOnInit
()
{
ngOnInit
()
{
// /guacamole/api/tokens will redirect to http://guacamole/api/tokens
// /guacamole/api/tokens will redirect to http://guacamole/api/tokens
if
(
this
.
token
)
{
if
(
this
.
token
)
{
this
.
userid
=
this
.
_localStorage
.
get
(
'user'
);
this
.
userid
=
this
.
_localStorage
.
get
(
'user-'
+
this
.
token
);
if
(
this
.
userid
)
{
this
.
authToken
=
this
.
_localStorage
.
get
(
'authToken-'
+
this
.
token
);
this
.
base
=
this
.
_localStorage
.
get
(
'base-'
+
this
.
token
);
if
(
!
this
.
userid
)
{
this
.
_http
.
get_user_id_from_token
(
this
.
token
)
.
subscribe
(
data
=>
{
this
.
_localStorage
.
set
(
'user-'
+
this
.
token
,
data
[
'user'
]);
}
);
}
if
(
!
this
.
authToken
)
{
this
.
_http
.
get_guacamole_token
(
this
.
userid
,
this
.
token
).
subscribe
(
this
.
_http
.
get_guacamole_token
(
this
.
userid
,
this
.
token
).
subscribe
(
data
=>
{
data
=>
{
DataStore
.
guacamole_token
=
data
[
'authToken'
];
if
(
data
[
'authToken'
])
{
this
.
_http
.
guacamole_token_add_asset
(
this
.
token
,
data
[
'authToken'
]).
subscribe
(
this
.
_localStorage
.
set
(
'authToken-'
+
this
.
token
,
data
[
'authToken'
]);
data2
=>
{
this
.
authToken
=
data
[
'authToken'
];
this
.
_logger
.
debug
(
data
);
if
(
data2
[
'result'
])
{
window
.
location
.
reload
();
}
}
this
.
target
=
document
.
location
.
origin
+
'/guacamole/#/client/'
+
data2
[
'result'
]
+
'?asset_token=jumpserver&token='
+
data
[
'authToken'
];
},
error2
=>
{
this
.
_logger
.
error
(
error2
);
}
}
);
);
});
}
}
else
{
if
(
!
this
.
base
)
{
this
.
_http
.
get_user_id_from_token
(
this
.
token
)
this
.
_http
.
guacamole_token_add_asset
(
this
.
token
,
this
.
authToken
).
subscribe
(
.
subscribe
(
data
=>
{
data
=>
{
this
.
_localStorage
.
set
(
'user'
,
data
[
'user'
]);
if
(
data
[
'result'
])
{
window
.
location
.
reload
();
this
.
_localStorage
.
set
(
'base-'
+
this
.
token
,
data
[
'result'
]);
this
.
base
=
data
[
'result'
];
}
});
}
}
);
if
(
this
.
authToken
&&
this
.
base
)
{
this
.
target
=
document
.
location
.
origin
+
'/guacamole/#/client/'
+
this
.
base
+
'?asset_token=jumpserver&token='
+
this
.
authToken
;
}
else
{
window
.
location
.
reload
();
}
}
}
else
{
}
else
{
const
base
=
window
.
btoa
(
this
.
host
.
id
+
'
\
0'
+
'c'
+
'
\
0'
+
'jumpserver'
);
const
base
=
window
.
btoa
(
this
.
host
.
id
+
'
\
0'
+
'c'
+
'
\
0'
+
'jumpserver'
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment