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
fd490bd6
Commit
fd490bd6
authored
Mar 12, 2015
by
halcyon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bugs
parent
75f06f9b
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
167 additions
and
56 deletions
+167
-56
urls.py
jasset/urls.py
+1
-0
views.py
jasset/views.py
+36
-2
views.py
jlog/views.py
+2
-0
views.py
jumpserver/views.py
+1
-3
index.html
templates/index.html
+12
-26
group_detail.html
templates/jasset/group_detail.html
+6
-0
host_search.html
templates/jasset/host_search.html
+39
-1
idc_add.html
templates/jasset/idc_add.html
+31
-2
idc_list.html
templates/jasset/idc_list.html
+1
-0
log_online.html
templates/jlog/log_online.html
+1
-2
log_search.html
templates/jlog/log_search.html
+3
-20
paginator.html
templates/paginator.html
+34
-0
No files found.
jasset/urls.py
View file @
fd490bd6
...
...
@@ -11,6 +11,7 @@ urlpatterns = patterns('',
url
(
r"^(\d+.\d+.\d+.\d+)/$"
,
jlist_ip
),
url
(
r'^idc_add/$'
,
add_idc
),
url
(
r'^idc_list/$'
,
list_idc
),
url
(
r'^idc_edit/$'
,
edit_idc
),
url
(
r'^idc_detail/$'
,
detail_idc
),
url
(
r'^idc_del/(\w+)/$'
,
del_idc
),
url
(
r'^jgroup_add/$'
,
add_group
),
...
...
jasset/views.py
View file @
fd490bd6
...
...
@@ -143,6 +143,14 @@ def batch_host_edit(request):
def
list_host
(
request
):
header_title
,
path1
,
path2
=
u'查看主机'
,
u'资产管理'
,
u'查看主机'
login_types
=
{
'L'
:
'LDAP'
,
'S'
:
'SSH_KEY'
,
'P'
:
'PASSWORD'
,
'M'
:
'MAP'
}
keyword
=
request
.
GET
.
get
(
'keyword'
,
''
)
if
keyword
:
posts
=
Asset
.
objects
.
filter
(
Q
(
ip__contains
=
keyword
)
|
Q
(
idc__name__contains
=
keyword
)
|
Q
(
bis_group__name__contains
=
keyword
)
|
Q
(
comment__contains
=
keyword
))
.
distinct
()
.
order_by
(
'ip'
)
contact_list
,
p
,
contacts
,
page_range
,
current_page
,
show_first
,
show_end
=
pages
(
posts
,
request
)
return
render_to_response
(
'jasset/host_list.html'
,
locals
(),
context_instance
=
RequestContext
(
request
))
else
:
posts
=
Asset
.
objects
.
all
()
.
order_by
(
'ip'
)
contact_list
,
p
,
contacts
,
page_range
,
current_page
,
show_first
,
show_end
=
pages
(
posts
,
request
)
...
...
@@ -250,6 +258,34 @@ def list_idc(request):
return
render_to_response
(
'jasset/idc_list.html'
,
locals
(),
context_instance
=
RequestContext
(
request
))
def
edit_idc
(
request
):
header_title
,
path1
,
path2
=
u'编辑IDC'
,
u'资产管理'
,
u'编辑IDC'
edit
=
1
idc_id
=
request
.
GET
.
get
(
'id'
)
j_idc
=
IDC
.
objects
.
get
(
id
=
idc_id
)
default
=
IDC
.
objects
.
get
(
name
=
'默认'
)
.
asset_set
.
all
()
eposts
=
contact_list
=
Asset
.
objects
.
filter
(
idc
=
j_idc
)
.
order_by
(
'ip'
)
posts
=
[
g
for
g
in
default
if
g
not
in
eposts
]
if
request
.
method
==
'POST'
:
j_group
=
request
.
POST
.
get
(
'j_idc'
)
j_hosts
=
request
.
POST
.
getlist
(
'j_hosts'
)
j_comment
=
request
.
POST
.
get
(
'j_comment'
)
idc_default
=
request
.
POST
.
getlist
(
'idc_default'
)
for
host
in
j_hosts
:
g
=
Asset
.
objects
.
get
(
id
=
host
)
Asset
.
objects
.
filter
(
id
=
host
)
.
update
(
idc
=
j_idc
)
for
host
in
idc_default
:
g
=
Asset
.
objects
.
get
(
id
=
host
)
i
=
IDC
.
objects
.
get
(
name
=
'默认'
)
Asset
.
objects
.
filter
(
id
=
host
)
.
update
(
idc
=
i
)
return
HttpResponseRedirect
(
'/jasset/idc_detail/?id=
%
s'
%
idc_id
)
return
render_to_response
(
'jasset/idc_add.html'
,
locals
(),
context_instance
=
RequestContext
(
request
))
def
del_idc
(
request
,
offset
):
if
offset
==
'multi'
:
len_list
=
request
.
POST
.
get
(
"len_list"
)
...
...
@@ -374,8 +410,6 @@ def group_del(request, offset):
return
HttpResponseRedirect
(
'/jasset/jgroup_list/'
)
def
host_search
(
request
):
keyword
=
request
.
GET
.
get
(
'keyword'
)
login_types
=
{
'L'
:
'LDAP'
,
'S'
:
'SSH_KEY'
,
'P'
:
'PASSWORD'
,
'M'
:
'MAP'
}
...
...
jlog/views.py
View file @
fd490bd6
...
...
@@ -18,6 +18,7 @@ CONF.read('%s/jumpserver.conf' % BASE_DIR)
def
log_list_online
(
request
):
header_title
,
path1
,
path2
=
u'查看日志'
,
u'查看日志'
,
u'在线用户'
keyword
=
request
.
GET
.
get
(
'keyword'
)
web_socket_host
=
CONF
.
get
(
'websocket'
,
'web_socket_host'
)
posts
=
Log
.
objects
.
filter
(
is_finished
=
0
)
.
order_by
(
'-start_time'
)
contact_list
,
p
,
contacts
,
page_range
,
current_page
,
show_first
,
show_end
=
pages
(
posts
,
request
)
...
...
@@ -27,6 +28,7 @@ def log_list_online(request):
def
log_list_offline
(
request
):
header_title
,
path1
,
path2
=
u'查看日志'
,
u'查看日志'
,
u'历史记录'
keyword
=
request
.
GET
.
get
(
'keyword'
)
web_socket_host
=
CONF
.
get
(
'websocket'
,
'web_socket_host'
)
posts
=
Log
.
objects
.
filter
(
is_finished
=
1
)
.
order_by
(
'-start_time'
)
contact_list
,
p
,
contacts
,
page_range
,
current_page
,
show_first
,
show_end
=
pages
(
posts
,
request
)
...
...
jumpserver/views.py
View file @
fd490bd6
...
...
@@ -45,7 +45,7 @@ def getDaysByNum(num):
for
i
in
range
(
0
,
num
):
today
=
today
-
oneday
li_date
.
append
(
today
)
li_str
.
append
(
str
(
today
)[
0
:
10
])
li_str
.
append
(
str
(
today
)[
5
:
10
])
li_date
.
reverse
()
li_str
.
reverse
()
t
=
(
li_date
,
li_str
)
...
...
@@ -103,8 +103,6 @@ def index(request):
return
render_to_response
(
'index.html'
,
locals
(),
context_instance
=
RequestContext
(
request
))
def
skin_config
(
request
):
return
render_to_response
(
'skin_config.html'
)
...
...
templates/index.html
View file @
fd490bd6
...
...
@@ -58,12 +58,13 @@
</div>
</div>
</div>
<div
id=
"top10"
style=
"width:100%;height:400px;"
></div>
<div
id=
"usertop10"
style=
"width:100%;height:400px;margin-top:170px"
></div>
<br/>
<div
id=
"hosttop10"
style=
"width:100%;height:400px;"
></div>
<br/>
<div
id=
"dynamic"
style=
"width:100%;height:400px;"
></div>
<div
class=
"row"
>
<div
class=
"col-lg-6"
id=
"top10"
style=
"width:50%;height:400px;"
></div>
<div
class=
"col-lg-6"
id=
"usertop10"
style=
"width:50%;height:400px;"
></div>
</div>
<div
class=
"row"
>
<div
class=
"col-lg-6"
id=
"hosttop10"
style=
"width:50%;height:400px; margin-top: 20px"
></div>
</div>
</div>
</div>
...
...
@@ -71,8 +72,11 @@
var
cate
=
{{
li_str
|
safe
}};
$
(
function
()
{
$
(
'#top10'
).
highcharts
({
chart
:
{
type
:
'column'
},
title
:
{
text
:
'数据总览'
,
text
:
'
一周
数据总览'
,
x
:
-
20
//center
},
subtitle
:
{
...
...
@@ -101,12 +105,6 @@ $(function () {
tooltip
:
{
valueSuffix
:
'次'
},
legend
:
{
layout
:
'vertical'
,
align
:
'right'
,
verticalAlign
:
'middle'
,
borderWidth
:
0
},
navigation
:
{
buttonOptions
:
{
align
:
'right'
...
...
@@ -149,12 +147,6 @@ $(function () {
tooltip
:
{
valueSuffix
:
'次'
},
legend
:
{
layout
:
'vertical'
,
align
:
'right'
,
verticalAlign
:
'middle'
,
borderWidth
:
0
},
series
:
[
{
%
for
k
,
v
in
user_dic
.
items
%
}
{
...
...
@@ -192,12 +184,6 @@ $(function () {
tooltip
:
{
valueSuffix
:
'次'
},
legend
:
{
layout
:
'vertical'
,
align
:
'right'
,
verticalAlign
:
'middle'
,
borderWidth
:
0
},
series
:
[
{
%
for
k
,
v
in
host_dic
.
items
%
}
{
...
...
@@ -227,7 +213,7 @@ $(function () {
});
};
setInterval
(
update
,
1
000
);
//5秒钟执行一次
setInterval
(
update
,
5
000
);
//5秒钟执行一次
update
();
});
...
...
templates/jasset/group_detail.html
View file @
fd490bd6
...
...
@@ -88,6 +88,9 @@
<a
href=
"#"
>
Previous
</a>
</li>
{% endif %}
{% ifequal show_first 1 %}
<li
class=
"paginate_button"
aria-controls=
"editable"
tabindex=
"0"
><a
href=
"?id={{ group_id }}&page=1"
title=
"第1页"
>
1...
</a></li>
{% endifequal %}
{% for page in page_range %}
{% ifequal current_page page %}
<li
class=
"paginate_button active"
aria-controls=
"editable"
tabindex=
"0"
><a
href=
"?id={{ group_id }}&page={{ page }}"
title=
"第{{ page }}页"
>
{{ page }}
</a></li>
...
...
@@ -95,6 +98,9 @@
<li
class=
"paginate_button"
aria-controls=
"editable"
tabindex=
"0"
><a
href=
"?id={{ group_id }}&page={{ page }}"
title=
"第{{ page }}页"
>
{{ page }}
</a></li>
{% endifequal %}
{% endfor %}
{% ifequal show_end 1 %}
<li
class=
"paginate_button"
aria-controls=
"editable"
tabindex=
"0"
><a
href=
"?id={{ group_id }}&page={{ p.num_pages }}"
title=
"第{{ page }}页"
>
...{{ p.num_pages }}
</a></li>
{% endifequal %}
{% if contacts.has_next %}
<li
class=
"paginate_button next"
aria-controls=
"editable"
tabindex=
"0"
id=
"editable_next"
>
<a
href=
"?id={{ group_id }}&page={{ contacts.next_page_number }}"
>
Next
</a>
...
...
templates/jasset/host_search.html
View file @
fd490bd6
...
...
@@ -40,7 +40,45 @@
<input
type=
"button"
id=
"del_button"
class=
"btn btn-danger btn-sm"
name=
"del_button"
value=
"删除"
onclick=
"del('contents_form')"
/>
<input
type=
"button"
id=
"alter_button"
class=
"btn btn-warning btn-sm"
name=
"alter_button"
value=
"修改"
onclick=
"alter('contents_form')"
/>
</div>
{% include 'paginator.html' %}
<div
class=
"col-sm-6"
>
<div
class=
"dataTables_paginate paging_simple_numbers"
id=
"editable_paginate"
>
<ul
class=
"pagination"
style=
"margin-top: 0; float: right"
>
{% if contacts.has_previous %}
<li
class=
"paginate_button previous"
aria-controls=
"editable"
tabindex=
"0"
id=
"editable_previous"
>
<a
href=
"?page={{ contacts.previous_page_number }}"
>
Previous
</a>
</li>
{% else %}
<li
class=
"paginate_button previous disabled"
aria-controls=
"editable"
tabindex=
"0"
id=
"editable_previous"
>
<a
href=
"#"
>
Previous
</a>
</li>
{% endif %}
{% ifequal show_first 1 %}
<li
class=
"paginate_button"
aria-controls=
"editable"
tabindex=
"0"
><a
href=
"?page=1"
title=
"第1页"
>
1...
</a></li>
{% endifequal %}
{% for page in page_range %}
{% ifequal current_page page %}
<li
class=
"paginate_button active"
aria-controls=
"editable"
tabindex=
"0"
><a
href=
"?keyword={{ keyword }}&page={{ page }}"
title=
"第{{ page }}页"
>
{{ page }}
</a></li>
{% else %}
<li
class=
"paginate_button"
aria-controls=
"editable"
tabindex=
"0"
><a
href=
"?keyword={{ keyword }}&page={{ page }}"
title=
"第{{ page }}页"
>
{{ page }}
</a></li>
{% endifequal %}
{% endfor %}
{% ifequal show_end 1 %}
<li
class=
"paginate_button"
aria-controls=
"editable"
tabindex=
"0"
><a
href=
"?page={{ p.num_pages }}"
title=
"第{{ page }}页"
>
...{{ p.num_pages }}
</a></li>
{% endifequal %}
{% if contacts.has_next %}
<li
class=
"paginate_button next"
aria-controls=
"editable"
tabindex=
"0"
id=
"editable_next"
>
<a
href=
"?page={{ contacts.next_page_number }}"
>
Next
</a>
</li>
{% else %}
<li
class=
"paginate_button next disabled"
aria-controls=
"editable"
tabindex=
"0"
id=
"editable_next"
>
<a
href=
"#"
>
Next
</a>
</li>
{% endif %}
</ul>
</div>
</div>
</div>
<script>
...
...
templates/jasset/idc_add.html
View file @
fd490bd6
...
...
@@ -35,14 +35,43 @@
{% endif %}
<form
id=
"assetForm"
method=
"post"
class=
"form-horizontal"
>
<div
class=
"form-group"
><label
class=
"col-sm-2 control-label"
>
IDC名
</label>
<div
class=
"col-sm-8"
><input
type=
"text"
value=
"{{ j_i
p
}}"
placeholder=
"北京联通"
name=
"j_idc"
class=
"form-control"
></div>
<div
class=
"col-sm-8"
><input
type=
"text"
value=
"{{ j_i
dc.name
}}"
placeholder=
"北京联通"
name=
"j_idc"
class=
"form-control"
></div>
</div>
<div
class=
"hr-line-dashed"
></div>
<div
class=
"form-group"
><label
class=
"col-sm-2 control-label"
>
备注
</label>
<div
class=
"col-sm-8"
><input
type=
"text"
value=
"{{
s_por
t }}"
placeholder=
"核心联通机房"
name=
"j_comment"
class=
"form-control"
></div>
<div
class=
"col-sm-8"
><input
type=
"text"
value=
"{{
j_idc.commen
t }}"
placeholder=
"核心联通机房"
name=
"j_comment"
class=
"form-control"
></div>
</div>
{% if edit %}
<div
class=
"hr-line-dashed"
></div>
<div
class=
"form-group"
>
<label
for=
"groups"
class=
"col-lg-2 control-label"
>
主机
</label>
<div
class=
"col-sm-3"
>
<select
id=
"groups"
name=
"idc_default"
size=
"12"
class=
"form-control m-b"
multiple
>
{% for post in posts %}
<option
value=
"{{ post.id }}"
>
{{ post.ip }}
</option>
{% endfor %}
</select>
</div>
<div
class=
"col-sm-1"
>
<div
class=
"btn-group"
style=
"margin-top: 50px;"
>
<button
type=
"button"
class=
"btn btn-white"
onclick=
"move('groups', 'groups_selected')"
><i
class=
"fa fa-chevron-right"
></i></button>
<button
type=
"button"
class=
"btn btn-white"
onclick=
"move_left('groups_selected', 'groups')"
><i
class=
"fa fa-chevron-left"
></i>
</button>
</div>
</div>
<div
class=
"col-sm-3"
>
<div>
<select
id=
"groups_selected"
name=
"j_hosts"
class=
"form-control m-b"
size=
"12"
multiple
>
{% for post in eposts %}
<option
value=
"{{ post.id }}"
>
{{ post.ip }}
</option>
{% endfor %}
</select>
</div>
</div>
</div>
{% endif %}
<div
class=
"hr-line-dashed"
></div>
<div
class=
"form-group"
>
<div
class=
"col-sm-4 col-sm-offset-5"
>
...
...
templates/jasset/idc_list.html
View file @
fd490bd6
...
...
@@ -31,6 +31,7 @@
<td
class=
"text-center"
>
{{ post.comment }}
</td>
<td
class=
"text-center"
>
<a
href=
"/jasset/idc_detail/?id={{ post.id }}"
class=
"iframe btn btn-xs btn-primary"
>
详情
</a>
<a
href=
"/jasset/idc_edit/?id={{ post.id }}"
class=
"btn btn-xs btn-info"
>
编辑
</a>
<a
href=
"/jasset/idc_del/{{ post.id }}"
class=
"btn btn-xs btn-danger"
>
删除
</a>
</td>
</tr>
...
...
templates/jlog/log_online.html
View file @
fd490bd6
...
...
@@ -97,8 +97,7 @@
</tbody>
</table>
<div
class=
"row"
>
<div
class=
"col-sm-6"
>
</div>
<div
class=
"col-sm-6"
></div>
{% include 'paginator.html' %}
</div>
</div>
...
...
templates/jlog/log_search.html
View file @
fd490bd6
...
...
@@ -23,25 +23,7 @@
</tbody>
</table>
<div
class=
"row"
>
<div
class=
"col-sm-6 col-sm-offset-6"
>
<div
class=
"dataTables_paginate paging_simple_numbers"
id=
"editable_paginate"
>
<ul
class=
"pagination"
style=
"margin-top: 0; float: right"
>
{% if contacts.has_previous %}
<li><a
href=
"?page={{ contacts.previous_page_number }}"
>
«
</a></li>
{% endif %}
{% for page in p.page_range %}
{% ifequal offset1 page %}
<li
class=
"active"
><a
href=
"?page={{ page }}"
title=
"第{{ page }}页"
>
{{ page }}
</a></li>
{% else %}
<li><a
href=
"?page={{ page }}"
title=
"第{{ page }}页"
>
{{ page }}
</a></li>
{% endifequal %}
{% endfor %}
{% if contacts.has_next %}
<li><a
href=
"?page={{ contacts.next_page_number }}"
>
»
</a></li>
{% endif %}
</ul>
</div>
<div
class=
"col-sm-6 "
></div>
{% include 'paginator.html' %}
</div>
</div>
\ No newline at end of file
templates/paginator.html
View file @
fd490bd6
<div
class=
"col-sm-6"
>
<div
class=
"dataTables_paginate paging_simple_numbers"
id=
"editable_paginate"
>
<ul
class=
"pagination"
style=
"margin-top: 0; float: right"
>
{% if keyword %}
{% if contacts.has_previous %}
<li
class=
"paginate_button previous"
aria-controls=
"editable"
tabindex=
"0"
id=
"editable_previous"
>
<a
href=
"?keyword={{ keyword }}&page={{ contacts.previous_page_number }}"
>
Previous
</a>
</li>
{% else %}
<li
class=
"paginate_button previous disabled"
aria-controls=
"editable"
tabindex=
"0"
id=
"editable_previous"
>
<a
href=
"#"
>
Previous
</a>
</li>
{% endif %}
{% ifequal show_first 1 %}
<li
class=
"paginate_button"
aria-controls=
"editable"
tabindex=
"0"
><a
href=
"?keyword={{ keyword }}&ppage=1"
title=
"第1页"
>
1...
</a></li>
{% endifequal %}
{% for page in page_range %}
{% ifequal current_page page %}
<li
class=
"paginate_button active"
aria-controls=
"editable"
tabindex=
"0"
><a
href=
"?keyword={{ keyword }}&page={{ page }}"
title=
"第{{ page }}页"
>
{{ page }}
</a></li>
{% else %}
<li
class=
"paginate_button"
aria-controls=
"editable"
tabindex=
"0"
><a
href=
"?keyword={{ keyword }}&page={{ page }}"
title=
"第{{ page }}页"
>
{{ page }}
</a></li>
{% endifequal %}
{% endfor %}
{% ifequal show_end 1 %}
<li
class=
"paginate_button"
aria-controls=
"editable"
tabindex=
"0"
><a
href=
"?keyword={{ keyword }}&page={{ p.num_pages }}"
title=
"第{{ page }}页"
>
...{{ p.num_pages }}
</a></li>
{% endifequal %}
{% if contacts.has_next %}
<li
class=
"paginate_button next"
aria-controls=
"editable"
tabindex=
"0"
id=
"editable_next"
>
<a
href=
"?keyword={{ keyword }}&page={{ contacts.next_page_number }}"
>
Next
</a>
</li>
{% else %}
<li
class=
"paginate_button next disabled"
aria-controls=
"editable"
tabindex=
"0"
id=
"editable_next"
>
<a
href=
"#"
>
Next
</a>
</li>
{% endif %}
{% else %}
{% if contacts.has_previous %}
<li
class=
"paginate_button previous"
aria-controls=
"editable"
tabindex=
"0"
id=
"editable_previous"
>
<a
href=
"?page={{ contacts.previous_page_number }}"
>
Previous
</a>
...
...
@@ -33,6 +66,7 @@
<a
href=
"#"
>
Next
</a>
</li>
{% endif %}
{% endif %}
</ul>
</div>
</div>
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