{% extends "base.html" %}
{% load compress staticfiles %}

{% block title %}My Checks - healthchecks.io{% endblock %}


{% block content %}
<div class="row">
    <div class="col-sm-12">
        <h1>
        {% if request.team == request.user.profile %}
            My Checks
        {% else %}
            {{ request.team.team_name }}
        {% endif %}
        </h1>
    </div>
    {% if tags %}
    <div id="my-checks-tags" class="col-sm-12">
        {% for tag, count in tags %}
            {% if tag in down_tags %}
                <button class="btn btn-danger btn-xs" data-toggle="button">{{ tag }}</button>
            {% elif tag in grace_tags %}
                <button class="btn btn-warning btn-xs" data-toggle="button">{{ tag }}</button>
            {% else %}
                <button class="btn btn-default btn-xs" data-toggle="button">{{ tag }}</button>
            {% endif %}
        {% endfor %}
    </div>
    {% endif %}

</div>
<div class="row">
    <div class="col-sm-12">


    {% if checks %}
        {% include "front/my_checks_mobile.html" %}
        {% include "front/my_checks_desktop.html" %}
    {% else %}
    <div class="alert alert-info">You don't have any checks yet.</div>
    {% endif %}
    </div>
</div>
<div class="row">
    <div class="col-sm-12">
        <form method="post" action="{% url 'hc-add-check' %}" class="text-center">
            {% csrf_token %}
            <input type="submit" class="btn btn-primary btn-lg" value="Add Check">
        </form>
    </div>
</div>

<div id="update-name-modal" class="modal">
    <div class="modal-dialog">
        <form id="update-name-form" class="form-horizontal" method="post">
            {% csrf_token %}
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal">&times;</button>
                    <h4 class="update-timeout-title">Name and Tags</h4>
                </div>
                <div class="modal-body">
                        <div class="form-group">
                            <label for="update-name-input" class="col-sm-2 control-label">
                                Name
                            </label>
                            <div class="col-sm-9">
                                <input
                                    id="update-name-input"
                                    name="name"
                                    type="text"
                                    value="---"
                                    placeholder="unnamed"
                                    class="input-name form-control" />

                                <span class="help-block">
                                    Give this check a human-friendly name,
                                    so you can easily recognize it later.
                                </span>
                            </div>
                        </div>

                        <div class="form-group">
                            <label for="update-tags-input" class="col-sm-2 control-label">
                                Tags
                            </label>
                            <div class="col-sm-9">
                                <input
                                    id="update-tags-input"
                                    name="tags"
                                    type="text"
                                    value=""
                                    placeholder="production www"
                                    class="form-control" />

                                <span class="help-block">
                                    Optionally, assign tags for easy filtering.
                                    Separate multiple tags with spaces.
                                </span>
                            </div>
                        </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
                    <button type="submit" class="btn btn-primary">Save</button>
                </div>
            </div>
        </form>
    </div>
</div>

<div id="update-timeout-modal" class="modal">
    <div class="modal-dialog">
        <form id="update-timeout-form" method="post">
            {% csrf_token %}
            <input type="hidden" name="timeout" id="update-timeout-timeout" />
            <input type="hidden" name="grace" id="update-timeout-grace" />
            <div class="modal-content">
                <div class="modal-body">
                    <div class="update-timeout-info text-center">
                        <span
                            class="update-timeout-label"
                            data-toggle="tooltip"
                            title="Expected time between pings.">
                            Period
                        </span>
                        <span
                            id="period-slider-value"
                            class="update-timeout-value">
                            1 day
                        </span>
                    </div>
                    <div id="period-slider"></div>

                    <div class="update-timeout-info text-center">
                        <span
                            class="update-timeout-label"
                            data-toggle="tooltip"
                            title="When check is late, how much time to wait until alert is sent">
                            Grace Time
                        </span>
                        <span
                            id="grace-slider-value"
                            class="update-timeout-value">
                            1 day
                        </span>
                    </div>

                    <div id="grace-slider"></div>

                    <div class="update-timeout-terms">
                        <p>
                            <span>Period</span>
                            Expected time between pings.
                        </p>
                        <p>
                            <span>Grace Time</span>
                            When a check is late, how much time to wait until alert is sent.
                        </p>
                    </div>

                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
                    <button type="submit" class="btn btn-primary">Save</button>
                </div>
            </div>
        </form>
    </div>
</div>

<div id="remove-check-modal" class="modal">
    <div class="modal-dialog">
        <form id="remove-check-form" method="post">
            {% csrf_token %}
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal">&times;</button>
                    <h4 class="remove-check-title">Remove Check <span class="remove-check-name"></span></h4>
                </div>
                <div class="modal-body">
                    <p>You are about to remove check
                        <strong class="remove-check-name">---</strong>.
                    </p>
                    <p>Once it's gone there is no "undo" and you cannot get
                    the old ping URL back.</p>
                    <p>Are you sure?</p>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
                    <button type="submit" class="btn btn-danger">Remove</button>
                </div>
            </div>
        </form>
    </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/nouislider.min.js' %}"></script>
<script src="{% static 'js/clipboard.min.js' %}"></script>
<script src="{% static 'js/checks.js' %}"></script>
{% endcompress %}
{% endblock %}
