<title>RtspLiveServer</title>

<div class="layui-card layadmin-header">
    <div class="layui-breadcrumb" lay-filter="breadcrumb">
        <a><cite>视频管理</cite></a>
        <a><cite>推流集群</cite></a>
    </div>
</div>

<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-header">RtspLiveCluster集群服务配置</div>
        <div class="layui-form layui-card-header layuiadmin-card-header-auto" lay-filter="layuiadmin-form">
            <div class="layui-form-item">
                <label class="layui-form-label">客户端标识</label>
                <div class="layui-input-inline" style="width:400px">
                    <input type="text" name="clientid" placeholder="同一集群服务不允许重复" maxlength="50" 
                        autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">IP地址</label>
                <div class="layui-input-inline" style="width:400px">
                    <input type="text" name="ip" value="" placeholder="集群服务IP" maxlength="50" autocomplete="off"
                        class="layui-input" />
                </div>
            </div>  
            <div class="layui-form-item">
                <label class="layui-form-label">端口</label>
                <div class="layui-input-inline" style="width:400px">
                    <input type="text" name="port" value="" placeholder="集群服务端口" maxlength="5" autocomplete="off"
                        class="layui-input" />
                </div>
            </div>  
            <div class="layui-form-item">
                <label class="layui-form-label">用户</label>
                <div class="layui-input-inline" style="width:400px">
                    <input type="text" name="username" value="" placeholder="集群用户名" maxlength="50" autocomplete="off"
                        class="layui-input" />
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">密码</label>
                <div class="layui-input-inline" style="width:400px">
                    <input type="password" name="password" value="" placeholder="集群密码" maxlength="50" autocomplete="off"
                        class="layui-input" />
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label"></label>
                <div class="layui-input-inline">
                    <input type="button" lay-submit lay-filter="LAY-front-submit" value="保存" class="layui-btn">
                </div>
            </div>
        <blockquote class="layui-elem-quote">说明:
            <ol>
                <li>1、启用集群功能支持将音视频推流至RTMP服务器；</li>
                <li>2、停用集群功能请将填写的信息清除并保存即可；</li>

            </ol>

        </blockquote>

        </div>

        <script>
            layui.use(['admin', 'auth', 'form'], function () {
                var $ = layui.$
                    , form = layui.form;


            })
        </script>
    </div>
</div>

<script>
    layui.use(['admin', 'form'], function () {
        var $ = layui.$
            , admin = layui.admin
            , view = layui.view
            , form = layui.form;

        form.render(null, 'layuiadmin-form');

        form.on('submit(LAY-front-submit)', function (data) {
            var field = data.field;
            $.ajax(
                {
                    type: "POST",
                    url: '/api/cluster/save',
                    cache: false,//禁止缓存
                    data: field,
                    error: function (XMLHttpRequest, textStatus, errorThrown) {
                        var res = XMLHttpRequest.responseJSON;
                        if (res != undefined)
                            layer.msg(res.message, { icon: 0, time: 2000 });
                    },
                    success: function (data) {
                        layer.msg('保存成功', {icon: 1, time: 2000});
                    }
                });
        });
        function search(){
            $.ajax(
                {
                    type: "get",
                    url: '/api/cluster/get',
                    cache: false,//禁止缓存
                    error: function (XMLHttpRequest, textStatus, errorThrown) {
                        var res = XMLHttpRequest.responseJSON;
                        if (res != undefined)
                            layer.msg(res.message, { icon: 0, time: 2000 });
                    },
                    success: function (data) {
                         $('input[name="clientid"]').val(data.clientid);
                         $('input[name="ip"]').val(data.ip);
                         $('input[name="port"]').val(data.port);
                         $('input[name="username"]').val(data.username);
                         $('input[name="password"]').val(data.password);

                    }
                });
        }
        search();
    });
</script>