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
30546d2e
Unverified
Commit
30546d2e
authored
Mar 13, 2018
by
liuzheng
Committed by
liuzheng712
Mar 13, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: update
parent
00ee9f1e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
68 additions
and
64 deletions
+68
-64
connect-page.component.html
src/app/connect-page/connect-page.component.html
+1
-1
connect-page.component.ts
src/app/connect-page/connect-page.component.ts
+64
-2
guacamole.component.ts
src/app/elements/guacamole/guacamole.component.ts
+3
-61
No files found.
src/app/connect-page/connect-page.component.html
View file @
30546d2e
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
*
ngIf=
"system =='linux'"
>
*
ngIf=
"system =='linux'"
>
</app-element-term>
</app-element-term>
<app-element-guacamole
<app-element-guacamole
[
t
oken
]="
token
"
[
t
arget
]="
target
"
[
index
]="
0
"
[
index
]="
0
"
*
ngIf=
"system=='windows'"
>
*
ngIf=
"system=='windows'"
>
</app-element-guacamole>
</app-element-guacamole>
src/app/connect-page/connect-page.component.ts
View file @
30546d2e
import
{
Component
,
OnInit
}
from
'@angular/core'
;
import
{
Component
,
OnInit
}
from
'@angular/core'
;
import
{
AppService
}
from
'../app.service'
;
import
{
AppService
,
HttpService
,
LocalStorageService
}
from
'../app.service'
;
import
{
DataStore
}
from
'../globals'
;
import
{
DataStore
}
from
'../globals'
;
import
*
as
jQuery
from
'jquery/dist/jquery.min.js'
;
import
*
as
jQuery
from
'jquery/dist/jquery.min.js'
;
...
@@ -11,8 +11,15 @@ import * as jQuery from 'jquery/dist/jquery.min.js';
...
@@ -11,8 +11,15 @@ import * as jQuery from 'jquery/dist/jquery.min.js';
export
class
ConnectPageComponent
implements
OnInit
{
export
class
ConnectPageComponent
implements
OnInit
{
token
:
string
;
token
:
string
;
system
:
string
;
system
:
string
;
authToken
:
string
;
userid
:
string
;
target
:
string
;
base
:
string
;
time
:
number
;
constructor
(
private
_appService
:
AppService
)
{
constructor
(
private
_appService
:
AppService
,
private
_http
:
HttpService
,
private
_localStorage
:
LocalStorageService
)
{
DataStore
.
NavShow
=
false
;
DataStore
.
NavShow
=
false
;
}
}
...
@@ -22,6 +29,61 @@ export class ConnectPageComponent implements OnInit {
...
@@ -22,6 +29,61 @@ export class ConnectPageComponent implements OnInit {
jQuery
(
'body'
).
css
(
'background-color'
,
'black'
);
jQuery
(
'body'
).
css
(
'background-color'
,
'black'
);
this
.
userid
=
this
.
_localStorage
.
get
(
'user-'
+
this
.
token
);
this
.
authToken
=
this
.
_localStorage
.
get
(
'authToken-'
+
this
.
token
);
this
.
base
=
this
.
_localStorage
.
get
(
'base-'
+
this
.
token
);
this
.
time
=
0
;
if
(
this
.
system
===
'windows'
)
{
if
(
!
this
.
userid
)
{
this
.
_http
.
get_user_id_from_token
(
this
.
token
)
.
subscribe
(
data
=>
{
this
.
_localStorage
.
set
(
'user-'
+
this
.
token
,
data
[
'user'
]);
this
.
time
=
this
.
time
+
1
;
}
);
}
else
{
this
.
time
=
this
.
time
+
1
;
}
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'
];
this
.
time
=
this
.
time
+
1
;
}
}
);
}
else
{
this
.
time
=
this
.
time
+
1
;
}
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'
];
this
.
time
=
this
.
time
+
1
;
}
});
}
else
{
this
.
time
=
this
.
time
+
1
;
}
setTimeout
(()
=>
{
if
(
this
.
time
===
3
)
{
if
(
this
.
authToken
&&
this
.
base
)
{
this
.
target
=
document
.
location
.
origin
+
'/guacamole/#/client/'
+
this
.
base
+
'?asset_token=jumpserver&token='
+
this
.
authToken
;
}
}
},
50
);
}
}
}
}
}
src/app/elements/guacamole/guacamole.component.ts
View file @
30546d2e
...
@@ -14,13 +14,10 @@ import {NavList} from '../../ControlPage/control/control.component';
...
@@ -14,13 +14,10 @@ import {NavList} from '../../ControlPage/control/control.component';
export
class
ElementGuacamoleComponent
implements
OnInit
{
export
class
ElementGuacamoleComponent
implements
OnInit
{
@
Input
()
host
:
any
;
@
Input
()
host
:
any
;
@
Input
()
userid
:
any
;
@
Input
()
userid
:
any
;
@
Input
()
t
oken
:
string
;
@
Input
()
t
arget
:
string
;
@
Input
()
index
:
number
;
@
Input
()
index
:
number
;
target
:
string
;
@
ViewChild
(
'rdp'
)
el
:
ElementRef
;
@
ViewChild
(
'rdp'
)
el
:
ElementRef
;
authToken
:
string
;
base
:
string
;
time
:
number
;
constructor
(
private
sanitizer
:
DomSanitizer
,
constructor
(
private
sanitizer
:
DomSanitizer
,
private
_http
:
HttpService
,
private
_http
:
HttpService
,
...
@@ -31,62 +28,7 @@ export class ElementGuacamoleComponent implements OnInit {
...
@@ -31,62 +28,7 @@ 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
.
target
)
{
this
.
userid
=
this
.
_localStorage
.
get
(
'user-'
+
this
.
token
);
this
.
authToken
=
this
.
_localStorage
.
get
(
'authToken-'
+
this
.
token
);
this
.
base
=
this
.
_localStorage
.
get
(
'base-'
+
this
.
token
);
this
.
time
=
0
;
if
(
!
this
.
userid
)
{
this
.
_http
.
get_user_id_from_token
(
this
.
token
)
.
subscribe
(
data
=>
{
this
.
_localStorage
.
set
(
'user-'
+
this
.
token
,
data
[
'user'
]);
this
.
time
=
this
.
time
+
1
;
}
);
}
else
{
this
.
time
=
this
.
time
+
1
;
}
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'
];
this
.
time
=
this
.
time
+
1
;
}
}
);
}
else
{
this
.
time
=
this
.
time
+
1
;
}
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'
];
this
.
time
=
this
.
time
+
1
;
}
});
}
else
{
this
.
time
=
this
.
time
+
1
;
}
setTimeout
(()
=>
{
if
(
this
.
time
===
3
)
{
if
(
this
.
authToken
&&
this
.
base
)
{
this
.
target
=
document
.
location
.
origin
+
'/guacamole/#/client/'
+
this
.
base
+
'?asset_token=jumpserver&token='
+
this
.
authToken
;
}
else
{
window
.
location
.
reload
();
}
}
},
50
);
}
else
{
const
base
=
window
.
btoa
(
this
.
host
.
id
+
'
\
0'
+
'c'
+
'
\
0'
+
'jumpserver'
);
const
base
=
window
.
btoa
(
this
.
host
.
id
+
'
\
0'
+
'c'
+
'
\
0'
+
'jumpserver'
);
if
(
environment
.
production
)
{
if
(
environment
.
production
)
{
if
(
DataStore
.
guacamole_token
)
{
if
(
DataStore
.
guacamole_token
)
{
...
...
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