<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:py="http://genshi.edgewall.org/"
      xmlns:xi="http://www.w3.org/2001/XInclude">
<head>
  <title>TOPP Outage Escalation Tool</title>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  <meta http-equiv="Content-Language" content="en-us" />
  <link type="text/css" rel="stylesheet" href="/css/tripoli.base.css" />
  <!--[if IE]><link rel="stylesheet" type="text/css" href="/css/tripoli.base.ie.css"><![endif]-->
  <link type="text/css" rel="stylesheet" href="/css/whatsup.css" />
</head>
<body>
  <xi:include href="site.html" />
  <div class="content">
  <h1>TOPP Outage Escalation Tool</h1>
  <table id="status-list">
    <thead>
      <tr>
        <th>Site</th>
        <th>Contact</th>
        <th>Description</th>
        <th>Status</th>
        <th>Report an Outage</th>
        <th>Resources</th>
    </tr>
    </thead>
    <tbody>
      <tr py:for="index, name in enumerate(sorted(sites))" 
          py:with="site=sites[name]; site_status=status.get(name, {'down': None})"
          class="${index%2 and 'odd' or 'even'}">
        <a name="${name}"></a>
        <td><a href="${site['url']}">${name}</a></td>
        <td>
          <ul py:choose="bool(site['contact'])" class="site-contacts">
            <li py:when="True" py:for="contact in site['contact']">
              <a href="/contact/${contact}">${contact}</a>
            </li>
            <li py:otherwise="" py:for="email in site['email']">
              <a href="mailto:${email}">${email}</a>
            </li>
          </ul>
        </td>
        <td class="site-description">${site.get('description', '')}</td>
        <td py:choose="site_status['down']">
          <div py:when="False">
            Ok
            
            <p>
            <i py:if="site_status.get('date')">
              ${site_status['date'].strftime("%c")}
            </i>
            <span py:with="message=site_status.get('message')"
               py:if="message">
              ${message}
            </span>
            </p>
          </div>
          <div py:when="None" py:strip="True" />
          <div py:otherwise="">
            <p>Down since ${site_status['date'].strftime("%c")}</p>
            <p>Last error on ${errors[name][-1][0].strftime("%c")}:</p> 
            <p><i>${errors[name][-1][1]}</i></p>

            <a href="/fixed?site=${name}">Report fixed</a>
          </div>
        </td>
        <td py:choose="'outage_procedure' in site">
          <py:when test="True">
            ${site['outage_procedure']}
          </py:when>
          <py:otherwise>
            <a href="outage?site=${name}">
              <py:choose test="site_status.get('down', False)">
                <py:when test="True">update the outage</py:when>
                <py:otherwise>report an outage</py:otherwise>
              </py:choose>
            </a>
          </py:otherwise>
        </td>
        <td>
          <ul>
            <li py:if="site.get('monit')">
              <b>Monit:</b> <a href="site['monit']">${site['monit']}</a>
            </li>
            <li py:if="site.get('trac')">
              <b>Trac:</b> <a href="${site['trac']}">${site['trac']}</a>
            </li>
          </ul>
        </td>
      </tr>
    </tbody>
  </table>
  </div>
</body>
</html>
