Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
J
jumpserver
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
jumpserver
Commits
7bef5175
Commit
7bef5175
authored
Jan 01, 2016
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
支持修改窗口大小
parent
ea973bbb
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
59 additions
and
6 deletions
+59
-6
views.py
jumpserver/views.py
+4
-0
run_websocket.py
run_websocket.py
+9
-1
asset_list.html
templates/jasset/asset_list.html
+13
-2
web_terminal.html
templates/jlog/web_terminal.html
+29
-2
perm_role_detail.html
templates/jperm/perm_role_detail.html
+4
-1
No files found.
jumpserver/views.py
View file @
7bef5175
...
@@ -352,6 +352,10 @@ def exec_cmd(request):
...
@@ -352,6 +352,10 @@ def exec_cmd(request):
def
web_terminal
(
request
):
def
web_terminal
(
request
):
asset_id
=
request
.
GET
.
get
(
'id'
)
asset_id
=
request
.
GET
.
get
(
'id'
)
role_name
=
request
.
GET
.
get
(
'role'
)
role_name
=
request
.
GET
.
get
(
'role'
)
asset
=
get_object
(
Asset
,
id
=
asset_id
)
if
asset
:
print
asset
hostname
=
asset
.
hostname
web_terminal_uri
=
'ws://
%
s/terminal?id=
%
s&role=
%
s'
%
(
WEB_SOCKET_HOST
,
asset_id
,
role_name
)
web_terminal_uri
=
'ws://
%
s/terminal?id=
%
s&role=
%
s'
%
(
WEB_SOCKET_HOST
,
asset_id
,
role_name
)
return
render_to_response
(
'jlog/web_terminal.html'
,
locals
())
return
render_to_response
(
'jlog/web_terminal.html'
,
locals
())
...
...
run_websocket.py
View file @
7bef5175
...
@@ -333,7 +333,13 @@ class WebTerminalHandler(tornado.websocket.WebSocketHandler):
...
@@ -333,7 +333,13 @@ class WebTerminalHandler(tornado.websocket.WebSocketHandler):
data
=
json
.
loads
(
message
)
data
=
json
.
loads
(
message
)
if
not
data
:
if
not
data
:
return
return
if
data
.
get
(
'data'
):
if
'resize'
in
data
.
get
(
'data'
):
self
.
channel
.
resize_pty
(
data
.
get
(
'data'
)
.
get
(
'resize'
)
.
get
(
'cols'
,
80
),
data
.
get
(
'data'
)
.
get
(
'resize'
)
.
get
(
'rows'
,
24
)
)
elif
data
.
get
(
'data'
):
self
.
term
.
input_mode
=
True
self
.
term
.
input_mode
=
True
if
str
(
data
[
'data'
])
in
[
'
\r
'
,
'
\n
'
,
'
\r\n
'
]:
if
str
(
data
[
'data'
])
in
[
'
\r
'
,
'
\n
'
,
'
\r\n
'
]:
if
self
.
term
.
vim_flag
:
if
self
.
term
.
vim_flag
:
...
@@ -350,6 +356,8 @@ class WebTerminalHandler(tornado.websocket.WebSocketHandler):
...
@@ -350,6 +356,8 @@ class WebTerminalHandler(tornado.websocket.WebSocketHandler):
self
.
term
.
data
=
''
self
.
term
.
data
=
''
self
.
term
.
input_mode
=
False
self
.
term
.
input_mode
=
False
self
.
channel
.
send
(
data
[
'data'
])
self
.
channel
.
send
(
data
[
'data'
])
else
:
pass
def
on_close
(
self
):
def
on_close
(
self
):
logger
.
debug
(
'Websocket: Close request'
)
logger
.
debug
(
'Websocket: Close request'
)
...
...
templates/jasset/asset_list.html
View file @
7bef5175
...
@@ -233,6 +233,7 @@
...
@@ -233,6 +233,7 @@
layer
.
alert
(
'没有授权系统用户'
)
layer
.
alert
(
'没有授权系统用户'
)
}
}
else
if
(
dataArray
.
length
==
1
&&
data
!=
'error'
&&
navigator
.
platform
==
'Win32'
){
else
if
(
dataArray
.
length
==
1
&&
data
!=
'error'
&&
navigator
.
platform
==
'Win32'
){
/*
var title = 'Jumpserver Web Terminal' + '<span class="text-info"> '+ hostname +'</span>';
var title = 'Jumpserver Web Terminal' + '<span class="text-info"> '+ hostname +'</span>';
layer.open({
layer.open({
type: 2,
type: 2,
...
@@ -242,8 +243,10 @@
...
@@ -242,8 +243,10 @@
area: ['628px', '420px'],
area: ['628px', '420px'],
content: new_url+data
content: new_url+data
});
});
*/
window
.
open
(
new_url
+
data
,
''
,
'width=628px, height=420px'
)
}
else
if
(
dataArray
.
length
==
1
&&
data
!=
'error'
){
}
else
if
(
dataArray
.
length
==
1
&&
data
!=
'error'
){
layer
.
open
({
/*
layer.open({
type: 2,
type: 2,
title: title,
title: title,
maxmin: true,
maxmin: true,
...
@@ -251,6 +254,9 @@
...
@@ -251,6 +254,9 @@
area: ['628px', '452px'],
area: ['628px', '452px'],
content: new_url+data
content: new_url+data
});
});
*/
window
.
open
(
new_url
+
data
,
''
,
'width=628px, height=440px'
)
}
}
else
{
else
{
aUrl
=
''
;
aUrl
=
''
;
...
@@ -276,6 +282,7 @@
...
@@ -276,6 +282,7 @@
var
hostname
=
$
(
a
).
attr
(
'value'
);
var
hostname
=
$
(
a
).
attr
(
'value'
);
var
title
=
'Jumpserver Web Terminal - '
+
'<span class="text-info"> '
+
hostname
+
'</span>'
;
var
title
=
'Jumpserver Web Terminal - '
+
'<span class="text-info"> '
+
hostname
+
'</span>'
;
if
(
navigator
.
platform
==
'Win32'
){
if
(
navigator
.
platform
==
'Win32'
){
/*
layer.open({
layer.open({
type: 2,
type: 2,
title: title,
title: title,
...
@@ -284,8 +291,11 @@
...
@@ -284,8 +291,11 @@
shade: false,
shade: false,
content: new_url
content: new_url
});
});
*/
window
.
open
(
new_url
,
''
,
'height=628px, width=420px'
)
}
else
{
}
else
{
/*
layer.open({
layer.open({
type: 2,
type: 2,
title: title,
title: title,
...
@@ -294,6 +304,8 @@
...
@@ -294,6 +304,8 @@
shade: false,
shade: false,
content: new_url
content: new_url
});
});
*/
window
.
open
(
new_url
,
''
,
'height=628px, width=452px'
)
}
}
return
false
return
false
...
@@ -310,7 +322,6 @@
...
@@ -310,7 +322,6 @@
shade
:
false
,
shade
:
false
,
content
:
new_url
content
:
new_url
});
});
console
.
log
(
new_url
);
return
false
return
false
}
}
...
...
templates/jlog/web_terminal.html
View file @
7bef5175
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
<html>
<html>
<head>
<head>
<meta
charset=
"utf-8"
>
<meta
charset=
"utf-8"
>
<title>
Jumpserver
web terminal
</title>
<title>
Jumpserver
Web Terminal: {{ hostname }}
</title>
<style>
<style>
body
{
body
{
...
@@ -37,6 +37,8 @@
...
@@ -37,6 +37,8 @@
<script
type=
"application/javascript"
src=
"/static/js/term.js"
>
<script
type=
"application/javascript"
src=
"/static/js/term.js"
>
</script>
</script>
<script
type=
"application/javascript"
>
<script
type=
"application/javascript"
>
var
rowHeight
=
1
;
var
colWidth
=
1
;
function
WSSHClient
()
{
function
WSSHClient
()
{
}
}
...
@@ -101,7 +103,22 @@
...
@@ -101,7 +103,22 @@
term
.
write
(
data
);
term
.
write
(
data
);
}
}
}));
}));
rowHeight
=
0.0
+
1.00
*
$
(
'.terminal'
).
height
()
/
24
;
colWidth
=
0.0
+
1.00
*
$
(
'.terminal'
).
width
()
/
80
;
return
{
'term'
:
term
,
'client'
:
client
};
}
}
function
resize
(){
$
(
'.terminal'
).
css
(
'width'
,
window
.
innerWidth
-
25
);
console
.
log
(
window
.
innerWidth
);
console
.
log
(
window
.
innerWidth
-
10
);
var
rows
=
Math
.
floor
(
window
.
innerHeight
/
rowHeight
)
-
1
;
var
cols
=
Math
.
floor
(
window
.
innerWidth
/
colWidth
)
-
1
;
return
{
rows
:
rows
,
cols
:
cols
};
}
</script>
</script>
<script
type=
'application/javascript'
>
<script
type=
'application/javascript'
>
...
@@ -110,7 +127,17 @@
...
@@ -110,7 +127,17 @@
};
};
$
(
'#ssh'
).
show
();
$
(
'#ssh'
).
show
();
openTerminal
(
options
);
var
term_client
=
openTerminal
(
options
);
console
.
log
(
rowHeight
);
window
.
onresize
=
function
(){
var
geom
=
resize
();
console
.
log
(
geom
);
term_client
.
term
.
resize
(
geom
.
cols
,
geom
.
rows
);
term_client
.
client
.
send
({
'resize'
:
{
'roles'
:
geom
.
rows
,
'cols'
:
geom
.
cols
}});
$
(
'#ssh'
).
show
();
}
});
});
</script>
</script>
</body>
</body>
...
...
templates/jperm/perm_role_detail.html
View file @
7bef5175
...
@@ -325,7 +325,10 @@
...
@@ -325,7 +325,10 @@
$
(
'.push_failed'
).
click
(
function
()
{
$
(
'.push_failed'
).
click
(
function
()
{
var
fail_reason
=
$
(
this
).
attr
(
'title'
);
var
fail_reason
=
$
(
this
).
attr
(
'title'
);
layer
.
alert
(
fail_reason
)
layer
.
alert
(
fail_reason
,
{
skin
:
'layui-layer-molv'
,
area
:
'500px'
})
});
});
...
...
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