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
3c70512d
Commit
3c70512d
authored
Mar 01, 2015
by
halcyon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard
parent
cf8af114
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
24 deletions
+31
-24
urls.py
jumpserver/urls.py
+1
-0
views.py
jumpserver/views.py
+9
-8
index.html
templates/index.html
+21
-16
No files found.
jumpserver/urls.py
View file @
3c70512d
...
@@ -6,6 +6,7 @@ urlpatterns = patterns('',
...
@@ -6,6 +6,7 @@ urlpatterns = patterns('',
# url(r'^$', 'jumpserver.views.home', name='home'),
# url(r'^$', 'jumpserver.views.home', name='home'),
# url(r'^blog/', include('blog.urls')),
# url(r'^blog/', include('blog.urls')),
(
r'^$'
,
'jumpserver.views.index'
),
(
r'^$'
,
'jumpserver.views.index'
),
(
r'^api/user/$'
,
'jumpserver.views.api_user'
),
(
r'^skin_config/$'
,
'jumpserver.views.skin_config'
),
(
r'^skin_config/$'
,
'jumpserver.views.skin_config'
),
(
r'^base/$'
,
'jumpserver.views.base'
),
(
r'^base/$'
,
'jumpserver.views.base'
),
(
r'^login/$'
,
'jumpserver.views.login'
),
(
r'^login/$'
,
'jumpserver.views.login'
),
...
...
jumpserver/views.py
View file @
3c70512d
...
@@ -6,7 +6,9 @@ import json
...
@@ -6,7 +6,9 @@ import json
from
django.db.models
import
Count
from
django.db.models
import
Count
from
django.shortcuts
import
render_to_response
from
django.shortcuts
import
render_to_response
from
django.http
import
HttpResponse
from
django.http
import
HttpResponseRedirect
from
django.http
import
HttpResponseRedirect
from
django.template
import
RequestContext
from
django.core.paginator
import
Paginator
,
EmptyPage
,
InvalidPage
from
django.core.paginator
import
Paginator
,
EmptyPage
,
InvalidPage
from
juser.models
import
User
from
juser.models
import
User
...
@@ -36,8 +38,6 @@ def index(request):
...
@@ -36,8 +38,6 @@ def index(request):
path1
,
path2
=
u'仪表盘'
,
'Dashboard'
path1
,
path2
=
u'仪表盘'
,
'Dashboard'
dic
=
{}
dic
=
{}
li_date
,
li_str
=
getDaysByNum
(
7
)
li_date
,
li_str
=
getDaysByNum
(
7
)
# li_str = json.dumps(li_str)
# print li_str, type(li_str)
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
)
week_data
=
Log
.
objects
.
filter
(
start_time__range
=
[
from_week
,
datetime
.
datetime
.
now
()])
week_data
=
Log
.
objects
.
filter
(
start_time__range
=
[
from_week
,
datetime
.
datetime
.
now
()])
...
@@ -51,12 +51,17 @@ def index(request):
...
@@ -51,12 +51,17 @@ def index(request):
times
=
user_data
.
filter
(
start_time__year
=
year
,
start_time__month
=
month
,
start_time__day
=
day
)
.
count
()
times
=
user_data
.
filter
(
start_time__year
=
year
,
start_time__month
=
month
,
start_time__day
=
day
)
.
count
()
li
.
append
(
times
)
li
.
append
(
times
)
dic
[
username
]
=
li
dic
[
username
]
=
li
print
dic
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_host
=
Log
.
objects
.
filter
(
is_finished
=
0
)
online_user
=
online_host
.
distinct
()
online_user
=
online_host
.
distinct
()
return
render_to_response
(
'index.html'
,
locals
())
return
render_to_response
(
'index.html'
,
locals
(),
context_instance
=
RequestContext
(
request
))
def
api_user
(
request
):
users
=
Log
.
objects
.
filter
(
is_finished
=
0
)
.
count
()
ret
=
{
'users'
:
users
}
return
HttpResponse
(
json
.
dumps
(
ret
))
def
skin_config
(
request
):
def
skin_config
(
request
):
...
@@ -76,14 +81,10 @@ def jasset_host_edit(j_id, j_ip, j_idc, j_port, j_type, j_group, j_active, j_com
...
@@ -76,14 +81,10 @@ def jasset_host_edit(j_id, j_ip, j_idc, j_port, j_type, j_group, j_active, j_com
is_active
=
{
u'是'
:
'1'
,
u'否'
:
'2'
}
is_active
=
{
u'是'
:
'1'
,
u'否'
:
'2'
}
login_types
=
{
'LDAP'
:
'L'
,
'SSH_KEY'
:
'S'
,
'PASSWORD'
:
'P'
,
'MAP'
:
'M'
}
login_types
=
{
'LDAP'
:
'L'
,
'SSH_KEY'
:
'S'
,
'PASSWORD'
:
'P'
,
'MAP'
:
'M'
}
for
group
in
j_group
[
0
]
.
split
():
for
group
in
j_group
[
0
]
.
split
():
print
group
.
strip
()
c
=
BisGroup
.
objects
.
get
(
name
=
group
.
strip
())
c
=
BisGroup
.
objects
.
get
(
name
=
group
.
strip
())
groups
.
append
(
c
)
groups
.
append
(
c
)
j_type
=
login_types
[
j_type
]
j_type
=
login_types
[
j_type
]
print
j_type
j_idc
=
IDC
.
objects
.
get
(
name
=
j_idc
)
j_idc
=
IDC
.
objects
.
get
(
name
=
j_idc
)
print
j_idc
print
a
=
Asset
.
objects
.
get
(
id
=
j_id
)
a
=
Asset
.
objects
.
get
(
id
=
j_id
)
if
j_type
==
'M'
:
if
j_type
==
'M'
:
a
.
ip
=
j_ip
a
.
ip
=
j_ip
...
...
templates/index.html
View file @
3c70512d
...
@@ -60,7 +60,7 @@
...
@@ -60,7 +60,7 @@
</div>
</div>
<div
id=
"high"
style=
"width:100%;height:400px;"
></div>
<div
id=
"high"
style=
"width:100%;height:400px;"
></div>
</br>
</br>
<div
id=
"dynamic"
style=
"width:100%;height:400px;"
></div>
<div
id=
"dynamic"
style=
"width:100%;height:400px;
margin-top:170px
"
></div>
</div>
</div>
</div>
</div>
...
@@ -102,8 +102,10 @@ $(function () {
...
@@ -102,8 +102,10 @@ $(function () {
},
},
series
:
[
series
:
[
{
%
for
k
,
v
in
dic
.
items
%
}
{
%
for
k
,
v
in
dic
.
items
%
}
{
name
:
'{{ k }}'
,
{
data
:
{{
v
}}},
name
:
'{{ k }}'
,
data
:
{{
v
}}
},
{
%
endfor
%
}
{
%
endfor
%
}
]
]
});
});
...
@@ -122,28 +124,31 @@ $(function () {
...
@@ -122,28 +124,31 @@ $(function () {
animation
:
Highcharts
.
svg
,
// don't animate in old IE
animation
:
Highcharts
.
svg
,
// don't animate in old IE
marginRight
:
10
,
marginRight
:
10
,
events
:
{
events
:
{
load
:
function
()
{
load
:
function
()
{
// set up the updating of the chart each second
var
series
=
this
.
series
[
0
];
var
series
=
this
.
series
[
0
];
setInterval
(
function
()
{
setInterval
(
function
()
{
var
x
=
(
new
Date
()).
getTime
(),
// current time
jQuery
.
getJSON
(
'api/user/'
,
function
(
data
)
{
y
=
Math
.
random
();
var
users
=
data
.
users
;
series
.
addPoint
([
x
,
y
],
true
,
true
);
var
x
=
(
new
Date
()).
getTime
(),
// current time
},
1000
);
y
=
users
;
console
.
log
(
users
)
series
.
addPoint
([
x
,
y
],
true
,
true
);
});
},
3000
);
}
}
}
}
},
},
title
:
{
title
:
{
text
:
'
Live random data
'
text
:
'
实时在线用户统计
'
},
},
xAxis
:
{
xAxis
:
{
type
:
'datetime'
,
type
:
'datetime'
,
tickPixelInterval
:
150
tickPixelInterval
:
150
},
},
yAxis
:
{
yAxis
:
{
min
:
0
,
title
:
{
title
:
{
text
:
'
Value
'
text
:
'
用户数量
'
},
},
plotLines
:
[{
plotLines
:
[{
value
:
0
,
value
:
0
,
...
@@ -155,7 +160,7 @@ $(function () {
...
@@ -155,7 +160,7 @@ $(function () {
formatter
:
function
()
{
formatter
:
function
()
{
return
'<b>'
+
this
.
series
.
name
+
'</b><br/>'
+
return
'<b>'
+
this
.
series
.
name
+
'</b><br/>'
+
Highcharts
.
dateFormat
(
'%Y-%m-%d %H:%M:%S'
,
this
.
x
)
+
'<br/>'
+
Highcharts
.
dateFormat
(
'%Y-%m-%d %H:%M:%S'
,
this
.
x
)
+
'<br/>'
+
Highcharts
.
numberFormat
(
this
.
y
,
2
);
Highcharts
.
numberFormat
(
this
.
y
);
}
}
},
},
legend
:
{
legend
:
{
...
@@ -165,7 +170,7 @@ $(function () {
...
@@ -165,7 +170,7 @@ $(function () {
enabled
:
false
enabled
:
false
},
},
series
:
[{
series
:
[{
name
:
'
Random data
'
,
name
:
'
实时在线用户数量
'
,
data
:
(
function
()
{
data
:
(
function
()
{
// generate an array of random data
// generate an array of random data
var
data
=
[],
var
data
=
[],
...
@@ -175,7 +180,7 @@ $(function () {
...
@@ -175,7 +180,7 @@ $(function () {
for
(
i
=
-
19
;
i
<=
0
;
i
++
)
{
for
(
i
=
-
19
;
i
<=
0
;
i
++
)
{
data
.
push
({
data
.
push
({
x
:
time
+
i
*
1000
,
x
:
time
+
i
*
1000
,
y
:
Math
.
random
()
y
:
0
});
});
}
}
return
data
;
return
data
;
...
...
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