jumpserver/templates/jasset/host_edit.html

228 lines
11 KiB
HTML
Raw Normal View History

{% 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">
2015-01-11 11:27:21 +00:00
<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地址<span class="red-fonts">*</span> </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"> 端口号<span class="red-fonts">*</span> </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"> 登录方式<span class="red-fonts">*</span> </label>
<div class="col-sm-8">
{% for t, type in login_types.items %}
{% ifequal t post.login_type %}
2015-04-13 13:25:43 +00:00
<div class="radio i-checks"><label> <input type="radio" checked="" value="{{ t }}" name="j_type" onclick="show(this)"> <i> {{ type }} </i></label></div>
{% else %}
2015-04-13 13:25:43 +00:00
<div class="radio i-checks"><label> <input type="radio" value="{{ t }}" name="j_type" onclick="show(this)"> <i> {{ type }} </i></label></div>
{% endifequal %}
{% endfor %}
</div>
2015-04-13 13:25:43 +00:00
{% ifequal post.login_type 'M' %}
<div name="type" id="type">
2015-03-14 05:13:46 +00:00
<div class="form-group"><label class="col-sm-2 col-sm-offset-1 control-label"> 普通用户名 </label>
2015-04-13 13:25:43 +00:00
<div class="col-sm-6"><input type="text" name="j_user" value="{{ post.username }}" class="form-control"></div>
2015-03-14 05:13:46 +00:00
</div>
<div class="form-group"><label class="col-sm-2 col-sm-offset-1 control-label"> 普通用户密码 </label>
2015-04-13 13:25:43 +00:00
<div class="col-sm-6"><input type="password" name="j_password" value="{{ post.password }}" class="form-control"></div>
2015-03-14 05:13:46 +00:00
</div>
</div>
{% endifequal %}
</div>
<div class="hr-line-dashed"></div>
<div class="form-group">
<label for="j_idc" class="col-lg-2 control-label"> 所属IDC<span class="red-fonts">*</span> </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 %}
2015-04-13 13:25:43 +00:00
<option value="{{i.id}}" selected> {{ i }} </option>
{% else %}
2015-04-13 13:25:43 +00:00
<option value="{{i.id}}"> {{ i }} </option>
{% endifequal %}
{% endfor %}
</select>
</div>
</div>
2015-04-13 13:25:43 +00:00
{% ifequal session_role_id 2 %}
<div class="hr-line-dashed"></div>
<div class="form-group">
<label for="j_dept" class="col-lg-2 control-label">所属部门<span class="red-fonts">*</span></label>
<div class="col-sm-8">
<select id="j_dept" name="j_dept" class="form-control m-b" multiple size="10">
{% for d in edept %}
{% if d in e_dept %}
<option type="checkbox" selected value="{{ d.id }}">{{ d.name }} {% if d.comment %} --- {{ d.comment }} {% endif %}</option>
{% else %}
<option type="checkbox" value="{{ d.id }}">{{ d.name }} {% if d.comment %} --- {{ d.comment }} {% endif %}</option>
{% endif %}
{% endfor %}
</select>
</div>
2015-03-14 09:54:27 +00:00
</div>
2015-04-13 13:25:43 +00:00
{% endifequal %}
{% ifequal session_role_id 1 %}
<div class="hr-line-dashed"></div>
<div class="form-group"><label class="col-sm-2 control-label"> 所属部门<span class="red-fonts">*</span> </label>
<input type="text" name="j_dept" value="{{ dept.id }}" style="display: none">
<div class="col-sm-8"><input type="text" value="{{ dept.name }}" class="form-control" readonly="readonly"></div>
</div>
{% endifequal %}
2015-03-14 09:54:27 +00:00
<div class="hr-line-dashed"></div>
<div class="form-group">
2015-04-13 13:25:43 +00:00
<label for="j_group" class="col-lg-2 control-label"> 所属主机组</label>
<div class="col-sm-8">
<select id="j_group" name="j_group" class="form-control m-b" multiple size="10">
{% for g in egroup %}
{% if g in e_group %}
2015-04-13 13:25:43 +00:00
<option type="checkbox" value="{{ g.id }}" selected>{{ g.name }} {% if g.comment %} --- {{ g.comment }} {% endif %}</option>
{% else %}
2015-04-13 13:25:43 +00:00
<option type="checkbox" value="{{ g.id }}" >{{ g.name }} {% if g.comment %} --- {{ g.comment }} {% endif %}</option>
{% endif %}
{% endfor %}
</select>
</div>
</div>
<div class="hr-line-dashed"></div>
<div class="form-group"><label class="col-sm-2 control-label"> 是否激活<span class="red-fonts">*</span> </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>
2015-04-13 13:25:43 +00:00
<button class="btn btn-primary" type="submit" style="display: i"> 提交 </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"){
2015-04-13 13:25:43 +00:00
document.getElementById("type").style.display="";
}
else{
2015-04-13 13:25:43 +00:00
document.getElementById("type").style.display="none";
}};
$('#assetForm').validator({
2015-01-14 11:19:56 +00:00
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");
}
2015-01-14 11:19:56 +00:00
},
fields: {
"j_ip": {
rule: "required;check_ip",
tip: "输入IP",
ok: "",
2015-01-14 11:19:56 +00:00
msg: {required: "必须填写!"}
},
"j_port": {
rule: "required;check_port",
tip: "输入端口号",
ok: "",
2015-01-14 11:19:56 +00:00
msg: {required: "必须填写!"}
},
2015-04-13 13:25:43 +00:00
"j_idc": {
rule: "required",
tip: "选择IDC",
ok: "",
msg: {checked: "必须填写!"}
},
"j_dept": {
rule: "required",
tip: "选择部门",
2015-01-14 11:19:56 +00:00
ok: "",
2015-04-13 13:25:43 +00:00
msg: {checked: "至少选择一个部门"}
2015-01-14 11:19:56 +00:00
},
"j_user": {
rule: "required(type_m)",
tip: "普通用户名",
ok: "",
msg: {required: "请填写用户名"}
},
"j_password": {
2015-03-14 05:13:46 +00:00
rule: "required(type_m);length[6~100]",
tip: "密码6-16位",
ok: "",
msg: {required: "6-16位"}
2015-01-14 11:19:56 +00:00
}
},
valid: function(form) {
form.submit();
2015-01-14 11:19:56 +00:00
}
});
</script>
{% endblock %}