{% extends "base_status.html" %}

{% block title %}Edit Check Command{% endblock %}
{% block smallheader %}edit{% endblock %}
{% block largeheader %}Check Command{% endblock %}
{% block nav1 %}misc{% endblock %}

{% block toolbar %}
{% endblock %}
{% block content %}

    {% if form %}
        <div class=row>
            <div class=span11>
            {% if form.results %}
                <h4>Parsed Plugin Output</h4> <a href="{% url misc.views.test  %}">Click here for a new paste</a>
                <table class="table table-condensed" border=1>
                    <tr>
                        <td>Plugin Summary</td>
                        <td>{{ form.results.summary }}</td>
                    </tr>
                    <tr>
                        <td>Long Output</td>
                        <td>{{ form.results.long_output }}</td>
                    </tr>
                    <tr>
                        <td>Parsed Performance Data</td>
                        <td>
                            {% if form.results.parsed_perfdata.metrics %}
                                <table border=1 class=table style="border-color: #ffffff;" >
                                    <tr>
                                        <th></th>
                                        <th>label</th>
                                        <th>value</th>
                                        <th>warn</th>
                                        <th>crit</th>
                                        <th>unit</th>
                                        <th>min</th>
                                        <th>max</th>
                                        <th>pnp</th>
                                    </tr>
                                    {% for i in form.results.parsed_perfdata.metrics %}
                                        <tr>
                                            <td class="nowrap"><div class="circle state_{{ i.get_status }}"> </div></td>
                                            <td>{{ i.label }}</td>
                                            <td>{{ i.value }} </td>
                                            <td>{{ i.warn }}  </td>
                                            <td>{{ i.crit }}  </td>
                                            <td> {{ i.uom }}</td>
                                            <td>{{ i.min }}   </td>
                                            <td>{{ i.max }}   </td>
                                            <td>
                                            </td>
                                        </tr>
                                    {% endfor %}
                                </table>
                            {% else %}
                                No valid performance data found in this plugin.
                            {% endif %}

                        </td>
                    </tr>
                    <tr>
                        <td>Raw Performance Data</td>
                        <td>{{ form.results.perfdata }}</td>
                    </tr>

                </table>
            {% else %}
            {% endif %}
            </div>

        </div>

        <div class="row">
            <div class="span11">

            <!-- On get requests, let display a paste form -->
            <form action="#" method="post" class="form-horizontal">{% csrf_token %}
                    <h4>Paste the output of a nagios plugin below</h4>
                    <hr>
                    <textarea wrap="off" id="id_plugin_output" rows="10" class=span11 cols="80" name="plugin_output">test | load1=5</textarea>
                    <hr>
                    <button class="pull-right btn btn-success" type="submit">Save</button>
            </form>
            </div>

        </div>




        <style>
            textarea{
                display: block;
                margin: 0px;
                padding: 0px;
                width: 500px;
                height: 300px;
            }
        </style>



    {% endif %}

{% endblock %}

{% block footer %}
    {{ block.super }}


        <script>
        $(document).ready(function(){

            editor = adagios.objectbrowser.CheckCommandEditor;
            editor.host_name = "{{ host_name }}";
            editor.check_command = "{{ check_command }}";
            editor.service_description = "{{ service_description }}";
            editor.generate_input_fields();


        });

        </script>


{% endblock %}