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

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

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

    <p>
    If your team uses <a href="https://matrix.org/">Matrix</a>,
    you can set up {% site_name %} to post notifications
    to an appropriate Matrix room.
    </p>

    <h2>Setup Guide</h2>
    <div class="row ai-step">
        <div class="col-sm-6">
            <span class="step-no">1</span>
            <div>
                <p>
                Invite <strong>{{ matrix_user_id }}</strong>
                into your Matrix room.
                </p>
                <p>
                    <strong>Note:</strong> after joining the room,
                    {{ matrix_user_id }} will be
                    able to read its messages.
                    Do not invite to rooms with sensitive content.
                    Consider creating a dedicated room for notifications.
                </p>
            </div>
        </div>
        <div class="col-sm-6">
            <img
                class="ai-guide-screenshot"
                alt="Screenshot"
                src="{% static 'img/integrations/setup_matrix_1.png' %}">
        </div>
    </div>

    <div class="row ai-step">
        <div class="col-sm-6">
            <span class="step-no">2</span>
            <p>
                Look up the room's <strong>alias</strong> or
                <strong>ID</strong>, and paste it in the form
                below and save the integration.
            </p>
        </div>
        <div class="col-sm-6">
            <img
                class="ai-guide-screenshot"
                alt="Screenshot"
                src="{% static 'img/integrations/setup_matrix_2.png' %}">
        </div>
    </div>

    <div class="row ai-step">
        <div class="col-sm-6">
            <span class="step-no">3</span>
            <p>
                {{ matrix_user_id }} will shortly join your room.
                After that, you are all set! From now on
                {% site_name %} will post notifications
                to your room when checks go down or up.
            </p>
        </div>
        <div class="col-sm-6">
            <img
                class="ai-guide-screenshot"
                alt="Screenshot"
                src="{% static 'img/integrations/setup_matrix_3.png' %}">
        </div>
    </div>

    <h2>Integration Settings</h2>

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

        <div class="form-group {{ form.room_id.css_classes }}">
            <label for="alias" class="col-sm-2 control-label">Room Alias or ID</label>
            <div class="col-sm-6">
                <input
                    id="alias"
                    type="text"
                    class="form-control"
                    name="alias"
                    placeholder="!abc:matrix.org"
                    value="{{ form.alias.value|default:"" }}">

                {% if form.alias.errors %}
                <div class="help-block">
                    {{ form.alias.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 %}
