<div class="row mt-2">
    <div class="col-md-12">
        <div class="card">
            <div class="card-header">
                <a class="card-link" data-toggle="collapse" href="#collapseproxy">
                    Proxy settings
                </a>
            </div>
            <div id="collapseproxy" class="collapse show" data-parent="#accordion">
                <div class="card-body">
                    <div class="row">
                        <div class="col-md-6">
                            <strong>Proxy server</strong>
                            <p>The proxy server intercepts HTTP(S) requests from the device.</p>
                            {% if proxy_running %}
                            <button class="btn btn-danger" onclick="kill_proxy()">Stop proxy</button>
                            {% else %}
                            <button class="btn btn-success" onclick="start_proxy()">Start proxy</button>
                            {% endif %}
                            <hr/>
                            <strong>Certificate</strong>
                            <br/>
                            {% if certificate %}
                            <p class="text-info">{{ certificate }}</p>
                            <button class="btn btn-info" onclick="install_certificate()">(Re)install certificate
                            </button>
                            <button class="btn btn-danger" onclick="remove_certificate()">Remove certificate</button>
                            {% else %}
                            <p class="text-danger">CA cert not found, this will be automatically generated by the
                                proxy.</p>
                            {% endif %}
                            <hr/>
                            <strong>Device proxy</strong>
                            <br/>
                            {% if not proxy_enabled %}
                            <button class="btn btn-info" onclick="enable_proxy()">Enable device proxy</button>
                            {% else %}
                            <p class="text-success">Proxy server on device: {{ proxy_enabled }}</p>
                            <button class="btn btn-danger" onclick="disable_proxy()">Remove device proxy</button>
                            {% endif %}
                            <hr/>
                            <strong>Proxy request parser</strong>
                            <p>The proxy collector loads raw requests and responses from Kafka and runs security checks
                                on them.</p>
                            <br/>
                            {% if not collector_running %}
                            <button class="btn btn-success" onclick="start_collector()">Enable proxy collector</button>
                            {% else %}
                            <p class="text-success">Collector running with pid: {{ collector_running }}</p>
                            <button class="btn btn-danger" onclick="kill_collector()">Disable device collector</button>
                            {% endif %}
                            <hr/>
                            <a href="{{ url_for('get_http_requests', application=application.identifier) }}"
                               class="btn btn-warning" target="_blank">View live requests</a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>