{% extends "../base.html" %}

{% block content1 %}                                                
<table border="0" cellpadding="0" cellspacing="0" width="100%">
    <tr>
        <td valign="top" align="right" class="textContent">
            <table border="0" cellpadding="0" cellspacing="0" width="100%">
                <tr>
                    <td align="center" valign="top" class="status_{{level}}">
                        {{ level.upper() }} [{{alert.name}}]
                        {% if target %} - {{ target }} {% end %}
                    </td>
                </tr>
                <tr>
                    <td align="center" valign="top" class="statusValue">
                        Value: {{ alert.convert(value) }}
                    </td>
                </tr>
            </table>

        </td>
    </tr>
</table>
{% end %}

{% block content2 %}
<table border="0" cellpadding="0" cellspacing="0" width="100%">
    <tr>
        <td align="center" valign="top" class="textContent">

            <b>Time:</b> {{ dt.datetime.now().strftime('%H:%M %d/%m/%Y') }}</b> <br/>

            <b>Method:</b> {{ alert.method }}</b> <br/>

            <b>Query:</b> {{ alert.query }}</b> <br/>

            {% if rule %}
                <b>Rule:</b> {{ rule['raw'] }}</b> <br/>
            {% end %}

            {% if target %}
                <b>Target:</b> {{ target }}</b> <br/>
                {% if alert.history[target] %}
                <b>History:</b> {{ [ alert.convert(v) for v in alert.history[target][:100] ] }} <br/> {% end %}
            {% end %}

            {% if target and rule %}
            {% for expr in filter(lambda x: isinstance(x, dict), rule['exprs']) %}
                <b>Tested value:</b> {{ alert.convert(alert.get_value_for_expr(expr, target)) }}</b> <br/>
            {% end %}
            {% end %}

        </td>
    </tr>
    <tr>
        <td align="center" valign="top" class="bottomShim">
            <img src="{{alert.get_graph_url(alert.query, graphite_url)}}" alt="graph"/>
            <br/> <br/>
            <table border="0" cellpadding="0" cellspacing="0" width="260" class="emailButton">
                <tr>
                    <td align="center" valign="middle" class="buttonContent">
                        <a href="{{alert.get_graph_url(alert.query, graphite_url)}}" target="_blank">Open the graph</a>
                    </td>
                </tr>
            </table>
        </td>
    </tr>
</table>
{% end %}
