merge with wangyong

pull/6/head
guanghongwei 2015-03-14 13:20:53 +08:00
commit d926cbdef2
21 changed files with 296 additions and 177 deletions

View File

@ -117,6 +117,7 @@ def log_record(username, host):
raise ServerError('Create logfile failed, Please modify %s permission.' % today_connect_log_dir)
log = Log(user=username, host=host, log_path=log_file_path, start_time=datetime.now(), pid=pid)
log_file.write('Starttime is %s\n' % datetime.now())
log.save()
return log_file, log
@ -159,6 +160,7 @@ def posix_shell(chan, username, host):
finally:
timestamp_end = time.time()
termios.tcsetattr(sys.stdin, termios.TCSADRAIN, old_tty)
log_file.write('Endtime is %s' % datetime.now())
log_file.close()
log.is_finished = True
log.log_finished = False

View File

@ -114,7 +114,7 @@ if __name__ == '__main__':
test_add_idc()
test_add_asset_group()
test_add_asset()
# test_add_log()
test_add_log()

View File

@ -11,6 +11,7 @@ urlpatterns = patterns('',
url(r"^(\d+.\d+.\d+.\d+)/$", jlist_ip),
url(r'^idc_add/$', add_idc),
url(r'^idc_list/$', list_idc),
url(r'^idc_edit/$', edit_idc),
url(r'^idc_detail/$', detail_idc),
url(r'^idc_del/(\w+)/$', del_idc),
url(r'^jgroup_add/$', add_group),

View File

@ -22,7 +22,8 @@ def index(request):
def f_add_host(ip, port, idc, jtype, group, active, comment, username='', password=''):
groups = []
idc = IDC.objects.get(name=idc)
if type == 'M':
if jtype == 'M':
print username, password
a = Asset(ip=ip, port=port,
login_type=jtype, idc=idc,
is_active=int(active),
@ -135,7 +136,15 @@ def batch_host_edit(request):
j_active = request.POST.get(j_active).strip()
j_comment = request.POST.get(j_comment).strip()
jasset_host_edit(j_id, j_ip, j_idc, j_port, j_type, j_group, j_active, j_comment)
if j_type == 'M':
j_user = "editable[" + str(i) + "][j_user]"
j_password = "editable[" + str(i) + "][j_password]"
j_user = request.POST.get(j_user).strip()
password = request.POST.get(j_password).strip()
j_password = cryptor.encrypt(password)
jasset_host_edit(j_id, j_ip, j_idc, j_port, j_type, j_group, j_active, j_comment, j_user, j_password)
else:
jasset_host_edit(j_id, j_ip, j_idc, j_port, j_type, j_group, j_active, j_comment)
return render_to_response('jasset/host_list.html')
@ -143,8 +152,15 @@ 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 = Asset.objects.all().order_by('ip')
contact_list, p, contacts, page_range, current_page, show_first, show_end = pages(posts, request)
keyword = request.GET.get('keyword', '')
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')
contact_list, p, contacts, page_range, current_page, show_first, show_end = pages(posts, request)
else:
posts = Asset.objects.all().order_by('ip')
contact_list, p, contacts, page_range, current_page, show_first, show_end = pages(posts, request)
return render_to_response('jasset/host_list.html', locals(), context_instance=RequestContext(request))
@ -192,8 +208,11 @@ def host_edit(request):
a = Asset.objects.get(id=int(offset))
if j_type == 'M':
if post.password == request.POST.get('j_password'):
j_password = post.password
else:
j_password = cryptor.encrypt(request.POST.get('j_password'))
j_user = request.POST.get('j_user')
j_password = cryptor.encrypt(request.POST.get('j_password'))
a.ip = j_ip
a.port = j_port
a.login_type = j_type
@ -245,11 +264,43 @@ def add_idc(request):
def list_idc(request):
header_title, path1, path2 = u'查看IDC', u'资产管理', u'查看IDC'
posts = IDC.objects.all().order_by('id')
keyword = request.GET.get('keyword', '')
if keyword:
posts = IDC.objects.filter(Q(name__contains=keyword) | Q(comment__contains=keyword))
else:
posts = IDC.objects.all().order_by('id')
contact_list, p, contacts, page_range, current_page, show_first, show_end = pages(posts, request)
return render_to_response('jasset/idc_list.html', locals(), context_instance=RequestContext(request))
def edit_idc(request):
header_title, path1, path2 = u'编辑IDC', u'资产管理', u'编辑IDC'
edit = 1
idc_id = request.GET.get('id')
j_idc = IDC.objects.get(id=idc_id)
default = IDC.objects.get(name='默认').asset_set.all()
eposts = contact_list = Asset.objects.filter(idc=j_idc).order_by('ip')
posts = [g for g in default if g not in eposts]
if request.method == 'POST':
j_group = request.POST.get('j_idc')
j_hosts = request.POST.getlist('j_hosts')
j_comment = request.POST.get('j_comment')
idc_default = request.POST.getlist('idc_default')
for host in j_hosts:
g = Asset.objects.get(id=host)
Asset.objects.filter(id=host).update(idc=j_idc)
for host in idc_default:
g = Asset.objects.get(id=host)
i = IDC.objects.get(name='默认')
Asset.objects.filter(id=host).update(idc=i)
return HttpResponseRedirect('/jasset/idc_detail/?id=%s' % idc_id)
return render_to_response('jasset/idc_add.html', locals(), context_instance=RequestContext(request))
def del_idc(request, offset):
if offset == 'multi':
len_list = request.POST.get("len_list")
@ -287,7 +338,11 @@ def add_group(request):
def list_group(request):
header_title, path1, path2 = u'查看主机组', u'资产管理', u'查看主机组'
posts = BisGroup.objects.filter(type='A').order_by('id')
keyword = request.GET.get('keyword', '')
if keyword:
posts = BisGroup.objects.filter(Q(name__contains=keyword) | Q(comment__contains=keyword))
else:
posts = BisGroup.objects.filter(type='A').order_by('id')
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))
@ -374,8 +429,6 @@ def group_del(request, offset):
return HttpResponseRedirect('/jasset/jgroup_list/')
def host_search(request):
keyword = request.GET.get('keyword')
login_types = {'L': 'LDAP', 'S': 'SSH_KEY', 'P': 'PASSWORD', 'M': 'MAP'}

View File

@ -18,18 +18,30 @@ CONF.read('%s/jumpserver.conf' % BASE_DIR)
def log_list_online(request):
header_title, path1, path2 = u'查看日志', u'查看日志', u'在线用户'
keyword = request.GET.get('keyword')
web_socket_host = CONF.get('websocket', 'web_socket_host')
posts = Log.objects.filter(is_finished=0).order_by('-start_time')
contact_list, p, contacts, page_range, current_page, show_first, show_end = pages(posts, request)
if keyword:
posts = contact_list = Log.objects.filter(Q(user__contains=keyword) | Q(host__contains=keyword)) \
.filter(is_finished=0).order_by('-start_time')
contact_list, p, contacts, page_range, current_page, show_first, show_end = pages(posts, request)
else:
posts = Log.objects.filter(is_finished=0).order_by('-start_time')
contact_list, p, contacts, page_range, current_page, show_first, show_end = pages(posts, request)
return render_to_response('jlog/log_online.html', locals())
def log_list_offline(request):
header_title, path1, path2 = u'查看日志', u'查看日志', u'历史记录'
keyword = request.GET.get('keyword')
web_socket_host = CONF.get('websocket', 'web_socket_host')
posts = Log.objects.filter(is_finished=1).order_by('-start_time')
contact_list, p, contacts, page_range, current_page, show_first, show_end = pages(posts, request)
if keyword:
posts = contact_list = Log.objects.filter(Q(user__contains=keyword) | Q(host__contains=keyword)) \
.filter(is_finished=1).order_by('-start_time')
contact_list, p, contacts, page_range, current_page, show_first, show_end = pages(posts, request)
else:
posts = Log.objects.filter(is_finished=1).order_by('-start_time')
contact_list, p, contacts, page_range, current_page, show_first, show_end = pages(posts, request)
return render_to_response('jlog/log_offline.html', locals())

View File

@ -1,8 +1,13 @@
#coding: utf-8
from django.http import HttpResponseRedirect
import json
from django.http import HttpResponse
from juser.models import User, UserGroup
from jasset.models import Asset, BisGroup
from jlog.models import Log
def user_perm_group_api(user):
@ -85,3 +90,10 @@ def is_group_admin(request):
return True
else:
return False
def api_user(request):
hosts = Log.objects.filter(is_finished=0).count()
users = Log.objects.filter(is_finished=0).values('user').distinct().count()
ret = {'users': users, 'hosts': hosts}
json_data = json.dumps(ret)
return HttpResponse(json_data)

View File

@ -6,7 +6,7 @@ urlpatterns = patterns('',
# url(r'^$', 'jumpserver.views.home', name='home'),
# url(r'^blog/', include('blog.urls')),
(r'^$', 'jumpserver.views.index'),
(r'^api/user/$', 'jumpserver.views.api_user'),
(r'^api/user/$', 'jumpserver.api.api_user'),
(r'^skin_config/$', 'jumpserver.views.skin_config'),
(r'^install/$', 'jumpserver.views.install'),
(r'^base/$', 'jumpserver.views.base'),

View File

@ -46,7 +46,7 @@ def getDaysByNum(num):
for i in range(0, num):
today = today-oneday
li_date.append(today)
li_str.append(str(today)[0:10])
li_str.append(str(today)[5:10])
li_date.reverse()
li_str.reverse()
t = (li_date, li_str)
@ -102,12 +102,6 @@ def index(request):
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):
return render_to_response('skin_config.html')
@ -131,7 +125,7 @@ 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):
def jasset_host_edit(j_id, j_ip, j_idc, j_port, j_type, j_group, j_active, j_comment, j_user='', j_password=''):
groups = []
is_active = {u'': '1', u'': '2'}
login_types = {'LDAP': 'L', 'SSH_KEY': 'S', 'PASSWORD': 'P', 'MAP': 'M'}

View File

@ -2,6 +2,7 @@
#coding: utf-8
import os
import re
import time
import psutil
from datetime import datetime
@ -15,14 +16,21 @@ from jlog.models import Log
def log_hanler(id):
log = Log.objects.get(id=id)
pattern = re.compile(r'\[.*@.*\][\$#].*')
if log:
filename = log.log_path
if os.path.isfile(filename):
ret1 = os.system('cat %s | grep "DateTime" > %s.his' % (filename, filename))
ret2 = os.system('cat %s | grep "\[.*@.*\][\$\#]" >> %s.his' % (filename, filename))
ret3 = os.system('cat %s | grep "EndTime" >> %s.his' % (filename, filename))
if (ret1 + ret2 + ret3) == 0:
print 'Handler %s ok.' % filename
f_his = filename + '.his'
f1 = open(filename)
f2 = open(f_his, 'a')
lines = f1.readlines()
for line in lines[7:]:
match = pattern.match(line)
if match:
newline = re.sub('\[[A-Z]', '', line)
f2.write(newline)
f1.close()
f2.close()
log.log_finished = True
log.save()

View File

@ -35,10 +35,10 @@
<div class="ibox float-e-margins">
<div class="ibox-title">
<span class="label label-primary pull-right">Today</span>
<h5>在线用户</h5>
<h5>实时在线用户</h5>
</div>
<div class="ibox-content">
<h1 class="no-margins"><a href="/jlog/log_list/online/">{{ online_user.count }}</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>
<small>Online user</small>
</div>
@ -52,18 +52,19 @@
<h5>已连接服务器</h5>
</div>
<div class="ibox-content">
<h1 class="no-margins"><a href="/jlog/log_list/online/">{{ online_host.count }}</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>
<small>Connect host</small>
</div>
</div>
</div>
<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 class="row">
<div class="col-lg-6" id="top10" style="width:50%;height:400px;"></div>
<div class="col-lg-6" id="usertop10" style="width:50%;height:400px;"></div>
</div>
<div class="row">
<div class="col-lg-6" id="hosttop10" style="width:50%;height:400px; margin-top: 20px"></div>
</div>
</div>
</div>
@ -71,8 +72,11 @@
var cate = {{ li_str|safe }};
$(function () {
$('#top10').highcharts({
chart: {
type: 'column'
},
title: {
text: '数据总览',
text: '一周数据总览',
x: -20 //center
},
subtitle: {
@ -101,12 +105,6 @@ $(function () {
tooltip: {
valueSuffix: '次'
},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'middle',
borderWidth: 0
},
navigation: {
buttonOptions: {
align: 'right'
@ -149,12 +147,6 @@ $(function () {
tooltip: {
valueSuffix: '次'
},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'middle',
borderWidth: 0
},
series: [
{% for k,v in user_dic.items %}
{
@ -192,12 +184,6 @@ $(function () {
tooltip: {
valueSuffix: '次'
},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'middle',
borderWidth: 0
},
series: [
{% for k,v in host_dic.items %}
{
@ -208,85 +194,27 @@ $(function () {
]
});
$(document).ready(function() {
Highcharts.setOptions({
global: {
useUTC: false
function magic_number(value, id) {
var num = $("#"+id);
num.animate({count: value}, {
duration: 500,
step: function() {
num.text(String(parseInt(this.count)));
}
});
};
var chart;
$('#dynamic').highcharts({
chart: {
type: 'spline',
animation: Highcharts.svg, // don't animate in old IE
marginRight: 10,
events: {
load: function () {
var series = this.series[0];
setInterval(function () {
jQuery.getJSON('api/user/', function (data) {
var users = data.users;
var x = (new Date()).getTime(), // current time
y = users;
console.log(users)
series.addPoint([x, y], true, true);
});
}, 3000);
}
}
},
title: {
text: '实时在线用户统计'
},
xAxis: {
type: 'datetime',
tickPixelInterval: 150
},
yAxis: {
min: 0,
title: {
text: '用户数量'
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
},
tooltip: {
formatter: function() {
return '<b>'+ this.series.name +'</b><br/>'+
Highcharts.dateFormat('%Y-%m-%d %H:%M:%S', this.x) +'<br/>'+
Highcharts.numberFormat(this.y);
}
},
legend: {
enabled: false
},
exporting: {
enabled: false
},
series: [{
name: '实时在线用户数量',
data: (function() {
// generate an array of random data
var data = [],
time = (new Date()).getTime(),
i;
for (i = -19; i <= 0; i++) {
data.push({
x: time + i * 1000,
y: 0
});
}
return data;
})()
}]
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')
});
});
};
setInterval(update, 5000); //5秒钟执行一次
update();
});
</script>

View File

@ -57,7 +57,7 @@
<td class="text-center" name="j_port"> {{ post.port }} </td>
<td class="text-center" name="j_type"> {{ login_types|get_item:post.login_type }} </td>
<td class="text-center" name="j_idc"> {{ post.idc.name }} </td>
<td class="text-center" name="j_group">{% for group in post.bis_group.all|filter_private %} {{ group }} {% endfor %}</td>
<td class="text-center" name="j_group">{{ post.bis_group.all | group_str2 }}</td>
<td class="text-center" name="j_active"> {{ post.is_active|bool2str }} </td>
<td class="text-center"> {{ post.date_added|date:"Y-m-d H:i:s" }} </td>
<td class="text-center" name="j_comment"> {{ post.comment }} </td>
@ -88,6 +88,9 @@
<a href="#">Previous</a>
</li>
{% endif %}
{% ifequal show_first 1 %}
<li class="paginate_button" aria-controls="editable" tabindex="0"><a href="?id={{ group_id }}&page=1" title="第1页">1...</a></li>
{% endifequal %}
{% 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>
@ -95,6 +98,9 @@
<li class="paginate_button" aria-controls="editable" tabindex="0"><a href="?id={{ group_id }}&page={{ page }}" title="第{{ page }}页">{{ page }}</a></li>
{% endifequal %}
{% endfor %}
{% ifequal show_end 1 %}
<li class="paginate_button" aria-controls="editable" tabindex="0"><a href="?id={{ group_id }}&page={{ p.num_pages }}" title="第{{ page }}页">...{{ p.num_pages }}</a></li>
{% endifequal %}
{% if contacts.has_next %}
<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>

View File

@ -9,6 +9,17 @@
<div class="ibox-content">
<div class="">
<a target="_blank" href="/jasset/jgroup_add" class="btn btn-sm btn-primary "> 添加主机组 </a>
<form id="search_form" method="get" action="" class="pull-right mail-search">
<div class="input-group">
<input type="text" class="form-control input-sm" id="search_input" name="keyword" placeholder="Search">
<input type="text" style="display: none">
<div class="input-group-btn">
<button id='search_btn' type="submit" class="btn btn-sm btn-primary">
Search
</button>
</div>
</div>
</form>
</div>
<form id="contents_form" name="contents_form">

View File

@ -56,15 +56,25 @@
{% endfor %}
</div>
<div name="a1" id=a1 style="display:none;">
{% ifequal post.login_type M %}
<div class="form-group"><label class="col-sm-2 col-sm-offset-1 control-label"> 普通用户名 </label>
<div class="col-sm-6"><input type="text" name="j_user" placeholder="lilei" class="form-control"></div>
<div class="col-sm-6"><input type="text" name="j_user" value="{{ post.username }}" class="form-control"></div>
</div>
<div class="form-group"><label class="col-sm-2 col-sm-offset-1 control-label"> 普通用户密码 </label>
<div class="col-sm-6"><input type="password" name="j_password" placeholder="Password" class="form-control"></div>
<div class="col-sm-6"><input type="password" name="j_password" value="{{ post.password }}" class="form-control"></div>
</div>
</div>
{% else %}
<div name="a1" id=a1 style="display:none;">
<div class="form-group"><label class="col-sm-2 col-sm-offset-1 control-label"> 普通用户名 </label>
<div class="col-sm-6"><input type="text" name="j_user" placeholder="lilei" class="form-control"></div>
</div>
<div class="form-group"><label class="col-sm-2 col-sm-offset-1 control-label"> 普通用户密码 </label>
<div class="col-sm-6"><input type="password" name="j_password" placeholder="Password" class="form-control"></div>
</div>
</div>
{% endifequal %}
</div>
<div class="hr-line-dashed"></div>
@ -177,19 +187,7 @@ $('#assetForm').validator({
msg: {required: "请填写用户名"}
},
"j_password": {
rule: "required(type_m);length[6~16]",
tip: "密码6-16位",
ok: "",
msg: {required: "6-16位"}
},
"j_root": {
rule: "required(type_m)",
tip: "超管用户名",
ok: "",
msg: {required: "请填写用户名"}
},
"j_passwd": {
rule: "required(type_m);length[6~16]",
rule: "required(type_m);length[6~100]",
tip: "密码6-16位",
ok: "",
msg: {required: "6-16位"}

View File

@ -68,7 +68,7 @@
<td class="text-center" name="j_port"> {{ post.port }} </td>
<td class="text-center" name="j_type"> {{ login_types|get_item:post.login_type }} </td>
<td class="text-center" name="j_idc"> {{ post.idc.name }} </td>
<td class="text-center" name="j_group">{{ post.bis_group.all | group_str2}}</td>
<td class="text-center" name="j_group">{{ post.bis_group.all | group_str2 }}</td>
<td class="text-center" name="j_active"> {{ post.is_active|bool2str }} </td>
<td class="text-center"> {{ post.date_added|date:"Y-m-d H:i:s" }} </td>
<td class="text-center" name="j_comment"> {{ post.comment }} </td>

View File

@ -22,7 +22,7 @@
<td class="text-center" name="j_port"> {{ post.port }} </td>
<td class="text-center" name="j_type"> {{ login_types|get_item:post.login_type }} </td>
<td class="text-center" name="j_idc"> {{ post.idc.name }} </td>
<td class="text-center" name="j_group">{% for group in post.bis_group.all|filter_private %} {{ group }} {% endfor %}</td>
<td class="text-center" name="j_group">{{ post.bis_group.all | group_str2 }}</td>
<td class="text-center" name="j_active"> {{ post.is_active|bool2str }} </td>
<td class="text-center"> {{ post.date_added|date:"Y-m-d H:i:s" }} </td>
<td class="text-center" name="j_comment"> {{ post.comment }} </td>
@ -40,7 +40,45 @@
<input type="button" id="del_button" class="btn btn-danger btn-sm" name="del_button" value="删除" onclick="del('contents_form')" />
<input type="button" id="alter_button" class="btn btn-warning btn-sm" name="alter_button" value="修改" onclick="alter('contents_form')" />
</div>
{% include 'paginator.html' %}
<div class="col-sm-6">
<div class="dataTables_paginate paging_simple_numbers" id="editable_paginate">
<ul class="pagination" style="margin-top: 0; float: right">
{% 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>
</li>
{% else %}
<li class="paginate_button previous disabled" aria-controls="editable" tabindex="0" id="editable_previous">
<a href="#">Previous</a>
</li>
{% endif %}
{% ifequal show_first 1 %}
<li class="paginate_button" aria-controls="editable" tabindex="0"><a href="?page=1" title="第1页">1...</a></li>
{% endifequal %}
{% 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 class="paginate_button" aria-controls="editable" tabindex="0"><a href="?keyword={{ keyword }}&page={{ page }}" title="第{{ page }}页">{{ page }}</a></li>
{% endifequal %}
{% endfor %}
{% ifequal show_end 1 %}
<li class="paginate_button" aria-controls="editable" tabindex="0"><a href="?page={{ p.num_pages }}" title="第{{ page }}页">...{{ p.num_pages }}</a></li>
{% endifequal %}
{% 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>
</li>
{% else %}
<li class="paginate_button next disabled" aria-controls="editable" tabindex="0" id="editable_next">
<a href="#">Next</a>
</li>
{% endif %}
</ul>
</div>
</div>
</div>
<script>

View File

@ -35,14 +35,43 @@
{% endif %}
<form id="assetForm" method="post" class="form-horizontal">
<div class="form-group"><label class="col-sm-2 control-label"> IDC名 </label>
<div class="col-sm-8"><input type="text" value="{{ j_ip }}" placeholder="北京联通" name="j_idc" class="form-control"></div>
<div class="col-sm-8"><input type="text" value="{{ j_idc.name }}" placeholder="北京联通" name="j_idc" class="form-control"></div>
</div>
<div class="hr-line-dashed"></div>
<div class="form-group"><label class="col-sm-2 control-label"> 备注 </label>
<div class="col-sm-8"><input type="text" value="{{ s_port }}" placeholder="核心联通机房" name="j_comment" class="form-control"></div>
<div class="col-sm-8"><input type="text" value="{{ j_idc.comment }}" placeholder="核心联通机房" name="j_comment" class="form-control"></div>
</div>
{% if edit %}
<div class="hr-line-dashed"></div>
<div class="form-group">
<label for="groups" class="col-lg-2 control-label">主机</label>
<div class="col-sm-3">
<select id="groups" name="idc_default" size="12" class="form-control m-b" multiple>
{% for post in posts %}
<option value="{{ post.id }}">{{ post.ip }}</option>
{% endfor %}
</select>
</div>
<div class="col-sm-1">
<div class="btn-group" style="margin-top: 50px;">
<button type="button" class="btn btn-white" onclick="move('groups', 'groups_selected')"><i class="fa fa-chevron-right"></i></button>
<button type="button" class="btn btn-white" onclick="move_left('groups_selected', 'groups')"><i class="fa fa-chevron-left"></i> </button>
</div>
</div>
<div class="col-sm-3">
<div>
<select id="groups_selected" name="j_hosts" class="form-control m-b" size="12" multiple>
{% for post in eposts %}
<option value="{{ post.id }}">{{ post.ip }}</option>
{% endfor %}
</select>
</div>
</div>
</div>
{% endif %}
<div class="hr-line-dashed"></div>
<div class="form-group">
<div class="col-sm-4 col-sm-offset-5">

View File

@ -57,7 +57,7 @@
<td class="text-center" name="j_port"> {{ post.port }} </td>
<td class="text-center" name="j_type"> {{ login_types|get_item:post.login_type }} </td>
<td class="text-center" name="j_idc"> {{ post.idc.name }} </td>
<td class="text-center" name="j_group">{% for group in post.bis_group.all|filter_private %} {{ group }} {% endfor %}</td>
<td class="text-center" name="j_group">{{ post.bis_group.all | group_str2 }}</td>
<td class="text-center" name="j_active"> {{ post.is_active|bool2str }} </td>
<td class="text-center"> {{ post.date_added|date:"Y-m-d H:i:s" }} </td>
<td class="text-center" name="j_comment"> {{ post.comment }} </td>

View File

@ -9,6 +9,17 @@
<div class="ibox-content">
<div class="">
<a target="_blank" href="/jasset/idc_add" class="btn btn-sm btn-primary "> 添加IDC </a>
<form id="search_form" method="get" action="" class="pull-right mail-search">
<div class="input-group">
<input type="text" class="form-control input-sm" id="search_input" name="keyword" placeholder="Search">
<input type="text" style="display: none">
<div class="input-group-btn">
<button id='search_btn' type="submit" class="btn btn-sm btn-primary">
Search
</button>
</div>
</div>
</form>
</div>
<form id="contents_form" name="contents_form">
@ -31,6 +42,7 @@
<td class="text-center"> {{ post.comment }} </td>
<td class="text-center">
<a href="/jasset/idc_detail/?id={{ post.id }}" class="iframe btn btn-xs btn-primary">详情</a>
<a href="/jasset/idc_edit/?id={{ post.id }}" class="btn btn-xs btn-info">编辑</a>
<a href="/jasset/idc_del/{{ post.id }}" class="btn btn-xs btn-danger">删除</a>
</td>
</tr>

View File

@ -97,8 +97,7 @@
</tbody>
</table>
<div class="row">
<div class="col-sm-6">
</div>
<div class="col-sm-6"></div>
{% include 'paginator.html' %}
</div>
</div>

View File

@ -23,25 +23,7 @@
</tbody>
</table>
<div class="row">
<div class="col-sm-6 col-sm-offset-6">
<div class="dataTables_paginate paging_simple_numbers" id="editable_paginate">
<ul class="pagination" style="margin-top: 0; float: right">
{% if contacts.has_previous %}
<li><a href="?page={{ contacts.previous_page_number }}">&laquo;</a></li>
{% endif %}
{% for page in p.page_range %}
{% ifequal offset1 page %}
<li class="active"><a href="?page={{ page }}" title="第{{ page }}页">{{ page }}</a></li>
{% else %}
<li><a href="?page={{ page }}" title="第{{ page }}页">{{ page }}</a></li>
{% endifequal %}
{% endfor %}
{% if contacts.has_next %}
<li><a href="?page={{ contacts.next_page_number }}">&raquo;</a></li>
{% endif %}
</ul>
</div>
<div class="col-sm-6 "></div>
{% include 'paginator.html' %}
</div>
</div>

View File

@ -1,7 +1,40 @@
<div class="col-sm-6">
<div class="dataTables_paginate paging_simple_numbers" id="editable_paginate">
<ul class="pagination" style="margin-top: 0; float: right">
{% if keyword %}
{% if contacts.has_previous %}
<li class="paginate_button previous" aria-controls="editable" tabindex="0" id="editable_previous">
<a href="?keyword={{ keyword }}&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 %}
{% ifequal show_first 1 %}
<li class="paginate_button" aria-controls="editable" tabindex="0"><a href="?keyword={{ keyword }}&ppage=1" title="第1页">1...</a></li>
{% endifequal %}
{% 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 class="paginate_button" aria-controls="editable" tabindex="0"><a href="?keyword={{ keyword }}&page={{ page }}" title="第{{ page }}页">{{ page }}</a></li>
{% endifequal %}
{% endfor %}
{% ifequal show_end 1 %}
<li class="paginate_button" aria-controls="editable" tabindex="0"><a href="?keyword={{ keyword }}&page={{ p.num_pages }}" title="第{{ page }}页">...{{ p.num_pages }}</a></li>
{% endifequal %}
{% if contacts.has_next %}
<li class="paginate_button next" aria-controls="editable" tabindex="0" id="editable_next">
<a href="?keyword={{ keyword }}&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 %}
{% else %}
{% 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>
@ -33,6 +66,7 @@
<a href="#">Next</a>
</li>
{% endif %}
{% endif %}
</ul>
</div>
</div>