{% 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 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">
                        <form method="post" id="userForm" class="form-horizontal" action="">
                            {% if error %}
                                <div class="alert alert-warning text-center">{{ error }}</div>
                            {% endif %}
                            {% if msg %}
                                <div class="alert alert-success text-center">{{ msg }}</div>
                            {% endif %}
                            <div class="form-group">
                                <div class="col-sm-8">
                                    <input id="user_id" name="user_id" type="text"  value="{{ user.id }}" style="display: none">
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="name" class="col-sm-2 control-label">姓名<span class="red-fonts">*</span></label>
                                <div class="col-sm-8">
                                    <input id="name" name="name" placeholder="Name" type="text" class="form-control" value="{{ user.name }}">
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <label for="password" class="col-sm-2 control-label">密码<span class="red-fonts">*</span></label>
                                <div class="col-sm-8">
                                    <input id="password" name="password" placeholder="Password" type="password" class="form-control" value="{{ user.password }}">
                                    <span class="help-block m-b-none">
                                        登陆web的密码
                                    </span>
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <label for="ssh_key_pwd" class="col-sm-2 control-label">密钥密码<span class="red-fonts">*</span></label>
                                <div class="col-sm-8">
                                    <input id="ssh_key_pwd" name="ssh_key_pwd" placeholder="SSH Key Password" type="password" class="form-control" value="{{ user.ssh_key_pwd }}">
                                    <span class="help-block m-b-none">
                                        登陆 Jumpserver 使用的SSH密钥的密码,更改密钥密码需要重新下载密钥
                                    </span>
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>

                            <div class="form-group">
                                <label for="email" class="col-sm-2 control-label">Email<span class="red-fonts">*</span></label>
                                <div class="col-sm-8">
                                    <input id="email" name="email" type="email" placeholder="Email" class="form-control" value="{{ user.email }}" >
                                </div>
                            </div>

                            <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="submit">取消</button>
                                    <button id="submit_button" class="btn btn-primary" type="submit">确认修改</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>

<script>
$('#userForm').validator({
    timely: 2,
    theme: "yellow_right_effect",

    fields: {
        "password": {
            rule: "required;length[6~50]",
            tip: "输入密码",
            ok: "",
            msg: {required: "必须填写!"}
        },
        "ssh_key_pwd": {
            rule: "required;length[6~50]",
            tip: "ssh私钥密码",
            ok: "",
            msg: {required: "必须填写"}
        },
        "name": {
            rule: "required",
            tip: "姓名",
            ok: "",
            msg: {required: "必须填写"}
        },
        "email": {
            rule: "required",
            tip: "Email",
            ok: "",
            msg: {required: "必须填写"}
        },
    },
    valid: function(form) {
        form.submit();
    }
});

</script>


{% endblock %}