资产管理页面基本完成,尚有部分小bug

pull/6/head
halcyon 10 years ago
parent 1925cf4033
commit 7863a6853c

@ -4,11 +4,16 @@ from jasset.views import *
urlpatterns = patterns('',
url(r'^$', index),
url(r'host_add/$', jadd_host),
url(r'host_list/$', jlist_host),
url(r"(\d+.\d+.\d+.\d+)/$",jlist_ip),
url(r'idc_add/$', jadd_idc),
url(r'idc_list/$', jlist_idc),
url(r'group_add/$', jadd_group),
url(r'group_list/$', jlist_group),
url(r'^host_add/$', jadd_host),
url(r'^host_list/$', jlist_host),
url(r"^(\d+.\d+.\d+.\d+)/$",jlist_ip),
url(r'^idc_add/$', jadd_idc),
url(r'^idc_list/$', jlist_idc),
url(r'^idc_del/(\d+)/$', idc_del),
url(r'^group_add/$', jadd_group),
url(r'^group_list/$', jlist_group),
url(r'^group_del/(\d+)/$', group_del),
url(r'^host_del/(\d+.\d+.\d+.\d+)/$', host_del),
url(r'^host_edit/(\d+.\d+.\d+.\d+)/$', host_edit),
url(r'^test/$', test),
)

@ -1,26 +1,25 @@
# coding:utf-8
from django.http import HttpResponseRedirect
from django.template import RequestContext
from django.shortcuts import render_to_response
from django.core.paginator import Paginator, EmptyPage
from models import IDC, Asset, BisGroup
from models import IDC, Asset, UserGroup
from connect import PyCrypt, KEY
cryptor = PyCrypt(KEY)
def index(request):
return render_to_response('jasset/jasset.html', )
def jadd_host(request):
header_title, path1, path2 = '添加主机 | Add Host', '资产管理', '添加主机'
login_types = {'L': 'LDAP', 'S': 'SSH_KEY', 'P': 'PASSWORD', 'M': 'MAP'}
header_title, path1, path2 = u'添加主机 | Add Host', u'资产管理', u'添加主机'
groups = []
cryptor = PyCrypt(KEY)
eidc = IDC.objects.all()
egroup = BisGroup.objects.all()
egroup = UserGroup.objects.all()
is_actived = {'active': 1, 'no_active': 0}
login_typed = {'LDAP': 'L', 'SSH_KEY': 'S', 'PASSWORD': 'P', 'MAP': 'M'}
if request.method == 'POST':
j_ip = request.POST.get('j_ip')
@ -30,26 +29,23 @@ def jadd_host(request):
j_group = request.POST.getlist('j_group')
j_active = request.POST.get('j_active')
j_comment = request.POST.get('j_comment')
j_idc = IDC.objects.get(name=j_idc)
for group in j_group:
c = BisGroup.objects.get(name=group)
c = UserGroup.objects.get(name=group)
groups.append(c)
if Asset.objects.filter(ip=str(j_ip)):
emg = u'该IP已存在!'
return render_to_response('jasset/jadd.html', locals(), context_instance=RequestContext(request))
return render_to_response('jasset/host_add.html', locals(), context_instance=RequestContext(request))
if j_type == 'MAP':
if j_type == 'M':
j_user = request.POST.get('j_user')
j_password = cryptor.encrypt(request.POST.get('j_password'))
j_root = request.POST.get('j_root')
j_passwd = cryptor.encrypt(request.POST.get('j_passwd'))
a = Asset(ip=j_ip,
port=j_port,
login_type=j_type,
idc=j_idc,
a = Asset(ip=j_ip, port=j_port,
login_type=j_type, idc=j_idc,
is_active=int(j_active),
comment=j_comment,
username_common=j_user,
@ -57,21 +53,21 @@ def jadd_host(request):
username_super=j_root,
password_super=j_passwd,)
else:
a = Asset(ip=j_ip,
port=j_port,
login_type=j_type,
idc=j_idc,
a = Asset(ip=j_ip, port=j_port,
login_type=j_type, idc=j_idc,
is_active=int(j_active),
comment=j_comment)
a.save()
print 'ok'
a.bis_group = groups
a.save()
return render_to_response('jasset/jadd.html', locals(), context_instance=RequestContext(request))
smg = u'主机 %s 添加成功' %j_ip
return render_to_response('jasset/host_add.html', locals(), context_instance=RequestContext(request))
def jlist_host(request):
header_title, path1, path2 = '查看主机 | List Host', '资产管理', '查看主机'
header_title, path1, path2 = u'查看主机 | List Host', u'资产管理', u'查看主机'
login_types = {'L': 'LDAP', 'S': 'SSH_KEY', 'P': 'PASSWORD', 'M': 'MAP'}
posts = contact_list = Asset.objects.all().order_by('ip')
print posts
p = paginator = Paginator(contact_list, 5)
@ -85,16 +81,77 @@ def jlist_host(request):
except (EmptyPage, InvalidPage):
contacts = paginator.page(paginator.num_pages)
return render_to_response('jasset/jlist.html', locals(), context_instance=RequestContext(request))
return render_to_response('jasset/host_list.html', locals(), context_instance=RequestContext(request))
def host_del(request, offset):
Asset.objects.filter(ip=str(offset)).delete()
return HttpResponseRedirect('/jasset/host_list/')
def host_edit(request, offset):
actives = {1: u'激活', 0: u'禁用'}
login_types = {'L': 'LDAP', 'S': 'SSH_KEY', 'P': 'PASSWORD', 'M': 'MAP'}
header_title, path1, path2 = u'修改主机 | Edit Host', u'资产管理', u'修改主机'
groups, e_group = [], []
eidc = IDC.objects.all()
egroup = BisGroup.objects.all()
for g in Asset.objects.get(ip=offset).bis_group.all():
e_group.append(g)
post = Asset.objects.get(ip = str(offset))
if request.method == 'POST':
j_ip = request.POST.get('j_ip')
j_idc = request.POST.get('j_idc')
j_port = request.POST.get('j_port')
j_type = request.POST.get('j_type')
j_group = request.POST.getlist('j_group')
j_active = request.POST.get('j_active')
j_comment = request.POST.get('j_comment')
j_idc = IDC.objects.get(name=j_idc)
for group in j_group:
c = BisGroup.objects.get(name=group)
groups.append(c)
a = Asset.objects.get(ip=str(offset))
if j_type == 'M':
j_user = request.POST.get('j_user')
j_password = cryptor.encrypt(request.POST.get('j_password'))
j_root = request.POST.get('j_root')
j_passwd = cryptor.encrypt(request.POST.get('j_passwd'))
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_common = j_user
a.password_common = j_password
a.username_super = j_root
a.password_super = j_passwd
else:
a.ip = j_ip
a.port = j_port
a.idc = j_idc
a.login_type = j_type
a.is_active = j_active
a.comment = j_comment
a.save()
a.bis_group = groups
a.save()
smg = u'主机 %s 修改成功' %j_ip
return HttpResponseRedirect('/jasset/host_list')
return render_to_response('jasset/host_edit.html', locals(), context_instance=RequestContext(request))
def jlist_ip(request, offset):
header_title, path1, path2 = '主机详细信息 | Host Detail.', '资产管理', '主机详情'
header_title, path1, path2 = u'主机详细信息 | Host Detail.', u'资产管理', u'主机详情'
print offset
post = contact_list = Asset.objects.get(ip = str(offset))
return render_to_response('jasset/jlist_ip.html', locals(), context_instance=RequestContext(request))
def jadd_idc(request):
header_title, path1, path2 = '添加IDC | Add IDC', '资产管理', '添加IDC'
header_title, path1, path2 = u'添加IDC | Add IDC', u'资产管理', u'添加IDC'
if request.method == 'POST':
j_idc = request.POST.get('j_idc')
j_comment = request.POST.get('j_comment')
@ -102,37 +159,47 @@ def jadd_idc(request):
if IDC.objects.filter(name=j_idc):
emg = u'该IDC已存在!'
return render_to_response('jasset/jadd_idc.html',
{'emg': emg, 'j_idc': j_idc, 'j_comment': j_comment,},
context_instance=RequestContext(request))
return render_to_response('jasset/idc_add.html', locals(), context_instance=RequestContext(request))
else:
smg = u'IDC:%s添加成功' %j_idc
IDC.objects.create(name=j_idc, comment=j_comment)
return render_to_response('jasset/jadd_idc.html', locals(), context_instance=RequestContext(request))
return render_to_response('jasset/idc_add.html', locals(), context_instance=RequestContext(request))
def jlist_idc(request):
header_title, path1, path2 = '查看IDC | List Host', '资产管理', '查看IDC'
header_title, path1, path2 = u'查看IDC | List Host', u'资产管理', u'查看IDC'
posts = IDC.objects.all().order_by('id')
return render_to_response('jasset/jlist_idc.html', locals(), context_instance=RequestContext(request))
return render_to_response('jasset/idc_list.html', locals(), context_instance=RequestContext(request))
def idc_del(request, offset):
IDC.objects.filter(id=offset).delete()
return HttpResponseRedirect('/jasset/idc_list/')
def jadd_group(request):
header_title, path1, path2 = '添加业务组 | Add Group', '资产管理', '添加业务组'
header_title, path1, path2 = u'添加业务组 | Add Group', u'资产管理', u'添加业务组'
if request.method == 'POST':
j_group = request.POST.get('j_group')
j_comment = request.POST.get('j_comment')
if BisGroup.objects.filter(name=j_group):
emg = u'该业务组已存在!'
return render_to_response('jasset/jadd_group.html', locals(), context_instance=RequestContext(request))
return render_to_response('jasset/group_add.html', locals(), context_instance=RequestContext(request))
else:
smg = u'业务组%s添加成功' %j_group
BisGroup.objects.create(name=j_group, comment=j_comment)
return render_to_response('jasset/jadd_group.html', locals(), context_instance=RequestContext(request))
return render_to_response('jasset/group_add.html', locals(), context_instance=RequestContext(request))
def jlist_group(request):
header_title, path1, path2 = '添加业务组 | Add Group', '资产管理', '查看业务组'
header_title, path1, path2 = u'查看业务组 | Add Group', u'资产管理', u'查看业务组'
posts = BisGroup.objects.all().order_by('id')
return render_to_response('jasset/jlist_group.html', locals(), context_instance=RequestContext(request))
return render_to_response('jasset/group_list.html', locals(), context_instance=RequestContext(request))
def group_del(request, offset):
BisGroup.objects.filter(id=offset).delete()
return HttpResponseRedirect('/jasset/group_list/')
def test(request):
return render_to_response('jasset/test.html', locals())

@ -15,3 +15,7 @@ def stamp2str(value):
@register.filter(name='int2str')
def int2str(value):
return str(value)
@register.filter(name='get_item')
def get_item(dictionary, key):
return dictionary.get(key)

@ -158,7 +158,6 @@ def user_list(request):
def db_add_user(**kwargs):
groups_post = kwargs.pop('groups')
user = User(**kwargs)
group_select = []
for group_id in groups_post:
group = UserGroup.objects.filter(id=group_id)
group_select.extend(group)

@ -30,14 +30,17 @@
{% if emg %}
<div class="alert alert-warning text-center">{{ emg }}</div>
{% endif %}
<form method="post" class="form-horizontal">
{% if smg %}
<div class="alert alert-success text-center">{{ smg }}</div>
{% endif %}
<form id="assetForm" method="post" class="form-horizontal">
<div class="form-group"><label class="col-sm-2 control-label"> 业务组名 </label>
<div class="col-sm-8"><input type="text" value="{{ j_ip }}" placeholder="网站" name="j_group" class="form-control"></div>
<div class="col-sm-8"><input type="text" value="{{ j_group }}" placeholder="网站" name="j_group" 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=包括web组所有主机 name="j_comment" class="form-control"></div>
<div class="col-sm-8"><input type="text" value="{{ j_comment }}" placeholder=包括web组所有主机 name="j_comment" class="form-control"></div>
</div>
<div class="hr-line-dashed"></div>
@ -54,52 +57,23 @@
</div>
</div>
<!-- Peity -->
<script src="static/js/plugins/peity/jquery.peity.min.js"></script>
<!-- Custom and plugin javascript -->
<script src="static/js/inspinia.js"></script>
<script src="static/js/plugins/pace/pace.min.js"></script>
<!-- Peity -->
<script src="static/js/demo/peity-demo.js"></script>
<script>
var showFlag={};
function show(o){
showFlag[o.name]=o.value;
if(showFlag.j_type=="MAP"){
document.getElementById("a1").style.display="";
$('#assetForm').validator({
timely: 2,
theme: "yellow_right_effect",
fields: {
"j_group": {
rule: "required",
tip: "输入业务组名",
ok: "",
msg: {required: "业务组名必须填写!"},
data: {'data-ok':"业务组名可以使用"}
}
},
valid: function(form) {
form.submit();
}
else{
document.getElementById("a1").style.display="none";
}};
$(document).ready(function(){
// Local script for demo purpose only
$('#lightVersion').click(function(event) {
event.preventDefault()
$('#ibox-content').removeClass('ibox-content');
$('#vertical-timeline').removeClass('dark-timeline');
$('#vertical-timeline').addClass('light-timeline');
});
$('#darkVersion').click(function(event) {
event.preventDefault()
$('#ibox-content').addClass('ibox-content');
$('#vertical-timeline').removeClass('light-timeline');
$('#vertical-timeline').addClass('dark-timeline');
});
$('#leftVersion').click(function(event) {
event.preventDefault()
$('#vertical-timeline').toggleClass('center-orientation');
});
});
});
</script>

@ -29,23 +29,29 @@
<div class="ibox-content">
<div class="">
<a onclick="fnClickAddRow();" href="javascript:void(0);" class="btn btn-primary "> 添加 </a>
<a target="_blank" href="/jasset/group_add" class="btn btn-sm btn-primary "> 添加 </a>
</div>
<table class="table table-striped table-bordered table-hover " id="editable" >
<thead>
<tr>
<th> ID </th>
<th> 机房名 </th>
<th> 备注 </th>
<th class="text-center"> ID </th>
<th class="text-center"> 机房名 </th>
<th class="text-center"> 备注 </th>
<th class="text-center"> 操作 </th>
</tr>
</thead>
<tbody>
{% for post in posts %}
<tr class="gradeX">
<td> {{ post.id }} </td>
<td> {{ post.name }} </td>
<td> {{ post.comment }} </td>
<td class="text-center"> {{ post.id }} </td>
<td class="text-center"> {{ post.name }} </td>
<td class="text-center"> {{ post.comment }} </td>
<td class="text-center">
<a href="/jasset/{{ post.ip }}/" class="iframe btn btn-xs btn-primary">详情</a>
<a href="/jasset/host_edit/{{ post.ip }}" class="btn btn-xs btn-info">编辑</a>
<a href="/jasset/group_del/{{ post.id }}" class="btn btn-xs btn-danger">删除</a>
</td>
</tr>
{% endfor %}
</tbody>

@ -32,53 +32,55 @@
</div>
</div>
<div class="ibox-content" id="addhost">
<div class="ibox-content">
{% if emg %}
<div class="alert alert-warning text-center">{{ emg }}</div>
{% endif %}
<form method="post" id="jasset_add" class="form-horizontal">
{% if smg %}
<div class="alert alert-success text-center">{{ smg }}</div>
{% endif %}
<form id="assetForm" method="post" class="form-horizontal">
<div class="form-group"><label class="col-sm-2 control-label"> IP地址 </label>
<div class="col-sm-8"><input type="text" value="{{ j_ip }}" name="j_ip" class="form-control"></div>
<div class="col-sm-8"><input type="text" name="j_ip" placeholder="192.168.1.1" 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="{{ j_port }}" placeholder="22" name="j_port" class="form-control"></div>
<div class="col-sm-8"><input type="text" placeholder="22" name="j_port" 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">
<div class="radio i-checks"><label> <input type="radio" checked="" value="L" name="j_type" onclick="show(this)"> <i> LDAP </i></label></div>
<div class="radio i-checks"><label> <input type="radio" value="S" name="j_type" onclick="show(this)"> <i> SSH_KEY </i></label></div>
<div class="radio i-checks"><label> <input type="radio" value="P" name="j_type" onclick="show(this)"> <i> PASSWORD </i></label></div>
<div class="radio i-checks"><label> <input type="radio" value="M" name="j_type" onclick="show(this)"> <i> MAP </i></label></div>
<div class="radio i-checks"><label> <input type="radio" id="L" checked="" value="L" name="j_type" onclick="show(this)"> <i> LDAP </i></label></div>
<div class="radio i-checks"><label> <input type="radio" id="S" value="S" name="j_type" onclick="show(this)"> <i> SSH_KEY </i></label></div>
<div class="radio i-checks"><label> <input type="radio" id="P" value="P" name="j_type" onclick="show(this)"> <i> PASSWORD </i></label></div>
<div class="radio i-checks"><label> <input type="radio" id="M" value="M" name="j_type" onclick="show(this)"> <i> MAP </i></label></div>
</div>
<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" value="{{ j_user }}" name="j_user" placeholder="lilei" class="form-control"></div>
<div class="col-sm-6"><input type="text" name="j_user" placeholder="lilei" class="form-control"></div>
</div>
<div class="hr-line-dashed"></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" value="{{ j_password }}" name="j_password" placeholder="Password" class="form-control"></div>
<div class="col-sm-6"><input type="password" name="j_password" placeholder="Password" class="form-control"></div>
</div>
<div class="hr-line-dashed"></div>
<div class="form-group"><label class="col-sm-2 col-sm-offset-1 control-label"> 超管用户名 </label>
<div class="col-sm-6"><input type="text" value="{{ j_root }}" name="j_root" placeholder="root" class="form-control"></div>
<div class="col-sm-6"><input type="text" name="j_root" placeholder="root" class="form-control"></div>
</div>
<div class="hr-line-dashed"></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" value="{{ j_passwd }}" name="j_passwd" placeholder="Password" class="form-control"></div>
<div class="col-sm-6"><input type="password" name="j_passwd" placeholder="Password" class="form-control"></div>
</div>
</div>
</div>
<div class="hr-line-dashed"></div>
<div class="form-group">
<label for="j_idc" class="col-lg-2 control-label"> 所属IDC </label>
@ -111,13 +113,13 @@
<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="{{ j_comment }}" placeholder="hadoop01" name="j_comment" class="form-control"></div>
<div class="col-sm-8"><input type="text" placeholder="hadoop01" name="j_comment" class="form-control"></div>
</div>
<div class="hr-line-dashed"></div>
<div class="form-group">
<div class="col-sm-4 col-sm-offset-5">
<button class="btn btn-white" type="submit"> 重置 </button>
<!--<button class="btn btn-white" type="submit"> 重置 </button>-->
<button class="btn btn-primary" type="submit"> 提交 </button>
</div>
</div>
@ -129,79 +131,71 @@
</div>
<script>
var showFlag={};
var showFlag={};
function show(o){
showFlag[o.name]=o.value;
if(showFlag.j_type=="MAP"){
if(showFlag.j_type=="M"){
document.getElementById("a1").style.display="";
}
else{
document.getElementById("a1").style.display="none";
}};
//验证初始化
$('#jasset_add').validator({
focusCleanup: true,
stopOnError:false,
//debug: true,
$('#assetForm').validator({
timely: 2,
theme: "yellow_right_effect",
//自定义规则PS建议尽量在全局配置中定义规则统一管理
rules: {
username: [/^[a-zA-Z0-9]+$/, '用户名无效! 仅支持字母与数字。'],
check_ip: [/^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])(\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])){3}$/, 'ip不正确'],
check_port: [/^\d{1,5}$/, '端口号不正确']
check_ip: [/^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])(\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])){3}$/, 'ip地址不正确'],
check_port: [/^\d{1,5}$/, '端口号不正确'],
type_m: function(element){
return $("#M").is(":checked");
}
},
fields: {
"j_ip": {
rule: "required;check_ip",
tip: "输入IP",
ok: "ok",
tip: "输入IP",
ok: "",
msg: {required: "必须填写!"}
},
"j_port": {
rule: "required;check_port",
tip: "输入端口号",
ok: "ok",
tip: "输入端口号",
ok: "",
msg: {required: "必须填写!"}
},
"user[user_password]": {
rule: "required;length[6~];password;strength",
tip: "6个或更多字符! 要复杂些。",
"j_group": {
rule: "required",
tip: "选择业务组",
ok: "",
msg: {
required: "密码不能为空!",
length: "密码最少为6位。"
}
msg: {required: "至少选择一个组"}
},
"j_user": {
rule: "required(type_m)",
tip: "普通用户名",
ok: "",
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: "请填写用户名"}
},
"user[screen_name]": {
rule: "required;username;remote[check/user.php]",
tip: "别担心,你可以稍后进行修改。",
ok: "用户名可以使用。<br>你可以稍后进行修改。",
msg: {required: "用户名必填!<br>你可以稍后进行修改。"}
"j_passwd": {
rule: "required(type_m);length[6~16]",
tip: "密码6-16位",
ok: "",
msg: {required: "6-16位"}
}
},
//验证成功
valid: function(form) {
$.ajax({
url: 'results.php',
type: 'POST',
data: $(form).serialize(),
success: function(d){
$('#result').fadeIn(300).delay(2000).fadeOut(500);
}
});
},
//验证失败
invalid: function(form) {
//按钮动画效果
$('#btn-submit').stop().delay(100)
.animate({left:-5}, 100)
.animate({left:5}, 100)
.animate({left:-4}, 100)
.animate({left:4}, 100)
.animate({left:-3}, 100)
.animate({left:0}, 100);
form.submit();
}
});

@ -0,0 +1,215 @@
{% extends 'base.html' %}
{% load mytags %}
{% block content %}
{% include 'nav_cat_bar.html' %}
<div class="wrapper wrapper-content animated fadeInRight">
<div class="row">
<div class="col-lg-10">
<div class="ibox float-e-margins">
<div id="ibox-content" class="ibox-title">
<h5> 填写主机基本信息 </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="#">未启用 1</a>
</li>
<li><a href="#">未启用 2</a>
</li>
</ul>
<a class="close-link">
<i class="fa fa-times"></i>
</a>
</div>
</div>
<div class="ibox-content">
{% if emg %}
<div class="alert alert-warning text-center">{{ emg }}</div>
{% endif %}
{% if smg %}
<div class="alert alert-success text-center">{{ smg }}</div>
{% endif %}
<form id="assetForm" method="post" class="form-horizontal" autocomplete="off">
<div class="form-group"><label class="col-sm-2 control-label"> IP地址 </label>
<div class="col-sm-8"><input type="text" name="j_ip" value="{{ post.ip }}" placeholder="192.168.1.1" 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" placeholder="22" name="j_port" value="{{ post.port }}" 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">
{% for t, type in login_types.items %}
{% ifequal t post.login_type %}
<div class="radio i-checks"><label> <input type="radio" id="{{ t }}" checked value="{{ t }}" name="j_type" onclick="show(this)"> <i> {{ type }} </i></label></div>
{% else %}
<div class="radio i-checks"><label> <input type="radio" id="{{ t }}" value="{{ t }}" name="j_type" onclick="show(this)"> <i> {{ type }} </i></label></div>
{% endifequal %}
{% endfor %}
</div>
<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" value="{{ post.username_common }}" name="j_user" placeholder="lilei" class="form-control"></div>
</div>
<div class="hr-line-dashed"></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" value="{{ post.password_common }}" name="j_password" placeholder="Password" class="form-control"></div>
</div>
<div class="hr-line-dashed"></div>
<div class="form-group"><label class="col-sm-2 col-sm-offset-1 control-label"> 超管用户名 </label>
<div class="col-sm-6"><input type="text" value="{{ post.username_super }}" name="j_root" placeholder="root" class="form-control"></div>
</div>
<div class="hr-line-dashed"></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" value="{{ post.password_super }}" name="j_passwd" placeholder="Password" class="form-control"></div>
</div>
</div>
</div>
<div class="hr-line-dashed"></div>
<div class="form-group">
<label for="j_idc" class="col-lg-2 control-label"> 所属IDC </label>
<div class="col-sm-8">
<select id="j_idc" name="j_idc" class="form-control m-b">
{% for i in eidc %}
{% ifequal i.id post.idc_id %}
<option selected> {{ i }} </option>
{% else %}
<option> {{ i }} </option>
{% endifequal %}
{% endfor %}
</select>
</div>
</div>
<div class="hr-line-dashed"></div>
<div class="form-group">
<label for="j_group" class="col-sm-2 control-label"> 所属业务组 </label>
<div class="col-sm-8">
{% for g in egroup %}
{% if g in e_group %}
<label class="checkbox-inline"><input type="checkbox" id="j_group" checked value="{{ g }}" name="j_group"> {{ g }} </label>
{% else %}
<label class="checkbox-inline"><input type="checkbox" id="j_group" value="{{ g }}" name="j_group"> {{ g }} </label>
{% endif %}
{% endfor %}
</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">
{% for a,active in actives.items %}
{% ifequal a post.is_active %}
<div class="radio i-checks"><label> <input type="radio" checked value="{{ a }}" name="j_active"> <i> {{ active }} </i></label></div>
{% else %}
<div class="radio i-checks"><label> <input type="radio" value="{{ a }}" name="j_active"> <i> {{ active }} </i></label></div>
{% endifequal %}
{% endfor %}
</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" placeholder="hadoop01" value="{{ post.comment }}" name="j_comment" class="form-control"></div>
</div>
<div class="hr-line-dashed"></div>
<div class="form-group">
<div class="col-sm-4 col-sm-offset-5">
<button class="btn btn-white" type="submit"> 重置 </button>
<button class="btn btn-primary" type="submit"> 提交 </button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<script>
var showFlag={};
function show(o){
showFlag[o.name]=o.value;
if(showFlag.j_type=="M"){
document.getElementById("a1").style.display="";
}
else{
document.getElementById("a1").style.display="none";
}};
$('#assetForm').validator({
timely: 2,
theme: "yellow_right_effect",
rules: {
check_ip: [/^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])(\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])){3}$/, 'ip地址不正确'],
check_port: [/^\d{1,5}$/, '端口号不正确'],
type_m: function(element){
return $("#M").is(":checked");
}
},
fields: {
"j_ip": {
rule: "required;check_ip",
tip: "输入IP",
ok: "",
msg: {required: "必须填写!"}
},
"j_port": {
rule: "required;check_port",
tip: "输入端口号",
ok: "",
msg: {required: "必须填写!"}
},
"j_group": {
rule: "required",
tip: "选择业务组",
ok: "",
msg: {required: "至少选择一个组"}
},
"j_user": {
rule: "required(type_m)",
tip: "普通用户名",
ok: "",
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]",
tip: "密码6-16位",
ok: "",
msg: {required: "6-16位"}
}
},
valid: function(form) {
form.submit();
}
});
</script>
{% endblock %}

@ -1,10 +1,11 @@
{% extends 'base.html' %}
{% load mytags %}
{% block content %}
{% include 'nav_cat_bar.html' %}
<div class="wrapper wrapper-content animated fadeInRight">
<div class="row">
<div class="col-lg-10">
<div class="col-lg-12">
<div class="ibox float-e-margins">
<div class="ibox-title">
<h5> 主机详细信息列表 </h5>
@ -29,35 +30,43 @@
<div class="ibox-content">
<div class="">
<a onclick="fnClickAddRow();" href="javascript:void(0);" class="btn btn-primary "> 添加 </a>
<a target="_blank" href="/jasset/host_add" class="btn btn-sm btn-primary "> 添加 </a>
</div>
<table class="table table-striped table-bordered table-hover " id="editable" >
<thead>
<tr>
<th> IP地址 </th>
<th> 端口号 </th>
<th> 登录方式 </th>
<th> 所属IDC </th>
<th> 所属业务组 </th>
<th> 添加时间 </th>
<th> 备注 </th>
<th class="text-center"><input type="checkbox" class="i-checks" name=""></th>
<th class="text-center"> IP地址 </th>
<th class="text-center"> 端口号 </th>
<th class="text-center"> 登录方式 </th>
<th class="text-center"> 所属IDC </th>
<th class="text-center"> 所属业务组 </th>
<th class="text-center"> 添加时间 </th>
<th class="text-center"> 备注 </th>
<th class="text-center"> 操作 </th>
</tr>
</thead>
<tbody>
{% for post in contacts.object_list %}
<tr class="gradeX">
<td> <a class="iframe" href="/jasset/{{ post.ip }}/">{{ post.ip }}</a></td>
<td> {{ post.port }} </td>
<td> {{ post.get_login_type}} </td>
<td class="center"> {{ post.idc.name }} </td>
<td class="center">
<td class="text-center"><input type="checkbox" class="i-checks" name=""></td>
<td class="text-center"> {{ post.ip }} </td>
<td class="text-center"> {{ post.port }} </td>
<td class="text-center"> {{ login_types|get_item:post.login_type }} </td>
<td class="text-center"> {{ post.idc.name }} </td>
<td class="text-center">
{% for group in post.bis_group.all %}
{{ group }}
{% endfor %}
</td>
<td class="center"> {{ post.date_added }} </td>
<td class="center"> {{ post.comment }} </td>
<td class="text-center"> {{ post.date_added }} </td>
<td class="text-center"> {{ post.comment }} </td>
<td class="text-center">
<a href="/jasset/{{ post.ip }}/" class="iframe btn btn-xs btn-primary">详情</a>
<a href="/jasset/host_edit/{{ post.ip }}" class="btn btn-xs btn-info">编辑</a>
<a href="/jasset/host_del/{{ post.ip }}" class="btn btn-xs btn-danger">删除</a>
</td>
</tr>
{% endfor %}
</tbody>

@ -30,7 +30,10 @@
{% if emg %}
<div class="alert alert-warning text-center">{{ emg }}</div>
{% endif %}
<form method="post" class="form-horizontal">
{% if smg %}
<div class="alert alert-success text-center">{{ smg }}</div>
{% 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>
@ -44,7 +47,7 @@
<div class="form-group">
<div class="col-sm-4 col-sm-offset-5">
<button class="btn btn-white" type="submit"> 重置 </button>
<button class="btn btn-primary" type="submit"> 提交 </button>
<button class="btn btn-primary" type="sumbit"> 提交 </button>
</div>
</div>
</form>
@ -54,53 +57,23 @@
</div>
</div>
<!-- Peity -->
<script src="static/js/plugins/peity/jquery.peity.min.js"></script>
<!-- Custom and plugin javascript -->
<script src="static/js/inspinia.js"></script>
<script src="static/js/plugins/pace/pace.min.js"></script>
<!-- Peity -->
<script src="static/js/demo/peity-demo.js"></script>
<script>
var showFlag={};
function show(o){
showFlag[o.name]=o.value;
if(showFlag.j_type=="MAP"){
document.getElementById("a1").style.display="";
$('#assetForm').validator({
timely: 2,
theme: "yellow_right_effect",
fields: {
"j_idc": {
rule: "required",
tip: "输入IDC名",
ok: "",
msg: {required: "IDC名必须填写!"},
data: {'data-ok':"主机名可以使用", 'data-msg-required': '主机名已正确'}
}
},
valid: function(form) {
form.submit();
}
else{
document.getElementById("a1").style.display="none";
}};
$(document).ready(function(){
// Local script for demo purpose only
$('#lightVersion').click(function(event) {
event.preventDefault()
$('#ibox-content').removeClass('ibox-content');
$('#vertical-timeline').removeClass('dark-timeline');
$('#vertical-timeline').addClass('light-timeline');
});
$('#darkVersion').click(function(event) {
event.preventDefault()
$('#ibox-content').addClass('ibox-content');
$('#vertical-timeline').removeClass('light-timeline');
$('#vertical-timeline').addClass('dark-timeline');
});
$('#leftVersion').click(function(event) {
event.preventDefault()
$('#vertical-timeline').toggleClass('center-orientation');
});
});
});
</script>
{% endblock %}

@ -29,23 +29,29 @@
<div class="ibox-content">
<div class="">
<a onclick="fnClickAddRow();" href="javascript:void(0);" class="btn btn-primary "> 添加 </a>
<a target="_blank" href="/jasset/idc_add" class="btn btn-sm btn-primary "> 添加 </a>
</div>
<table class="table table-striped table-bordered table-hover " id="editable" >
<thead>
<tr>
<th> ID </th>
<th> 机房名 </th>
<th> 备注 </th>
<th class="text-center"> ID </th>
<th class="text-center"> 机房名 </th>
<th class="text-center"> 备注 </th>
<th class="text-center"> 操作 </th>
</tr>
</thead>
<tbody>
{% for post in posts %}
<tr class="gradeX">
<td> {{ post.id }} </td>
<td> {{ post.name }} </td>
<td> {{ post.comment }} </td>
<td class="text-center"> {{ post.id }} </td>
<td class="text-center"> {{ post.name }} </td>
<td class="text-center"> {{ post.comment }} </td>
<td class="text-center">
<a href="/jasset/{{ post.ip }}/" class="iframe btn btn-xs btn-primary">详情</a>
<a href="/jasset/host_edit/{{ post.ip }}" class="btn btn-xs btn-info">编辑</a>
<a href="/jasset/idc_del/{{ post.id }}" class="btn btn-xs btn-danger">删除</a>
</td>
</tr>
{% endfor %}
</tbody>

@ -0,0 +1,30 @@
<div id="result" class="tip-ok" style="display:none">提交成功</div>
<form id="signup_form" class="signup" autocomplete="off">
<fieldset>
<div class="form-item">
<div class="field-name">全名</div>
<div class="field-input">
<input type="text" name="user[name]" maxlength="20" autocomplete="off">
</div>
</div>
<div class="form-item">
<div class="field-name">电子邮件地址</div>
<div class="field-input">
<input type="text" name="user[email]" autocomplete="off">
</div>
</div>
<div class="form-item">
<div class="field-name">创建密码</div>
<div class="field-input">
<input type="password" name="user[user_password]">
</div>
</div>
<div class="form-item">
<div class="field-name">选择你的用户名</div>
<div class="field-input">
<input type="text" name="user[screen_name]" maxlength="15" autocomplete="off">
</div>
</div>
</fieldset>
<button id="btn-submit" class="btn-submit" type="submit">创建我的账号</button>
</form>
Loading…
Cancel
Save