<div class="panel panel-default">
    <div class="panel-body">
        <br>{{$node := .node}}
        <form class="form-horizontal" method="post" action="{{if $node}} /node/modify {{else}} /node/save {{end}}">
            <div class="form-group">
                <label class="col-sm-2 control-label"><span class="text-danger"> * </span> 节点IP </label>
                <div class="col-sm-4">
                    <input type="text" name="ip" class="form-control" value="{{$node.ip}}" placeholder="请输入节点IP" required>
                </div>
            </div>
			<div class="form-group">
                <label class="col-sm-2 control-label"><span class="text-danger"> * </span> 端口 </label>
                <div class="col-sm-4">
                    <input type="text" name="port" class="form-control" value="{{$node.port}}" placeholder="请输入节点端口" required>
                </div>
            </div>
            {{if $node}}
            <div class="form-group">
                <label class="col-sm-2 control-label"><span class="text-danger"> * </span> Token </label>
                <div class="col-sm-4">
                    <input type="text" name="token" class="form-control" value="{{$node.token}}" placeholder="请输入节点token" required>
                </div>
            </div>
            {{end}}
            <input type="hidden" name="node_id" class="form-control" value="{{$node.node_id}}">
            <div class="form-group">
                <label class="col-sm-2 control-label"><span class="text-danger"> * </span> 节点组 </label>
                <div class="col-sm-4">
                    <select data-placeholder="  请点击选择节点组" class="chosen-select" multiple tabindex="4" name="nodes_ids">
                        {{range $nodeGroup := $.nodeGroups}}
                        {{if $node}}
                        <option value="{{$nodeGroup.nodes_id}}"  {{if eq $nodeGroup.is_default "1"}} selected {{end}}>{{$nodeGroup.name}}</option>
                        {{else}}
                        <option value="{{$nodeGroup.nodes_id}}">{{$nodeGroup.name}}</option>
                        {{end}}
                        {{end}}
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label"> 备注 </label>
                <div class="col-sm-4">
                    <input type="text" name="comment" class="form-control" value="{{$node.comment}}" placeholder="请输入节点备注" required>
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-offset-2 col-sm-10">
                    <button type="button" onclick="Form.ajaxSubmit(this.form, {{if $node}} true {{else}} false {{end}})" class="btn btn-primary">保存</button>
                </div>
            </div>
        </form>
    </div>
</div>
<script>
    $(function() {
        $('.chosen-select').chosen();
        $('.chosen-select-deselect').chosen({ allow_single_deselect: true });
    });
</script>