{% extends "base.html" %}
{% load compress humanize static hc_extras %}

{% block title %}Add Pushover - {% site_name %}{% endblock %}


{% block content %}
<div class="row">
<div class="col-sm-12">
    <h1>Pushbover</h1>
    <div class="jumbotron">
        {% if request.user.is_authenticated %}
        <p>
            <a href="https://www.pushover.net/">Pushover</a> delivers
            real-time notifications on your Android, iPhone, iPad, Desktop,
            Android Wear and Apple Watch. You can set up {% site_name %} to
            receive Pushover notifications in a few simple steps.
        </p>
        {% else %}
        <p>
        {% site_name %} is a <strong>free</strong> and
        <a href="https://github.com/healthchecks/healthchecks">open source</a>
        service for monitoring your cron jobs, background processes and
        scheduled tasks. Before adding Pushover integration, please log into
        {% site_name %}:</p>

        <div class="text-center">
            <a href="{% url 'hc-login' %}?next={% url 'hc-add-pushover' %}"
               class="btn btn-primary btn-lg">Sign In</a>
        </div>
        {% endif %}
    </div>

    {% if not request.user.is_authenticated %}
    <h2>Setup Guide</h2>

    <div class="row ai-step">
        <div class="col-sm-6">
            <span class="step-no">1</span>
            <p>
                After logging in, go to "Integrations &rarr; Add Pushover".
                Pushover supports different notification priorities from
                silent to "Emergency". Select your preferred priorities
                and click "Subscribe with Pushover".
            </p>
        </div>
        <div class="col-sm-6">
            <img
                class="ai-guide-screenshot"
                alt="Screenshot"
                src="{% static 'img/integrations/setup_pushover_1.png' %}">
        </div>
    </div>

    <div class="row ai-step">
        <div class="col-sm-6">
            <span class="step-no">2</span>
            <p>
                You will be redirected to
                <a href="https://pushover.net">pushover.net</a> and
                asked to confirm a subscription. Review the subscription
                details and click "Subscribe Me".
            </p>
        </div>
        <div class="col-sm-6">
            <img
                class="ai-guide-screenshot"
                alt="Screenshot"
                src="{% static 'img/integrations/setup_pushover_2.png' %}">
        </div>
    </div>

    <div class="row ai-step">
        <div class="col-sm-6">
            <span class="step-no">3</span>
            <p>
                That is all! You will now be redirected back to
                "Integrations" page on {% site_name %} and see
                the new integration!
            </p>
        </div>
        <div class="col-sm-6">
            <img
                class="ai-guide-screenshot"
                alt="Screenshot"
                src="{% static 'img/integrations/setup_pushover_3.png' %}">
        </div>
    </div>

    {% else %}
    <h2>Integration Settings</h2>

    <form id="add-pushover" method="post" class="form-horizontal" action="{% url 'hc-add-pushover' %}">
        {% csrf_token %}
        <div class="form-group">
            <label class="col-sm-3 control-label">Priority for "down" events</label>
            <div class="col-sm-8">
                <select name="po_priority" class="selectpicker form-control">
                    <option
                        value="-2"
                        data-content="Lowest Priority. <span class='help'>Generates no notification on your device.</span>">
                        Lowest Priority
                    </option>
                    <option
                        value="-1"
                        data-content="Low Priority. <span class='help'>Sends a quiet notification.</span>">
                        Low Priority
                    </option>
                    <option value="0" selected="selected">
                        Normal Priority
                    </option>
                    <option
                        value="1"
                        data-content="High Priority. <span class='help'>Bypasses user's quiet hours.</span>">
                        High Priority
                    </option>
                    <option
                        value="2"
                        data-content="Emergency Priority. <span class='help'>Repeated every {{po_retry_delay|hc_duration }} for at most {{ po_expiration|hc_duration }} until you acknowledge them.</span>">
                        Emergency Priority
                    </option>
                </select>
           </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">Priority for "up" events</label>
            <div class="col-sm-8">
                <select name="po_priority_up" class="selectpicker form-control">
                    <option
                        value="-2"
                        data-content="Lowest Priority. <span class='help'>Generates no notification on your device.</span>">
                        Lowest Priority
                    </option>
                    <option
                        value="-1"
                        data-content="Low Priority. <span class='help'>Sends a quiet notification.</span>">
                        Low Priority
                    </option>
                    <option value="0" selected="selected">
                        Normal Priority
                    </option>
                    <option
                        value="1"
                        data-content="High Priority. <span class='help'>Bypasses user's quiet hours.</span>">
                        High Priority
                    </option>
                    <option
                        value="2"
                        data-content="Emergency Priority. <span class='help'>Repeated every {{po_retry_delay|hc_duration }} for at most {{ po_expiration|hc_duration }} until you acknowledge them.</span>">
                        Emergency Priority
                    </option>
                </select>
           </div>
        </div>

        <div class="form-group">
            <div class="col-sm-offset-3 col-sm-8">
                <button type="submit" class="btn btn-default">
                    <img class="ai-icon" src="{% static 'img/integrations/po.png' %}" alt="Pushover" />
                    Subscribe with Pushover
                </button>
            </div>
        </div>
    </form>
    {% endif %}
</div>
</div>
{% endblock %}

{% block scripts %}
{% compress js %}
<script src="{% static 'js/jquery-2.1.4.min.js' %}"></script>
<script src="{% static 'js/bootstrap.min.js' %}"></script>
<script src="{% static 'js/bootstrap-select.min.js' %}"></script>
{% endcompress %}
{% endblock %}
