jumpserver/templates/index.html

368 lines
13 KiB
HTML
Raw Normal View History

2015-02-11 09:53:17 +00:00
{% extends 'base.html' %}
2015-04-05 14:52:37 +00:00
{% load mytags %}
{% load humanize %}
2015-02-11 09:53:17 +00:00
{% block content %}
{% include 'nav_cat_bar.html' %}
<div class="wrapper wrapper-content">
<div class="row">
<div class="col-lg-3">
<div class="ibox float-e-margins">
<div class="ibox-title">
2015-03-21 04:58:29 +00:00
<span class="label label-success pull-right">Users</span>
2015-02-11 09:53:17 +00:00
<h5>用户总数</h5>
</div>
<div class="ibox-content">
2015-02-12 10:54:40 +00:00
<h1 class="no-margins"><a href="/juser/user_list/">{{ users.count}}</a></h1>
2015-04-05 14:52:37 +00:00
<div class="stat-percent font-bold text-success">{{ percent_user }} <i class="fa fa-bolt"></i></div>
2015-02-11 09:53:17 +00:00
<small>All user</small>
</div>
</div>
</div>
<div class="col-lg-3">
<div class="ibox float-e-margins">
<div class="ibox-title">
2015-03-21 04:58:29 +00:00
<span class="label label-info pull-right">Hosts</span>
2015-02-11 09:53:17 +00:00
<h5>主机总数</h5>
</div>
<div class="ibox-content">
2015-02-12 10:54:40 +00:00
<h1 class="no-margins"><a href="/jasset/host_list/">{{ hosts.count }}</a></h1>
2015-04-05 14:52:37 +00:00
<div class="stat-percent font-bold text-info">{{ percent_host }} <i class="fa fa-level-up"></i></div>
2015-02-11 09:53:17 +00:00
<small>All host</small>
</div>
</div>
</div>
<div class="col-lg-3">
<div class="ibox float-e-margins">
<div class="ibox-title">
2015-03-21 04:58:29 +00:00
<span class="label label-primary pull-right">Online</span>
2015-03-10 10:27:47 +00:00
<h5>实时在线用户</h5>
2015-02-11 09:53:17 +00:00
</div>
<div class="ibox-content">
2015-03-10 10:27:47 +00:00
<h1 class="no-margins"><a href="/jlog/log_list/online/"> <span id="online_users"></span></a></h1>
2015-04-05 14:52:37 +00:00
<div class="stat-percent font-bold text-navy">{{ percent_online_user }} <i class="fa fa-level-up"></i></div>
2015-02-11 09:53:17 +00:00
<small>Online user</small>
</div>
</div>
</div>
<div class="col-lg-3">
<div class="ibox float-e-margins">
<div class="ibox-title">
2015-03-21 04:58:29 +00:00
<span class="label label-danger pull-right">Connected</span>
2015-02-11 09:53:17 +00:00
<h5>已连接服务器</h5>
</div>
<div class="ibox-content">
2015-03-10 10:27:47 +00:00
<h1 class="no-margins"><a href="/jlog/log_list/online/"> <span id="online_hosts"></span></a></h1>
2015-04-05 14:52:37 +00:00
<div class="stat-percent font-bold text-danger">{{ percent_online_host }} <i class="fa fa-level-down"></i></div>
2015-03-21 04:58:29 +00:00
<small>Connected host</small>
2015-02-11 09:53:17 +00:00
</div>
</div>
</div>
2015-04-05 14:52:37 +00:00
</div>
<div class="row">
<div class="col-lg-3 border-bottom white-bg dashboard-header" style="margin-left:15px;">
<h2>活跃用户TOP5</h2>
<small>过去一周共有<span class="text-info">{{ week_users }}</span>位用户登录<span class="text-success">{{ week_hosts }}</span>次服务器.</small>
<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>
2015-03-12 03:03:53 +00:00
</div>
2015-04-05 14:52:37 +00:00
<div class="col-lg-9" id="top10" style="margin-left: -15px;height: 345px"></div>
2015-02-11 09:53:17 +00:00
</div>
2015-04-05 14:52:37 +00:00
<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>-->
2015-02-11 09:53:17 +00:00
</div>
2015-02-12 10:54:40 +00:00
<script>
2015-02-27 15:18:40 +00:00
var cate = {{ li_str|safe }};
2015-02-12 10:54:40 +00:00
$(function () {
2015-03-05 10:46:12 +00:00
$('#top10').highcharts({
2015-04-05 14:52:37 +00:00
// chart: {
// type: 'column'
// },
2015-03-05 10:46:12 +00:00
title: {
2015-03-12 03:03:53 +00:00
text: '一周数据总览',
2015-03-05 10:46:12 +00:00
x: -20 //center
},
subtitle: {
text: 'Source: JumpServer',
x: -20
},
rangeSelector: {
allButtonsEnabled: true,
selected: 2
},
xAxis: {
type: 'datetime',
categories: cate
},
yAxis:{
min: 0,
title: {
2015-04-05 14:52:37 +00:00
text: ''
2015-03-05 10:46:12 +00:00
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
},
tooltip: {
valueSuffix: '次'
},
2015-03-07 07:29:49 +00:00
navigation: {
buttonOptions: {
align: 'right'
}
},
2015-03-05 10:46:12 +00:00
series: [
{% for k,v in top_dic.items %}
{
name: '{{ k }}',
data: {{ v }}
},
{% endfor %}
]
});
2015-03-04 15:14:07 +00:00
$('#usertop10').highcharts({
2015-02-12 10:54:40 +00:00
title: {
text: '一周用户登录TOP10',
x: -20 //center
},
subtitle: {
text: 'Source: JumpServer',
x: -20
},
xAxis: {
2015-02-27 10:48:24 +00:00
type: 'datetime',
categories: cate
2015-02-12 10:54:40 +00:00
},
2015-02-27 15:18:40 +00:00
yAxis:{
min: 0,
2015-02-12 10:54:40 +00:00
title: {
2015-02-26 10:02:39 +00:00
text: '登录次数'
2015-02-12 10:54:40 +00:00
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
},
tooltip: {
valueSuffix: '次'
},
2015-02-26 10:02:39 +00:00
series: [
2015-03-04 15:14:07 +00:00
{% for k,v in user_dic.items %}
2015-03-01 04:09:33 +00:00
{
name: '{{ k }}',
data: {{ v }}
},
2015-02-26 10:02:39 +00:00
{% endfor %}
]
2015-02-12 10:54:40 +00:00
});
2015-02-27 15:18:40 +00:00
2015-03-04 15:14:07 +00:00
$('#hosttop10').highcharts({
title: {
text: '一周主机登录TOP10',
x: -20 //center
},
subtitle: {
text: 'Source: JumpServer',
x: -20
},
xAxis: {
type: 'datetime',
categories: cate
},
yAxis:{
min: 0,
title: {
text: '登录次数'
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
},
tooltip: {
valueSuffix: '次'
},
series: [
{% for k,v in host_dic.items %}
{
name: '{{ k }}',
data: {{ v }}
},
{% endfor %}
]
});
2015-03-10 10:27:47 +00:00
function magic_number(value, id) {
var num = $("#"+id);
num.animate({count: value}, {
duration: 500,
step: function() {
num.text(String(parseInt(this.count)));
2015-02-27 15:18:40 +00:00
}
});
2015-03-10 10:27:47 +00:00
};
2015-02-27 15:18:40 +00:00
2015-03-10 10:27:47 +00:00
function update() {
$.getJSON('api/user/', function(data) {
var users = data.users;
var hosts = data.hosts;
magic_number(users, 'online_users');
magic_number(hosts, 'online_hosts')
2015-02-27 15:18:40 +00:00
});
2015-03-10 10:27:47 +00:00
};
2015-03-12 03:03:53 +00:00
setInterval(update, 5000); //5秒钟执行一次
2015-03-10 10:27:47 +00:00
update();
2015-02-27 15:18:40 +00:00
2015-02-12 10:54:40 +00:00
});
</script>
2015-02-11 09:53:17 +00:00
{% endblock %}