<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head profile="http://www.w3.org/2005/10/profile">
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
    <link rel="icon" type="image/png" href="{{ url_for('static', file='images/sy_brown.png') }}">
    <link rel="stylesheet" type="text/css" href="{{ url_for('static', file='css/scheduler_ui.css') }}">
    <link rel="stylesheet" type="text/css" href="{{ url_for('static', file='css/context_menu.css') }}">
    <link rel="stylesheet" type="text/css" href="{{ url_for('static', file='css/mx_page.css') }}">
    <link rel="stylesheet" type="text/css" href="{{ url_for('static', file='css/font-awesome-4.3.0.css') }}">
    <link rel="stylesheet" type="text/css" href="{{ url_for('static', file='css/jquery.dataTables-1.10.7.css') }}">
    <link rel="stylesheet" type="text/css" href="{{ url_for('static', file='css/alertify.css') }}">
    <script type="text/javascript" src="{{ url_for('static', file='js/jquery-2.1.4.min.js') }}"></script>
    <script type="text/javascript" src="{{ url_for('static', file='js/jquery.dataTables-1.10.7.min.js') }}"></script>
    <script type="text/javascript" src="{{ url_for('static', file='js/alertify-0.3.17.trunk.js') }}"></script>
    <script type="text/javascript" src="{{ url_for('static', file='js/mx_utils.js') }}"></script>

    <title>Synergy Scheduler</title>
</head>

{% macro render_td(endpoint, title) %}
    {% set td_class = '' %}
    {%- if endpoint in local.request.path -%}
        <script type="text/javascript">
            var mx_page = "{{ endpoint|safe }}";
        </script>
        {% set mx_page = endpoint %}
        {% set td_class = 'class="active"' %}
    {%- endif -%}

    <td {{ td_class|safe }}>
        <a href="{{ endpoint }}"> {{ title }}</a>
    </td>
{% endmacro %}

<body>
<table class="header-table">
    <thead>
    <tr>
        <th colspan="2">Synergy Scheduler</th>
        {%- for mx_rule, mx_name in mx_processing_context.items() -%}
        <th></th>
        {%- endfor -%}
        <th></th>
        <th></th>
    </tr>
    </thead>
    <tbody>
    <tr>
        {{  render_td(url_for('dashboard_managed'), 'dashboard jobs') }}
        {{  render_td(url_for('dashboard_freeruns'), 'dashboard freeruns') }}
        {%- for mx_rule, mx_page_name in mx_processing_context.items() %}
            {{  render_td("/" + mx_rule, mx_page_name) }}
        {%- endfor -%}
        {{  render_td(url_for('scheduler_managed_entries'), 'scheduler managed entries') }}
        {{  render_td(url_for('scheduler_freerun_entries'), 'scheduler freerun entries') }}
    </tr>
    </tbody>
</table>

{% import 'block_enable_auto_refresh.html' as block_enable_refresh %}
{{ block_enable_refresh.enable_auto_refresh() }}

<br/>
<br/>
<div class="body">{% block body %}{% endblock %}</div>
<br/>

<div id="footer" class="table_layout">
    <div class="table_layout_element">
        page rendered: {{ get_current_time() }}
    </div>
    <div class="table_layout_element" style="text-align: right">
        <a href="mailto:scheduler.feedback@gmail.com?subject=Comments to Scheduler MX page">Feedback</a>
    </div>
</div>
</body>
</html>
