jumpserver/templates/jasset/host_edit.html

228 lines
11 KiB
HTML

{% 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地址<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 %}
<div class="radio i-checks"><label> <input type="radio" checked="" value="{{ t }}" name="j_type" onclick="show(this)"> <i> {{ type }} </i></label></div>
{% else %}
<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>
{% ifequal post.login_type 'M' %}
<div name="type" id="type">
<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" 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" value="{{ post.password }}" class="form-control"></div>
</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 %}
<option value="{{i.id}}" selected> {{ i }} </option>
{% else %}
<option value="{{i.id}}"> {{ i }} </option>
{% endifequal %}
{% endfor %}
</select>
</div>
</div>
{% 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>
</div>
{% 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 %}
<div class="hr-line-dashed"></div>
<div class="form-group">
<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 %}
<option type="checkbox" value="{{ g.id }}" selected>{{ g.name }} {% if g.comment %} --- {{ g.comment }} {% endif %}</option>
{% else %}
<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>
<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"){
document.getElementById("type").style.display="";
}
else{
document.getElementById("type").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_idc": {
rule: "required",
tip: "选择IDC",
ok: "",
msg: {checked: "必须填写!"}
},
"j_dept": {
rule: "required",
tip: "选择部门",
ok: "",
msg: {checked: "至少选择一个部门"}
},
"j_user": {
rule: "required(type_m)",
tip: "普通用户名",
ok: "",
msg: {required: "请填写用户名"}
},
"j_password": {
rule: "required(type_m);length[6~100]",
tip: "密码6-16位",
ok: "",
msg: {required: "6-16位"}
}
},
valid: function(form) {
form.submit();
}
});
</script>
{% endblock %}