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
f4c84c3e
Unverified
Commit
f4c84c3e
authored
Mar 13, 2018
by
liuzheng712
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: single page reload bug
parent
64047868
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
23 deletions
+35
-23
guacamole.component.ts
src/app/elements/guacamole/guacamole.component.ts
+35
-23
No files found.
src/app/elements/guacamole/guacamole.component.ts
View file @
f4c84c3e
...
@@ -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
.
_http
.
get_guacamole_token
(
this
.
userid
,
this
.
token
).
subscribe
(
this
.
base
=
this
.
_localStorage
.
get
(
'base-'
+
this
.
token
);
data
=>
{
DataStore
.
guacamole_token
=
data
[
'authToken'
];
this
.
_http
.
guacamole_token_add_asset
(
this
.
token
,
data
[
'authToken'
]).
subscribe
(
if
(
!
this
.
userid
)
{
data2
=>
{
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
{
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'
,
data
[
'user'
]);
this
.
_localStorage
.
set
(
'user-'
+
this
.
token
,
data
[
'user'
]);
window
.
location
.
reload
();
}
}
);
);
}
if
(
!
this
.
authToken
)
{
this
.
_http
.
get_guacamole_token
(
this
.
userid
,
this
.
token
).
subscribe
(
data
=>
{
if
(
data
[
'authToken'
])
{
this
.
_localStorage
.
set
(
'authToken-'
+
this
.
token
,
data
[
'authToken'
]);
this
.
authToken
=
data
[
'authToken'
];
}
}
);
}
if
(
!
this
.
base
)
{
this
.
_http
.
guacamole_token_add_asset
(
this
.
token
,
this
.
authToken
).
subscribe
(
data
=>
{
if
(
data
[
'result'
])
{
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