{% extends 'main_header.html' %}
{% block body %}

<div style="text-align: center;">
<strong>NOTICE:</strong> list can contain processes from manual context.py update or decommissioned boxes
</div>
<br/>
<div><table class="one-column-emphasis synergy-datatable" id="supervisor_table">
    <thead>
    <tr class="one-column-emphasis-first">
        <th scope="col">Box Id</th>
        <th scope="col">Process Name</th>
        <th scope="col">Is On</th>
        <th scope="col">PID</th>
        <th scope="col"></th> <!-- start/stop-->
    </tr>
    </thead>
    <tbody>

    {%- for bc_entry in details -%}
    <tr class="{{ bc_entry.state }}">
        <td>{{ bc_entry.box_id }}</td>
        <td>{{ bc_entry.process_name }}</td>
        <td>{{ bc_entry.is_on }}</td>
        <td>{{ bc_entry.pid }}</td>

        {% set action_url = '/supervisor/entry/stop/' if bc_entry.is_on else '/supervisor/entry/start/' %}
        {% set button_title = 'Stop' if bc_entry.is_on else 'Start' %}
        {% set button_value = '&#xf04d;&nbsp;Stop' if bc_entry.is_on else '&#xf04b;&nbsp;Start' %}

        <td>
            <form method="POST" action="{{ action_url }}" onsubmit="refreshWithDelay()">
                <input type="hidden" name="box_id" value="{{ bc_entry.box_id }}" />
                <input type="hidden" name="process_name" value="{{ bc_entry.process_name }}" />
                <input type="submit" class="action_button fa-input" title="{{ button_title }}" value="{{ button_value|safe }}"/>
            </form>
        </td>
    </tr>
    {%- endfor -%}

    </tbody>
</table></div>

{% endblock %}
