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
0d87dbcd
Commit
0d87dbcd
authored
Jun 26, 2019
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Bugfix] 修复guacamole重启后无法打开的问题
parent
9c80c191
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
39 deletions
+35
-39
guacamole.component.ts
src/app/elements/guacamole/guacamole.component.ts
+35
-39
No files found.
src/app/elements/guacamole/guacamole.component.ts
View file @
0d87dbcd
...
@@ -18,6 +18,7 @@ export class ElementGuacamoleComponent implements OnInit {
...
@@ -18,6 +18,7 @@ export class ElementGuacamoleComponent implements OnInit {
@
Input
()
target
:
string
;
@
Input
()
target
:
string
;
@
Input
()
index
:
number
;
@
Input
()
index
:
number
;
@
ViewChild
(
'rdp'
)
el
:
ElementRef
;
@
ViewChild
(
'rdp'
)
el
:
ElementRef
;
registered
=
false
;
constructor
(
private
sanitizer
:
DomSanitizer
,
constructor
(
private
sanitizer
:
DomSanitizer
,
private
_http
:
HttpService
,
private
_http
:
HttpService
,
...
@@ -26,29 +27,42 @@ export class ElementGuacamoleComponent implements OnInit {
...
@@ -26,29 +27,42 @@ export class ElementGuacamoleComponent implements OnInit {
}
}
registerHost
()
{
registerHost
()
{
let
action
:
any
;
if
(
this
.
remoteAppId
)
{
if
(
this
.
remoteAppId
)
{
this
.
_http
.
guacamole_add_remote_app
(
User
.
id
,
this
.
remoteAppId
).
subscribe
(
action
=
this
.
_http
.
guacamole_add_remote_app
(
User
.
id
,
this
.
remoteAppId
);
data
=>
{
const
base
=
data
.
result
;
this
.
target
=
document
.
location
.
origin
+
'/guacamole/#/client/'
+
base
+
'?token='
+
DataStore
.
guacamole_token
;
NavList
.
List
[
this
.
index
].
Rdp
=
this
.
el
.
nativeElement
;
},
error
=>
{
this
.
_logger
.
error
(
error
);
}
);
}
else
{
}
else
{
this
.
_http
.
guacamole_add_asset
(
User
.
id
,
this
.
host
.
id
,
this
.
userid
).
subscribe
(
action
=
this
.
_http
.
guacamole_add_asset
(
User
.
id
,
this
.
host
.
id
,
this
.
userid
);
data
=>
{
const
base
=
data
.
result
;
this
.
target
=
document
.
location
.
origin
+
'/guacamole/#/client/'
+
base
+
'?token='
+
DataStore
.
guacamole_token
;
NavList
.
List
[
this
.
index
].
Rdp
=
this
.
el
.
nativeElement
;
},
error2
=>
{
this
.
_logger
.
error
(
error2
);
}
);
}
}
action
.
subscribe
(
data
=>
{
const
base
=
data
.
result
;
this
.
target
=
document
.
location
.
origin
+
'/guacamole/#/client/'
+
base
+
'?token='
+
DataStore
.
guacamole_token
;
NavList
.
List
[
this
.
index
].
Rdp
=
this
.
el
.
nativeElement
;
},
error
=>
{
if
(
!
this
.
registered
)
{
this
.
registerToken
();
}
}
);
}
registerToken
()
{
const
now
=
new
Date
();
const
nowTime
=
now
.
getTime
()
/
1000
;
this
.
registered
=
true
;
this
.
_http
.
get_guacamole_token
(
User
.
id
,
''
).
subscribe
(
data
=>
{
// /guacamole/client will redirect to http://guacamole/#/client
DataStore
.
guacamole_token
=
data
[
'authToken'
];
DataStore
.
guacamole_token_time
=
nowTime
;
this
.
registerHost
();
},
error
=>
{
this
.
_logger
.
error
(
error
);
return
null
;
}
);
}
}
ngOnInit
()
{
ngOnInit
()
{
...
@@ -63,25 +77,7 @@ export class ElementGuacamoleComponent implements OnInit {
...
@@ -63,25 +77,7 @@ export class ElementGuacamoleComponent implements OnInit {
NavList
.
List
[
this
.
index
].
Rdp
=
this
.
el
.
nativeElement
;
NavList
.
List
[
this
.
index
].
Rdp
=
this
.
el
.
nativeElement
;
return
null
;
return
null
;
}
}
const
now
=
new
Date
();
this
.
registerHost
();
const
nowTime
=
now
.
getTime
()
/
1000
;
if
(
!
DataStore
.
guacamole_token
||
nowTime
-
DataStore
.
guacamole_token_time
>
3600
)
{
this
.
_http
.
get_guacamole_token
(
User
.
id
,
''
).
subscribe
(
data
=>
{
// /guacamole/client will redirect to http://guacamole/#/client
DataStore
.
guacamole_token
=
data
[
'authToken'
];
DataStore
.
guacamole_token_time
=
nowTime
;
this
.
registerHost
();
},
error
=>
{
this
.
_logger
.
error
(
error
);
alert
(
error
.
message
);
return
null
;
}
);
}
else
{
this
.
registerHost
();
}
}
}
trust
(
url
)
{
trust
(
url
)
{
...
...
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