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
d0600662
Commit
d0600662
authored
Mar 05, 2015
by
halcyon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard and bugs
parent
e086a036
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
128 additions
and
84 deletions
+128
-84
views.py
jasset/views.py
+24
-55
views.py
jumpserver/views.py
+9
-6
highstock.js
static/js/highcharts/highstock.js
+0
-0
foot_script.html
templates/foot_script.html
+1
-0
index.html
templates/index.html
+52
-3
group_detail.html
templates/jasset/group_detail.html
+19
-8
host_search.html
templates/jasset/host_search.html
+18
-7
idc_detail.html
templates/jasset/idc_detail.html
+5
-5
No files found.
jasset/views.py
View file @
d0600662
...
...
@@ -4,13 +4,12 @@ from django.db.models import Q
from
django.http
import
HttpResponseRedirect
from
django.template
import
RequestContext
from
django.shortcuts
import
render_to_response
from
django.core.paginator
import
Paginator
,
EmptyPage
,
InvalidPage
from
models
import
IDC
,
Asset
,
BisGroup
from
juser.models
import
UserGroup
from
connect
import
PyCrypt
,
KEY
from
jlog.models
import
Log
from
jumpserver.views
import
jasset_group_add
,
jasset_host_edit
,
pages
,
page_list_return
from
jumpserver.views
import
jasset_group_add
,
jasset_host_edit
,
pages
cryptor
=
PyCrypt
(
KEY
)
...
...
@@ -143,20 +142,8 @@ 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'
}
posts
=
contact_list
=
Asset
.
objects
.
all
()
.
order_by
(
'ip'
)
p
=
paginator
=
Paginator
(
contact_list
,
10
)
try
:
current_page
=
int
(
request
.
GET
.
get
(
'page'
,
'1'
))
except
ValueError
:
current_page
=
1
page_range
=
page_list_return
(
len
(
p
.
page_range
),
current_page
)
try
:
contacts
=
paginator
.
page
(
current_page
)
except
(
EmptyPage
,
InvalidPage
):
contacts
=
paginator
.
page
(
paginator
.
num_pages
)
posts
=
Asset
.
objects
.
all
()
.
order_by
(
'ip'
)
contact_list
,
p
,
contacts
,
page_range
,
current_page
=
pages
(
posts
,
request
)
return
render_to_response
(
'jasset/host_list.html'
,
locals
(),
context_instance
=
RequestContext
(
request
))
...
...
@@ -311,7 +298,7 @@ def edit_group(request):
group
.
asset_set
.
add
(
g
)
BisGroup
.
objects
.
filter
(
id
=
group_id
)
.
update
(
name
=
j_group
,
comment
=
j_comment
)
smg
=
u'主机组
%
s修改成功'
%
j_group
return
HttpResponseRedirect
(
'/jasset/group_detail/
%
s'
%
group_id
)
return
HttpResponseRedirect
(
'/jasset/group_detail/
?id=
%
s'
%
group_id
)
return
render_to_response
(
'jasset/group_add.html'
,
locals
(),
context_instance
=
RequestContext
(
request
))
...
...
@@ -319,47 +306,30 @@ def edit_group(request):
def
detail_group
(
request
):
header_title
,
path1
,
path2
=
u'主机组详情'
,
u'资产管理'
,
u'主机组详情'
login_types
=
{
'L'
:
'LDAP'
,
'S'
:
'SSH_KEY'
,
'P'
:
'PASSWORD'
,
'M'
:
'MAP'
}
offset
=
request
.
GET
.
get
(
'id'
)
group_name
=
BisGroup
.
objects
.
get
(
id
=
offset
)
.
name
b
=
BisGroup
.
objects
.
get
(
id
=
offset
)
posts
=
contact_list
=
Asset
.
objects
.
filter
(
bis_group
=
b
)
.
order_by
(
'ip'
)
p
=
paginator
=
Paginator
(
contact_list
,
5
)
try
:
page
=
int
(
request
.
GET
.
get
(
'page'
,
'1'
))
except
ValueError
:
page
=
1
try
:
contacts
=
paginator
.
page
(
page
)
except
(
EmptyPage
,
InvalidPage
):
contacts
=
paginator
.
page
(
paginator
.
num_pages
)
group_id
=
request
.
GET
.
get
(
'id'
)
group_name
=
BisGroup
.
objects
.
get
(
id
=
group_id
)
.
name
b
=
BisGroup
.
objects
.
get
(
id
=
group_id
)
posts
=
Asset
.
objects
.
filter
(
bis_group
=
b
)
.
order_by
(
'ip'
)
contact_list
,
p
,
contacts
,
page_range
,
current_page
=
pages
(
posts
,
request
)
return
render_to_response
(
'jasset/group_detail.html'
,
locals
(),
context_instance
=
RequestContext
(
request
))
def
detail_idc
(
request
):
header_title
,
path1
,
path2
=
u'
主机组详情'
,
u'资产管理'
,
u'主机组
详情'
header_title
,
path1
,
path2
=
u'
IDC详情'
,
u'资产管理'
,
u'IDC
详情'
login_types
=
{
'L'
:
'LDAP'
,
'S'
:
'SSH_KEY'
,
'P'
:
'PASSWORD'
,
'M'
:
'MAP'
}
offset
=
request
.
GET
.
get
(
'id'
)
idc_name
=
IDC
.
objects
.
get
(
id
=
offset
)
.
name
b
=
IDC
.
objects
.
get
(
id
=
offset
)
posts
=
contact_list
=
Asset
.
objects
.
filter
(
idc
=
b
)
.
order_by
(
'ip'
)
p
=
paginator
=
Paginator
(
contact_list
,
5
)
try
:
page
=
int
(
request
.
GET
.
get
(
'page'
,
'1'
))
except
ValueError
:
page
=
1
try
:
contacts
=
paginator
.
page
(
page
)
except
(
EmptyPage
,
InvalidPage
):
contacts
=
paginator
.
page
(
paginator
.
num_pages
)
idc_id
=
request
.
GET
.
get
(
'id'
)
idc_name
=
IDC
.
objects
.
get
(
id
=
idc_id
)
.
name
b
=
IDC
.
objects
.
get
(
id
=
idc_id
)
posts
=
Asset
.
objects
.
filter
(
idc
=
b
)
.
order_by
(
'ip'
)
contact_list
,
p
,
contacts
,
page_range
,
current_page
=
pages
(
posts
,
request
)
return
render_to_response
(
'jasset/idc_detail.html'
,
locals
(),
context_instance
=
RequestContext
(
request
))
def
group_del_host
(
request
,
offset
):
if
request
.
method
==
'POST'
:
group_name
=
request
.
POST
.
get
(
'group_name'
)
print
group_name
if
offset
==
'group'
:
group
=
BisGroup
.
objects
.
get
(
name
=
group_name
)
elif
offset
==
'idc'
:
...
...
@@ -367,14 +337,15 @@ def group_del_host(request, offset):
len_list
=
request
.
POST
.
get
(
"len_list"
)
for
i
in
range
(
int
(
len_list
)):
key
=
"id_list["
+
str
(
i
)
+
"]"
print
key
jid
=
request
.
POST
.
get
(
key
)
print
jid
g
=
Asset
.
objects
.
get
(
id
=
jid
)
print
g
if
offset
==
'group'
:
group
.
asset_set
.
remove
(
g
)
print
'ok'
return
HttpResponseRedirect
(
'/jasset/
%
s_detail/
%
s'
%
(
offset
,
group
.
id
))
elif
offset
==
'idc'
:
Asset
.
objects
.
filter
(
id
=
jid
)
.
delete
()
BisGroup
.
objects
.
filter
(
name
=
g
.
ip
)
.
delete
()
return
HttpResponseRedirect
(
'/jasset/
%
s_detail/?id=
%
s'
%
(
offset
,
group
.
id
))
def
group_del
(
request
,
offset
):
...
...
@@ -388,9 +359,7 @@ def host_search(request):
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'
)
print
posts
contact_list
,
p
,
contacts
=
pages
(
posts
,
request
)
print
contact_list
,
p
,
contacts
contact_list
,
p
,
contacts
,
page_range
,
current_page
=
pages
(
posts
,
request
)
return
render_to_response
(
'jasset/host_search.html'
,
locals
(),
context_instance
=
RequestContext
(
request
))
...
...
jumpserver/views.py
View file @
d0600662
...
...
@@ -89,6 +89,7 @@ def index(request):
hosts
=
Asset
.
objects
.
all
()
online_host
=
Log
.
objects
.
filter
(
is_finished
=
0
)
online_user
=
online_host
.
distinct
()
top_dic
=
{
'活跃用户数'
:
[
8
,
10
,
5
,
9
,
8
,
12
,
3
],
'活跃主机数'
:
[
10
,
16
,
20
,
8
,
9
,
5
,
9
],
'登录次数'
:
[
20
,
30
,
35
,
18
,
40
,
38
,
65
]}
return
render_to_response
(
'index.html'
,
locals
(),
context_instance
=
RequestContext
(
request
))
...
...
@@ -121,7 +122,6 @@ def page_list_return(total, current=1):
return
range
(
min_page
,
max_page
+
1
)
def
jasset_host_edit
(
j_id
,
j_ip
,
j_idc
,
j_port
,
j_type
,
j_group
,
j_active
,
j_comment
):
groups
=
[]
is_active
=
{
u'是'
:
'1'
,
u'否'
:
'2'
}
...
...
@@ -154,19 +154,22 @@ def jasset_host_edit(j_id, j_ip, j_idc, j_port, j_type, j_group, j_active, j_com
def
pages
(
posts
,
r
):
"""分页公用函数"""
contact_list
=
posts
p
=
paginator
=
Paginator
(
contact_list
,
1
0
)
p
=
paginator
=
Paginator
(
contact_list
,
2
0
)
try
:
page
=
int
(
r
.
GET
.
get
(
'page'
,
'1'
))
current_
page
=
int
(
r
.
GET
.
get
(
'page'
,
'1'
))
except
ValueError
:
page
=
1
current_page
=
1
page_range
=
page_list_return
(
len
(
p
.
page_range
),
current_page
)
try
:
contacts
=
paginator
.
page
(
page
)
contacts
=
paginator
.
page
(
current_
page
)
except
(
EmptyPage
,
InvalidPage
):
contacts
=
paginator
.
page
(
paginator
.
num_pages
)
return
contact_list
,
p
,
contacts
return
contact_list
,
p
,
contacts
,
page_range
,
current_page
def
login
(
request
):
...
...
static/js/highcharts/highstock.js
0 → 100644
View file @
d0600662
This source diff could not be displayed because it is too large. You can
view the blob
instead.
templates/foot_script.html
View file @
d0600662
...
...
@@ -21,6 +21,7 @@
<!-- highcharts -->
<script
src=
"/static/js/highcharts/highcharts.js"
></script>
<script
src=
"/static/js/highcharts/highstock.js"
></script>
<!-- active menu -->
<script>
...
...
templates/index.html
View file @
d0600662
...
...
@@ -58,9 +58,11 @@
</div>
</div>
</div>
<div
id=
"usertop10"
style=
"width:100%;height:400px;"
></div>
<div
id=
"hosttop10"
style=
"width:100%;height:400px; margin-top:170px"
></div>
</br>
<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>
</div>
...
...
@@ -68,6 +70,53 @@
<script>
var
cate
=
{{
li_str
|
safe
}};
$
(
function
()
{
$
(
'#top10'
).
highcharts
({
title
:
{
text
:
'数据总览'
,
x
:
-
20
//center
},
subtitle
:
{
text
:
'Source: JumpServer'
,
x
:
-
20
},
rangeSelector
:
{
allButtonsEnabled
:
true
,
selected
:
2
},
xAxis
:
{
type
:
'datetime'
,
categories
:
cate
},
yAxis
:{
min
:
0
,
title
:
{
text
:
'登录次数'
},
plotLines
:
[{
value
:
0
,
width
:
1
,
color
:
'#808080'
}]
},
tooltip
:
{
valueSuffix
:
'次'
},
legend
:
{
layout
:
'vertical'
,
align
:
'right'
,
verticalAlign
:
'middle'
,
borderWidth
:
0
},
series
:
[
{
%
for
k
,
v
in
top_dic
.
items
%
}
{
name
:
'{{ k }}'
,
data
:
{{
v
}}
},
{
%
endfor
%
}
]
});
$
(
'#usertop10'
).
highcharts
({
title
:
{
text
:
'一周用户登录TOP10'
,
...
...
templates/jasset/group_detail.html
View file @
d0600662
...
...
@@ -80,18 +80,29 @@
<ul
class=
"pagination"
style=
"margin-top: 0; float: right"
>
{% if contacts.has_previous %}
<li><a
href=
"?page={{ contacts.previous_page_number }}"
>
«
</a></li>
<li
class=
"paginate_button previous"
aria-controls=
"editable"
tabindex=
"0"
id=
"editable_previous"
>
<a
href=
"?id={{ group_id }}&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 %}
{% for page in p.page_range %}
{% ifequal offset1 page %}
<li
class=
"active"
><a
href=
"?page={{ page }}"
title=
"第{{ page }}页"
>
{{ page }}
</a></li>
{% 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>
{% else %}
<li><a
href=
"?
page={{ page }}"
title=
"第{{ page }}页"
>
{{ page }}
</a></li>
<li
class=
"paginate_button"
aria-controls=
"editable"
tabindex=
"0"
><a
href=
"?id={{ group_id }}&
page={{ page }}"
title=
"第{{ page }}页"
>
{{ page }}
</a></li>
{% endifequal %}
{% endfor %}
{% if contacts.has_next %}
<li><a
href=
"?page={{ contacts.next_page_number }}"
>
»
</a></li>
<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>
</li>
{% else %}
<li
class=
"paginate_button next disabled"
aria-controls=
"editable"
tabindex=
"0"
id=
"editable_next"
>
<a
href=
"#"
>
Next
</a>
</li>
{% endif %}
</ul>
</div>
...
...
@@ -157,7 +168,7 @@
url
:
"/jasset/group_del_host/group/"
,
data
:
{
"id_list"
:
id_list
,
"len_list"
:
j
,
"group_name"
:
group_name
},
success
:
function
(
data
)
{
window
.
open
(
window
.
location
.
pathname
,
"_self"
);
window
.
open
(
window
.
location
.
href
,
"_self"
);
}
});
}
...
...
templates/jasset/host_search.html
View file @
d0600662
...
...
@@ -45,18 +45,29 @@
<ul
class=
"pagination"
style=
"margin-top: 0; float: right"
>
{% if contacts.has_previous %}
<li><a
href=
"?page={{ contacts.previous_page_number }}"
>
«
</a></li>
<li
class=
"paginate_button previous"
aria-controls=
"editable"
tabindex=
"0"
id=
"editable_previous"
>
<a
href=
"?id={{ group_id }}&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 %}
{% for page in p.page_range %}
{% ifequal offset1 page %}
<li
class=
"active"
><a
href=
"?page={{ page }}"
title=
"第{{ page }}页"
>
{{ page }}
</a></li>
{% 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><a
href=
"?
page={{ page }}"
title=
"第{{ page }}页"
>
{{ page }}
</a></li>
<li
class=
"paginate_button"
aria-controls=
"editable"
tabindex=
"0"
><a
href=
"?keyword={{ keyword }}&
page={{ page }}"
title=
"第{{ page }}页"
>
{{ page }}
</a></li>
{% endifequal %}
{% endfor %}
{% if contacts.has_next %}
<li><a
href=
"?page={{ contacts.next_page_number }}"
>
»
</a></li>
<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>
</li>
{% else %}
<li
class=
"paginate_button next disabled"
aria-controls=
"editable"
tabindex=
"0"
id=
"editable_next"
>
<a
href=
"#"
>
Next
</a>
</li>
{% endif %}
</ul>
</div>
...
...
templates/jasset/idc_detail.html
View file @
d0600662
...
...
@@ -80,7 +80,7 @@
{% 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>
<a
href=
"?
id={{ idc_id }}&
page={{ contacts.previous_page_number }}"
>
Previous
</a>
</li>
{% else %}
<li
class=
"paginate_button previous disabled"
aria-controls=
"editable"
tabindex=
"0"
id=
"editable_previous"
>
...
...
@@ -89,14 +89,14 @@
{% endif %}
{% for page in page_range %}
{% ifequal current_page page %}
<li
class=
"paginate_button active"
aria-controls=
"editable"
tabindex=
"0"
><a
href=
"?page={{ page }}"
title=
"第{{ page }}页"
>
{{ page }}
</a></li>
<li
class=
"paginate_button active"
aria-controls=
"editable"
tabindex=
"0"
><a
href=
"?
id={{ idc_id }}&
page={{ page }}"
title=
"第{{ page }}页"
>
{{ page }}
</a></li>
{% else %}
<li
class=
"paginate_button"
aria-controls=
"editable"
tabindex=
"0"
><a
href=
"?page={{ page }}"
title=
"第{{ page }}页"
>
{{ page }}
</a></li>
<li
class=
"paginate_button"
aria-controls=
"editable"
tabindex=
"0"
><a
href=
"?
id={{ idc_id }}&
page={{ page }}"
title=
"第{{ page }}页"
>
{{ page }}
</a></li>
{% endifequal %}
{% endfor %}
{% 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>
<a
href=
"?
id={{ idc_id }}&
page={{ contacts.next_page_number }}"
>
Next
</a>
</li>
{% else %}
<li
class=
"paginate_button next disabled"
aria-controls=
"editable"
tabindex=
"0"
id=
"editable_next"
>
...
...
@@ -167,7 +167,7 @@
url
:
"/jasset/group_del_host/idc/"
,
data
:
{
"id_list"
:
id_list
,
"len_list"
:
j
,
"group_name"
:
group_name
},
success
:
function
(
data
)
{
window
.
open
(
window
.
location
.
pathname
,
"_self"
);
window
.
open
(
window
.
location
.
href
,
"_self"
);
}
});
}
...
...
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