<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--
Style and HTML derived from https://github.com/mailgun/transactional-email-templates


The MIT License (MIT)

Copyright (c) 2014 Mailgun

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
-->
<html xmlns="http://www.w3.org/1999/xhtml" xmlns="http://www.w3.org/1999/xhtml"
    style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">

<head>
    <meta name="viewport" content="width=device-width" />
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>OpenPAI Alerts: [<%= alerts[0].status %>:<%= alerts.length %>] <%= alerts[0].labels.alertname %></title>
</head>

<body itemscope="" itemtype="http://schema.org/EmailMessage"
    style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 14px; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none; height: 100%; line-height: 1.6em; width: 100% !important; background-color: #f6f6f6; margin: 0; padding: 0;"
    bgcolor="#f6f6f6">

    <table
        style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 14px; width: 100%; background-color: #f6f6f6; margin: 0;"
        bgcolor="#f6f6f6">
        <tr>
            <td valign="top"></td>
            <td width="600"
                style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; display: block !important; max-width: 600px !important; clear: both !important; width: 100% !important; margin: 0 auto; padding: 0;"
                valign="top">
                <div
                    style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 14px; max-width: 600px; display: block; margin: 0 auto; padding: 0;">
                    <table width="100%" cellpadding="0" cellspacing="0"
                        style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 14px; border-radius: 3px; background-color: #fff; margin: 0; border: 1px solid #e9e9e9;"
                        bgcolor="#fff">
                        <tr>
                            <% if (alerts.filter( element => element.status =="firing").length > 0) { %>
                            <td style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 16px; vertical-align: top; color: #fff; font-weight: 500; text-align: center; border-radius: 3px 3px 0 0; background-color: #E6522C; margin: 0; padding: 20px;"
                                align="center" bgcolor="#E6522C" valign="top">
                                <% } %>
                                <% if (alerts.filter( element => element.status =="firing").length == 0) { %>
                            <td style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 16px; vertical-align: top; color: #fff; font-weight: 500; text-align: center; border-radius: 3px 3px 0 0; background-color: #2CBE4E; margin: 0; padding: 20px;"
                                align="center" bgcolor="#2CBE4E" valign="top">
                                <!--changed color-->
                                <% } %>
                                <%= alerts.length %> alert<% if (alerts.length > 1) { %>s <% } %> for
                                <%= JSON.stringify(groupLabels) %>
                                from Cluster-ID: <%= cluster_id %>
                            </td>
                        </tr>
                        <tr>
                            <td style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; margin: 0; padding: 10px;"
                                valign="top">
                                <table width="100%" cellpadding="0" cellspacing="0">
                                    <tr>
                                        <td style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; margin: 0; padding: 0 0 20px;"
                                            valign="top">
                                            <a href=<%= externalURL %>
                                                style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 14px; color: #FFF; text-decoration: none; line-height: 2em; font-weight: bold; text-align: center; cursor: pointer; display: inline-block; border-radius: 5px; text-transform: capitalize; background-color: #348eda; margin: 5px; border-color: #348eda; border-style: solid; border-width: 10px 20px;">
                                                View in AlertManager </a>

                                            <a href=<%= troubleshootingURL %>
                                                style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 14px; color: #FFF; text-decoration: none; line-height: 2em; font-weight: bold; text-align: center; cursor: pointer; display: inline-block; border-radius: 5px; text-transform: capitalize; background-color: #348eda; margin: 5px; border-color: #348eda; border-style: solid; border-width: 10px 20px;">
                                                Troubleshooting </a>
                                        </td>
                                    </tr>
                                    <% if (alerts.filter( element => element.status =="firing").length > 0) { %>
                                    <tr>
                                        <td style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; margin: 0; padding: 0 0 20px;"
                                            valign="top">
                                            <strong>[<%= alerts.filter( element => element.status =="firing").length %>]
                                                Firing</strong>
                                        </td>
                                    </tr>
                                    <% } %>
                                    <% alerts.filter( element => element.status =="firing").forEach(function(alert){ %>
                                    <tr>
                                        <td style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; margin: 0; padding: 0 0 20px;"
                                            valign="top">
                                            <% if (alert.annotations.summary) { %>
                                            <%= alert.annotations.summary %>
                                            <% } %>
                                            <% if (!alert.annotations.summary) { %>
                                            <strong>Labels</strong><br />
                                            <%= JSON.stringify(alert.labels) %>
                                            <% if (alert.annotations.length > 0) { %>
                                            <strong>Annotations</strong><br />
                                            <%= JSON.stringify(alert.annotations) %>
                                            <% } %>
                                            <% } %>
                                            <a href=<%= alert.generatorURL %>
                                                style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 14px; color: #348eda; text-decoration: underline; margin: 0;">Source</a><br />
                                        </td>
                                    </tr>
                                    <% }); %>

                                    <% if (alerts.filter( element => element.status =="resolved").length > 0) { %>
                                    <tr>
                                        <td style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; margin: 0; padding: 0 0 20px;"
                                            valign="top">
                                            <strong>[<%= alerts.filter( element => element.status =="resolved").length %>]
                                                Resolved</strong>
                                        </td>
                                    </tr>
                                    <% } %>
                                    <% alerts.filter( element => element.status =="resolved").forEach(function(alert){ %>
                                    <tr>
                                        <td style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; margin: 0; padding: 0 0 20px;"
                                            valign="top">
                                            <% if (alert.annotations.summary) { %>
                                            <%= alert.annotations.summary %>
                                            <% }  %>
                                            <% if (!alert.annotations.summary) { %>
                                            <strong>Labels</strong><br />
                                            <%= JSON.stringify(alert.labels) %>
                                            <% if (alert.annotations.length > 0) { %>
                                            <strong>Annotations</strong><br />
                                            <%= JSON.stringify(alert.annotations) %>
                                            <% } %>
                                            <% } %>
                                            <a href=<%= alert.generatorURL %>
                                                style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 14px; color: #348eda; text-decoration: underline; margin: 0;">Source</a><br />
                                        </td>
                                    </tr>
                                    <% }); %>
                                </table>
                            </td>
                        </tr>
                    </table>

                    <div
                        style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 14px; width: 100%; clear: both; color: #999; margin: 0; padding: 20px;">
                        <table width="100%">
                            <tr>
                                <td style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 12px; vertical-align: top; text-align: center; color: #999; margin: 0; padding: 0 0 20px;"
                                    align="center" valign="top"><a href=<%= externalURL %>
                                        style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 12px; color: #999; text-decoration: underline; margin: 0;">Sent
                                        by AlertManager</a>
                                </td>
                            </tr>
                        </table>
                    </div>
                </div>
            </td>
            <td valign="top"></td>
        </tr>
    </table>

</body>

</html>