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
7de943c6
Commit
7de943c6
authored
Apr 05, 2015
by
halcyon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
管理员仪表盘基本完成
parent
17be0bb3
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
328 additions
and
113 deletions
+328
-113
urls.py
jasset/urls.py
+2
-2
views.py
jasset/views.py
+95
-36
jumpserver.conf
jumpserver.conf
+1
-1
api.py
jumpserver/api.py
+8
-3
settings.py
jumpserver/settings.py
+1
-0
mytags.py
jumpserver/templatetags/mytags.py
+16
-1
views.py
jumpserver/views.py
+36
-47
index.html
templates/index.html
+160
-14
dept_perm_list.html
templates/jperm/dept_perm_list.html
+2
-2
perm_list.html
templates/jperm/perm_list.html
+3
-3
nav.html
templates/nav.html
+4
-4
No files found.
jasset/urls.py
View file @
7de943c6
...
@@ -13,9 +13,9 @@ urlpatterns = patterns('',
...
@@ -13,9 +13,9 @@ urlpatterns = patterns('',
url
(
r'^idc_edit/$'
,
edit_idc
),
url
(
r'^idc_edit/$'
,
edit_idc
),
url
(
r'^idc_detail/$'
,
detail_idc
),
url
(
r'^idc_detail/$'
,
detail_idc
),
url
(
r'^idc_del/(\w+)/$'
,
del_idc
),
url
(
r'^idc_del/(\w+)/$'
,
del_idc
),
url
(
r'^
j
group_add/$'
,
add_group
),
url
(
r'^group_add/$'
,
add_group
),
url
(
r'^group_edit/$'
,
edit_group
),
url
(
r'^group_edit/$'
,
edit_group
),
url
(
r'^
j
group_list/$'
,
list_group
),
url
(
r'^group_list/$'
,
list_group
),
url
(
r'^group_detail/$'
,
detail_group
),
url
(
r'^group_detail/$'
,
detail_group
),
url
(
r'^group_del_host/(\w+)/$'
,
group_del_host
),
url
(
r'^group_del_host/(\w+)/$'
,
group_del_host
),
url
(
r'^group_del/(\w+)/$'
,
group_del
),
url
(
r'^group_del/(\w+)/$'
,
group_del
),
...
...
jasset/views.py
View file @
7de943c6
...
@@ -3,16 +3,13 @@
...
@@ -3,16 +3,13 @@
import
ast
import
ast
from
django.db.models
import
Q
from
django.db.models
import
Q
from
django.http
import
Http404
from
django.http
import
HttpResponseRedirect
from
django.template
import
RequestContext
from
django.template
import
RequestContext
from
django.shortcuts
import
render_to_response
from
django.shortcuts
import
render_to_response
from
models
import
IDC
,
Asset
,
BisGroup
from
jasset.
models
import
IDC
,
Asset
,
BisGroup
from
juser.models
import
UserGroup
,
DEPT
from
juser.models
import
UserGroup
,
DEPT
from
connect
import
PyCrypt
,
KEY
from
jperm.models
import
Perm
from
jlog.models
import
Log
from
jumpserver.views
import
pages
from
jumpserver.views
import
jasset_host_edit
,
pages
from
jumpserver.api
import
*
from
jumpserver.api
import
*
cryptor
=
PyCrypt
(
KEY
)
cryptor
=
PyCrypt
(
KEY
)
...
@@ -55,6 +52,42 @@ def f_add_host(ip, port, idc, jtype, group, dept, active, comment, username='',
...
@@ -55,6 +52,42 @@ def f_add_host(ip, port, idc, jtype, group, dept, active, comment, username='',
a
.
save
()
a
.
save
()
def
jasset_host_edit
(
j_id
,
j_ip
,
j_idc
,
j_port
,
j_type
,
j_group
,
j_dept
,
j_active
,
j_comment
,
j_user
=
''
,
j_password
=
''
):
groups
,
depts
=
[],
[]
is_active
=
{
u'是'
:
'1'
,
u'否'
:
'2'
}
login_types
=
{
'LDAP'
:
'L'
,
'MAP'
:
'M'
}
for
group
in
j_group
[
0
]
.
split
():
c
=
BisGroup
.
objects
.
get
(
name
=
group
.
strip
())
groups
.
append
(
c
)
print
j_dept
for
d
in
j_dept
[
0
]
.
split
():
p
=
DEPT
.
objects
.
get
(
name
=
d
.
strip
())
depts
.
append
(
p
)
j_type
=
login_types
[
j_type
]
j_idc
=
IDC
.
objects
.
get
(
name
=
j_idc
)
a
=
Asset
.
objects
.
get
(
id
=
j_id
)
if
j_type
==
'M'
:
a
.
ip
=
j_ip
a
.
port
=
j_port
a
.
login_type
=
j_type
a
.
idc
=
j_idc
a
.
is_active
=
j_active
a
.
comment
=
j_comment
a
.
username
=
j_user
a
.
password
=
j_password
else
:
a
.
ip
=
j_ip
a
.
port
=
j_port
a
.
idc
=
j_idc
a
.
login_type
=
j_type
a
.
is_active
=
is_active
[
j_active
]
a
.
comment
=
j_comment
a
.
save
()
a
.
bis_group
=
groups
a
.
dept
=
depts
a
.
save
()
@require_admin
@require_admin
def
add_host
(
request
):
def
add_host
(
request
):
login_types
=
{
'L'
:
'LDAP'
,
'M'
:
'MAP'
}
login_types
=
{
'L'
:
'LDAP'
,
'M'
:
'MAP'
}
...
@@ -183,27 +216,45 @@ def list_host(request):
...
@@ -183,27 +216,45 @@ def list_host(request):
keyword
=
request
.
GET
.
get
(
'keyword'
,
''
)
keyword
=
request
.
GET
.
get
(
'keyword'
,
''
)
dept_id
=
get_user_dept
(
request
)
dept_id
=
get_user_dept
(
request
)
dept
=
DEPT
.
objects
.
get
(
id
=
dept_id
)
dept
=
DEPT
.
objects
.
get
(
id
=
dept_id
)
if
is_super_user
(
request
):
did
=
request
.
GET
.
get
(
'did'
)
if
keyword
:
gid
=
request
.
GET
.
get
(
'gid'
)
posts
=
Asset
.
objects
.
filter
(
Q
(
ip__contains
=
keyword
)
|
Q
(
idc__name__contains
=
keyword
)
|
sid
=
request
.
GET
.
get
(
'sid'
)
Q
(
bis_group__name__contains
=
keyword
)
|
Q
(
comment__contains
=
keyword
))
.
distinct
()
.
order_by
(
'ip'
)
if
did
:
else
:
dept
=
DEPT
.
objects
.
get
(
id
=
did
)
posts
=
Asset
.
objects
.
all
()
.
order_by
(
'ip'
)
posts
=
dept
.
asset_set
.
all
()
contact_list
,
p
,
contacts
,
page_range
,
current_page
,
show_first
,
show_end
=
pages
(
posts
,
request
)
elif
gid
:
elif
is_group_admin
(
request
):
posts
=
[]
if
keyword
:
user_group
=
UserGroup
.
objects
.
get
(
id
=
gid
)
posts
=
Asset
.
objects
.
filter
(
Q
(
ip__contains
=
keyword
)
|
Q
(
idc__name__contains
=
keyword
)
|
perms
=
Perm
.
objects
.
filter
(
user_group
=
user_group
)
Q
(
bis_group__name__contains
=
keyword
)
|
Q
(
comment__contains
=
keyword
))
.
filter
(
dept
=
dept
)
.
distinct
()
.
order_by
(
'ip'
)
for
perm
in
perms
:
else
:
for
post
in
perm
.
asset_group
.
asset_set
.
all
():
posts
=
Asset
.
objects
.
all
()
.
filter
(
dept
=
dept
)
.
order_by
(
'ip'
)
posts
.
append
(
post
)
contact_list
,
p
,
contacts
,
page_range
,
current_page
,
show_first
,
show_end
=
pages
(
posts
,
request
)
posts
=
list
(
set
(
posts
))
elif
sid
:
pass
else
:
if
is_super_user
(
request
):
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'
)
else
:
posts
=
Asset
.
objects
.
all
()
.
order_by
(
'ip'
)
elif
is_group_admin
(
request
):
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
))
.
filter
(
dept
=
dept
)
.
distinct
()
.
order_by
(
'ip'
)
else
:
posts
=
Asset
.
objects
.
all
()
.
filter
(
dept
=
dept
)
.
order_by
(
'ip'
)
elif
is_common_user
(
request
):
user_id
=
request
.
session
.
get
(
'user_id'
)
username
=
User
.
objects
.
get
(
id
=
user_id
)
.
name
posts
=
user_perm_asset_api
(
username
)
contact_list
,
p
,
contacts
,
page_range
,
current_page
,
show_first
,
show_end
=
pages
(
posts
,
request
)
elif
is_common_user
(
request
):
user_id
=
request
.
session
.
get
(
'user_id'
)
username
=
User
.
objects
.
get
(
id
=
user_id
)
.
name
posts
=
user_perm_asset_api
(
username
)
contact_list
,
p
,
contacts
,
page_range
,
current_page
,
show_first
,
show_end
=
pages
(
posts
,
request
)
print
posts
,
username
return
render_to_response
(
'jasset/host_list.html'
,
locals
(),
context_instance
=
RequestContext
(
request
))
return
render_to_response
(
'jasset/host_list.html'
,
locals
(),
context_instance
=
RequestContext
(
request
))
...
@@ -426,16 +477,24 @@ def list_group(request):
...
@@ -426,16 +477,24 @@ def list_group(request):
dept_id
=
get_user_dept
(
request
)
dept_id
=
get_user_dept
(
request
)
dept
=
DEPT
.
objects
.
get
(
id
=
dept_id
)
dept
=
DEPT
.
objects
.
get
(
id
=
dept_id
)
keyword
=
request
.
GET
.
get
(
'keyword'
,
''
)
keyword
=
request
.
GET
.
get
(
'keyword'
,
''
)
if
is_super_user
(
request
):
gid
=
request
.
GET
.
get
(
'gid'
)
if
keyword
:
if
gid
:
posts
=
BisGroup
.
objects
.
exclude
(
name
=
'ALL'
)
.
filter
(
Q
(
name__contains
=
keyword
)
|
Q
(
comment__contains
=
keyword
))
posts
=
[]
else
:
user_group
=
UserGroup
.
objects
.
get
(
id
=
gid
)
posts
=
BisGroup
.
objects
.
exclude
(
name
=
'ALL'
)
.
order_by
(
'id'
)
perms
=
Perm
.
objects
.
filter
(
user_group
=
user_group
)
elif
is_group_admin
(
request
):
for
perm
in
perms
:
if
keyword
:
posts
.
append
(
perm
.
asset_group
)
posts
=
BisGroup
.
objects
.
filter
(
Q
(
name__contains
=
keyword
)
|
Q
(
comment__contains
=
keyword
))
.
filter
(
dept
=
dept
)
else
:
else
:
if
is_super_user
(
request
):
posts
=
BisGroup
.
objects
.
filter
(
dept
=
dept
)
.
order_by
(
'id'
)
if
keyword
:
posts
=
BisGroup
.
objects
.
exclude
(
name
=
'ALL'
)
.
filter
(
Q
(
name__contains
=
keyword
)
|
Q
(
comment__contains
=
keyword
))
else
:
posts
=
BisGroup
.
objects
.
exclude
(
name
=
'ALL'
)
.
order_by
(
'id'
)
elif
is_group_admin
(
request
):
if
keyword
:
posts
=
BisGroup
.
objects
.
filter
(
Q
(
name__contains
=
keyword
)
|
Q
(
comment__contains
=
keyword
))
.
filter
(
dept
=
dept
)
else
:
posts
=
BisGroup
.
objects
.
filter
(
dept
=
dept
)
.
order_by
(
'id'
)
contact_list
,
p
,
contacts
,
page_range
,
current_page
,
show_first
,
show_end
=
pages
(
posts
,
request
)
contact_list
,
p
,
contacts
,
page_range
,
current_page
,
show_first
,
show_end
=
pages
(
posts
,
request
)
return
render_to_response
(
'jasset/group_list.html'
,
locals
(),
context_instance
=
RequestContext
(
request
))
return
render_to_response
(
'jasset/group_list.html'
,
locals
(),
context_instance
=
RequestContext
(
request
))
...
...
jumpserver.conf
View file @
7de943c6
...
@@ -9,7 +9,7 @@ database = jumpserver
...
@@ -9,7 +9,7 @@ database = jumpserver
[
ldap
]
[
ldap
]
ldap_enable
=
1
ldap_enable
=
1
host_url
=
ldap
://
1
27
.
0
.
0
.
1
:
389
host_url
=
ldap
://
1
92
.
168
.
173
.
129
:
389
base_dn
=
dc
=
jumpserver
,
dc
=
org
base_dn
=
dc
=
jumpserver
,
dc
=
org
root_dn
=
cn
=
admin
,
dc
=
jumpserver
,
dc
=
org
root_dn
=
cn
=
admin
,
dc
=
jumpserver
,
dc
=
org
root_pw
=
secret234
root_pw
=
secret234
...
...
jumpserver/api.py
View file @
7de943c6
...
@@ -12,7 +12,7 @@ from ldap import modlist
...
@@ -12,7 +12,7 @@ from ldap import modlist
import
hashlib
import
hashlib
from
django.core.paginator
import
Paginator
,
EmptyPage
,
InvalidPage
from
django.core.paginator
import
Paginator
,
EmptyPage
,
InvalidPage
from
django.http
import
HttpResponse
,
Http404
from
django.http
import
HttpResponse
,
Http404
from
juser.models
import
User
,
UserGroup
from
juser.models
import
User
,
UserGroup
,
DEPT
from
jasset.models
import
Asset
,
BisGroup
from
jasset.models
import
Asset
,
BisGroup
from
jlog.models
import
Log
from
jlog.models
import
Log
...
@@ -345,4 +345,9 @@ def validate(request, user_group=None, user=None, asset_group=None, asset=None,
...
@@ -345,4 +345,9 @@ def validate(request, user_group=None, user=None, asset_group=None, asset=None,
if
not
set
(
assets
)
.
issubset
(
eassets
):
if
not
set
(
assets
)
.
issubset
(
eassets
):
return
False
return
False
return
True
return
True
\ No newline at end of file
def
get_dept_asset
(
request
):
dept_id
=
get_user_dept
(
request
)
dept_asset
=
DEPT
.
objects
.
get
(
id
=
dept_id
)
.
asset_set
.
all
()
\ No newline at end of file
jumpserver/settings.py
View file @
7de943c6
...
@@ -53,6 +53,7 @@ INSTALLED_APPS = (
...
@@ -53,6 +53,7 @@ INSTALLED_APPS = (
'django.contrib.sessions'
,
'django.contrib.sessions'
,
'django.contrib.messages'
,
'django.contrib.messages'
,
'django.contrib.staticfiles'
,
'django.contrib.staticfiles'
,
'django.contrib.humanize'
,
'jumpserver'
,
'jumpserver'
,
'juser'
,
'juser'
,
'jasset'
,
'jasset'
,
...
...
jumpserver/templatetags/mytags.py
View file @
7de943c6
...
@@ -174,7 +174,12 @@ def group_type_to_str(type_name):
...
@@ -174,7 +174,12 @@ def group_type_to_str(type_name):
@register.filter
(
name
=
'ast_to_list'
)
@register.filter
(
name
=
'ast_to_list'
)
def
ast_to_list
(
lis
):
def
ast_to_list
(
lis
):
return
ast
.
literal_eval
(
lis
)[
0
:
2
]
ast_lis
=
ast
.
literal_eval
(
lis
)
if
len
(
ast_lis
)
<=
2
:
return
','
.
join
([
i
for
i
in
ast_lis
])
else
:
restr
=
','
.
join
([
i
for
i
in
ast_lis
[
0
:
2
]])
+
'...'
return
restr
@register.filter
(
name
=
'ast_to_list_1'
)
@register.filter
(
name
=
'ast_to_list_1'
)
...
@@ -191,6 +196,16 @@ def string_length(string, length):
...
@@ -191,6 +196,16 @@ def string_length(string, length):
return
'
%
s ...'
%
string
[
0
:
length
]
return
'
%
s ...'
%
string
[
0
:
length
]
@register.filter
(
name
=
'get_dic_user'
)
def
get_dic_user
(
dic
):
return
dic
.
get
(
'user'
)
@register.filter
(
name
=
'get_dic_times'
)
def
get_dic_times
(
dic
):
return
dic
.
get
(
'times'
)
@register.filter
(
name
=
'to_name'
)
@register.filter
(
name
=
'to_name'
)
def
to_name
(
user_id
):
def
to_name
(
user_id
):
try
:
try
:
...
...
jumpserver/views.py
View file @
7de943c6
# coding: utf-8
# coding: utf-8
from
__future__
import
division
import
datetime
import
datetime
from
django.db.models
import
Count
from
django.db.models
import
Count
...
@@ -7,6 +9,7 @@ from django.shortcuts import render_to_response
...
@@ -7,6 +9,7 @@ from django.shortcuts import render_to_response
from
django.template
import
RequestContext
from
django.template
import
RequestContext
from
jasset.models
import
IDC
from
jasset.models
import
IDC
from
juser.models
import
DEPT
from
juser.models
import
DEPT
from
jperm.models
import
Apply
from
jumpserver.api
import
*
from
jumpserver.api
import
*
...
@@ -46,8 +49,18 @@ def get_data(data, items, option):
...
@@ -46,8 +49,18 @@ def get_data(data, items, option):
def
index
(
request
):
def
index
(
request
):
users
=
User
.
objects
.
all
()
users
=
User
.
objects
.
all
()
hosts
=
Asset
.
objects
.
all
()
hosts
=
Asset
.
objects
.
all
()
online_host
=
Log
.
objects
.
filter
(
is_finished
=
0
)
online
=
Log
.
objects
.
filter
(
is_finished
=
0
)
online_user
=
online_host
.
distinct
()
online_host
=
online
.
values
(
'host'
)
.
distinct
()
online_user
=
online
.
values
(
'user'
)
.
distinct
()
active_users
=
User
.
objects
.
filter
(
is_active
=
1
)
active_hosts
=
Asset
.
objects
.
filter
(
is_active
=
1
)
# percent of dashboard
percent_user
=
format
(
active_users
.
count
()
/
users
.
count
(),
'.0
%
'
)
percent_host
=
format
(
active_hosts
.
count
()
/
hosts
.
count
(),
'.0
%
'
)
percent_online_user
=
format
(
online_user
.
count
()
/
users
.
count
(),
'.0
%
'
)
percent_online_host
=
format
(
online_host
.
count
()
/
hosts
.
count
(),
'.0
%
'
)
li_date
,
li_str
=
getDaysByNum
(
7
)
li_date
,
li_str
=
getDaysByNum
(
7
)
today
=
datetime
.
datetime
.
now
()
.
day
today
=
datetime
.
datetime
.
now
()
.
day
from_week
=
datetime
.
datetime
.
now
()
-
datetime
.
timedelta
(
days
=
7
)
from_week
=
datetime
.
datetime
.
now
()
-
datetime
.
timedelta
(
days
=
7
)
...
@@ -56,6 +69,27 @@ def index(request):
...
@@ -56,6 +69,27 @@ def index(request):
host_top_ten
=
week_data
.
values
(
'host'
)
.
annotate
(
times
=
Count
(
'host'
))
.
order_by
(
'-times'
)[:
10
]
host_top_ten
=
week_data
.
values
(
'host'
)
.
annotate
(
times
=
Count
(
'host'
))
.
order_by
(
'-times'
)[:
10
]
user_dic
,
host_dic
=
get_data
(
week_data
,
user_top_ten
,
'user'
),
get_data
(
week_data
,
host_top_ten
,
'host'
)
user_dic
,
host_dic
=
get_data
(
week_data
,
user_top_ten
,
'user'
),
get_data
(
week_data
,
host_top_ten
,
'host'
)
# a week data
week_users
=
week_data
.
values
(
'user'
)
.
distinct
()
.
count
()
week_hosts
=
week_data
.
count
()
user_top_five
=
week_data
.
values
(
'user'
)
.
annotate
(
times
=
Count
(
'user'
))
.
order_by
(
'-times'
)[:
5
]
color
=
[
'label-success'
,
'label-info'
,
'label-primary'
,
'label-default'
,
'label-warnning'
]
# perm apply latest 10
perm_apply_10
=
Apply
.
objects
.
order_by
(
'-date_add'
)[:
10
]
# latest 10 login
login_10
=
Log
.
objects
.
order_by
(
'-start_time'
)[:
10
]
# a week top 10
# user_top_ten_more = []
for
user_info
in
user_top_ten
:
username
=
user_info
.
get
(
'user'
)
last
=
Log
.
objects
.
filter
(
user
=
username
)
.
latest
(
'start_time'
)
user_info
[
'last'
]
=
last
print
user_top_ten
top
=
{
'user'
:
'活跃用户数'
,
'host'
:
'活跃主机数'
,
'times'
:
'登录次数'
}
top
=
{
'user'
:
'活跃用户数'
,
'host'
:
'活跃主机数'
,
'times'
:
'登录次数'
}
top_dic
=
{}
top_dic
=
{}
for
key
,
value
in
top
.
items
():
for
key
,
value
in
top
.
items
():
...
@@ -75,51 +109,6 @@ def skin_config(request):
...
@@ -75,51 +109,6 @@ def skin_config(request):
return
render_to_response
(
'skin_config.html'
)
return
render_to_response
(
'skin_config.html'
)
def
jasset_group_add
(
name
,
comment
,
jtype
):
if
BisGroup
.
objects
.
filter
(
name
=
name
):
emg
=
u'该业务组已存在!'
else
:
BisGroup
.
objects
.
create
(
name
=
name
,
comment
=
comment
,
type
=
jtype
)
smg
=
u'业务组
%
s添加成功'
%
name
def
jasset_host_edit
(
j_id
,
j_ip
,
j_idc
,
j_port
,
j_type
,
j_group
,
j_dept
,
j_active
,
j_comment
,
j_user
=
''
,
j_password
=
''
):
groups
,
depts
=
[],
[]
is_active
=
{
u'是'
:
'1'
,
u'否'
:
'2'
}
login_types
=
{
'LDAP'
:
'L'
,
'MAP'
:
'M'
}
for
group
in
j_group
[
0
]
.
split
():
c
=
BisGroup
.
objects
.
get
(
name
=
group
.
strip
())
groups
.
append
(
c
)
print
j_dept
for
d
in
j_dept
[
0
]
.
split
():
p
=
DEPT
.
objects
.
get
(
name
=
d
.
strip
())
depts
.
append
(
p
)
j_type
=
login_types
[
j_type
]
j_idc
=
IDC
.
objects
.
get
(
name
=
j_idc
)
a
=
Asset
.
objects
.
get
(
id
=
j_id
)
if
j_type
==
'M'
:
a
.
ip
=
j_ip
a
.
port
=
j_port
a
.
login_type
=
j_type
a
.
idc
=
j_idc
a
.
is_active
=
j_active
a
.
comment
=
j_comment
a
.
username
=
j_user
a
.
password
=
j_password
else
:
a
.
ip
=
j_ip
a
.
port
=
j_port
a
.
idc
=
j_idc
a
.
login_type
=
j_type
a
.
is_active
=
is_active
[
j_active
]
a
.
comment
=
j_comment
a
.
save
()
a
.
bis_group
=
groups
a
.
dept
=
depts
a
.
save
()
def
pages
(
posts
,
r
):
def
pages
(
posts
,
r
):
"""分页公用函数"""
"""分页公用函数"""
contact_list
=
posts
contact_list
=
posts
...
...
templates/index.html
View file @
7de943c6
{% extends 'base.html' %}
{% extends 'base.html' %}
{% load mytags %}
{% load humanize %}
{% block content %}
{% block content %}
{% include 'nav_cat_bar.html' %}
{% include 'nav_cat_bar.html' %}
...
@@ -12,7 +14,7 @@
...
@@ -12,7 +14,7 @@
</div>
</div>
<div
class=
"ibox-content"
>
<div
class=
"ibox-content"
>
<h1
class=
"no-margins"
><a
href=
"/juser/user_list/"
>
{{ users.count}}
</a></h1>
<h1
class=
"no-margins"
><a
href=
"/juser/user_list/"
>
{{ users.count}}
</a></h1>
<div
class=
"stat-percent font-bold text-success"
>
98%
<i
class=
"fa fa-bolt"
></i></div>
<div
class=
"stat-percent font-bold text-success"
>
{{ percent_user }}
<i
class=
"fa fa-bolt"
></i></div>
<small>
All user
</small>
<small>
All user
</small>
</div>
</div>
</div>
</div>
...
@@ -25,7 +27,7 @@
...
@@ -25,7 +27,7 @@
</div>
</div>
<div
class=
"ibox-content"
>
<div
class=
"ibox-content"
>
<h1
class=
"no-margins"
><a
href=
"/jasset/host_list/"
>
{{ hosts.count }}
</a></h1>
<h1
class=
"no-margins"
><a
href=
"/jasset/host_list/"
>
{{ hosts.count }}
</a></h1>
<div
class=
"stat-percent font-bold text-info"
>
20%
<i
class=
"fa fa-level-up"
></i></div>
<div
class=
"stat-percent font-bold text-info"
>
{{ percent_host }}
<i
class=
"fa fa-level-up"
></i></div>
<small>
All host
</small>
<small>
All host
</small>
</div>
</div>
</div>
</div>
...
@@ -39,7 +41,7 @@
...
@@ -39,7 +41,7 @@
</div>
</div>
<div
class=
"ibox-content"
>
<div
class=
"ibox-content"
>
<h1
class=
"no-margins"
><a
href=
"/jlog/log_list/online/"
>
<span
id=
"online_users"
></span></a></h1>
<h1
class=
"no-margins"
><a
href=
"/jlog/log_list/online/"
>
<span
id=
"online_users"
></span></a></h1>
<div
class=
"stat-percent font-bold text-navy"
>
44%
<i
class=
"fa fa-level-up"
></i></div>
<div
class=
"stat-percent font-bold text-navy"
>
{{ percent_online_user }}
<i
class=
"fa fa-level-up"
></i></div>
<small>
Online user
</small>
<small>
Online user
</small>
</div>
</div>
</div>
</div>
...
@@ -53,28 +55,172 @@
...
@@ -53,28 +55,172 @@
</div>
</div>
<div
class=
"ibox-content"
>
<div
class=
"ibox-content"
>
<h1
class=
"no-margins"
><a
href=
"/jlog/log_list/online/"
>
<span
id=
"online_hosts"
></span></a></h1>
<h1
class=
"no-margins"
><a
href=
"/jlog/log_list/online/"
>
<span
id=
"online_hosts"
></span></a></h1>
<div
class=
"stat-percent font-bold text-danger"
>
38%
<i
class=
"fa fa-level-down"
></i></div>
<div
class=
"stat-percent font-bold text-danger"
>
{{ percent_online_host }}
<i
class=
"fa fa-level-down"
></i></div>
<small>
Connected host
</small>
<small>
Connected host
</small>
</div>
</div>
</div>
</div>
</div>
</div>
<div
class=
"row"
>
</div>
<div
class=
"col-lg-6"
id=
"top10"
style=
"width:50%;height:400px;"
></div>
<div
class=
"row"
>
<div
class=
"col-lg-6"
id=
"usertop10"
style=
"width:50%;height:400px;"
></div>
<div
class=
"col-lg-3 border-bottom white-bg dashboard-header"
style=
"margin-left:15px;"
>
</div>
<h2>
活跃用户TOP5
</h2>
<div
class=
"row"
>
<small>
过去一周共有
<span
class=
"text-info"
>
{{ week_users }}
</span>
位用户登录
<span
class=
"text-success"
>
{{ week_hosts }}
</span>
次服务器.
</small>
<div
class=
"col-lg-6"
id=
"hosttop10"
style=
"width:50%;height:400px; margin-top: 20px"
></div>
<ul
class=
"list-group clear-list m-t"
>
{% for data in user_top_five %}
<li
class=
"list-group-item fist-item"
>
<span
class=
"pull-right"
>
{{ data|get_dic_times }}次/周
</span>
<span
class=
"label {{ color|random }}"
>
{{ forloop.counter }}
</span>
{{ data|get_dic_user }}
</li>
{% endfor %}
</ul>
</div>
</div>
<div
class=
"col-lg-9"
id=
"top10"
style=
"margin-left: -15px;height: 345px"
></div>
</div>
</div>
<br/>
<div
class=
"row"
>
<div
class=
"col-lg-4"
>
<div
class=
"ibox float-e-margins"
>
<div
class=
"ibox-title"
>
<h5>
权限申请
</h5>
<div
class=
"ibox-tools"
>
<a
class=
"collapse-link"
>
<i
class=
"fa fa-chevron-up"
></i>
</a>
<a
class=
"close-link"
>
<i
class=
"fa fa-times"
></i>
</a>
</div>
</div>
<div
class=
"ibox-content ibox-heading"
>
<h3><i
class=
"fa fa-envelope-o"
></i>
New messages
</h3>
<small><i
class=
"fa fa-tim"
></i>
You have 22 new messages and 16 waiting in draft folder.
</small>
</div>
<div
class=
"ibox-content"
>
<div
class=
"feed-activity-list"
>
{% for perm in perm_apply_10 %}
<div
class=
"feed-element"
>
<div>
{% ifequal perm.status 0 %}
<small
class=
"pull-right text-navy"
>
{{ perm.date_add|naturaltime }}
</small>
{% else %}
<small
class=
"pull-right"
>
{{ perm.date_add|naturaltime }}
</small>
{% endifequal %}
<strong>
{{ perm.applyer }}
</strong>
<div>
申请 {{ perm.bisgroup|ast_to_list }} 主机组权限
</div>
<div>
申请 {{ perm.asset|ast_to_list }} 主机权限
</div>
<small
class=
"text-muted"
>
{{ perm.date_add }}
</small>
</div>
</div>
{% endfor %}
</div>
</div>
</div>
</div>
<div
class=
"col-lg-4"
>
<div
class=
"ibox float-e-margins"
>
<div
class=
"ibox-title"
>
<h5>
最近十次登录
</h5>
<div
class=
"ibox-tools"
>
<span
class=
"label label-warning-light"
>
10 Messages
</span>
</div>
</div>
<div
class=
"ibox-content"
>
<div>
<div
class=
"feed-activity-list"
>
{% for login in login_10 %}
<div
class=
"feed-element"
>
<a
href=
"profile.html"
class=
"pull-left"
>
<img
alt=
"image"
class=
"img-circle"
src=
"/static/img/root.png"
>
</a>
<div
class=
"media-body "
>
{% ifequal login.is_finished 0 %}
<small
class=
"pull-right text-navy"
>
{{ login.start_time|naturaltime }}
</small>
{% else %}
<small
class=
"pull-right"
>
{{ login.start_time|naturaltime }}
</small>
{% endifequal %}
<strong>
{{ login.user }}
</strong>
登录了{{ login.host }}
<br>
<small
class=
"text-muted"
>
{{ login.start_time }}
</small>
</div>
</div>
{% endfor %}
</div>
<button
class=
"btn btn-primary btn-block m-t"
><i
class=
"fa fa-arrow-down"
></i>
Show More
</button>
</div>
</div>
</div>
</div>
<div
class=
"col-lg-4"
>
<div
class=
"ibox float-e-margins"
>
<div
class=
"ibox-title"
>
<h5>
一周Top10用户
</h5>
<div
class=
"ibox-tools"
>
<a
class=
"collapse-link"
>
<i
class=
"fa fa-chevron-up"
></i>
</a>
<a
class=
"dropdown-toggle"
data-toggle=
"dropdown"
href=
"#"
>
<i
class=
"fa fa-wrench"
></i>
</a>
<ul
class=
"dropdown-menu dropdown-user"
>
<li><a
href=
"#"
>
Config option 1
</a>
</li>
<li><a
href=
"#"
>
Config option 2
</a>
</li>
</ul>
<a
class=
"close-link"
>
<i
class=
"fa fa-times"
></i>
</a>
</div>
</div>
<div
class=
"ibox-content ibox-heading"
>
<h3>
You have meeting today!
</h3>
<small><i
class=
"fa fa-map-marker"
></i>
Meeting is on 6:00am. Check your schedule to see detail.
</small>
</div>
<div
class=
"ibox-content inspinia-timeline"
>
{% for data in user_top_ten %}
<div
class=
"timeline-item"
>
<div
class=
"row"
>
<div
class=
"col-xs-5 date"
>
<i
class=
"fa fa-info-circle"
></i>
<strong>
{{ data|get_dic_user }}
</strong>
<br/>
<small
class=
"text-navy"
>
{{ data|get_dic_times }}次
</small>
</div>
<div
class=
"col-xs-7 content no-top-border"
>
<p
class=
"m-b-xs"
>
最近一次登录
</p>
<p>
{{ data.last.host }}
</p>
<p>
于{{ data.last.start_time |date:"Y-m-d H:i:s" }}
</p>
</div>
</div>
</div>
{% endfor %}
</div>
</div>
</div>
<!--</div>-->
<!--<div class="col-xm-6" id="top10" style="width:50%;height:400px;"></div>-->
<!--<div class="col-xm-6" id="usertop10" style="width:50%;height:400px;"></div>-->
<!--<div class="row">-->
<!--<div class="col-lg-6" id="hosttop10" style="width:50%;height:400px; margin-top: 20px"></div>-->
<!--</div>-->
</div>
</div>
<script>
<script>
var
cate
=
{{
li_str
|
safe
}};
var
cate
=
{{
li_str
|
safe
}};
$
(
function
()
{
$
(
function
()
{
$
(
'#top10'
).
highcharts
({
$
(
'#top10'
).
highcharts
({
chart
:
{
//
chart: {
type
:
'column'
//
type: 'column'
},
//
},
title
:
{
title
:
{
text
:
'一周数据总览'
,
text
:
'一周数据总览'
,
x
:
-
20
//center
x
:
-
20
//center
...
@@ -94,7 +240,7 @@ $(function () {
...
@@ -94,7 +240,7 @@ $(function () {
yAxis
:{
yAxis
:{
min
:
0
,
min
:
0
,
title
:
{
title
:
{
text
:
'
登录次数
'
text
:
''
},
},
plotLines
:
[{
plotLines
:
[{
value
:
0
,
value
:
0
,
...
...
templates/jperm/dept_perm_list.html
View file @
7de943c6
...
@@ -58,8 +58,8 @@
...
@@ -58,8 +58,8 @@
{% for dept in contacts.object_list %}
{% for dept in contacts.object_list %}
<tr
class=
"gradeX"
>
<tr
class=
"gradeX"
>
<td
class=
"text-center"
>
{{ dept.name }}
</td>
<td
class=
"text-center"
>
{{ dept.name }}
</td>
<td
class=
"text-center"
><a
href=
"/juser/user_list/?did={{ dept.id }}"
>
{{ dept.id | dept_user_num }}
</a>
</td>
<td
class=
"text-center"
><a
href=
"/juser/user_list/?did={{ dept.id }}"
>
{{ dept.id | dept_user_num }}
</a>
</td>
<td
class=
"text-center"
>
{{ dept.id | dept_asset_num }}
</td>
<td
class=
"text-center"
>
<a
href=
"/jasset/host_list/?did={{ dept.id }}"
>
{{ dept.id | dept_asset_num }}
</a>
</td>
<td
class=
"text-center"
>
{{ dept.comment }}
</td>
<td
class=
"text-center"
>
{{ dept.comment }}
</td>
<td
class=
"text-center"
>
<td
class=
"text-center"
>
{#
<a
title=
"[ {{ dept.name }} ] 成员信息"
href=
"../dept_detail/?id={{ dept.id }}"
class=
"iframe btn btn-xs btn-primary"
>
主机
</a>
#}
{#
<a
title=
"[ {{ dept.name }} ] 成员信息"
href=
"../dept_detail/?id={{ dept.id }}"
class=
"iframe btn btn-xs btn-primary"
>
主机
</a>
#}
...
...
templates/jperm/perm_list.html
View file @
7de943c6
...
@@ -60,9 +60,9 @@
...
@@ -60,9 +60,9 @@
<tr
class=
"gradeX"
>
<tr
class=
"gradeX"
>
<td
class=
"text-center"
>
{{ group.name }}
</td>
<td
class=
"text-center"
>
{{ group.name }}
</td>
<td
class=
"text-center"
>
{{ group.dept.name }}
</td>
<td
class=
"text-center"
>
{{ group.dept.name }}
</td>
<td
class=
"text-center"
><a
href=
"/juser/user_list/?gid={{ group.id }}"
>
{{ group.id | member_count }}
</a>
</td>
<td
class=
"text-center"
>
<a
href=
"/juser/user_list/?gid={{ group.id }}"
>
{{ group.id | member_count }}
</a>
</td>
<td
class=
"text-center"
>
{{ group.id | ugrp_perm_agrp_count }}
</td>
<td
class=
"text-center"
>
<a
href=
"/jasset/group_list/?gid={{ group.id }}"
>
{{ group.id | ugrp_perm_agrp_count }}
</a>
</td>
<td
class=
"text-center"
>
{{ group.id | ugrp_perm_asset_count }}
</td>
<td
class=
"text-center"
>
<a
href=
"/jasset/host_list/?gid={{ group.id }}"
>
{{ group.id | ugrp_perm_asset_count }}
</a>
</td>
<td
class=
"text-center"
>
{{ group.comment }}
</td>
<td
class=
"text-center"
>
{{ group.comment }}
</td>
<td
class=
"text-center"
>
<td
class=
"text-center"
>
<a
href=
"../perm_edit/?id={{ group.id }}"
class=
"btn btn-xs btn-danger"
>
授权编辑
</a>
<a
href=
"../perm_edit/?id={{ group.id }}"
class=
"btn btn-xs btn-danger"
>
授权编辑
</a>
...
...
templates/nav.html
View file @
7de943c6
...
@@ -28,8 +28,8 @@
...
@@ -28,8 +28,8 @@
<ul
class=
"nav nav-second-level"
>
<ul
class=
"nav nav-second-level"
>
<li
class=
"host_add host_add_multi"
><a
href=
"/jasset/host_add/"
>
添加资产
</a></li>
<li
class=
"host_add host_add_multi"
><a
href=
"/jasset/host_add/"
>
添加资产
</a></li>
<li
class=
"host_list"
><a
href=
"/jasset/host_list/"
>
查看资产
&
nbsp
&
nbsp
</span><span
class=
"label label-info pull-right"
>
{{ host_active_num }}/{{ host_total_num}}
</span></a></li>
<li
class=
"host_list"
><a
href=
"/jasset/host_list/"
>
查看资产
&
nbsp
&
nbsp
</span><span
class=
"label label-info pull-right"
>
{{ host_active_num }}/{{ host_total_num}}
</span></a></li>
<li
class=
"
jgroup_add"
><a
href=
"/jasset/j
group_add/"
>
添加主机组
</a></li>
<li
class=
"
group_add"
><a
href=
"/jasset/
group_add/"
>
添加主机组
</a></li>
<li
class=
"
jgroup_list group_detail"
><a
href=
"/jasset/j
group_list/"
>
查看主机组
</a></li>
<li
class=
"
group_list group_detail"
><a
href=
"/jasset/
group_list/"
>
查看主机组
</a></li>
<li
class=
"idc_add"
><a
href=
"/jasset/idc_add/"
>
添加IDC
</a></li>
<li
class=
"idc_add"
><a
href=
"/jasset/idc_add/"
>
添加IDC
</a></li>
<li
class=
"idc_list idc_detail"
><a
href=
"/jasset/idc_list/"
>
查看IDC
</a></li>
<li
class=
"idc_list idc_detail"
><a
href=
"/jasset/idc_list/"
>
查看IDC
</a></li>
</ul>
</ul>
...
@@ -98,8 +98,8 @@
...
@@ -98,8 +98,8 @@
<ul
class=
"nav nav-second-level"
>
<ul
class=
"nav nav-second-level"
>
<li
class=
"host_add host_add_multi"
><a
href=
"/jasset/host_add/"
>
添加资产
</a></li>
<li
class=
"host_add host_add_multi"
><a
href=
"/jasset/host_add/"
>
添加资产
</a></li>
<li
class=
"host_list"
><a
href=
"/jasset/host_list/"
>
查看资产
&
nbsp
&
nbsp
</span><span
class=
"label label-info pull-right"
>
{{ host_active_num }}/{{ host_total_num}}
</span></a></li>
<li
class=
"host_list"
><a
href=
"/jasset/host_list/"
>
查看资产
&
nbsp
&
nbsp
</span><span
class=
"label label-info pull-right"
>
{{ host_active_num }}/{{ host_total_num}}
</span></a></li>
<li
class=
"
jgroup_add"
><a
href=
"/jasset/j
group_add/"
>
添加主机组
</a></li>
<li
class=
"
group_add"
><a
href=
"/jasset/
group_add/"
>
添加主机组
</a></li>
<li
class=
"
jgroup_list group_detail"
><a
href=
"/jasset/j
group_list/"
>
查看主机组
</a></li>
<li
class=
"
group_list group_detail"
><a
href=
"/jasset/
group_list/"
>
查看主机组
</a></li>
<li
class=
"idc_list idc_detail"
><a
href=
"/jasset/idc_list/"
>
查看IDC
</a></li>
<li
class=
"idc_list idc_detail"
><a
href=
"/jasset/idc_list/"
>
查看IDC
</a></li>
</ul>
</ul>
</li>
</li>
...
...
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