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

{% block title %}OpsGenie Integration for {{ site_name }}{% endblock %}


{% block content %}
<div class="row">
<div class="col-sm-12">
    <h1>OpsGenie</h1>

    <p><a href="https://www.opsgenie.com/">OpsGenie</a> provides
    alerting, on-call scheduling, escalation policies and incident tracking.
    You can can integrate it with your {{ site_name }} account in few
    simple steps.</p>

    <h2>Setup Guide</h2>
    <div class="row ai-step">
        <div class="col-sm-6">
            <span class="step-no"></span>
            <p>
                Log into your OpsGenie account,
                go to <strong>Settings › Integration list</strong>,
                and add a new "API" integration.
            </p>
            <p>
                Give it a descriptive name, select its team, then
                save the integration.
            </p>

        </div>
        <div class="col-sm-6">
            <img
                class="ai-guide-screenshot"
                alt="Screenshot"
                src="{% static 'img/integrations/setup_opsgenie_1.png' %}">
        </div>
    </div>
    <div class="row ai-step">
        <div class="col-sm-6">
            <span class="step-no"></span>
            After adding the new integration, take note of its
            <strong>API Key</strong>, a long string
            of letters and digits.

        </div>
        <div class="col-sm-6">
            <img
                class="ai-guide-screenshot"
                alt="Screenshot"
                src="{% static 'img/integrations/setup_opsgenie_2.png' %}">
        </div>
    </div>

    <div class="row ai-step">
        <div class="col-sm-6">
            <span class="step-no"></span>
            <p>Paste the API Key down below, and make sure the correct
                <strong>service region</strong> is selected.
                Save the integration, and you are done!
            </p>
        </div>
    </div>

    <h2>Integration Settings</h2>

    <form method="post" class="form-horizontal">
        {% csrf_token %}
        <div class="form-group {{ form.key.css_classes }}">
            <label for="api-key" class="col-sm-2 control-label">API Key</label>
            <div class="col-sm-4">
                <input
                    id="api-key"
                    type="text"
                    class="form-control"
                    name="key"
                    placeholder=""
                    value="{{ form.key.value|default:"" }}">

                {% if form.key.errors %}
                <div class="help-block">
                    {{ form.key.errors|join:"" }}
                </div>
                {% endif %}
            </div>
        </div>
        <div class="form-group {{ form.region.css_classes }}">
            <label for="api-key" class="col-sm-2 control-label">Region</label>
            <div class="col-sm-4">
                <label class="radio-container">
                    <input
                        type="radio"
                        name="region"
                        value="us"
                        {% if form.region.value == "us" %} checked {% endif %}>
                    <span class="radiomark"></span>
                    US (default)
                </label>
                <label class="radio-container">
                    <input
                        type="radio"
                        name="region"
                        value="eu"
                        {% if form.region.value == "eu" %} checked {% endif %}>
                    <span class="radiomark"></span>
                    EU
                </label>

                {% if form.region.errors %}
                <div class="help-block">
                    {{ form.region.errors|join:"" }}
                </div>
                {% endif %}
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-offset-2 col-sm-10">
                <button type="submit" class="btn btn-primary">Save Integration</button>
            </div>
        </div>
    </form>
</div>
</div>
{% endblock %}
