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
8ee3124e
Unverified
Commit
8ee3124e
authored
Aug 26, 2019
by
老广
Committed by
GitHub
Aug 26, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Update] remote app可以填写密码 (#97)
parent
c6b443be
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
76 additions
and
58 deletions
+76
-58
app.service.ts
src/app/app.service.ts
+15
-5
asset-tree.component.ts
src/app/elements/asset-tree/asset-tree.component.ts
+60
-52
guacamole.component.ts
src/app/elements/guacamole/guacamole.component.ts
+1
-1
No files found.
src/app/app.service.ts
View file @
8ee3124e
...
@@ -106,11 +106,12 @@ export class HttpService {
...
@@ -106,11 +106,12 @@ export class HttpService {
.
set
(
'asset_id'
,
asset_id
)
.
set
(
'asset_id'
,
asset_id
)
.
set
(
'system_user_id'
,
system_user_id
)
.
set
(
'system_user_id'
,
system_user_id
)
.
set
(
'token'
,
DataStore
.
guacamole_token
);
.
set
(
'token'
,
DataStore
.
guacamole_token
);
let
body
=
new
HttpParams
();
if
(
system_user_username
)
{
if
(
system_user_username
)
{
params
=
params
.
set
(
'username'
,
system_user_username
);
body
=
body
.
set
(
'username'
,
system_user_username
);
}
}
if
(
system_user_password
)
{
if
(
system_user_password
)
{
params
=
params
.
set
(
'password'
,
system_user_password
);
body
=
body
.
set
(
'password'
,
system_user_password
);
}
}
const
solution
=
localStorage
.
getItem
(
'rdpSolution'
)
||
'Auto'
;
const
solution
=
localStorage
.
getItem
(
'rdpSolution'
)
||
'Auto'
;
if
(
solution
!==
'Auto'
)
{
if
(
solution
!==
'Auto'
)
{
...
@@ -119,8 +120,9 @@ export class HttpService {
...
@@ -119,8 +120,9 @@ export class HttpService {
params
=
params
.
set
(
'width'
,
width
).
set
(
'height'
,
height
);
params
=
params
.
set
(
'width'
,
width
).
set
(
'height'
,
height
);
}
}
return
this
.
http
.
ge
t
<
GuacObjAddResp
>
(
return
this
.
http
.
pos
t
<
GuacObjAddResp
>
(
'/guacamole/api/session/ext/jumpserver/asset/add'
,
'/guacamole/api/session/ext/jumpserver/asset/add'
,
body
.
toString
(),
{
{
headers
:
new
HttpHeaders
().
set
(
'Content-Type'
,
'application/x-www-form-urlencoded'
),
headers
:
new
HttpHeaders
().
set
(
'Content-Type'
,
'application/x-www-form-urlencoded'
),
params
:
params
params
:
params
...
@@ -128,11 +130,18 @@ export class HttpService {
...
@@ -128,11 +130,18 @@ export class HttpService {
);
);
}
}
guacamole_add_remote_app
(
user_id
:
string
,
remote_app_id
:
string
)
{
guacamole_add_remote_app
(
user_id
:
string
,
remote_app_id
:
string
,
system_user_username
?:
string
,
system_user_password
?:
string
)
{
let
params
=
new
HttpParams
()
let
params
=
new
HttpParams
()
.
set
(
'user_id'
,
user_id
)
.
set
(
'user_id'
,
user_id
)
.
set
(
'remote_app_id'
,
remote_app_id
)
.
set
(
'remote_app_id'
,
remote_app_id
)
.
set
(
'token'
,
DataStore
.
guacamole_token
);
.
set
(
'token'
,
DataStore
.
guacamole_token
);
let
body
=
new
HttpParams
();
if
(
system_user_username
)
{
body
=
body
.
set
(
'username'
,
system_user_username
);
}
if
(
system_user_password
)
{
body
=
body
.
set
(
'password'
,
system_user_password
);
}
const
solution
=
localStorage
.
getItem
(
'rdpSolution'
)
||
'Auto'
;
const
solution
=
localStorage
.
getItem
(
'rdpSolution'
)
||
'Auto'
;
if
(
solution
!==
'Auto'
)
{
if
(
solution
!==
'Auto'
)
{
const
width
=
solution
.
split
(
'x'
)[
0
];
const
width
=
solution
.
split
(
'x'
)[
0
];
...
@@ -140,8 +149,9 @@ export class HttpService {
...
@@ -140,8 +149,9 @@ export class HttpService {
params
=
params
.
set
(
'width'
,
width
).
set
(
'height'
,
height
);
params
=
params
.
set
(
'width'
,
width
).
set
(
'height'
,
height
);
}
}
return
this
.
http
.
ge
t
<
GuacObjAddResp
>
(
return
this
.
http
.
pos
t
<
GuacObjAddResp
>
(
'/guacamole/api/session/ext/jumpserver/remote-app/add'
,
'/guacamole/api/session/ext/jumpserver/remote-app/add'
,
body
.
toString
(),
{
{
headers
:
new
HttpHeaders
().
set
(
'Content-Type'
,
'application/x-www-form-urlencoded'
),
headers
:
new
HttpHeaders
().
set
(
'Content-Type'
,
'application/x-www-form-urlencoded'
),
params
:
params
params
:
params
...
...
src/app/elements/asset-tree/asset-tree.component.ts
View file @
8ee3124e
...
@@ -5,6 +5,7 @@ import {MAT_DIALOG_DATA, MatDialog, MatDialogRef} from '@angular/material';
...
@@ -5,6 +5,7 @@ import {MAT_DIALOG_DATA, MatDialog, MatDialogRef} from '@angular/material';
import
{
FormControl
,
Validators
}
from
'@angular/forms'
;
import
{
FormControl
,
Validators
}
from
'@angular/forms'
;
import
{
BehaviorSubject
}
from
'rxjs/BehaviorSubject'
;
import
{
BehaviorSubject
}
from
'rxjs/BehaviorSubject'
;
import
{
ActivatedRoute
}
from
'@angular/router'
;
import
{
ActivatedRoute
}
from
'@angular/router'
;
import
*
as
jQuery
from
'jquery/dist/jquery.min'
;
declare
var
$
:
any
;
declare
var
$
:
any
;
...
@@ -60,16 +61,16 @@ export class ElementAssetTreeComponent implements OnInit, OnChanges {
...
@@ -60,16 +61,16 @@ export class ElementAssetTreeComponent implements OnInit, OnChanges {
public
_logger
:
LogService
,
public
_logger
:
LogService
,
private
activatedRoute
:
ActivatedRoute
,
private
activatedRoute
:
ActivatedRoute
,
private
_http
:
HttpService
private
_http
:
HttpService
)
{
)
{
this
.
searchEvt$
=
new
BehaviorSubject
<
string
>
(
this
.
query
);
this
.
searchEvt$
=
new
BehaviorSubject
<
string
>
(
this
.
query
);
}
}
getGrantedAssetsNodes
()
{
getGrantedAssetsNodes
()
{
this
.
_http
.
get_my_granted_nodes
()
this
.
_http
.
get_my_granted_nodes
()
.
subscribe
(
response
=>
{
.
subscribe
(
response
=>
{
this
.
Data
=
[...
response
,
...
this
.
Data
];
this
.
Data
=
[...
response
,
...
this
.
Data
];
this
.
draw
();
this
.
draw
();
});
});
}
}
refreshGrantedAssetsNodes
()
{
refreshGrantedAssetsNodes
()
{
...
@@ -87,7 +88,7 @@ export class ElementAssetTreeComponent implements OnInit, OnChanges {
...
@@ -87,7 +88,7 @@ export class ElementAssetTreeComponent implements OnInit, OnChanges {
this
.
Data
=
[...
this
.
Data
,
...
response
];
this
.
Data
=
[...
this
.
Data
,
...
response
];
this
.
draw
();
this
.
draw
();
}
}
});
});
}
}
ngOnInit
()
{
ngOnInit
()
{
...
@@ -126,16 +127,16 @@ export class ElementAssetTreeComponent implements OnInit, OnChanges {
...
@@ -126,16 +127,16 @@ export class ElementAssetTreeComponent implements OnInit, OnChanges {
});
});
this
.
activatedRoute
.
queryParams
.
subscribe
(
params
=>
{
this
.
activatedRoute
.
queryParams
.
subscribe
(
params
=>
{
const
login_to
=
params
[
'login_to'
];
const
login_to
=
params
[
'login_to'
];
if
(
login_to
&&
!
this
.
hasLoginTo
)
{
if
(
login_to
&&
!
this
.
hasLoginTo
)
{
this
.
Data
.
forEach
(
t
=>
{
this
.
Data
.
forEach
(
t
=>
{
if
(
login_to
===
t
.
id
&&
t
.
isParent
===
false
)
{
if
(
login_to
===
t
.
id
&&
t
.
isParent
===
false
)
{
this
.
hasLoginTo
=
true
;
this
.
hasLoginTo
=
true
;
this
.
Connect
(
t
);
this
.
Connect
(
t
);
return
;
return
;
}
}
});
});
}
}
});
});
}
}
...
@@ -146,7 +147,7 @@ export class ElementAssetTreeComponent implements OnInit, OnChanges {
...
@@ -146,7 +147,7 @@ export class ElementAssetTreeComponent implements OnInit, OnChanges {
$rootNodeRef
.
after
(
refreshIcon
);
$rootNodeRef
.
after
(
refreshIcon
);
const
refreshIconRef
=
$
(
'#tree-refresh'
);
const
refreshIconRef
=
$
(
'#tree-refresh'
);
refreshIconRef
.
bind
(
'click'
,
function
()
{
refreshIconRef
.
bind
(
'click'
,
function
()
{
callback
();
callback
();
});
});
}
}
...
@@ -165,7 +166,7 @@ export class ElementAssetTreeComponent implements OnInit, OnChanges {
...
@@ -165,7 +166,7 @@ export class ElementAssetTreeComponent implements OnInit, OnChanges {
}
}
onRightClick
(
event
,
treeId
,
treeNode
)
{
onRightClick
(
event
,
treeId
,
treeNode
)
{
if
(
!
treeNode
||
treeNode
.
isParent
)
{
if
(
!
treeNode
||
treeNode
.
isParent
)
{
return
null
;
return
null
;
}
}
const
host
=
treeNode
.
meta
.
asset
;
const
host
=
treeNode
.
meta
.
asset
;
...
@@ -175,10 +176,10 @@ export class ElementAssetTreeComponent implements OnInit, OnChanges {
...
@@ -175,10 +176,10 @@ export class ElementAssetTreeComponent implements OnInit, OnChanges {
protocols
.
push
(
host
.
protocol
);
protocols
.
push
(
host
.
protocol
);
}
}
for
(
let
i
=
0
;
i
<
protocols
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
protocols
.
length
;
i
++
)
{
const
protocol
=
protocols
[
i
];
const
protocol
=
protocols
[
i
];
if
(
protocol
&&
protocol
.
startsWith
(
'ssh'
))
{
if
(
protocol
&&
protocol
.
startsWith
(
'ssh'
))
{
findSSHProtocol
=
true
;
findSSHProtocol
=
true
;
}
}
}
}
if
(
!
findSSHProtocol
)
{
if
(
!
findSSHProtocol
)
{
alert
(
'Windows 请使用Ctrl+Shift+Alt呼出侧边栏上传下载'
);
alert
(
'Windows 请使用Ctrl+Shift+Alt呼出侧边栏上传下载'
);
...
@@ -193,7 +194,20 @@ export class ElementAssetTreeComponent implements OnInit, OnChanges {
...
@@ -193,7 +194,20 @@ export class ElementAssetTreeComponent implements OnInit, OnChanges {
this
.
rightClickSelectNode
=
treeNode
;
this
.
rightClickSelectNode
=
treeNode
;
}
}
}
}
Connect
(
node
)
{
switch
(
node
.
meta
.
type
)
{
case
'asset'
:
this
.
connectAsset
(
node
);
break
;
case
'remote_app'
:
this
.
connectRemoteApp
(
node
);
break
;
default
:
alert
(
'Unknown type: '
+
node
.
meta
.
type
);
}
}
connectAsset
(
node
)
{
connectAsset
(
node
)
{
const
system_users
=
node
.
meta
.
system_users
;
const
system_users
=
node
.
meta
.
system_users
;
const
host
=
node
.
meta
.
asset
;
const
host
=
node
.
meta
.
asset
;
...
@@ -230,30 +244,26 @@ export class ElementAssetTreeComponent implements OnInit, OnChanges {
...
@@ -230,30 +244,26 @@ export class ElementAssetTreeComponent implements OnInit, OnChanges {
}
}
connectRemoteApp
(
node
)
{
connectRemoteApp
(
node
)
{
const
user
=
node
.
meta
.
user
;
return
this
.
loginRemoteApp
(
node
,
user
);
}
loginRemoteApp
(
node
,
user
)
{
const
id
=
NavList
.
List
.
length
-
1
;
const
id
=
NavList
.
List
.
length
-
1
;
if
(
user
.
login_mode
===
'manual'
&&
!
user
.
password
&&
user
.
protocol
===
'rdp'
)
{
return
this
.
manualSetUserAuthLogin
(
node
,
user
,
this
.
loginRemoteApp
);
}
if
(
node
)
{
if
(
node
)
{
NavList
.
List
[
id
].
nick
=
node
.
name
;
NavList
.
List
[
id
].
nick
=
node
.
name
;
NavList
.
List
[
id
].
connected
=
true
;
NavList
.
List
[
id
].
connected
=
true
;
NavList
.
List
[
id
].
edit
=
false
;
NavList
.
List
[
id
].
edit
=
false
;
NavList
.
List
[
id
].
closed
=
false
;
NavList
.
List
[
id
].
closed
=
false
;
NavList
.
List
[
id
].
remoteApp
=
node
.
id
;
NavList
.
List
[
id
].
remoteApp
=
node
.
id
;
NavList
.
List
[
id
].
user
=
user
;
NavList
.
List
[
id
].
type
=
'rdp'
;
NavList
.
List
[
id
].
type
=
'rdp'
;
NavList
.
List
.
push
(
new
View
());
NavList
.
List
.
push
(
new
View
());
NavList
.
Active
=
id
;
NavList
.
Active
=
id
;
}
jQuery
(
'.tabs'
).
animate
({
'scrollLeft'
:
150
*
id
},
400
);
this
.
_logger
.
debug
(
NavList
);
}
Connect
(
node
)
{
switch
(
node
.
meta
.
type
)
{
case
'asset'
:
this
.
connectAsset
(
node
);
break
;
case
'remote_app'
:
this
.
connectRemoteApp
(
node
);
break
;
default
:
alert
(
'Unknown type: '
+
node
.
meta
.
type
);
}
}
}
}
...
@@ -269,8 +279,8 @@ export class ElementAssetTreeComponent implements OnInit, OnChanges {
...
@@ -269,8 +279,8 @@ export class ElementAssetTreeComponent implements OnInit, OnChanges {
NavList
.
List
[
id
].
type
=
'sftp'
;
NavList
.
List
[
id
].
type
=
'sftp'
;
NavList
.
List
.
push
(
new
View
());
NavList
.
List
.
push
(
new
View
());
NavList
.
Active
=
id
;
NavList
.
Active
=
id
;
jQuery
(
'.tabs'
).
animate
({
'scrollLeft'
:
150
*
id
},
400
);
}
}
this
.
_logger
.
debug
(
NavList
);
}
}
connectTerminal
()
{
connectTerminal
()
{
...
@@ -278,7 +288,7 @@ export class ElementAssetTreeComponent implements OnInit, OnChanges {
...
@@ -278,7 +288,7 @@ export class ElementAssetTreeComponent implements OnInit, OnChanges {
this
.
Connect
(
host
);
this
.
Connect
(
host
);
}
}
manualSetUserAuthLogin
(
host
,
user
)
{
manualSetUserAuthLogin
(
host
,
user
,
callback
)
{
user
=
Object
.
assign
({},
user
);
user
=
Object
.
assign
({},
user
);
const
dialogRef
=
this
.
_dialog
.
open
(
ManualPasswordDialogComponent
,
{
const
dialogRef
=
this
.
_dialog
.
open
(
ManualPasswordDialogComponent
,
{
height
:
'250px'
,
height
:
'250px'
,
...
@@ -287,20 +297,18 @@ export class ElementAssetTreeComponent implements OnInit, OnChanges {
...
@@ -287,20 +297,18 @@ export class ElementAssetTreeComponent implements OnInit, OnChanges {
});
});
dialogRef
.
afterClosed
().
subscribe
(
result
=>
{
dialogRef
.
afterClosed
().
subscribe
(
result
=>
{
if
(
!
result
)
{
if
(
!
result
)
{
return
;
return
callback
(
host
,
user
)
;
}
}
user
.
username
=
btoa
(
result
.
username
);
user
.
username
=
btoa
(
result
.
username
);
user
.
password
=
btoa
(
result
.
password
);
user
.
password
=
btoa
(
result
.
password
);
return
this
.
login
(
host
,
user
);
return
callback
(
host
,
user
);
});
});
}
}
login
(
host
,
user
)
{
login
(
host
,
user
)
{
const
id
=
NavList
.
List
.
length
-
1
;
const
id
=
NavList
.
List
.
length
-
1
;
this
.
_logger
.
debug
(
NavList
);
this
.
_logger
.
debug
(
host
);
if
(
user
.
login_mode
===
'manual'
&&
!
user
.
password
&&
user
.
protocol
===
'rdp'
)
{
if
(
user
.
login_mode
===
'manual'
&&
!
user
.
password
&&
user
.
protocol
===
'rdp'
)
{
return
this
.
manualSetUserAuthLogin
(
host
,
user
);
return
this
.
manualSetUserAuthLogin
(
host
,
user
,
this
.
login
);
}
}
if
(
user
)
{
if
(
user
)
{
NavList
.
List
[
id
].
nick
=
host
.
hostname
;
NavList
.
List
[
id
].
nick
=
host
.
hostname
;
...
@@ -316,8 +324,8 @@ export class ElementAssetTreeComponent implements OnInit, OnChanges {
...
@@ -316,8 +324,8 @@ export class ElementAssetTreeComponent implements OnInit, OnChanges {
}
}
NavList
.
List
.
push
(
new
View
());
NavList
.
List
.
push
(
new
View
());
NavList
.
Active
=
id
;
NavList
.
Active
=
id
;
jQuery
(
'.tabs'
).
animate
({
'scrollLeft'
:
150
*
id
},
400
);
}
}
this
.
_logger
.
debug
(
NavList
);
}
}
checkPriority
(
sysUsers
)
{
checkPriority
(
sysUsers
)
{
...
@@ -384,7 +392,7 @@ export class ElementAssetTreeComponent implements OnInit, OnChanges {
...
@@ -384,7 +392,7 @@ export class ElementAssetTreeComponent implements OnInit, OnChanges {
}
}
_keywords
=
_keywords
.
toLowerCase
();
_keywords
=
_keywords
.
toLowerCase
();
let
shouldShow
=
[];
let
shouldShow
=
[];
const
matchedNodes
=
zTreeObj
.
getNodesByFilter
(
function
(
node
)
{
const
matchedNodes
=
zTreeObj
.
getNodesByFilter
(
function
(
node
)
{
if
(
node
.
meta
.
type
===
'asset'
)
{
if
(
node
.
meta
.
type
===
'asset'
)
{
const
host
=
node
.
meta
.
asset
;
const
host
=
node
.
meta
.
asset
;
return
host
.
hostname
.
toLowerCase
().
indexOf
(
_keywords
)
!==
-
1
||
host
.
ip
.
indexOf
(
_keywords
)
!==
-
1
;
return
host
.
hostname
.
toLowerCase
().
indexOf
(
_keywords
)
!==
-
1
||
host
.
ip
.
indexOf
(
_keywords
)
!==
-
1
;
...
@@ -393,18 +401,18 @@ export class ElementAssetTreeComponent implements OnInit, OnChanges {
...
@@ -393,18 +401,18 @@ export class ElementAssetTreeComponent implements OnInit, OnChanges {
}
}
});
});
matchedNodes
.
forEach
((
node
)
=>
{
matchedNodes
.
forEach
((
node
)
=>
{
const
parents
=
this
.
recurseParent
(
node
);
const
parents
=
this
.
recurseParent
(
node
);
const
children
=
this
.
recurseChildren
(
node
);
const
children
=
this
.
recurseChildren
(
node
);
shouldShow
=
[...
shouldShow
,
...
parents
,
...
children
,
node
];
shouldShow
=
[...
shouldShow
,
...
parents
,
...
children
,
node
];
});
});
this
.
hiddenNodes
=
nodes
;
this
.
hiddenNodes
=
nodes
;
this
.
expandNodes
=
shouldShow
;
this
.
expandNodes
=
shouldShow
;
zTreeObj
.
hideNodes
(
nodes
);
zTreeObj
.
hideNodes
(
nodes
);
zTreeObj
.
showNodes
(
shouldShow
);
zTreeObj
.
showNodes
(
shouldShow
);
shouldShow
.
forEach
((
node
)
=>
{
shouldShow
.
forEach
((
node
)
=>
{
if
(
node
.
isParent
)
{
if
(
node
.
isParent
)
{
zTreeObj
.
expandNode
(
node
,
true
);
zTreeObj
.
expandNode
(
node
,
true
);
}
}
});
});
// zTreeObj.expandAll(true);
// zTreeObj.expandAll(true);
}
}
...
...
src/app/elements/guacamole/guacamole.component.ts
View file @
8ee3124e
...
@@ -29,7 +29,7 @@ export class ElementGuacamoleComponent implements OnInit {
...
@@ -29,7 +29,7 @@ export class ElementGuacamoleComponent implements OnInit {
registerHost
()
{
registerHost
()
{
let
action
:
any
;
let
action
:
any
;
if
(
this
.
remoteAppId
)
{
if
(
this
.
remoteAppId
)
{
action
=
this
.
_http
.
guacamole_add_remote_app
(
User
.
id
,
this
.
remoteAppId
);
action
=
this
.
_http
.
guacamole_add_remote_app
(
User
.
id
,
this
.
remoteAppId
,
this
.
sysUser
.
username
,
this
.
sysUser
.
password
);
}
else
{
}
else
{
action
=
this
.
_http
.
guacamole_add_asset
(
User
.
id
,
this
.
host
.
id
,
this
.
sysUser
.
id
,
this
.
sysUser
.
username
,
this
.
sysUser
.
password
);
action
=
this
.
_http
.
guacamole_add_asset
(
User
.
id
,
this
.
host
.
id
,
this
.
sysUser
.
id
,
this
.
sysUser
.
username
,
this
.
sysUser
.
password
);
}
}
...
...
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