{% extends 'base.html' %}
{% 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> 填写IDC基本信息 </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">
                        <div class="form-group"><label class="col-sm-2 control-label"> IDC名 </label>
                            <div class="col-sm-8"><input type="text" value="{{ j_idc.name }}" placeholder="北京联通" name="j_idc" 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_idc.comment }}" placeholder="核心联通机房" name="j_comment" class="form-control"></div>
                        </div>

                        {% if edit %}
                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <label for="groups" class="col-lg-2 control-label">主机</label>
                                <div class="col-sm-3">
                                    <select id="groups" name="idc_default" size="12" class="form-control m-b" multiple>
                                        {% for post in posts %}
                                            <option value="{{ post.id }}">{{ post.ip }}</option>
                                        {% endfor %}
                                    </select>
                                </div>
                                <div class="col-sm-1">
                                    <div class="btn-group" style="margin-top: 50px;">
                                        <button type="button" class="btn btn-white" onclick="move('groups', 'groups_selected')"><i class="fa fa-chevron-right"></i></button>
                                        <button type="button" class="btn btn-white" onclick="move_left('groups_selected', 'groups')"><i class="fa fa-chevron-left"></i> </button>
                                    </div>
                                </div>
                                <div class="col-sm-3">
                                    <div>
                                        <select id="groups_selected" name="j_hosts" class="form-control m-b" size="12"  multiple>
                                            {% for post in eposts %}
                                                <option value="{{ post.id }}">{{ post.ip }}</option>
                                            {% endfor %}
                                        </select>
                                    </div>
                                </div>
                            </div>
                        {% endif %}

                        <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="sumbit"> 提交 </button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
$('#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();
    }
});
</script>

{% endblock %}