{% extends "simple_service.html" %}
{% comment %}
#
# This file is part of FreedomBox.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
{% endcomment %}

{% load bootstrap %}
{% load i18n %}

{% block page_head %}

  {% if status.setup_running %}
    <meta http-equiv="refresh" content="3" />
  {% endif %}

{% endblock %}


{% block configuration %}

  {% if status.is_setup %}

    <h3>{% trans "Profile" %}</h3>

    <p>
      {% blocktrans trimmed %}
        To connect to {{ box_name }}'s VPN, you need to download a
        profile and feed it to an OpenVPN client on your mobile or
        desktop machine.  OpenVPN Clients are available for most
        platforms.  See
        <a href="https://wiki.debian.org/FreedomBox/Manual/OpenVPN"
           title="{{ box_name }} Manual - OpenVPN">documentation</a> on
        recommended clients and instructions on how to configure them.
      {% endblocktrans %}
    </p>

    <p>
      {% blocktrans trimmed %}
        Profile is specific to each user of {{ box_name }}.  Keep it a
        secret.
      {% endblocktrans %}
    </p>

    <form class="form" method="post" action="{% url 'openvpn:profile' %}">
      {% csrf_token %}

      <input type="submit" class="btn btn-primary"
             value="{% trans "Download my profile" %}"/>
    </form>

  {% endif %}

  <h3>{% trans "Status" %}</h3>

  {% if not status.is_setup and not status.setup_running %}
    <p>
      {% blocktrans trimmed %}
        OpenVPN has not yet been setup.  Performing a secure setup
        takes a very long time.  Depending on how fast your
        {{ box_name }} is, it may even take hours.  If the setup
        is interrupted, you may start it again.
      {% endblocktrans %}
    </p>

    <form class="form" method="post" action="{% url 'openvpn:setup' %}">
      {% csrf_token %}

      <input type="submit" class="btn btn-primary"
             value="{% trans "Start setup" %}"/>
    </form>
  {% endif %}

  {% if not status.is_setup and status.setup_running %}
    <p class="running-status-parent">
      <span class='running-status loading'></span>
      {% trans "OpenVPN setup is running" %}
    </p>

    <p>
      {% blocktrans trimmed %}
        To perform a secure setup, this process takes a very long
        time.  Depending on how fast your {{ box_name }} is, it may
        even take hours.  If the setup is interrupted, you may start
        it again.
      {% endblocktrans %}
    </p>
  {% endif %}

  {% if status.is_setup %}
    <p class="running-status-parent">
      {% if status.is_running %}
        <span class='running-status active'></span>
        {% trans "OpenVPN server is running" %}
      {% else %}
        <span class='running-status inactive'></span>
        {% trans "OpenVPN server is not running" %}
      {% endif %}
    </p>

    {% include "diagnostics_button.html" with module="openvpn" enabled=status.enabled %}

    <h3>{% trans "Configuration" %}</h3>

    <form class="form" method="post">
      {% csrf_token %}

      {{ form|bootstrap }}

      <input type="submit" class="btn btn-primary"
             value="{% trans "Update setup" %}"/>
    </form>
  {% endif %}

{% endblock %}
