<%doc>
USAGE DOCUMENTATION :: PLEASE LEAVE THIS AT THE TOP OF THIS FILE

For Mako templating syntax documentation please visit: http://docs.makotemplates.org/en/latest/

Filename:           notifiers_table.html
Version:            0.1

DOCUMENTATION :: END
</%doc>

<ul class="stacked-configs list-unstyled">
    % for notifier in sorted(notifiers_list, key=lambda k: (k['agent_label'].lower(), k['friendly_name'], k['id'])):
    <li class="notification-agent pointer" data-id="${notifier['id']}">
        <span>
            <span class="toggle-left trigger-tooltip ${'active' if notifier['active'] else ''}" data-toggle="tooltip" data-placement="top" title="Triggers ${'active' if notifier['active'] else 'inactive'}"><i class="fa fa-lg fa-fw fa-bell"></i></span>
            % if notifier['friendly_name']:
            ${notifier['agent_label']} &nbsp;<span class="friendly_name">(${notifier['id']} - ${notifier['friendly_name']})</span>
            % else:
            ${notifier['agent_label']} &nbsp;<span class="friendly_name">(${notifier['id']})</span>
            % endif
            <span class="toggle-right friendly_name">
                % if notifier['last_triggered']:
                <% icon, icon_tooltip = ('fa-check', 'Success') if notifier['last_success'] else ('fa-times', 'Failed') %>
                <span id="notifier-last_triggered-${notifier['id']}">
                    <script>
                        $("#notifier-last_triggered-${notifier['id']}").html(
                            moment("${notifier['last_triggered']}", "X").fromNow() + ' <i class="fa fa-lg fa-fw ${icon}" data-toggle="tooltip" data-placement="top" title="${icon_tooltip}"></i>'
                        )
                    </script>
                </span>
            % else:
            never
            <i class="fa fa-lg fa-fw fa-minus"></i>
            % endif
        </span>
    </li>
    % endfor
    <li class="add-notification-agent pointer" id="add-notification-agent" data-target="#add-notifier-modal" data-toggle="modal">
        <span>
            <span class="toggle-left"><i class="fa fa-lg fa-fw fa-bell"></i></span> Add a new notification agent
            <span class="toggle-right"><i class="fa fa-lg fa-fw fa-plus"></i></span>
        </span>
    </li>
</ul>

<script>
    // Load notification agent config modal
    $(".notification-agent").click(function () {
        var notifier_id = $(this).data('id');
        loadNotifierConfig(notifier_id);
    });

    $('.trigger-tooltip').tooltip();
</script>