{% extends 'wgcomm/base.html' %}

{% block title %}
    SearchController
{% endblock %}
{% block tail %}
    <script src="{{ url_for('static',filename='wgcomm/js/setup-search-controller.js') }}"></script>
    {#    <script src="{{ url_for('static',filename='assets/js/axios.js') }}"></script>#}
{% endblock %}
{% block tail_min %}
    <script src="{{ url_for('static',filename='wgcomm/js/setup-search-controller.min.js') }}"></script>
    {#    <script src="{{ url_for('static',filename='assets/js/axios.min.js') }}"></script>#}
{% endblock %}
{% block main_content %}
    <!--app-content open-->
    <div class="app-content main-content mt-0">
        <div class="side-app">
            <!-- CONTAINER -->
            <div class="main-container container-fluid">
                <!-- PAGE-HEADER -->
                <div class="page-header">
                    <div>
                        <h1 class="page-title">SearchController</h1>
                    </div>
                    <div class="ms-auto pageheader-btn">
                        <ol class="breadcrumb">
                            <li class="breadcrumb-item">Configuration</li>
                            <li class="breadcrumb-item">SearchController</li>
                        </ol>
                    </div>
                </div>
                <!-- PAGE-HEADER END -->
                {% with messages = get_flashed_messages() %}
                    {% if messages %}
                        <div class="form-group">
                            <ul>
                                {% for message in messages %}
                                    <li class="text-danger">{{ message }}</li>
                                {% endfor %}
                            </ul>
                        </div>
                    {% endif %}
                {% endwith %}
                <!-- row -->
                <div class="row">
                    <div class="col-md-12 mb-3">
                        <div class="btn-list">
                            {% if g.extfunc5678_develop_mode %}
                            {% else %}
                                <button href="#" class="btn btn-primary" id="btnautoaddall">
                                    <i class="fe fe-plus-square"></i>Auto Add The followed Controllers
                                </button>
                            {% endif %}
                            <button class="btn btn-primary-light" onclick="location.reload()">Refresh page  </button>
                        </div>

                        <p class="card-text text-warning" id="opSelectedResultInfo" hidden></p>
                        {% if deleteUrl!="/" %}
                            <h1 class="page-title" style="color: red">1001 service connection failed, please verify if 1001 service is enabled  ???</h1>
                        {% endif %}
                    </div>
                    <input type="hidden" name="wgserver1001" id="wgserver1001"
                           value="{{ g.wgwsserver1001 }}">
                    <!--ROW OPENED-->

                    <div class="col-lg-12 col-md-12" id="editnetconfig" hidden="hidden">
                        <div class="card">
                            <input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
                            {{ wgform._csrf }}

                            <div class="card-header border-bottom">
                                <h4 class="mb-0">Net Configuration</h4>
                            </div>
                            <div class="card-body">

                                <div class="col-sm-12 col-md-12 col-xl-3">
                                    <div class="form-group">
                                        {{ wgform.f_ControllerSN.label }}
                                        {{ wgform.f_ControllerSN( class="form-control", readonly ="true") }}
                                    </div>
                                </div>
                                <div class="col-sm-12 col-md-12 col-xl-3">
                                    <div class="form-group">
                                        {{ wgform.f_MAC.label }}
                                        {{ wgform.f_MAC( class="form-control", readonly ="true") }}
                                    </div>
                                </div>
                                <div class="col-sm-12 col-md-12 col-xl-3">
                                    <div class="form-group">
                                        {{ wgform.f_DHCP.label }}
                                        <select class="form-control  form-select text-dark"
                                                id="f_DHCP" name="f_DHCP"
                                                tabindex="-1" aria-hidden="true">
                                            <option value="1" {% if wgform.f_DHCP.data==1 %}
                                                    selected {% endif %}>DHCP
                                            </option>
                                            <option value="0"{% if wgform.f_DHCP.data==0 %}
                                                    selected {% endif %}>Static IP
                                            </option>
                                        </select>
                                    </div>
                                </div>
                                <div id='ipconfiginfo' {% if wgform.f_DHCP.data!='0' %} hidden="hidden" {% endif %} >
                                    <div class="col-sm-12 col-md-12 col-xl-3">
                                        <div class="form-group">
                                            {{ wgform.f_IP.label }}
                                            {{ wgform.f_IP( class="form-control text-dark") }}

                                        </div>
                                    </div>
                                    <div class="col-sm-12 col-md-12 col-xl-3">
                                        <div class="form-group">
                                            {{ wgform.f_MASK.label }}
                                            {{ wgform.f_MASK( class="form-control text-dark") }}

                                        </div>
                                    </div>

                                    <div class="col-sm-12 col-md-12 col-xl-3">
                                        <div class="form-group">
                                            {{ wgform.f_Gateway.label }}
                                            {{ wgform.f_Gateway( class="form-control text-dark") }}
                                        </div>
                                    </div>
                                </div>
                                <div class="col-sm-12 col-md-12 col-xl-3" id="UdpServerIP" hidden="hidden">
                                    <div class="form-group">
                                        {{ wgform.f_UdpServerIP.label }}
                                        {{ wgform.f_UdpServerIP( class="form-control text-dark") }}
                                    </div>
                                </div>
                                <div class="col-sm-12 col-md-12 col-xl-3" id="UdpServerPort" hidden="hidden">
                                    <div class="form-group">
                                        {{ wgform.f_UdpServerPort.label }}
                                        {{ wgform.f_UdpServerPort( class="form-control text-dark") }}
                                    </div>
                                </div>
                                <div class="col-sm-12 col-md-12 col-xl-3" id="TcpServerIP">
                                    <div class="form-group">
                                        {{ wgform.f_TcpServerIP.label }}
                                        {{ wgform.f_TcpServerIP( class="form-control text-dark") }}
                                    </div>
                                </div>
                                <div class="col-sm-12 col-md-12 col-xl-3" id="TcpServerPort" hidden="hidden">
                                    <div class="form-group">
                                        {{ wgform.f_TcpServerPort.label }}
                                        {{ wgform.f_TcpServerPort( class="form-control text-dark") }}
                                    </div>
                                </div>
                                {% if pcip %}
                                    <div class="col-sm-12 col-md-12 col-xl-3">
                                        <div class="form-group"><label id="pcip">*PC IP Address: {{ pcip }}</label></div>
                                    </div>
                                {% endif %}
                            </div>
                            <div class="row p-5">
                                <div class="col-sm-12 col-md-12 col-xl-3">
                                    <div class="btn-list text-end">
                                        <button id="submitcancel" name="submitcancel" class="btn btn-outline-danger"
                                                value="Cancel">
                                            <i class="fe fe-x-circle"></i>
                                            Cancel
                                        </button>
                                        <button id="submitsave" name="submitsave" class="btn btn-primary" type="submit"
                                                value="Save">
                                            <i class="fe fe-check-circle"></i>
                                            OK
                                        </button>
                                    </div>
                                </div>

                            </div>
                        </div>
                    </div>

                    <div class="col-lg-12 col-md-12" id="wifinetconfig" hidden="hidden">
                        <div class="card">
                            <input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
                            {{ wgformwifi._csrf }}

                            <div class="card-header border-bottom">
                                <h4 class="mb-0">Wi-FiConfigure</h4>
                            </div>
                            <div class="card-body">
                                <div class="col-sm-12 col-md-12 col-xl-3">
                                    <div class="form-group">
                                        {{ wgformwifi.f_Wi_Fi_ControllerSN.label }}
                                        {{ wgformwifi.f_Wi_Fi_ControllerSN( class="form-control", readonly ="true") }}
                                    </div>
                                </div>
                                <div class="col-sm-12 col-md-12 col-xl-3">
                                    <div class="form-group">
                                        {{ wgformwifi.f_Wi_Fi_Name.label }}
                                        {{ wgformwifi.f_Wi_Fi_Name( class="form-control text-dark") }}
                                    </div>
                                </div>
                                <div class="col-sm-12 col-md-12 col-xl-3">
                                    <div class="form-group">
                                        {{ wgformwifi.f_Wi_Fi_Password.label }}
                                        {{ wgformwifi.f_Wi_Fi_Password( class="form-control text-dark") }}
                                    </div>
                                </div>
                                <div class="col-sm-12 col-md-12 col-xl-3">
                                    <div class="form-group">
                                        {{ wgformwifi.f_Wi_Fi_TcpServerIP.label }}
                                        {{ wgformwifi.f_Wi_Fi_TcpServerIP( class="form-control text-dark") }}
                                    </div>
                                </div>

                                <div class="col-sm-12 col-md-12 col-xl-3" hidden="hidden">
                                    <div class="form-group">
                                        {{ wgformwifi.f_Wi_Fi_TcpServerPort.label }}
                                        {{ wgformwifi.f_Wi_Fi_TcpServerPort( class="form-control text-dark") }}
                                    </div>
                                </div>
                                <div class="col-sm-12 col-md-12 col-xl-3" hidden="hidden">
                                    <div class="form-group">
                                        {{ wgformwifi.f_Wi_Fi_UdpServerIP.label }}
                                        {{ wgformwifi.f_Wi_Fi_UdpServerIP( class="form-control text-dark") }}
                                    </div>
                                </div>
                                <div class="col-sm-12 col-md-12 col-xl-3" hidden="hidden">
                                    <div class="form-group">
                                        {{ wgformwifi.f_Wi_Fi_UdpServerPort.label }}
                                        {{ wgformwifi.f_Wi_Fi_UdpServerPort( class="form-control text-dark") }}
                                    </div>
                                </div>
                                {% if pcip %}
                                    <div class="col-sm-12 col-md-12 col-xl-3">
                                        <div class="form-group"><label id="pcip">*PC IP Address: {{ pcip }}</label></div>
                                    </div>
                                {% endif %}
                            </div>
                            <div class="row p-5">
                                <div class="btn-list text-start">
                                    <button id="wifisubmitcancel" name="wifisubmitcancel" class="btn btn-outline-danger"
                                            value="Cancel">
                                        <i class="fe fe-x-circle"></i>
                                        Cancel
                                    </button>
                                    <button id="wifisubmitsave" name="wifisubmitsave" class="btn btn-primary"
                                            type="submit"
                                            value="Save">
                                        <i class="fe fe-check-circle"></i>
                                        OK
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="row">

                        <div class="col-lg-12 col-xl-12" id="controllerlist-frame">
                            <div class="col-md-12">
                                <div class="card">
                                    <div id="calendar3" class="fc fc-media-screen fc-direction-ltr fc-theme-standard">
                                        <div class="card-body">
                                            <div class="fc-view-harness fc-view-harness-active" style="height: 300px;">
                                                <div class="fc-list  fc-list-sticky fc-listMonth-view fc-view">
                                                    <div class="fc-scroller fc-scroller-liquid" id="logscroll"
                                                         style="overflow: hidden auto;">
                                                        <div class="table-responsive">
                                                            <table class="table table-bordered text-nowrap border-bottom wp-100"
                                                                    {#                                                               id="basic-datatable">#}
                                                                   id="controller-datatable">
                                                                <thead class="table-head">
                                                                <tr>
                                                                    <th class="bg-transparent border-bottom-0">ID</th>
                                                                    <th class="bg-transparent border-bottom-0">
                                                                        Controller SN  
                                                                    </th>
                                                                    <th class="bg-transparent border-bottom-0">IP</th>
                                                                    <th class="bg-transparent border-bottom-0">
                                                                        Acquisition method  
                                                                    </th>
                                                                    <th class="bg-transparent border-bottom-0">
                                                                        Receiving server  
                                                                    </th>
                                                                    <th class="bg-transparent border-bottom-0">
                                                                        Driver Version
                                                                    </th>
                                                                    <th class="bg-transparent border-bottom-0">Operation</th>
                                                                </tr>
                                                                </thead>
                                                                <tbody class="table-body" id="controllerlist">
                                                                {#                                                                  <tr id="con-1-src">#}
                                                                {#                                                                    <td class="text-muted fs-15 fw-semibold text-start">226000002</td>#}
                                                                {#                                                                    <td class="text-muted fs-15 fw-semibold text-start">226000002</td>#}
                                                                {#                                                                    <td class="text-muted fs-15 fw-semibold text-start">192.168.168.123</td>#}
                                                                {#                                                                    <td class="text-muted fs-15 fw-semibold text-start">Static IP</td>#}
                                                                {#                                                                    <td class="text-muted fs-15 fw-semibold text-start">192.168.168.153:61005(TCP)</td>#}
                                                                {#                                                                    <td class="text-muted fs-15 fw-semibold text-start">V10.53</td>#}
                                                                {#                                                                    <td class="text-muted fs-15 fw-semibold text-start"><button href="#"#}
                                                                {#                                                            class="btn btn-primary"#}
                                                                {#                                                            data-id="226000002"#}
                                                                {#                                                            data-sn="226000002"#}
                                                                {#                                                    >Edit网络Configure</button></td>#}
                                                                {#                                                                </tr>#}
                                                                </tbody>
                                                            </table>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                            {% if pcip %}
                                                <div class="col-sm-12 col-md-12 col-xl-3">
                                                    <div class="form-group"><label
                                                            id="pcip">*PC IP Address: {{ pcip }}</label></div>
                                                </div>
                                            {% endif %}
                                        </div>
                                    </div>

                                </div>

                            </div>
                        </div>
                        {#                    <div class="col-lg-8 col-xl-8">#}
                        <div class="col-lg-4 col-xl-4"></div>
                    </div>
                    <div class="col-lg-12 col-xl-12">
                        <input type="hidden" name="allcontrollerscnt" id="allcontrollerscnt"
                               value="0">
                        <div class="row" id="allcontrollersid">
                            {#                            {% for con in objlist %}#}
                            {#                                <div class="col-xl-2 col-md-4 col-sm-6">#}
                            {#                                    <div class="card p-0 ">#}
                            {#                                        <div class="d-flex align-items-center px-3 pt-3">#}
                            {#                                            <div class="float-end ms-auto"#}
                            {#                                                 id="{{ con.f_ControllerSN }}-{{ con.f_DoorNO }}op" hidden>#}
                            {#                                                <a href="#" class="option-dots" data-bs-toggle="dropdown"#}
                            {#                                                   aria-haspopup="true"#}
                            {#                                                   aria-expanded="false"><i class="fe fe-more-vertical"></i></a>#}
                            {#                                                <div class="dropdown-menu dropdown-menu-start folder-options">#}
                            {#                                                    <button href="#"#}
                            {#                                                            class="dropdown-item active-btnquerycontroller"#}
                            {#                                                            data-id="{{ con.f_ControllerSN }}-{{ con.f_DoorNO }}"#}
                            {#                                                            data-sn="{{ con.f_ControllerSN }}"#}
                            {#                                                            data-doorno="{{ con.f_DoorNO }}"#}
                            {#                                                            data-name="{{ con.f_DoorName }}"#}
                            {#                                                    ><i class="typcn typcn-spanner">Check</i></button>#}
                            {#                                                    <button href="#"#}
                            {#                                                            class="dropdown-item active-btnadjusttime"#}
                            {#                                                            data-id="{{ con.f_ControllerSN }}-{{ con.f_DoorNO }}"#}
                            {#                                                            data-sn="{{ con.f_ControllerSN }}"#}
                            {#                                                            data-doorno="{{ con.f_DoorNO }}"#}
                            {#                                                            data-name="{{ con.f_DoorName }}"#}
                            {#                                                    ><i class="typcn typcn-stopwatch">Adjust Time</i></button>#}
                            {#                                                    <button href="#"#}
                            {#                                                            class="dropdown-item active-btnopendoor"#}
                            {#                                                            data-id="{{ con.f_ControllerSN }}-{{ con.f_DoorNO }}"#}
                            {#                                                            data-sn="{{ con.f_ControllerSN }}"#}
                            {#                                                            data-doorno="{{ con.f_DoorNO }}"#}
                            {#                                                            data-name="{{ con.f_DoorName }}"#}
                            {#                                                    ><i class="typcn typcn-lock-open">Remote Open</i></button>#}
                            {#                                                </div>#}
                            {#                                            </div>#}
                            {#                                        </div>#}
                            {#                                        <div class="card-body pt-0 text-center">#}
                            {#                                            <div class="door-icon">#}
                            {#                                                <img src="static/wgcomm/images/pConsole_Door_Unknown.png" alt="img"#}
                            {#                                                     class="br-7" id="{{ con.f_ControllerSN }}-{{ con.f_DoorNO }}img">#}
                            {#                                            </div>#}
                            {#                                            <div style="padding-top: 8px">#}
                            {#                                                <h6 class="mb-1 font-weight-semibold">{{ con.f_DoorName }}</h6>#}
                            {#                                            </div>#}
                            {#                                            <span class="text-muted fs-11"#}
                            {#                                                  id="{{ con.f_ControllerSN }}-{{ con.f_DoorNO }}">Unconnected</span>#}
                            {#                                        </div>#}
                            {#                                    </div>#}
                            {#                                </div>#}
                            {#                            {% endfor %}#}
                        </div>
                    </div>
                    <!--ROW CLOSED-->
                </div>
            </div>
        </div>
    </div>
    <!-- CONTAINER CLOSED -->
{% endblock %}
