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
adc3703f
Commit
adc3703f
authored
Nov 09, 2015
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加绘图
parent
f31bea2c
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
60 additions
and
51 deletions
+60
-51
views.py
jumpserver/views.py
+35
-7
foot_script.html
templates/foot_script.html
+1
-9
index.html
templates/index.html
+0
-0
test2.html
templates/test2.html
+24
-35
No files found.
jumpserver/views.py
View file @
adc3703f
...
@@ -20,17 +20,20 @@ from jlog.models import Log
...
@@ -20,17 +20,20 @@ from jlog.models import Log
def
getDaysByNum
(
num
):
def
getDaysByNum
(
num
):
"""
输出格式:([datetime.date(2015, 11, 6), datetime.date(2015, 11, 8)], ['11-06', '11-08'])
"""
today
=
datetime
.
date
.
today
()
today
=
datetime
.
date
.
today
()
oneday
=
datetime
.
timedelta
(
days
=
1
)
oneday
=
datetime
.
timedelta
(
days
=
1
)
li_date
,
li
_str
=
[],
[]
date_li
,
date
_str
=
[],
[]
for
i
in
range
(
0
,
num
):
for
i
in
range
(
0
,
num
):
today
=
today
-
oneday
today
=
today
-
oneday
li_date
.
append
(
today
)
date_li
.
append
(
today
)
li_str
.
append
(
str
(
today
)[
5
:
10
])
date_str
.
append
(
str
(
today
)[
5
:
10
])
li_date
.
reverse
()
date_li
.
reverse
()
li_str
.
reverse
()
date_str
.
reverse
()
t
=
(
li_date
,
li_str
)
return
date_li
,
date_str
return
t
def
get_data
(
data
,
items
,
option
):
def
get_data
(
data
,
items
,
option
):
...
@@ -51,6 +54,24 @@ def get_data(data, items, option):
...
@@ -51,6 +54,24 @@ def get_data(data, items, option):
return
dic
return
dic
def
get_count_by_day
(
date_li
,
item
):
data_li
=
[]
for
d
in
date_li
:
logs
=
Log
.
objects
.
filter
(
start_time__year
=
d
.
year
,
start_time__month
=
d
.
month
,
start_time__day
=
d
.
day
)
if
item
==
'user'
:
count
=
len
(
set
([
log
.
user
for
log
in
logs
]))
elif
item
==
'asset'
:
count
=
len
(
set
([
log
.
host
for
log
in
logs
]))
elif
item
==
'login'
:
count
=
len
(
logs
)
else
:
count
=
0
data_li
.
append
(
count
)
return
data_li
@require_role
(
role
=
'user'
)
@require_role
(
role
=
'user'
)
def
index_cu
(
request
):
def
index_cu
(
request
):
user_id
=
request
.
user
.
id
user_id
=
request
.
user
.
id
...
@@ -90,6 +111,13 @@ def index(request):
...
@@ -90,6 +111,13 @@ def index(request):
active_hosts
=
Asset
.
objects
.
filter
(
is_active
=
1
)
active_hosts
=
Asset
.
objects
.
filter
(
is_active
=
1
)
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
()])
date_li
,
date_str
=
getDaysByNum
(
30
)
date_month
=
repr
(
date_str
)
print
date_month
active_user_month
=
str
(
get_count_by_day
(
date_li
,
'user'
))
active_asset_month
=
str
(
get_count_by_day
(
date_li
,
'asset'
))
active_login_month
=
str
(
get_count_by_day
(
date_li
,
'login'
))
elif
is_role_request
(
request
,
'admin'
):
elif
is_role_request
(
request
,
'admin'
):
return
index_cu
(
request
)
return
index_cu
(
request
)
# user = get_session_user_info(request)[2]
# user = get_session_user_info(request)[2]
...
...
templates/foot_script.html
View file @
adc3703f
...
@@ -23,15 +23,7 @@
...
@@ -23,15 +23,7 @@
<!-- highcharts -->
<!-- highcharts -->
<script
src=
"/static/js/highcharts/highcharts.js"
></script>
<script
src=
"/static/js/highcharts/highcharts.js"
></script>
<script
type=
"text/javascript"
>
require
.
config
({
paths
:
{
echarts
:
'/static/js/echarts/chart'
}
});
</script>
<!-- echarts -->
<script
src=
"/static/js/echarts/echarts.js"
></script>
<script
src=
"/static/js/dropzone/dropzone.js"
></script>
<script
src=
"/static/js/dropzone/dropzone.js"
></script>
<!-- active menu -->
<!-- active menu -->
...
...
templates/index.html
View file @
adc3703f
This diff is collapsed.
Click to expand it.
templates/test2.html
View file @
adc3703f
...
@@ -6,33 +6,34 @@
...
@@ -6,33 +6,34 @@
<script
type=
"text/javascript"
>
<script
type=
"text/javascript"
>
require
.
config
({
require
.
config
({
paths
:
{
paths
:
{
{
#
'echarts'
:
'/static/js/echarts/chart'
,
#
}
'echarts'
:
'/static/js/echarts/chart'
,
'line'
:
'/static/js/echarts/chart/line'
'
echarts/chart/
line'
:
'/static/js/echarts/chart/line'
}
}
});
});
require
(
require
(
[
[
'line'
,
'echarts'
,
'echarts/chart/line'
],
],
function
(
ec
)
{
function
(
ec
)
{
var
myChart
=
ec
.
init
(
document
.
getElementById
(
'main'
));
var
myChart
=
ec
.
init
(
document
.
getElementById
(
'main'
));
var
option
=
{
var
option
=
{
title
:
{
title
:
{
text
:
'
未来一周气温变化
'
,
text
:
'
某楼盘销售情况
'
,
subtext
:
'纯属虚构'
subtext
:
'纯属虚构'
},
},
tooltip
:
{
tooltip
:
{
trigger
:
'axis'
trigger
:
'axis'
},
},
legend
:
{
legend
:
{
data
:[
'
最高气温'
,
'最低气温
'
]
data
:[
'
意向'
,
'预购'
,
'成交
'
]
},
},
toolbox
:
{
toolbox
:
{
show
:
true
,
show
:
true
,
feature
:
{
feature
:
{
mark
:
{
show
:
true
},
mark
:
{
show
:
true
},
dataView
:
{
show
:
true
,
readOnly
:
false
},
dataView
:
{
show
:
true
,
readOnly
:
false
},
magicType
:
{
show
:
true
,
type
:
[
'line'
,
'bar'
]},
magicType
:
{
show
:
true
,
type
:
[
'line'
,
'bar'
,
'stack'
,
'tiled'
]},
restore
:
{
show
:
true
},
restore
:
{
show
:
true
},
saveAsImage
:
{
show
:
true
}
saveAsImage
:
{
show
:
true
}
}
}
...
@@ -47,47 +48,35 @@
...
@@ -47,47 +48,35 @@
],
],
yAxis
:
[
yAxis
:
[
{
{
type
:
'value'
,
type
:
'value'
axisLabel
:
{
formatter
:
'{value} °C'
}
}
}
],
],
series
:
[
series
:
[
{
{
name
:
'
最高气温
'
,
name
:
'
成交
'
,
type
:
'line'
,
type
:
'line'
,
data
:[
11
,
11
,
15
,
13
,
12
,
13
,
10
],
smooth
:
true
,
markPoint
:
{
itemStyle
:
{
normal
:
{
areaStyle
:
{
type
:
'default'
}}},
data
:
[
data
:[
10
,
12
,
21
,
54
,
260
,
830
,
710
]
{
type
:
'max'
,
name
:
'最大值'
},
{
type
:
'min'
,
name
:
'最小值'
}
]
},
markLine
:
{
data
:
[
{
type
:
'average'
,
name
:
'平均值'
}
]
}
},
},
{
{
name
:
'
最低气温
'
,
name
:
'
预购
'
,
type
:
'line'
,
type
:
'line'
,
data
:[
1
,
-
2
,
2
,
5
,
3
,
2
,
0
],
smooth
:
true
,
markPoint
:
{
itemStyle
:
{
normal
:
{
areaStyle
:
{
type
:
'default'
}}},
data
:
[
data
:[
30
,
182
,
434
,
791
,
390
,
30
,
10
]
{
name
:
'周最低'
,
value
:
-
2
,
xAxis
:
1
,
yAxis
:
-
1.5
}
},
]
{
},
name
:
'意向'
,
markLine
:
{
type
:
'line'
,
data
:
[
smooth
:
true
,
{
type
:
'average'
,
name
:
'平均值'
}
itemStyle
:
{
normal
:
{
areaStyle
:
{
type
:
'default'
}}},
]
data
:[
1320
,
1132
,
601
,
234
,
120
,
90
,
20
]
}
}
}
]
]
};
};
myChart
.
setOption
(
option
);
myChart
.
setOption
(
option
);
}
}
);
);
...
...
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