jumpserver/templates/jasset/asset_edit.html

241 lines
12 KiB
HTML
Raw Normal View History

2015-12-19 09:27:12 +00:00
{% extends 'base.html' %}
{% load mytags %}
{% load bootstrap %}
{% block content %}
{% include 'nav_cat_bar.html' %}
<div class="wrapper wrapper-content animated fadeInRight">
<div class="row">
<div class="col-sm-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>
<a class="close-link">
<i class="fa fa-times"></i>
</a>
</div>
</div>
<div class="ibox-content">
<div class="panel-body">
<div class="tab-content">
<div id="tab-1" class="ibox float-e-margins tab-pane active">
{% if error %}
<div class="alert alert-warning text-center">{{ error }}</div>
{% endif %}
{% if msg %}
<div class="alert alert-success text-center">{{ msg }}</div>
{% endif %}
<form id="assetForm" method="post" class="form-horizontal">
{{ af.hostname|bootstrap_horizontal }}
<div class="hr-line-dashed"></div>
{{ af.ip|bootstrap_horizontal }}
<div class="hr-line-dashed"></div>
{{ af.other_ip|bootstrap_horizontal }}
<p class="col-sm-offset-2">Tips: 多个IP使用,号隔开</p>
<div class="hr-line-dashed"></div>
{{ af.remote_ip|bootstrap_horizontal }}
<div class="hr-line-dashed"></div>
{{ af.mac|bootstrap_horizontal }}
{# <div class="hr-line-dashed"></div>#}
{# {{ af.port|bootstrap_horizontal }}#}
<div class="hr-line-dashed"></div>
<div class="form-group">
<label for="j_group" class="col-sm-2 control-label">管理账号 <span class="red-fonts">*</span></label>
<div class="col-sm-2">
<div class="radio i-checks">
<label>
<input type="checkbox" {% if asset.use_default_auth %} checked="checked" {% endif %} id="id_use_default_auth" name="use_default_auth"><span> 使用默认 </span>
</label>
</div>
</div>
</div>
<div class="form-group" id="admin_account" {% if asset.use_default_auth %} style="display: none" {% endif %}>
<div class="hr-line-dashed"></div>
<label class="col-sm-2 control-label"> 管理用户名 <span class="red-fonts">*</span> </label>
<div class="col-sm-3">
<input type="text" value="{{ asset.username }}" name="username" class="form-control">
</div>
<label class="col-sm-1 control-label"> 密码<span class="red-fonts">*</span> </label>
<div class="col-sm-4">
<input type="password" value="" name="password" placeholder="不填写即不更改密码." class="form-control">
</div>
</div>
<div class="form-group" id="id_port">
<div class="hr-line-dashed"></div>
<label class="col-sm-2 control-label"> 端口<span class="red-fonts">*</span> </label>
<div class="col-sm-8">
<input type="text" placeholder="Port" value="{{ asset.port|default_if_none:"" }}" name="port" class="form-control">
</div>
</div>
<div class="hr-line-dashed"></div>
{{ af.group|bootstrap_horizontal }}
<div class="hr-line-dashed"></div>
{{ af.idc|bootstrap_horizontal }}
<div class="hr-line-dashed"></div>
{{ af.brand|bootstrap_horizontal }}
<div class="hr-line-dashed"></div>
{{ af.cpu|bootstrap_horizontal }}
<div class="hr-line-dashed"></div>
{{ af.memory|bootstrap_horizontal }}
<div class="hr-line-dashed"></div>
{{ af.disk|bootstrap_horizontal }}
<div class="hr-line-dashed"></div>
{{ af.system_type|bootstrap_horizontal }}
<div class="hr-line-dashed"></div>
{{ af.system_version|bootstrap_horizontal }}
<div class="hr-line-dashed"></div>
{{ af.system_arch|bootstrap_horizontal }}
<div class="hr-line-dashed"></div>
{{ af.number|bootstrap_horizontal }}
<div class="hr-line-dashed"></div>
{{ af.sn|bootstrap_horizontal }}
<div class="hr-line-dashed"></div>
{{ af.cabinet|bootstrap_horizontal }}
<div class="hr-line-dashed"></div>
{{ af.position|bootstrap_horizontal }}
<div class="hr-line-dashed"></div>
{{ af.asset_type|bootstrap_horizontal }}
<div class="hr-line-dashed"></div>
{{ af.env|bootstrap_horizontal }}
<div class="hr-line-dashed"></div>
{{ af.status|bootstrap_horizontal }}
{# <div class="hr-line-dashed"></div>#}
{# {{ af.is_active|bootstrap_horizontal }}#}
<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">
<div class="radio i-checks">
{% ifequal asset.is_active 1 %}
<label> <input type="radio" checked="" value="1" name="is_active">激活 </label>
<label> <input type="radio" value="0" name="is_active"> 禁用</label>
{% else %}
<label> <input type="radio" value="1" name="is_active">激活 </label>
<label> <input type="radio" checked="" value="0" name="is_active"> 禁用</label>
{% endifequal %}
</div>
</div>
</div>
<div class="hr-line-dashed"></div>
{{ af.comment|bootstrap_horizontal }}
<div class="hr-line-dashed"></div>
<div class="form-group">
<div class="col-sm-4 col-sm-offset-2">
<button class="btn btn-white" type="reset"> 重置 </button>
<button class="btn btn-primary" type="submit"> 提交 </button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
{% endblock %}
{% block self_footer_js %}
<script>
$('document').ready(function(){
$('#id_use_default_auth').click(function(){
if ($(this).is(':checked')){
$('#admin_account').css('display', 'none');
}
else {
$('#admin_account').css('display', 'block');
}
})
});
var required_fields = ["id_hostname", "id_port"];
required_fields.forEach(function(field) {
$('label[for="' + field + '"]').parent().addClass("required");
});
$('#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}$/, '端口号不正确'],
use_default_auth: function() {
var str1 = $("#id_use_default_auth").is(":checked");
if (str1 == true){
var decide = false;
} else {
var decide = true;
}
return decide}
},
fields: {
"hostname": {
rule: "required",
tip: "填写主机名",
ok: "",
msg: {required: "必须填写!"}
},
"port": {
rule: "required(use_default_auth)",
tip: "输入端口号",
ok: "",
msg: {required: "必须填写!"}
},
"username": {
rule: "required(use_default_auth)",
tip: "输入用户名",
ok: "",
msg: {required: "必须填写!"}
},
{# "password": {#}
{# rule: "required(use_default_auth)",#}
{# tip: "输入密码",#}
{# ok: "",#}
{# msg: {required: "必须填写!"}#}
{# }#}
},
valid: function(form) {
form.submit();
}
});
</script>
{% endblock %}